BOOL cmdlne_SetArgument(const char* token, const char* value) /************************************************************** INPUT: two pointers RETURNS: TRUE if the argument <token> has not been added to the list of arguments before and FALSE otherwise. EFFECT: Adds argument <token> with value <value> to list of arguments (<cmdlne_ArgumentsList>) CAUTION: <value> has to be a character pointer pointing to a string representing an integer ***************************************************************/ { LIST Pair; LIST Scan; /* Check if Argument has already been defined */ for(Scan=cmdlne_ArgumentsList; !list_Empty(Scan); Scan = list_Cdr(Scan)) { if(string_Equal(list_PairFirst(list_Car(Scan)),token)) { misc_StartUserErrorReport(); misc_UserErrorReport("\n Option %s is multiply defined.\n\n", token); misc_FinishUserErrorReport(); return FALSE; } } /* Add <token> to argument list with value <value>*/ Pair = list_PairCreate(string_StringCopy(token), string_StringCopy(value)); cmdlne_ArgumentsList = list_Cons(Pair, cmdlne_ArgumentsList); return TRUE; }
BOOL cmdlne_SetFlags(FLAGSTORE flagstore) /**************************************************************** INPUT: a FLAGSTORE RETURNS: TRUE if all arguments of <cmdlne_ArgumentsList> are valid arguments and the respective flags of <flagstore> could be set and FALSE otherwise. EFFECT: Set flags of <flagstore> according to arguments stored in <cmdlne_ArgumentsList> *****************************************************************/ { int id, tk; LIST Scan; BOOL found; for(Scan=cmdlne_ArgumentsList; !list_Empty(Scan); Scan = list_Cdr(Scan)) { found = FALSE; for (id=0; id < flag_GetMaxFlag() && !found; id++) { if (!flag_IsUndefined(id) && string_Equal(flag_Name(id), (char*) list_PairFirst(list_Car(Scan))) ) { if (flag_IsOfValueType(id, flag_INTEGER)) { if(!string_StringIsInteger(list_PairSecond(list_Car(Scan)))){ misc_StartUserErrorReport(); misc_UserErrorReport("\nError: Argument of option %s must be an integer.\n\n", flag_Name(id)); misc_FinishUserErrorReport(); return FALSE; } tk = atoi((char*) list_PairSecond(list_Car(Scan))); flag_SetFlagIntValue(flagstore, id, tk); } else { flag_SetFlagStringValue(flagstore, id, string_StringCopy((char*)list_PairSecond(list_Car(Scan)))); } found = TRUE; } } if(!found) { misc_StartUserErrorReport(); misc_UserErrorReport("\n Unrecognized option %s\n\n", (char*) list_PairFirst(list_Car(Scan))); misc_FinishUserErrorReport(); return FALSE; } } return TRUE; }
FLAG_ID flag_Id(const char* String) /************************************************************** INPUT: A string <String>. RETURNS: The identification of the flag <String> if it exists -1 otherwise. ***************************************************************/ { FLAG_ID i; for (i = (FLAG_ID) 0; i < flag_MAXFLAG; i++) if (string_Equal(flag_Name(i), String)) return i; return (FLAG_ID) -1; }
SYMBOL symbol_Lookup(const char* String) /********************************************************** INPUT: A pointer to a string. RETURNS: If a symbol with name String exists in the signature, the symbol; 0 otherwise ********************************************************/ { if (symbol_SignatureExists()) { int Index; SIGNATURE S; for (Index = 1; Index < symbol_ACTINDEX; Index++) { S = symbol_Signature(Index); if (S != NULL && string_Equal(String, S->name)) return S->info; } } return 0; }