int Rmf_set_info (Isis_Rmf_t *rmf, Rmf_Info_Type *info) /*{{{*/ { if ((rmf == NULL) || (info == NULL)) return -1; /* don't overwrite arg-string, index or method fields */ rmf->order = info->order; isis_strcpy(rmf->grating,info->grating, sizeof(rmf->grating)); isis_strcpy(rmf->instrument,info->instrument, sizeof(rmf->instrument)); return 0; }
/** * isis_update_option_string assumes that *optstring starts with a name * from which the first updatable option is separated by a ';', * in order to prevent, e.g., * isis_update_option_string ("simann;initial_step=0.05;t=1.0", "t", "2") * to produce * *optstring = "simann;init=2;t=1.0" */ int isis_update_option_string (char **optstring, char *optname, char *optvalue) { char *start, *end, *newstring, *s; int len12, len3, len4; if (optstring == NULL || optname == NULL) return -1; /* *optstring = $12 + $3 + $4 * where $12 = $prefix + ";" + $optname * $3 = "=" + $optvalue * (opt.) $4 = ";" + $suffix */ /* find option */ start = *optstring; do if (NULL == (start = strstr (start+1, optname))) return -1; while (*(start-1) != ';'); /* NULL means this option appears last */ end = strchr (start, ';'); len12 = start - *optstring + strlen(optname); len3 = optvalue ? strlen(optvalue) + 1 : 0; len4 = end ? strlen (end) : 0; if (NULL == (newstring = (char *) ISIS_MALLOC (len12 + len3 + len4 + 1))) return -1; s = isis_strcpy (newstring, *optstring, len12); if (len3 > 0) { sprintf (s, "=%s", optvalue); s += len3; } if (len4 > 0) { s = isis_strcpy (s, end, len4 + 1); } ISIS_FREE (*optstring); *optstring = newstring; return 0; }