static void make_confirm_menu(void) { Menu* ms; ms = &root.confirm_menu; ms->title = NULL; ms->numoptions = 2; ms->origin.x = 0; ms->origin.y = 0; ms->type = normal_menu; ms->option = (MenuItem*)simm_malloc(ms->numoptions*sizeof(MenuItem)); if (ms->option == NULL) error(exit_program,tool_message); ms->option[0].active = yes; ms->option[1].active = yes; ms->option[0].visible = yes; ms->option[1].visible = yes; mstrcpy(&ms->option[0].name,confirmstr[0]); mstrcpy(&ms->option[1].name,confirmstr[1]); SET_BOX(ms->option[0].box,30,100,30,ms->option[0].box.y1+MENU_ITEM_HEIGHT); SET_BOX(ms->option[1].box,160,230,30,ms->option[1].box.y1+MENU_ITEM_HEIGHT); }
int main(int argc, char ** argv) { #ifdef ENABLE_GETTEXT setlocale(LC_ALL, ""); bindtextdomain(PACKAGE_NAME, LOCALEDIR); #endif static struct option longopts[] = { { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { "input", required_argument, NULL, 'i' }, { "output", required_argument, NULL, 'o' }, { "config", required_argument, NULL, 'c' }, { 0, 0, 0, 0 }, }; static int oc; static char *input_file, *output_file, *config_file; while((oc = getopt_long(argc, argv, "vh:i:o:c:", longopts, NULL)) != -1) { switch (oc) { case 'v': show_version(); return 0; case 'h': show_usage(); return 0; case '?': printf(_("Please use %s --help.\n"), argv[0]); return 1; case 'i': input_file = mstrcpy(optarg); break; case 'o': output_file = mstrcpy(optarg); break; case 'c': config_file = mstrcpy(optarg); break; } } if (config_file == NULL) { config_file = mstrcpy(OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD); } convert(input_file, output_file, config_file); free(input_file); free(output_file); free(config_file); return 0; }
ReturnCode make_dynparams_form(ModelStruct* ms) { int i, name_len, num_options; Form* form; if (ms->default_muscle) num_options = ms->default_muscle->num_dynamic_params + 1; // one extra for muscle model else num_options = 1; // one extra for muscle model form = &ms->dynparamsform; form->numoptions = num_options; form->selected_item = -1; form->cursor_position = 0; form->highlight_start = 0; form->title = NULL; ms->longest_dynparam_name = 0; form->option = (FormItem*)simm_malloc(form->numoptions*sizeof(FormItem)); if (form->option == NULL) return code_bad; ms->dynparamsSize = 0; for (i=0; i<form->numoptions; i++) { form->option[i].justify = yes; form->option[i].active = yes; form->option[i].visible = yes; form->option[i].editable = yes; form->option[i].use_alternate_colors = no; form->option[i].data = NULL; if (i == num_options - 1) { form->option[i].decimal_places = 0; mstrcpy(&form->option[i].name, "muscle_model"); } else { form->option[i].decimal_places = 3; mstrcpy(&form->option[i].name, ms->default_muscle->dynamic_param_names[i]); } name_len = glueGetStringWidth(root.gfont.defaultfont, form->option[i].name); if (name_len > ms->longest_dynparam_name) ms->longest_dynparam_name = name_len; SET_BOX1221(form->option[i].box, 0, 90,-FORM_FIELD_YSPACING*i, form->option[i].box.y2-FORM_FIELD_HEIGHT); ms->dynparamsSize = form->option[i].box.y2 - FORM_FIELD_HEIGHT; } ms->longest_dynparam_name -= 30; return code_fine; }
static int parse_add_dict(config_desc * config, size_t index, const char * dictstr) { const char * pstr = dictstr; while (*pstr != '\0' && *pstr !=' ') pstr ++; opencc_dictionary_type dict_type; if (strncmp(dictstr, CONFIG_DICT_TYPE_OCD, sizeof(CONFIG_DICT_TYPE_OCD) - 1) == 0) dict_type = OPENCC_DICTIONARY_TYPE_DATRIE; else if (strncmp(dictstr, CONFIG_DICT_TYPE_TEXT, sizeof(CONFIG_DICT_TYPE_OCD) - 1) == 0) dict_type = OPENCC_DICTIONARY_TYPE_TEXT; else { errnum = CONFIG_ERROR_INVALID_DICT_TYPE; return -1; } while (*pstr != '\0' && (*pstr == ' ' || *pstr == '\t')) pstr ++; size_t i = config->dicts_count ++; config->dicts[i].dict_type = dict_type; config->dicts[i].file_name = mstrcpy(pstr); config->dicts[i].index = index; config->dicts[i].stamp = config->stamp ++; return 0; }
static int parse_line(const char * line, char ** key, char ** value) { const char * line_begin = line; while (*line != '\0' && (*line != ' ' && *line != '\t' && *line != '=')) line ++; size_t key_len = line - line_begin; while (*line != '\0' && *line != '=') line ++; if (*line == '\0') return -1; assert(*line == '='); *key = mstrncpy(line_begin, key_len); line ++; while (*line != '\0' && (*line == ' ' || *line =='\t')) line ++; if (*line == '\0') { free(*key); return -1; } *value = mstrcpy(line); return 0; }
int main(int argc, char *argv[]) { char s1[20]; char s2[] = "hello seattle"; mstrcpy(s1, s2); printf("s1 = %s\n", s1); printf("s2 = %s\n", s2); return 0; }
static int parse_property(config_desc * config, const char * key, const char * value) { if (strncmp(key, "dict", 4) == 0) { int index = 0; sscanf(key + 4, "%d", &index); return parse_add_dict(config, index, value); } else if (strcmp(key, "title") == 0) { free(config->title); config->title = mstrcpy(value); return 0; } else if (strcmp(key, "description") == 0) { free(config->description); config->description = mstrcpy(value); return 0; } errnum = CONFIG_ERROR_NO_PROPERTY; return -1; }
void open_main_window() { int xtmp, ytmp; WindowParams bwin; WinUnion wun; init_main_menu(); /* the main menu must be created *before* the SIMM window */ glueSetWindowPlacement(GLUT_NORMAL_WINDOW, GLUE_CENTER, root.gldesc.max_screen_x, root.gldesc.max_screen_y, 0, 0, NULL); bwin.id = glueOpenWindow("simm",no,GLUE_NO_WINDOW_FLAGS); glueSetWindowMinSize(950,700); #if SIMM_DEMO_VERSION sprintf(buffer,"%s - Tryout Version (%s)", program_name, program_version); #elif SIMM_VIEWER sprintf(buffer,"%s (%s)", program_name, program_version); #elif defined WIN32 strcpy(buffer, program_with_version); if (is_in_demo_mode()) strcat(buffer, " - Demo Mode"); #else sprintf(buffer,"%s: %s, %s %s", program_name, program_full_name, program_version, copyright_notice); #endif mstrcpy(&bwin.name,buffer); glutSetIconTitle(program_name); glutSetWindowTitle(bwin.name); wun.tool = NULL; root.basewindow = add_window(&bwin,&wun,NOTYPE,-1,no,display_background, update_background,background); if (root.basewindow == -1) error(exit_program,tool_message); glutSetWindowData(bwin.id, root.basewindow); glueGetWindowOrigin(&root.surgwin.x1,&root.surgwin.y1); glueGetWindowSize(&xtmp,&ytmp); root.surgwin.x2 = root.surgwin.x1 + xtmp; root.surgwin.y2 = root.surgwin.y1 + ytmp; }
/** * Match a window against a single leaf window condition. * * For internal use. */ static inline void c2_match_once_leaf(session_t *ps, win *w, const c2_l_t *pleaf, bool *pres, bool *perr) { assert(pleaf); const Window wid = (pleaf->tgt_onframe ? w->client_win: w->id); // Return if wid is missing if (!pleaf->predef && !wid) return; const int idx = (pleaf->index < 0 ? 0: pleaf->index); switch (pleaf->ptntype) { // Deal with integer patterns case C2_L_PTINT: { long tgt = 0; // Get the value // A predefined target if (pleaf->predef) { *perr = false; switch (pleaf->predef) { case C2_L_PID: tgt = wid; break; case C2_L_PX: tgt = w->a.x; break; case C2_L_PY: tgt = w->a.y; break; case C2_L_PX2: tgt = w->a.x + w->widthb; break; case C2_L_PY2: tgt = w->a.y + w->heightb; break; case C2_L_PWIDTH: tgt = w->a.width; break; case C2_L_PHEIGHT: tgt = w->a.height; break; case C2_L_PWIDTHB: tgt = w->widthb; break; case C2_L_PHEIGHTB: tgt = w->heightb; break; case C2_L_PBDW: tgt = w->a.border_width; break; case C2_L_PFULLSCREEN: tgt = win_is_fullscreen(ps, w); break; case C2_L_POVREDIR: tgt = w->a.override_redirect; break; case C2_L_PARGB: tgt = (WMODE_ARGB == w->mode); break; case C2_L_PFOCUSED: tgt = w->focused_real; break; case C2_L_PWMWIN: tgt = w->wmwin; break; case C2_L_PCLIENT: tgt = w->client_win; break; case C2_L_PLEADER: tgt = w->leader; break; default: *perr = true; assert(0); break; } } // A raw window property else { winprop_t prop = wid_get_prop_adv(ps, wid, pleaf->tgtatom, idx, 1L, c2_get_atom_type(pleaf), pleaf->format); if (prop.nitems) { *perr = false; tgt = winprop_get_int(prop); } free_winprop(&prop); } if (*perr) return; // Do comparison switch (pleaf->op) { case C2_L_OEXISTS: *pres = (pleaf->predef ? tgt: true); break; case C2_L_OEQ: *pres = (tgt == pleaf->ptnint); break; case C2_L_OGT: *pres = (tgt > pleaf->ptnint); break; case C2_L_OGTEQ: *pres = (tgt >= pleaf->ptnint); break; case C2_L_OLT: *pres = (tgt < pleaf->ptnint); break; case C2_L_OLTEQ: *pres = (tgt <= pleaf->ptnint); break; default: *perr = true; assert(0); break; } } break; // String patterns case C2_L_PTSTRING: { const char *tgt = NULL; char *tgt_free = NULL; // A predefined target if (pleaf->predef) { switch (pleaf->predef) { case C2_L_PWINDOWTYPE: tgt = WINTYPES[w->window_type]; break; case C2_L_PNAME: tgt = w->name; break; case C2_L_PCLASSG: tgt = w->class_general; break; case C2_L_PCLASSI: tgt = w->class_instance; break; case C2_L_PROLE: tgt = w->role; break; default: assert(0); break; } } // If it's an atom type property, convert atom to string else if (C2_L_TATOM == pleaf->type) { winprop_t prop = wid_get_prop_adv(ps, wid, pleaf->tgtatom, idx, 1L, c2_get_atom_type(pleaf), pleaf->format); Atom atom = winprop_get_int(prop); if (atom) { tgt_free = XGetAtomName(ps->dpy, atom); } if (tgt_free) { tgt = tgt_free; } free_winprop(&prop); } // Otherwise, just fetch the string list else { char **strlst = NULL; int nstr; if (wid_get_text_prop(ps, wid, pleaf->tgtatom, &strlst, &nstr) && nstr > idx) { tgt_free = mstrcpy(strlst[idx]); tgt = tgt_free; } if (strlst) XFreeStringList(strlst); } if (tgt) { *perr = false; } else { return; } // Actual matching switch (pleaf->op) { case C2_L_OEXISTS: *pres = true; break; case C2_L_OEQ: switch (pleaf->match) { case C2_L_MEXACT: if (pleaf->match_ignorecase) *pres = !strcasecmp(tgt, pleaf->ptnstr); else *pres = !strcmp(tgt, pleaf->ptnstr); break; case C2_L_MCONTAINS: if (pleaf->match_ignorecase) *pres = strcasestr(tgt, pleaf->ptnstr); else *pres = strstr(tgt, pleaf->ptnstr); break; case C2_L_MSTART: if (pleaf->match_ignorecase) *pres = !strncasecmp(tgt, pleaf->ptnstr, strlen(pleaf->ptnstr)); else *pres = !strncmp(tgt, pleaf->ptnstr, strlen(pleaf->ptnstr)); break; case C2_L_MWILDCARD: { int flags = 0; if (pleaf->match_ignorecase) flags |= FNM_CASEFOLD; *pres = !fnmatch(pleaf->ptnstr, tgt, flags); } break; case C2_L_MPCRE: #ifdef CONFIG_REGEX_PCRE *pres = (pcre_exec(pleaf->regex_pcre, pleaf->regex_pcre_extra, tgt, strlen(tgt), 0, 0, NULL, 0) >= 0); #else assert(0); #endif break; } break; default: *perr = true; assert(0); } // Free the string after usage, if necessary if (tgt_free) { if (C2_L_TATOM == pleaf->type) cxfree(tgt_free); else free(tgt_free); } } break; default: assert(0); break; } }
/** * Parse the pattern part of a leaf. */ static int c2_parse_pattern(session_t *ps, const char *pattern, int offset, c2_ptr_t *presult) { c2_l_t * const pleaf = presult->l; // Exists operator cannot have pattern if (!pleaf->op) return offset; C2H_SKIP_SPACES(); char *endptr = NULL; // Check for boolean patterns if (!strcmp_wd("true", &pattern[offset])) { pleaf->ptntype = C2_L_PTINT; pleaf->ptnint = true; offset += strlen("true"); } else if (!strcmp_wd("false", &pattern[offset])) { pleaf->ptntype = C2_L_PTINT; pleaf->ptnint = false; offset += strlen("false"); } // Check for integer patterns else if (pleaf->ptnint = strtol(pattern + offset, &endptr, 0), pattern + offset != endptr) { pleaf->ptntype = C2_L_PTINT; offset = endptr - pattern; // Make sure we are stopping at the end of a word if (isalnum(pattern[offset])) c2_error("Trailing characters after a numeric pattern."); } // Check for string patterns else { bool raw = false; char delim = '\0'; // String flags if ('r' == tolower(pattern[offset])) { raw = true; ++offset; C2H_SKIP_SPACES(); } // Check for delimiters if ('\"' == pattern[offset] || '\'' == pattern[offset]) { pleaf->ptntype = C2_L_PTSTRING; delim = pattern[offset]; ++offset; } if (C2_L_PTSTRING != pleaf->ptntype) c2_error("Invalid pattern type."); // Parse the string now // We can't determine the length of the pattern, so we use the length // to the end of the pattern string -- currently escape sequences // cannot be converted to a string longer than itself. char *tptnstr = malloc((strlen(pattern + offset) + 1) * sizeof(char)); char *ptptnstr = tptnstr; pleaf->ptnstr = tptnstr; for (; pattern[offset] && delim != pattern[offset]; ++offset) { // Handle escape sequences if it's not a raw string if ('\\' == pattern[offset] && !raw) { switch(pattern[++offset]) { case '\\': *(ptptnstr++) = '\\'; break; case '\'': *(ptptnstr++) = '\''; break; case '\"': *(ptptnstr++) = '\"'; break; case 'a': *(ptptnstr++) = '\a'; break; case 'b': *(ptptnstr++) = '\b'; break; case 'f': *(ptptnstr++) = '\f'; break; case 'n': *(ptptnstr++) = '\n'; break; case 'r': *(ptptnstr++) = '\r'; break; case 't': *(ptptnstr++) = '\t'; break; case 'v': *(ptptnstr++) = '\v'; break; case 'o': case 'x': { char *tstr = mstrncpy(pattern + offset + 1, 2); char *pstr = NULL; long val = strtol(tstr, &pstr, ('o' == pattern[offset] ? 8: 16)); free(tstr); if (pstr != &tstr[2] || val <= 0) c2_error("Invalid octal/hex escape sequence."); assert(val < 256 && val >= 0); *(ptptnstr++) = val; offset += 2; break; } default: c2_error("Invalid escape sequence."); } } else { *(ptptnstr++) = pattern[offset]; } } if (!pattern[offset]) c2_error("Premature end of pattern string."); ++offset; *ptptnstr = '\0'; pleaf->ptnstr = mstrcpy(tptnstr); free(tptnstr); } C2H_SKIP_SPACES(); if (!pleaf->ptntype) c2_error("Invalid pattern type."); // Check if the type is correct if (!(((C2_L_TSTRING == pleaf->type || C2_L_TATOM == pleaf->type) && C2_L_PTSTRING == pleaf->ptntype) || ((C2_L_TCARDINAL == pleaf->type || C2_L_TWINDOW == pleaf->type || C2_L_TDRAWABLE == pleaf->type) && C2_L_PTINT == pleaf->ptntype))) c2_error("Pattern type incompatible with target type."); if (C2_L_PTINT == pleaf->ptntype && pleaf->match) c2_error("Integer/boolean pattern cannot have operator qualifiers."); if (C2_L_PTINT == pleaf->ptntype && pleaf->match_ignorecase) c2_error("Integer/boolean pattern cannot have flags."); if (C2_L_PTSTRING == pleaf->ptntype && (C2_L_OGT == pleaf->op || C2_L_OGTEQ == pleaf->op || C2_L_OLT == pleaf->op || C2_L_OLTEQ == pleaf->op)) c2_error("String pattern cannot have an arithmetic operator."); return offset; }
void banlrec_setnick(banlrec *b, char *nick) { mstrcpy(&b->nick,nick); }
void banlrec_setban(banlrec *b, char *ban) { mstrcpy(&b->ban,ban); }
void generec_setdisplay(generec *x, char *display) { mstrcpy(&x->display,display); }
/** * Initialize D-Bus connection. */ bool cdbus_init(session_t *ps) { DBusError err = { }; // Initialize dbus_error_init(&err); // Connect to D-Bus // Use dbus_bus_get_private() so we can fully recycle it ourselves ps->dbus_conn = dbus_bus_get_private(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { printf_errf("(): D-Bus connection failed (%s).", err.message); dbus_error_free(&err); return false; } if (!ps->dbus_conn) { printf_errf("(): D-Bus connection failed for unknown reason."); return false; } // Avoid exiting on disconnect dbus_connection_set_exit_on_disconnect(ps->dbus_conn, false); // Request service name { // Get display name char *display = DisplayString(ps->dpy); if (!display) display = "unknown"; display = mstrcpy(display); // Convert all special characters in display name to underscore { char *pdisp = display; while (*pdisp) { if (!isalnum(*pdisp)) *pdisp = '_'; ++pdisp; } } // Build service name char *service = mstrjoin3(CDBUS_SERVICE_NAME, ".", display); ps->dbus_service = service; free(display); display = NULL; // Request for the name int ret = dbus_bus_request_name(ps->dbus_conn, service, DBUS_NAME_FLAG_DO_NOT_QUEUE, &err); if (dbus_error_is_set(&err)) { printf_errf("(): Failed to obtain D-Bus name (%s).", err.message); dbus_error_free(&err); } if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret && DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER != ret) { printf_errf("(): Failed to become the primary owner of requested " "D-Bus name (%d).", ret); } } // Add watch handlers if (!dbus_connection_set_watch_functions(ps->dbus_conn, cdbus_callback_add_watch, cdbus_callback_remove_watch, cdbus_callback_watch_toggled, ps, NULL)) { printf_errf("(): Failed to add D-Bus watch functions."); return false; } // Add timeout handlers if (!dbus_connection_set_timeout_functions(ps->dbus_conn, cdbus_callback_add_timeout, cdbus_callback_remove_timeout, cdbus_callback_timeout_toggled, ps, NULL)) { printf_errf("(): Failed to add D-Bus timeout functions."); return false; } // Add match dbus_bus_add_match(ps->dbus_conn, "type='method_call',interface='" CDBUS_INTERFACE_NAME "'", &err); if (dbus_error_is_set(&err)) { printf_errf("(): Failed to add D-Bus match."); dbus_error_free(&err); return false; } return true; }
static void cmdrec_setname(cmdrec_t *c, char *name) { mstrcpy(&c->name,name); }
void radirec_setnick(radirec *x, char *nick) { mstrcpy(&x->nick,nick); }
void init_segments(void) { sdm.num_body_segments = 16; sdm.body_segment = (BodyStruct*)simm_malloc(sdm.num_body_segments*sizeof(BodyStruct)); mstrcpy(&sdm.body_segment[0].name,"ground"); sdm.body_segment[0].mass = 0.000000; sdm.body_segment[0].inertia[0][0] = 0.000000; sdm.body_segment[0].inertia[0][1] = 0.000000; sdm.body_segment[0].inertia[0][2] = 0.000000; sdm.body_segment[0].inertia[1][0] = 0.000000; sdm.body_segment[0].inertia[1][1] = 0.000000; sdm.body_segment[0].inertia[1][2] = 0.000000; sdm.body_segment[0].inertia[2][0] = 0.000000; sdm.body_segment[0].inertia[2][1] = 0.000000; sdm.body_segment[0].inertia[2][2] = 0.000000; sdm.body_segment[0].mass_center[0] = 0.000000; sdm.body_segment[0].mass_center[1] = 0.000000; sdm.body_segment[0].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[1].name,"pelvis"); sdm.body_segment[1].mass = 51.100000; sdm.body_segment[1].inertia[0][0] = 1.396000; sdm.body_segment[1].inertia[0][1] = 0.000000; sdm.body_segment[1].inertia[0][2] = 0.000000; sdm.body_segment[1].inertia[1][0] = 0.000000; sdm.body_segment[1].inertia[1][1] = 0.715300; sdm.body_segment[1].inertia[1][2] = 0.000000; sdm.body_segment[1].inertia[2][0] = 0.000000; sdm.body_segment[1].inertia[2][1] = 0.000000; sdm.body_segment[1].inertia[2][2] = 2.580000; sdm.body_segment[1].mass_center[0] = -0.070700; sdm.body_segment[1].mass_center[1] = 0.263900; sdm.body_segment[1].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[2].name,"femur_r"); sdm.body_segment[2].mass = 7.760000; sdm.body_segment[2].inertia[0][0] = 0.137000; sdm.body_segment[2].inertia[0][1] = 0.000000; sdm.body_segment[2].inertia[0][2] = 0.000000; sdm.body_segment[2].inertia[1][0] = 0.000000; sdm.body_segment[2].inertia[1][1] = 0.031600; sdm.body_segment[2].inertia[1][2] = 0.000000; sdm.body_segment[2].inertia[2][0] = 0.000000; sdm.body_segment[2].inertia[2][1] = 0.000000; sdm.body_segment[2].inertia[2][2] = 0.137000; sdm.body_segment[2].mass_center[0] = 0.000000; sdm.body_segment[2].mass_center[1] = -0.170000; sdm.body_segment[2].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[3].name,"tibia_r"); sdm.body_segment[3].mass = 3.030000; sdm.body_segment[3].inertia[0][0] = 0.044400; sdm.body_segment[3].inertia[0][1] = 0.000000; sdm.body_segment[3].inertia[0][2] = 0.000000; sdm.body_segment[3].inertia[1][0] = 0.000000; sdm.body_segment[3].inertia[1][1] = 0.003830; sdm.body_segment[3].inertia[1][2] = 0.000000; sdm.body_segment[3].inertia[2][0] = 0.000000; sdm.body_segment[3].inertia[2][1] = 0.000000; sdm.body_segment[3].inertia[2][2] = 0.044500; sdm.body_segment[3].mass_center[0] = 0.000000; sdm.body_segment[3].mass_center[1] = -0.186700; sdm.body_segment[3].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[4].name,"patella_r"); sdm.body_segment[4].mass = 0.100000; sdm.body_segment[4].inertia[0][0] = 0.001000; sdm.body_segment[4].inertia[0][1] = 0.000000; sdm.body_segment[4].inertia[0][2] = 0.000000; sdm.body_segment[4].inertia[1][0] = 0.000000; sdm.body_segment[4].inertia[1][1] = 0.001000; sdm.body_segment[4].inertia[1][2] = 0.000000; sdm.body_segment[4].inertia[2][0] = 0.000000; sdm.body_segment[4].inertia[2][1] = 0.000000; sdm.body_segment[4].inertia[2][2] = 0.001000; sdm.body_segment[4].mass_center[0] = 0.000000; sdm.body_segment[4].mass_center[1] = 0.000000; sdm.body_segment[4].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[5].name,"talus_r"); sdm.body_segment[5].mass = 0.100000; sdm.body_segment[5].inertia[0][0] = 0.001000; sdm.body_segment[5].inertia[0][1] = 0.000000; sdm.body_segment[5].inertia[0][2] = 0.000000; sdm.body_segment[5].inertia[1][0] = 0.000000; sdm.body_segment[5].inertia[1][1] = 0.001000; sdm.body_segment[5].inertia[1][2] = 0.000000; sdm.body_segment[5].inertia[2][0] = 0.000000; sdm.body_segment[5].inertia[2][1] = 0.000000; sdm.body_segment[5].inertia[2][2] = 0.001000; sdm.body_segment[5].mass_center[0] = 0.000000; sdm.body_segment[5].mass_center[1] = 0.000000; sdm.body_segment[5].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[6].name,"calcn_r"); sdm.body_segment[6].mass = 0.418300; sdm.body_segment[6].inertia[0][0] = 0.001000; sdm.body_segment[6].inertia[0][1] = 0.000000; sdm.body_segment[6].inertia[0][2] = 0.000000; sdm.body_segment[6].inertia[1][0] = 0.000000; sdm.body_segment[6].inertia[1][1] = 0.001000; sdm.body_segment[6].inertia[1][2] = 0.000000; sdm.body_segment[6].inertia[2][0] = 0.000000; sdm.body_segment[6].inertia[2][1] = 0.000000; sdm.body_segment[6].inertia[2][2] = 0.001000; sdm.body_segment[6].mass_center[0] = 0.025000; sdm.body_segment[6].mass_center[1] = 0.015000; sdm.body_segment[6].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[7].name,"midfoot_r"); sdm.body_segment[7].mass = 0.400000; sdm.body_segment[7].inertia[0][0] = 0.001000; sdm.body_segment[7].inertia[0][1] = 0.000000; sdm.body_segment[7].inertia[0][2] = 0.000000; sdm.body_segment[7].inertia[1][0] = 0.000000; sdm.body_segment[7].inertia[1][1] = 0.001000; sdm.body_segment[7].inertia[1][2] = 0.000000; sdm.body_segment[7].inertia[2][0] = 0.000000; sdm.body_segment[7].inertia[2][1] = 0.000000; sdm.body_segment[7].inertia[2][2] = 0.001000; sdm.body_segment[7].mass_center[0] = 0.025000; sdm.body_segment[7].mass_center[1] = 0.015000; sdm.body_segment[7].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[8].name,"toes_r"); sdm.body_segment[8].mass = 0.205800; sdm.body_segment[8].inertia[0][0] = 0.001000; sdm.body_segment[8].inertia[0][1] = 0.000000; sdm.body_segment[8].inertia[0][2] = 0.000000; sdm.body_segment[8].inertia[1][0] = 0.000000; sdm.body_segment[8].inertia[1][1] = 0.001000; sdm.body_segment[8].inertia[1][2] = 0.000000; sdm.body_segment[8].inertia[2][0] = 0.000000; sdm.body_segment[8].inertia[2][1] = 0.000000; sdm.body_segment[8].inertia[2][2] = 0.001000; sdm.body_segment[8].mass_center[0] = 0.034600; sdm.body_segment[8].mass_center[1] = 0.006000; sdm.body_segment[8].mass_center[2] = -0.017500; mstrcpy(&sdm.body_segment[9].name,"femur_l"); sdm.body_segment[9].mass = 7.760000; sdm.body_segment[9].inertia[0][0] = 0.137000; sdm.body_segment[9].inertia[0][1] = 0.000000; sdm.body_segment[9].inertia[0][2] = 0.000000; sdm.body_segment[9].inertia[1][0] = 0.000000; sdm.body_segment[9].inertia[1][1] = 0.031600; sdm.body_segment[9].inertia[1][2] = 0.000000; sdm.body_segment[9].inertia[2][0] = 0.000000; sdm.body_segment[9].inertia[2][1] = 0.000000; sdm.body_segment[9].inertia[2][2] = 0.137000; sdm.body_segment[9].mass_center[0] = 0.000000; sdm.body_segment[9].mass_center[1] = -0.170000; sdm.body_segment[9].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[10].name,"tibia_l"); sdm.body_segment[10].mass = 3.030000; sdm.body_segment[10].inertia[0][0] = 0.044400; sdm.body_segment[10].inertia[0][1] = 0.000000; sdm.body_segment[10].inertia[0][2] = 0.000000; sdm.body_segment[10].inertia[1][0] = 0.000000; sdm.body_segment[10].inertia[1][1] = 0.003830; sdm.body_segment[10].inertia[1][2] = 0.000000; sdm.body_segment[10].inertia[2][0] = 0.000000; sdm.body_segment[10].inertia[2][1] = 0.000000; sdm.body_segment[10].inertia[2][2] = 0.044500; sdm.body_segment[10].mass_center[0] = 0.000000; sdm.body_segment[10].mass_center[1] = -0.186700; sdm.body_segment[10].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[11].name,"patella_l"); sdm.body_segment[11].mass = 0.100000; sdm.body_segment[11].inertia[0][0] = 0.001000; sdm.body_segment[11].inertia[0][1] = 0.000000; sdm.body_segment[11].inertia[0][2] = 0.000000; sdm.body_segment[11].inertia[1][0] = 0.000000; sdm.body_segment[11].inertia[1][1] = 0.001000; sdm.body_segment[11].inertia[1][2] = 0.000000; sdm.body_segment[11].inertia[2][0] = 0.000000; sdm.body_segment[11].inertia[2][1] = 0.000000; sdm.body_segment[11].inertia[2][2] = 0.001000; sdm.body_segment[11].mass_center[0] = 0.000000; sdm.body_segment[11].mass_center[1] = 0.000000; sdm.body_segment[11].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[12].name,"talus_l"); sdm.body_segment[12].mass = 0.100000; sdm.body_segment[12].inertia[0][0] = 0.001000; sdm.body_segment[12].inertia[0][1] = 0.000000; sdm.body_segment[12].inertia[0][2] = 0.000000; sdm.body_segment[12].inertia[1][0] = 0.000000; sdm.body_segment[12].inertia[1][1] = 0.001000; sdm.body_segment[12].inertia[1][2] = 0.000000; sdm.body_segment[12].inertia[2][0] = 0.000000; sdm.body_segment[12].inertia[2][1] = 0.000000; sdm.body_segment[12].inertia[2][2] = 0.001000; sdm.body_segment[12].mass_center[0] = 0.000000; sdm.body_segment[12].mass_center[1] = 0.000000; sdm.body_segment[12].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[13].name,"calcn_l"); sdm.body_segment[13].mass = 0.418300; sdm.body_segment[13].inertia[0][0] = 0.001000; sdm.body_segment[13].inertia[0][1] = 0.000000; sdm.body_segment[13].inertia[0][2] = 0.000000; sdm.body_segment[13].inertia[1][0] = 0.000000; sdm.body_segment[13].inertia[1][1] = 0.001000; sdm.body_segment[13].inertia[1][2] = 0.000000; sdm.body_segment[13].inertia[2][0] = 0.000000; sdm.body_segment[13].inertia[2][1] = 0.000000; sdm.body_segment[13].inertia[2][2] = 0.001000; sdm.body_segment[13].mass_center[0] = 0.025000; sdm.body_segment[13].mass_center[1] = 0.015000; sdm.body_segment[13].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[14].name,"midfoot_l"); sdm.body_segment[14].mass = 0.400000; sdm.body_segment[14].inertia[0][0] = 0.001000; sdm.body_segment[14].inertia[0][1] = 0.000000; sdm.body_segment[14].inertia[0][2] = 0.000000; sdm.body_segment[14].inertia[1][0] = 0.000000; sdm.body_segment[14].inertia[1][1] = 0.001000; sdm.body_segment[14].inertia[1][2] = 0.000000; sdm.body_segment[14].inertia[2][0] = 0.000000; sdm.body_segment[14].inertia[2][1] = 0.000000; sdm.body_segment[14].inertia[2][2] = 0.001000; sdm.body_segment[14].mass_center[0] = 0.025000; sdm.body_segment[14].mass_center[1] = 0.015000; sdm.body_segment[14].mass_center[2] = 0.000000; mstrcpy(&sdm.body_segment[15].name,"toes_l"); sdm.body_segment[15].mass = 0.205800; sdm.body_segment[15].inertia[0][0] = 0.001000; sdm.body_segment[15].inertia[0][1] = 0.000000; sdm.body_segment[15].inertia[0][2] = 0.000000; sdm.body_segment[15].inertia[1][0] = 0.000000; sdm.body_segment[15].inertia[1][1] = 0.001000; sdm.body_segment[15].inertia[1][2] = 0.000000; sdm.body_segment[15].inertia[2][0] = 0.000000; sdm.body_segment[15].inertia[2][1] = 0.000000; sdm.body_segment[15].inertia[2][2] = 0.001000; sdm.body_segment[15].mass_center[0] = 0.034600; sdm.body_segment[15].mass_center[1] = 0.006000; sdm.body_segment[15].mass_center[2] = 0.017500; }
int main(int argc, char *argv[]) { char *prgm = *argv; argv++; argc--; dictionary_t dictionary; if(argc < 1) { printf("Usage: %s [options]\n",prgm); printf("Use any combination of the following:\n"); printf(" -i: Initialize the dictionary\n"); printf(" -a [key] [value]: Add a key/value to the dictionary\n"); printf(" -p [string]: Parse a string into the dictionary\n"); printf(" -g [key]: Get a value by its key from the dictionary\n"); printf(" -r [key]: Remove a key from the dictionary\n"); printf(" -d: Destroy the dictionary\n"); } char *key, *value, *string; while(argc > 0) { if(strcmp(*argv,"-i") == 0) { //Initialize printf("Running init()\n"); dictionary_init(&dictionary); printf(" completed\n"); } else if(strcmp(*argv,"-a") == 0) { if(argc < 3) { printf("Not enough parameters to -a\n"); return 2; } key = mstrcpy(argv[1]); value = mstrcpy(argv[2]); printf("Running add(\"%s\",\"%s\")\n",argv[1],argv[2]); d_retint(dictionary_add(&dictionary, key, value)); d_compare("key",argv[1],key); d_compare("value",argv[2],value); argv += 2; argc -= 2; } else if(strcmp(*argv,"-p") == 0) { if(argc < 2) { printf("Not enough parameters to -p\n"); return 2; } string = mstrcpy(argv[1]); printf("Running parse(\"%s\")\n",argv[1]); d_retint(dictionary_parse(&dictionary, string)); d_compare("string",argv[1],string); argv += 1; argc -= 1; } else if(strcmp(*argv,"-g") == 0) { if(argc < 2) { printf("Not enough parameters to -g\n"); return 2; } key = mstrcpy(argv[1]); printf("Running get(\"%s\")\n",argv[1]); d_retstr(dictionary_get(&dictionary, key)); d_compare("key",argv[1],key); argv += 1; argc -= 1; } else if(strcmp(*argv,"-r") == 0) { if(argc < 2) { printf("Not enough parameters to -r\n"); return 2; } key = mstrcpy(argv[1]); printf("Running remove(\"%s\")\n",argv[1]); d_retint(dictionary_remove(&dictionary, key)); d_compare("remove",argv[1],key); argv += 1; argc -= 1; } else if(strcmp(*argv,"-d") == 0) { printf("Running destroy()\n"); dictionary_destroy(&dictionary); printf(" completed\n"); } else { printf("Did not understand parameter: %s\n",*argv); return 3; } argv++; argc--; } }
/** * Parse a condition with legacy syntax. */ static int c2_parse_legacy(session_t *ps, const char *pattern, int offset, c2_ptr_t *presult) { unsigned plen = strlen(pattern + offset); if (plen < 4 || ':' != pattern[offset + 1] || !strchr(pattern + offset + 2, ':')) c2_error("Legacy parser: Invalid format."); // Allocate memory for new leaf c2_l_t *pleaf = malloc(sizeof(c2_l_t)); if (!pleaf) printf_errfq(1, "(): Failed to allocate memory for new leaf."); presult->isbranch = false; presult->l = pleaf; memcpy(pleaf, &leaf_def, sizeof(c2_l_t)); pleaf->type = C2_L_TSTRING; pleaf->op = C2_L_OEQ; pleaf->ptntype = C2_L_PTSTRING; // Determine the pattern target #define TGTFILL(pdefid) \ (pleaf->predef = pdefid, \ pleaf->type = C2_PREDEFS[pdefid].type, \ pleaf->format = C2_PREDEFS[pdefid].format) switch (pattern[offset]) { case 'n': TGTFILL(C2_L_PNAME); break; case 'i': TGTFILL(C2_L_PCLASSI); break; case 'g': TGTFILL(C2_L_PCLASSG); break; case 'r': TGTFILL(C2_L_PROLE); break; default: c2_error("Target \"%c\" invalid.\n", pattern[offset]); } #undef TGTFILL offset += 2; // Determine the match type switch (pattern[offset]) { case 'e': pleaf->match = C2_L_MEXACT; break; case 'a': pleaf->match = C2_L_MCONTAINS; break; case 's': pleaf->match = C2_L_MSTART; break; case 'w': pleaf->match = C2_L_MWILDCARD; break; case 'p': pleaf->match = C2_L_MPCRE; break; default: c2_error("Type \"%c\" invalid.\n", pattern[offset]); } ++offset; // Determine the pattern flags while (':' != pattern[offset]) { switch (pattern[offset]) { case 'i': pleaf->match_ignorecase = true; break; default: c2_error("Flag \"%c\" invalid.", pattern[offset]); } ++offset; } ++offset; // Copy the pattern pleaf->ptnstr = mstrcpy(pattern + offset); if (!c2_l_postprocess(ps, pleaf)) return -1; return offset; }
void make_message_port(void) { IntBox bbox; HelpStruct* hp; int windex; WindowParams mwin; WinUnion wun; SBoolean iconified; hp = &root.messages; hp->lines_per_page = 10; hp->window_width = 750; hp->window_height = 10*HELP_WINDOW_TEXT_Y_SPACING + 4; hp->line = (TextLine*)simm_malloc(100*sizeof(TextLine)); if (hp->line == NULL) error(exit_program,tool_message); hp->num_lines_malloced = 100; hp->num_lines = 0; hp->starting_line = 0; hp->background_color = HELP_WINDOW_BACKGROUND; bbox.x2 = hp->window_width; bbox.x1 = bbox.x2 - 20; bbox.y2 = hp->window_height; bbox.y1 = 0; make_slider(&hp->sl,vertical_slider,bbox,0,(double)(hp->num_lines)*20.0, (double)(hp->lines_per_page)*20.0,(double)(hp->num_lines)*20.0,4.0,NULL,NULL); glueSetWindowPlacement(GLUT_NORMAL_WINDOW, GLUE_SOUTHWEST, hp->window_width, hp->window_height, 0, 0, NULL); #if defined WIN32 && SIMM_DEMO_VERSION iconified = is_in_demo_mode(); #else iconified = no; #endif mwin.id = hp->window_id = glueOpenWindow("simmmess",iconified,GLUE_TOOL_WINDOW); glueSetWindowMinSize(500,100); mstrcpy(&mwin.name,"SIMM Messages"); glutSetIconTitle("Messages"); glutSetWindowTitle(mwin.name); wun.tool = NULL; windex = add_window(&mwin,&wun,NOTYPE,ZERO,no,draw_message_window, update_message_window,messages_input); if (windex == -1) error(exit_program,tool_message); glutSetWindowData(mwin.id, windex); if (expirationMessage) { error(none, expirationMessage); FREE_IFNOTNULL(expirationMessage); } }
void copyf (char * c) /*@requires MaxSet(c) >= MaxRead(f); @*/ { mstrcpy (c, f); }
void init_qs(void) { int i; sdm.nq = 25; sdm.nu = 25; sdm.q = (QStruct*)simm_malloc(sdm.nq*sizeof(QStruct)); sdm.num_closed_loops = 0; mstrcpy(&sdm.q[leg_tx].name,"leg_tx"); sdm.q[leg_tx].type = unconstrained_q; sdm.q[leg_tx].joint = ground_pelvis; sdm.q[leg_tx].axis = 0; sdm.q[leg_tx].conversion = 1.00000; sdm.q[leg_tx].initial_value = 0.00000; sdm.q[leg_tx].range_start = -2.00000; sdm.q[leg_tx].range_end = 4.00000; sdm.q[leg_tx].restraint_func = NULL; sdm.q[leg_tx].min_restraint_func = NULL; sdm.q[leg_tx].max_restraint_func = NULL; mstrcpy(&sdm.q[leg_ty].name,"leg_ty"); sdm.q[leg_ty].type = unconstrained_q; sdm.q[leg_ty].joint = ground_pelvis; sdm.q[leg_ty].axis = 1; sdm.q[leg_ty].conversion = 1.00000; sdm.q[leg_ty].initial_value = 0.91356; sdm.q[leg_ty].range_start = 0.00000; sdm.q[leg_ty].range_end = 2.00000; sdm.q[leg_ty].restraint_func = NULL; sdm.q[leg_ty].min_restraint_func = NULL; sdm.q[leg_ty].max_restraint_func = NULL; mstrcpy(&sdm.q[pelvis_rotation].name,"pelvis_rotation"); sdm.q[pelvis_rotation].type = unconstrained_q; sdm.q[pelvis_rotation].joint = ground_pelvis; sdm.q[pelvis_rotation].axis = 2; sdm.q[pelvis_rotation].conversion = 57.29578; sdm.q[pelvis_rotation].initial_value = -0.72068; sdm.q[pelvis_rotation].range_start = -90.00000; sdm.q[pelvis_rotation].range_end = 90.00000; sdm.q[pelvis_rotation].restraint_func = NULL; sdm.q[pelvis_rotation].min_restraint_func = &q_restraint_func[0]; sdm.q[pelvis_rotation].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[hip_angle_r].name,"hip_angle_r"); sdm.q[hip_angle_r].type = unconstrained_q; sdm.q[hip_angle_r].joint = hip_r; sdm.q[hip_angle_r].axis = 0; sdm.q[hip_angle_r].conversion = 57.29578; sdm.q[hip_angle_r].initial_value = 30.67604; sdm.q[hip_angle_r].range_start = -40.00000; sdm.q[hip_angle_r].range_end = 120.00000; sdm.q[hip_angle_r].restraint_func = NULL; sdm.q[hip_angle_r].min_restraint_func = &q_restraint_func[0]; sdm.q[hip_angle_r].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[knee_r_tx].name,"knee_r_tx"); sdm.q[knee_r_tx].type = constrained_q; sdm.q[knee_r_tx].joint = knee_r; sdm.q[knee_r_tx].axis = 0; sdm.q[knee_r_tx].conversion = 1.00000; sdm.q[knee_r_tx].initial_value = -0.00453; sdm.q[knee_r_tx].range_start = -99999.9; sdm.q[knee_r_tx].range_end = 99999.9; sdm.q[knee_r_tx].restraint_func = NULL; sdm.q[knee_r_tx].min_restraint_func = NULL; sdm.q[knee_r_tx].max_restraint_func = NULL; mstrcpy(&sdm.q[knee_r_ty].name,"knee_r_ty"); sdm.q[knee_r_ty].type = constrained_q; sdm.q[knee_r_ty].joint = knee_r; sdm.q[knee_r_ty].axis = 1; sdm.q[knee_r_ty].conversion = 1.00000; sdm.q[knee_r_ty].initial_value = -0.39618; sdm.q[knee_r_ty].range_start = -99999.9; sdm.q[knee_r_ty].range_end = 99999.9; sdm.q[knee_r_ty].restraint_func = NULL; sdm.q[knee_r_ty].min_restraint_func = NULL; sdm.q[knee_r_ty].max_restraint_func = NULL; mstrcpy(&sdm.q[knee_angle_r].name,"knee_angle_r"); sdm.q[knee_angle_r].type = unconstrained_q; sdm.q[knee_angle_r].joint = knee_r; sdm.q[knee_angle_r].axis = 2; sdm.q[knee_angle_r].conversion = 57.29578; sdm.q[knee_angle_r].initial_value = -4.21151; sdm.q[knee_angle_r].range_start = -120.00000; sdm.q[knee_angle_r].range_end = 5.00000; sdm.q[knee_angle_r].restraint_func = NULL; sdm.q[knee_angle_r].min_restraint_func = &q_restraint_func[0]; sdm.q[knee_angle_r].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[tib_pat_r_tx].name,"tib_pat_r_tx"); sdm.q[tib_pat_r_tx].type = constrained_q; sdm.q[tib_pat_r_tx].joint = tib_pat_r; sdm.q[tib_pat_r_tx].axis = 0; sdm.q[tib_pat_r_tx].conversion = 1.00000; sdm.q[tib_pat_r_tx].initial_value = 0.04921; sdm.q[tib_pat_r_tx].range_start = -99999.9; sdm.q[tib_pat_r_tx].range_end = 99999.9; sdm.q[tib_pat_r_tx].restraint_func = NULL; sdm.q[tib_pat_r_tx].min_restraint_func = NULL; sdm.q[tib_pat_r_tx].max_restraint_func = NULL; mstrcpy(&sdm.q[tib_pat_r_ty].name,"tib_pat_r_ty"); sdm.q[tib_pat_r_ty].type = constrained_q; sdm.q[tib_pat_r_ty].joint = tib_pat_r; sdm.q[tib_pat_r_ty].axis = 1; sdm.q[tib_pat_r_ty].conversion = 1.00000; sdm.q[tib_pat_r_ty].initial_value = -0.02256; sdm.q[tib_pat_r_ty].range_start = -99999.9; sdm.q[tib_pat_r_ty].range_end = 99999.9; sdm.q[tib_pat_r_ty].restraint_func = NULL; sdm.q[tib_pat_r_ty].min_restraint_func = NULL; sdm.q[tib_pat_r_ty].max_restraint_func = NULL; mstrcpy(&sdm.q[tib_pat_r_r3].name,"tib_pat_r_r3"); sdm.q[tib_pat_r_r3].type = constrained_q; sdm.q[tib_pat_r_r3].joint = tib_pat_r; sdm.q[tib_pat_r_r3].axis = 2; sdm.q[tib_pat_r_r3].conversion = 57.29578; sdm.q[tib_pat_r_r3].initial_value = 4.52253; sdm.q[tib_pat_r_r3].range_start = -99999.9; sdm.q[tib_pat_r_r3].range_end = 99999.9; sdm.q[tib_pat_r_r3].restraint_func = NULL; sdm.q[tib_pat_r_r3].min_restraint_func = NULL; sdm.q[tib_pat_r_r3].max_restraint_func = NULL; mstrcpy(&sdm.q[ankle_angle_r].name,"ankle_angle_r"); sdm.q[ankle_angle_r].type = unconstrained_q; sdm.q[ankle_angle_r].joint = ankle_r; sdm.q[ankle_angle_r].axis = 0; sdm.q[ankle_angle_r].conversion = 57.29578; sdm.q[ankle_angle_r].initial_value = 1.73984; sdm.q[ankle_angle_r].range_start = -40.00000; sdm.q[ankle_angle_r].range_end = 40.00000; sdm.q[ankle_angle_r].restraint_func = NULL; sdm.q[ankle_angle_r].min_restraint_func = &q_restraint_func[0]; sdm.q[ankle_angle_r].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[prescribed11].name,"prescribed11"); sdm.q[prescribed11].type = prescribed_q; sdm.q[prescribed11].joint = subtalar_r; sdm.q[prescribed11].axis = 0; sdm.q[prescribed11].conversion = 57.29578; sdm.q[prescribed11].initial_value = 0.00000; sdm.q[prescribed11].range_start = -99999.9; sdm.q[prescribed11].range_end = 99999.9; sdm.q[prescribed11].restraint_func = NULL; sdm.q[prescribed11].min_restraint_func = NULL; sdm.q[prescribed11].max_restraint_func = NULL; mstrcpy(&sdm.q[midfoot_angle_r].name,"midfoot_angle_r"); sdm.q[midfoot_angle_r].type = unconstrained_q; sdm.q[midfoot_angle_r].joint = midfoot_r; sdm.q[midfoot_angle_r].axis = 0; sdm.q[midfoot_angle_r].conversion = 57.29578; sdm.q[midfoot_angle_r].initial_value = 0.00000; sdm.q[midfoot_angle_r].range_start = -60.00000; sdm.q[midfoot_angle_r].range_end = 60.00000; sdm.q[midfoot_angle_r].restraint_func = NULL; sdm.q[midfoot_angle_r].min_restraint_func = &q_restraint_func[0]; sdm.q[midfoot_angle_r].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[mtp_angle_r].name,"mtp_angle_r"); sdm.q[mtp_angle_r].type = unconstrained_q; sdm.q[mtp_angle_r].joint = mtp_r; sdm.q[mtp_angle_r].axis = 0; sdm.q[mtp_angle_r].conversion = 57.29578; sdm.q[mtp_angle_r].initial_value = 0.00000; sdm.q[mtp_angle_r].range_start = -60.00000; sdm.q[mtp_angle_r].range_end = 60.00000; sdm.q[mtp_angle_r].restraint_func = NULL; sdm.q[mtp_angle_r].min_restraint_func = &q_restraint_func[0]; sdm.q[mtp_angle_r].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[hip_angle_l].name,"hip_angle_l"); sdm.q[hip_angle_l].type = unconstrained_q; sdm.q[hip_angle_l].joint = hip_l; sdm.q[hip_angle_l].axis = 0; sdm.q[hip_angle_l].conversion = 57.29578; sdm.q[hip_angle_l].initial_value = -20.39872; sdm.q[hip_angle_l].range_start = -40.00000; sdm.q[hip_angle_l].range_end = 120.00000; sdm.q[hip_angle_l].restraint_func = NULL; sdm.q[hip_angle_l].min_restraint_func = &q_restraint_func[0]; sdm.q[hip_angle_l].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[knee_l_tx].name,"knee_l_tx"); sdm.q[knee_l_tx].type = constrained_q; sdm.q[knee_l_tx].joint = knee_l; sdm.q[knee_l_tx].axis = 0; sdm.q[knee_l_tx].conversion = 1.00000; sdm.q[knee_l_tx].initial_value = -0.00260; sdm.q[knee_l_tx].range_start = -99999.9; sdm.q[knee_l_tx].range_end = 99999.9; sdm.q[knee_l_tx].restraint_func = NULL; sdm.q[knee_l_tx].min_restraint_func = NULL; sdm.q[knee_l_tx].max_restraint_func = NULL; mstrcpy(&sdm.q[knee_l_ty].name,"knee_l_ty"); sdm.q[knee_l_ty].type = constrained_q; sdm.q[knee_l_ty].joint = knee_l; sdm.q[knee_l_ty].axis = 1; sdm.q[knee_l_ty].conversion = 1.00000; sdm.q[knee_l_ty].initial_value = -0.39678; sdm.q[knee_l_ty].range_start = -99999.9; sdm.q[knee_l_ty].range_end = 99999.9; sdm.q[knee_l_ty].restraint_func = NULL; sdm.q[knee_l_ty].min_restraint_func = NULL; sdm.q[knee_l_ty].max_restraint_func = NULL; mstrcpy(&sdm.q[knee_angle_l].name,"knee_angle_l"); sdm.q[knee_angle_l].type = unconstrained_q; sdm.q[knee_angle_l].joint = knee_l; sdm.q[knee_angle_l].axis = 2; sdm.q[knee_angle_l].conversion = 57.29578; sdm.q[knee_angle_l].initial_value = -12.10386; sdm.q[knee_angle_l].range_start = -120.00000; sdm.q[knee_angle_l].range_end = 5.00000; sdm.q[knee_angle_l].restraint_func = NULL; sdm.q[knee_angle_l].min_restraint_func = &q_restraint_func[0]; sdm.q[knee_angle_l].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[tib_pat_l_tx].name,"tib_pat_l_tx"); sdm.q[tib_pat_l_tx].type = constrained_q; sdm.q[tib_pat_l_tx].joint = tib_pat_l; sdm.q[tib_pat_l_tx].axis = 0; sdm.q[tib_pat_l_tx].conversion = 1.00000; sdm.q[tib_pat_l_tx].initial_value = 0.04809; sdm.q[tib_pat_l_tx].range_start = -99999.9; sdm.q[tib_pat_l_tx].range_end = 99999.9; sdm.q[tib_pat_l_tx].restraint_func = NULL; sdm.q[tib_pat_l_tx].min_restraint_func = NULL; sdm.q[tib_pat_l_tx].max_restraint_func = NULL; mstrcpy(&sdm.q[tib_pat_l_ty].name,"tib_pat_l_ty"); sdm.q[tib_pat_l_ty].type = constrained_q; sdm.q[tib_pat_l_ty].joint = tib_pat_l; sdm.q[tib_pat_l_ty].axis = 1; sdm.q[tib_pat_l_ty].conversion = 1.00000; sdm.q[tib_pat_l_ty].initial_value = -0.02221; sdm.q[tib_pat_l_ty].range_start = -99999.9; sdm.q[tib_pat_l_ty].range_end = 99999.9; sdm.q[tib_pat_l_ty].restraint_func = NULL; sdm.q[tib_pat_l_ty].min_restraint_func = NULL; sdm.q[tib_pat_l_ty].max_restraint_func = NULL; mstrcpy(&sdm.q[tib_pat_l_r3].name,"tib_pat_l_r3"); sdm.q[tib_pat_l_r3].type = constrained_q; sdm.q[tib_pat_l_r3].joint = tib_pat_l; sdm.q[tib_pat_l_r3].axis = 2; sdm.q[tib_pat_l_r3].conversion = 57.29578; sdm.q[tib_pat_l_r3].initial_value = 10.40390; sdm.q[tib_pat_l_r3].range_start = -99999.9; sdm.q[tib_pat_l_r3].range_end = 99999.9; sdm.q[tib_pat_l_r3].restraint_func = NULL; sdm.q[tib_pat_l_r3].min_restraint_func = NULL; sdm.q[tib_pat_l_r3].max_restraint_func = NULL; mstrcpy(&sdm.q[ankle_angle_l].name,"ankle_angle_l"); sdm.q[ankle_angle_l].type = unconstrained_q; sdm.q[ankle_angle_l].joint = ankle_l; sdm.q[ankle_angle_l].axis = 0; sdm.q[ankle_angle_l].conversion = 57.29578; sdm.q[ankle_angle_l].initial_value = -0.90216; sdm.q[ankle_angle_l].range_start = -40.00000; sdm.q[ankle_angle_l].range_end = 40.00000; sdm.q[ankle_angle_l].restraint_func = NULL; sdm.q[ankle_angle_l].min_restraint_func = &q_restraint_func[0]; sdm.q[ankle_angle_l].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[prescribed22].name,"prescribed22"); sdm.q[prescribed22].type = prescribed_q; sdm.q[prescribed22].joint = subtalar_l; sdm.q[prescribed22].axis = 0; sdm.q[prescribed22].conversion = 57.29578; sdm.q[prescribed22].initial_value = 0.00000; sdm.q[prescribed22].range_start = -99999.9; sdm.q[prescribed22].range_end = 99999.9; sdm.q[prescribed22].restraint_func = NULL; sdm.q[prescribed22].min_restraint_func = NULL; sdm.q[prescribed22].max_restraint_func = NULL; mstrcpy(&sdm.q[midfoot_angle_l].name,"midfoot_angle_l"); sdm.q[midfoot_angle_l].type = unconstrained_q; sdm.q[midfoot_angle_l].joint = midfoot_l; sdm.q[midfoot_angle_l].axis = 0; sdm.q[midfoot_angle_l].conversion = 57.29578; sdm.q[midfoot_angle_l].initial_value = 0.00000; sdm.q[midfoot_angle_l].range_start = -60.00000; sdm.q[midfoot_angle_l].range_end = 60.00000; sdm.q[midfoot_angle_l].restraint_func = NULL; sdm.q[midfoot_angle_l].min_restraint_func = &q_restraint_func[0]; sdm.q[midfoot_angle_l].max_restraint_func = &q_restraint_func[0]; mstrcpy(&sdm.q[mtp_angle_l].name,"mtp_angle_l"); sdm.q[mtp_angle_l].type = unconstrained_q; sdm.q[mtp_angle_l].joint = mtp_l; sdm.q[mtp_angle_l].axis = 0; sdm.q[mtp_angle_l].conversion = 57.29578; sdm.q[mtp_angle_l].initial_value = 30.00000; sdm.q[mtp_angle_l].range_start = -60.00000; sdm.q[mtp_angle_l].range_end = 60.00000; sdm.q[mtp_angle_l].restraint_func = NULL; sdm.q[mtp_angle_l].min_restraint_func = &q_restraint_func[0]; sdm.q[mtp_angle_l].max_restraint_func = &q_restraint_func[0]; for (i=0, sdm.num_gencoords=0; i<sdm.nq; i++) if (sdm.q[i].type == unconstrained_q) sdm.num_gencoords++; }
ReturnCode makegencform(ModelStruct* ms) { int i, name_len; Form* form; CheckBoxPanel* check; form = &ms->gencform; form->numoptions = ms->numgencoords; form->selected_item = -1; form->cursor_position = 0; form->highlight_start = 0; form->title = NULL; ms->longest_genc_name = 0; form->option = (FormItem*)simm_malloc(form->numoptions*sizeof(FormItem)); if (form->option == NULL) return code_bad; for (i=0; i<form->numoptions; i++) { form->option[i].justify = yes; form->option[i].active = yes; form->option[i].visible = yes; form->option[i].editable = yes; form->option[i].use_alternate_colors = no; form->option[i].decimal_places = 3; form->option[i].data = NULL; mstrcpy(&form->option[i].name, ms->gencoord[i]->name); name_len = glueGetStringWidth(root.gfont.defaultfont, ms->gencoord[i]->name); if (name_len > ms->longest_genc_name) ms->longest_genc_name = name_len; SET_BOX1221(form->option[i].box,0,75,-FORM_FIELD_YSPACING*i, form->option[i].box.y2-FORM_FIELD_HEIGHT); } /* make the gencoord checkbox panel */ check = &ms->gc_chpanel; check->title = "C"; check->type = normal_checkbox; check->numoptions = ms->numgencoords; check->checkbox = (CheckBox*)simm_malloc(check->numoptions*sizeof(CheckBox)); if (check->checkbox == NULL) error(exit_program,tool_message); for (i=0; i<check->numoptions; i++) { check->checkbox[i].just = right; check->checkbox[i].active = yes; check->checkbox[i].visible = yes; if (ms->gencoord[i]->clamped == no) check->checkbox[i].state = off; else check->checkbox[i].state = on; check->checkbox[i].name = NULL; check->checkbox[i].box.x1 = form->option[i].box.x1; check->checkbox[i].box.x2 = check->checkbox[i].box.x1 + CHECKBOX_XSIZE*2/3; check->checkbox[i].box.y1 = form->option[i].box.y1; check->checkbox[i].box.y2 = check->checkbox[i].box.y1 + CHECKBOX_YSIZE*2/3; check->checkbox[i].use_alternate_colors = no; } /* make the gencoord lock checkbox panel */ check = &ms->gc_lockPanel; check->title = "L"; //NULL; check->type = normal_checkbox; check->numoptions = ms->numgencoords; check->checkbox = (CheckBox*)simm_malloc(check->numoptions*sizeof(CheckBox)); if (check->checkbox == NULL) error(exit_program,tool_message); for (i=0; i<check->numoptions; i++) { check->checkbox[i].just = right; check->checkbox[i].active = yes; check->checkbox[i].visible = yes; if (ms->gencoord[i]->locked == no) check->checkbox[i].state = off; else check->checkbox[i].state = on; check->checkbox[i].name = NULL; check->checkbox[i].box.x1 = form->option[i].box.x1; check->checkbox[i].box.x2 = check->checkbox[i].box.x1 + CHECKBOX_XSIZE*2/3; check->checkbox[i].box.y1 = form->option[i].box.y1; check->checkbox[i].box.y2 = check->checkbox[i].box.y1 + CHECKBOX_YSIZE*2/3; } return code_fine; }