23 size_t white = strspn(line,
" \t");
24 return line[
white] == 0;
43 const char *msg =
GBS_global_string(
"[Above this line] Invalid item '%s' defined: %s", itemName, error);
59 throwItemError(I,
"item defines seqtype ('seqtype:' <> '-'), but is lacking input-specification ('in:')", file);
66 throwItemError(I,
"item defines no seqtype ('seqtype:' = '-'), but defines input-specification ('in:')", file);
71 #define THROW_IF_NO(ptr,name) do { if (!ptr) throwParseError(GBS_global_string("'%s' used w/o '" name "'", head), in); } while(0)
73 #define THROW_IF_NO_MENU() THROW_IF_NO(thismenu, "menu")
74 #define THROW_IF_NO_ITEM() THROW_IF_NO(thisitem, "item")
75 #define THROW_IF_NO_ARG() THROW_IF_NO(thisarg, "arg")
76 #define THROW_IF_NO_INPUT() THROW_IF_NO(thisinput, "in")
77 #define THROW_IF_NO_OUTPUT() THROW_IF_NO(thisoutput, "out")
92 while (isspace(str[s])) ++
s;
93 while (str[s]) str[d++] = str[s++];
96 while (d>0 && isspace(str[d-1])) str[--d] = 0;
99 static void splitEntry(
const char *input,
char *head,
char *tail) {
102 const char *colon = strchr(input,
':');
104 int len = colon-input;
105 memcpy(head, input, len);
108 strcpy(tail, colon+1);
139 bool thismenu_firstOccurrence =
true;
151 const char *in_line = lineStr.c_str();
152 if (in_line[0] ==
'#' || (in_line[0] && in_line[1] ==
'#')) {
162 if (strcmp(head,
"menu") == 0) {
164 for (j=0; j<
num_menus && curmenu == -1; j++) {
165 if (strcmp(temp,
menu[j].
label) == 0) curmenu=j;
168 thismenu_firstOccurrence = curmenu == -1;
171 if (thismenu_firstOccurrence) {
173 thismenu = &
menu[curmenu];
179 thismenu = &
menu[curmenu];
188 else if (strcmp(head,
"menumask") == 0) {
191 if (!thismenu_firstOccurrence && thismenu->
active_mask != wanted_mask) {
196 else if (strcmp(head,
"menumeta") == 0) {
198 char wanted_meta = temp[0];
199 if (!thismenu_firstOccurrence && thismenu->
meta != wanted_meta) {
200 if (wanted_meta != 0) {
201 if (thismenu->
meta != 0) {
205 thismenu->
meta = wanted_meta;
210 thismenu->
meta = wanted_meta;
214 else if (strcmp(head,
"item") == 0) {
233 thisitem = &(thismenu->
item[curitem]);
243 thisitem->
meta =
'\0';
253 for (
int i = 0; i<curitem; ++i) {
263 else if (strcmp(head,
"itemmethod") == 0) {
268 char *to = thisitem->
method;
275 if (c ==
'@' && last ==
'@') {
292 else if (strcmp(head,
"itemhelp") == 0) {
298 else if (strcmp(head,
"itemmeta") == 0) {
301 thisitem->
meta = temp[0];
303 else if (strcmp(head,
"itemmask") == 0) {
308 else if (strcmp(head,
"seqtype") == 0) {
310 thisitem->
seqtype = toupper(temp[0]);
322 else if (strcmp(head,
"arg") == 0) {
328 thisarg = &(thisitem->
arg[curarg]);
343 else if (strcmp(head,
"argtype") == 0) {
346 if (strncmp(temp,
"text", (arglen = 4)) == 0) {
352 if (temp[arglen] !=
'(' || temp[strlen(temp)-1] !=
')') {
353 sprintf(head,
"Unknown argtype '%s' -- syntax: text(width) e.g. text(20)",
truncate_4000(temp));
356 thisarg->
textwidth = atoi(temp+arglen+1);
358 sprintf(head,
"Illegal textwidth specified in '%s'",
truncate_4000(temp));
363 else if (strcmp(temp,
"choice_list") == 0) thisarg->
type =
CHOICE_LIST;
364 else if (strcmp(temp,
"choice_menu") == 0) thisarg->
type =
CHOICE_MENU;
365 else if (strcmp(temp,
"chooser") == 0) thisarg->
type =
CHOOSER;
366 else if (strcmp(temp,
"filename") == 0) {
371 else if (strcmp(temp,
"slider") == 0) thisarg->
type =
SLIDER;
383 else if (strcmp(head,
"argtext") == 0) {
390 else if (strcmp(head,
"arglabel") == 0) {
401 else if (strcmp(head,
"argchoice") == 0) {
412 else if (strcmp(head,
"argmin") == 0) {
414 (void)sscanf(temp,
"%lf", &(thisarg->
min));
417 else if (strcmp(head,
"argmax") == 0) {
419 (void)sscanf(temp,
"%lf", &(thisarg->
max));
422 else if (strcmp(head,
"argvalue") == 0) {
428 (void)sscanf(temp,
"%lf", &(thisarg->
fvalue));
432 else if (strcmp(head,
"argmask") == 0) {
437 else if (strcmp(head,
"in") == 0) {
443 thisinput = &(thisitem->
input)[curinput];
445 thisinput->
save =
false;
451 else if (strcmp(head,
"informat") == 0) {
457 else if (strcmp(head,
"insave") == 0) {
459 thisinput->
save =
true;
461 else if (strcmp(head,
"intyped") == 0) {
468 else if (strcmp(head,
"out") == 0) {
474 thisoutput = &(thisitem->
output)[curoutput];
476 thisoutput->
save =
false;
481 else if (strcmp(head,
"outformat") == 0) {
488 else if (strcmp(head,
"outaligned") == 0) {
493 else if (strcmp(head,
"outsave") == 0) {
495 thisoutput->
save =
true;
534 MultiFileReader menus(files);
535 error = menus.get_error();
540 catch (
const string& err) {
550 bool Find(
const char *target,
const char *key) {
552 return strstr(target, key) ?
true :
false;
555 int Find2(
const char *target,
const char *key) {
559 const char *found = strstr(target, key);
560 return found ?
int(found-target) : -1;
570 void TEST_load_menu() {
594 "Import;Export;Print;Align;SAI;Incremental phylogeny;Phylogeny Distance Matrix;"
595 "Phylogeny max. parsimony;Phylogeny max. Likelihood EXP;Phylogeny max. Likelihood;Phylogeny (Other);User;");
GB_CSTR GB_path_in_arbprop(const char *relative_path)
GB_ERROR GB_incur_error()
return string(buffer, length)
bool getLine(string &line)
char * ARB_strdup(const char *str)
const char * GBS_global_string(const char *templat,...)
char * GBS_string_eval(const char *insource, const char *icommand)
NOT4PERL gb_getenv_hook GB_install_getenv_hook(gb_getenv_hook hook)
char buffer[MESSAGE_BUFFERSIZE]
size_t getLineNumber() const
void strcpy_truncate(char *dest, const char *source, size_t dest_size)
TYPE * ARB_alloc(size_t nelem)
static void error(const char *msg)
void ARB_recalloc(TYPE *&tgt, size_t oelem, size_t nelem)
const char *(* gb_getenv_hook)(const char *varname)
GB_CSTR GB_path_in_ARBLIB(const char *relative_path)
void GBS_read_dir(StrArray &names, const char *dir, const char *mask)
virtual const string & getFilename() const =0
TYPE * ARB_calloc(size_t nelem)
bool GB_is_directory(const char *path)
void ARB_realloc(TYPE *&tgt, size_t nelem)
const char * GBS_static_string(const char *str)
#define TEST_EXPECT_NO_ERROR(call)
#define TEST_EXPECT_EQUAL(expr, want)
GB_ERROR GB_create_directory(const char *path)
char * GBS_global_string_copy(const char *templat,...)
GB_write_int const char s