2022-03-08 04:43:05 +08:00
|
|
|
#include <malloc.h>
|
2023-04-09 02:17:32 +08:00
|
|
|
#include <stdio.h>
|
2022-03-08 04:43:05 +08:00
|
|
|
#include <xview/panel.h>
|
2023-04-09 02:17:32 +08:00
|
|
|
#include <xview/xview.h>
|
|
|
|
|
2022-03-08 04:43:05 +08:00
|
|
|
#include "defines.h"
|
2023-04-09 02:17:32 +08:00
|
|
|
#include "menudefs.h"
|
2022-03-08 04:43:05 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
ParseMenus(): Read in the menu config file, and generate the internal
|
|
|
|
menu structures used by the window system.
|
|
|
|
|
|
|
|
Copyright (c) 1989, University of Illinois board of trustees. All rights
|
|
|
|
reserved. Written by Steven Smith at the Center for Prokaryote Genome
|
|
|
|
Analysis. Design and implementation guidance by Dr. Gary Olsen and Dr.
|
|
|
|
Carl Woese.
|
|
|
|
|
|
|
|
Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern Gmenu menu[];
|
|
|
|
int num_menus;
|
|
|
|
|
|
|
|
ParseMenu()
|
|
|
|
{
|
2023-04-09 02:17:32 +08:00
|
|
|
int j, curmenu = -1, curitem = 0;
|
|
|
|
int curchoice = 0, curarg = 0, curinput = 0, curoutput = 0;
|
|
|
|
char Inline[GBUFSIZ], temp[GBUFSIZ], head[GBUFSIZ];
|
|
|
|
char tail[GBUFSIZ], *home;
|
2022-03-08 04:43:05 +08:00
|
|
|
Gmenu *thismenu;
|
|
|
|
GmenuItem *thisitem;
|
|
|
|
GmenuItemArg *thisarg;
|
2023-04-09 02:17:32 +08:00
|
|
|
GfileFormat *thisinput, *thisoutput;
|
2022-03-08 04:43:05 +08:00
|
|
|
FILE *file;
|
|
|
|
char *resize;
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Open the menu configuration file ".GDEmenus"
|
|
|
|
* First search the local directory, then the home directory.
|
|
|
|
*/
|
|
|
|
file = fopen(".GDEmenus", "r");
|
|
|
|
if (file == NULL) {
|
|
|
|
home = (char *)getenv("HOME");
|
|
|
|
strcpy(temp, home);
|
|
|
|
strcat(temp, "/.GDEmenus");
|
|
|
|
|
|
|
|
file = fopen(temp, "r");
|
|
|
|
if (file == NULL) {
|
|
|
|
home = (char *)getenv("GDE_HELP_DIR");
|
|
|
|
if (home != NULL) {
|
|
|
|
strcpy(temp, home);
|
|
|
|
strcat(temp, "/.GDEmenus");
|
|
|
|
file = fopen(temp, "r");
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
if (file == NULL)
|
|
|
|
Error(
|
|
|
|
".GDEmenus file not in the home, local, or "
|
|
|
|
"$GDE_HELP_DIR directory");
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Read the .GDEmenus file, and assemble an internal representation
|
|
|
|
* of the menu/menu-item hierarchy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (; gde_getline(file, Inline) != EOF;) {
|
|
|
|
/*
|
|
|
|
* menu: chooses menu to use
|
|
|
|
*/
|
|
|
|
if (Inline[0] == '#')
|
|
|
|
;
|
|
|
|
else if (Find(Inline, "menu:")) {
|
|
|
|
crop(Inline, head, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
curmenu = -1;
|
2023-04-09 02:17:32 +08:00
|
|
|
for (j = 0; j < num_menus; j++)
|
|
|
|
if (Find(temp, menu[j].label)) curmenu = j;
|
|
|
|
/*
|
|
|
|
* If menu not found, make a new one
|
|
|
|
*/
|
|
|
|
if (curmenu == -1) {
|
2022-03-08 04:43:05 +08:00
|
|
|
curmenu = num_menus++;
|
|
|
|
thismenu = &menu[curmenu];
|
2023-04-09 02:17:32 +08:00
|
|
|
thismenu->label = (char *)calloc(
|
|
|
|
strlen(temp) + 1, sizeof(char));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (thismenu->label == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thismenu->label, temp);
|
|
|
|
thismenu->numitems = 0;
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* item: chooses menu item to use
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "item:")) {
|
2022-03-08 04:43:05 +08:00
|
|
|
curarg = -1;
|
|
|
|
curinput = -1;
|
|
|
|
curoutput = -1;
|
2023-04-09 02:17:32 +08:00
|
|
|
crop(Inline, head, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
curitem = thismenu->numitems++;
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Resize the item list for this menu (add one
|
|
|
|
*item);
|
|
|
|
*/
|
|
|
|
if (curitem == 0)
|
|
|
|
resize = (char *)calloc(1, sizeof(GmenuItem));
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
2023-04-09 02:17:32 +08:00
|
|
|
resize = realloc(
|
|
|
|
thismenu->item,
|
|
|
|
thismenu->numitems * sizeof(GmenuItem));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (resize == NULL) Error("Calloc");
|
|
|
|
thismenu->item = (GmenuItem *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
|
|
|
|
thisitem = &(thismenu->item[curitem]);
|
2023-04-09 02:17:32 +08:00
|
|
|
thisitem->label =
|
|
|
|
(char *)calloc(strlen(temp) + 1, sizeof(char));
|
2022-03-08 04:43:05 +08:00
|
|
|
thisitem->meta = '\0';
|
|
|
|
thisitem->numinputs = 0;
|
|
|
|
thisitem->numoutputs = 0;
|
|
|
|
thisitem->numargs = 0;
|
|
|
|
thisitem->X = 0;
|
|
|
|
thisitem->help = NULL;
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Create new item
|
|
|
|
*/
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (thisitem->label == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisitem->label, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* itemmethod: generic command line generated by this item
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "itemmethod:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
thisitem->method =
|
|
|
|
(char *)calloc(strlen(temp) + 1, sizeof(char));
|
|
|
|
if (thisitem->method == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisitem->method, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Help file
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "itemhelp:")) {
|
|
|
|
crop(Inline, head, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
thisitem->help =
|
2023-04-09 02:17:32 +08:00
|
|
|
(char *)calloc(strlen(temp) + 1, sizeof(char));
|
|
|
|
if (thisitem->method == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisitem->help, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Meta key equiv
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "itemmeta:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
thisitem->meta = temp[0];
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* arg: defines the symbol for a command line arguement.
|
|
|
|
* this is used for substitution into the
|
|
|
|
*itemmethod definition.
|
|
|
|
*/
|
|
|
|
|
|
|
|
else if (Find(Inline, "arg:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
curarg = thisitem->numargs++;
|
|
|
|
if (curarg == 0)
|
|
|
|
resize =
|
|
|
|
(char *)calloc(1, sizeof(GmenuItemArg));
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
2023-04-09 02:17:32 +08:00
|
|
|
resize = realloc(
|
|
|
|
thisitem->arg,
|
|
|
|
thisitem->numargs * sizeof(GmenuItemArg));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (resize == NULL) Error("arg: Realloc");
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
(thisitem->arg) = (GmenuItemArg *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisarg = &(thisitem->arg[curarg]);
|
2023-04-09 02:17:32 +08:00
|
|
|
thisarg->symbol =
|
|
|
|
(char *)calloc(strlen(temp) + 1, sizeof(char));
|
|
|
|
if (thisarg->symbol == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisarg->symbol, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
thisarg->optional = FALSE;
|
|
|
|
thisarg->type = 0;
|
|
|
|
thisarg->min = 0;
|
|
|
|
thisarg->max = 0;
|
|
|
|
thisarg->numchoices = 0;
|
|
|
|
thisarg->choice = NULL;
|
|
|
|
thisarg->textvalue = NULL;
|
|
|
|
thisarg->value = 0;
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argtype: Defines the type of argument (menu,chooser,
|
|
|
|
*text, slider)
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argtype:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
if (strcmp(temp, "text") == 0) {
|
|
|
|
thisarg->type = TEXTFIELD;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisarg->textvalue =
|
2023-04-09 02:17:32 +08:00
|
|
|
(char *)calloc(GBUFSIZ, sizeof(char));
|
|
|
|
if (thisarg->textvalue == NULL) Error("Calloc");
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (strcmp(temp, "choice_list") == 0)
|
|
|
|
thisarg->type = CHOICE_LIST;
|
|
|
|
else if (strcmp(temp, "choice_menu") == 0)
|
|
|
|
thisarg->type = CHOICE_MENU;
|
|
|
|
else if (strcmp(temp, "chooser") == 0)
|
|
|
|
thisarg->type = CHOOSER;
|
|
|
|
else if (strcmp(temp, "slider") == 0)
|
|
|
|
thisarg->type = SLIDER;
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
2023-04-09 02:17:32 +08:00
|
|
|
Error(
|
|
|
|
sprintf(head, "Unknown argtype %s", temp));
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argtext: The default text value of the symbol.
|
|
|
|
* $argument is replaced by this value if it is not
|
|
|
|
* changed in the dialog box by the user.
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argtext:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
(void)strcpy(thisarg->textvalue, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* arglabel: Text label displayed in the dialog box for
|
|
|
|
* this argument. It should be a discriptive
|
|
|
|
*label.
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "arglabel:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
thisarg->label =
|
|
|
|
(char *)calloc(strlen(temp) + 1, sizeof(char));
|
|
|
|
if (thisarg->label == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisarg->label, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Argument choice values use the following notation:
|
|
|
|
*
|
|
|
|
* argchoice:Displayed value:Method
|
|
|
|
*
|
|
|
|
* Where "Displayed value" is the label displayed in the
|
|
|
|
*dialog box and "Method" is the value passed back on the
|
|
|
|
*command line.
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argchoice:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
crop(temp, head, tail);
|
2022-03-08 04:43:05 +08:00
|
|
|
curchoice = thisarg->numchoices++;
|
2023-04-09 02:17:32 +08:00
|
|
|
if (curchoice == 0)
|
|
|
|
resize = (char *)calloc(1, sizeof(GargChoice));
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
2023-04-09 02:17:32 +08:00
|
|
|
resize = realloc(
|
|
|
|
thisarg->choice,
|
|
|
|
thisarg->numchoices * sizeof(GargChoice));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (resize == NULL) Error("argchoice: Realloc");
|
|
|
|
thisarg->choice = (GargChoice *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
|
|
|
|
(thisarg->choice[curchoice].label) = NULL;
|
|
|
|
(thisarg->choice[curchoice].method) = NULL;
|
|
|
|
|
|
|
|
(thisarg->choice[curchoice].label) =
|
2023-04-09 02:17:32 +08:00
|
|
|
(char *)calloc(strlen(head) + 1, sizeof(char));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
|
|
|
(thisarg->choice[curchoice].method) =
|
2023-04-09 02:17:32 +08:00
|
|
|
(char *)calloc(strlen(tail) + 1, sizeof(char));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (thisarg->choice[curchoice].method == NULL ||
|
|
|
|
thisarg->choice[curchoice].label == NULL)
|
2022-03-08 04:43:05 +08:00
|
|
|
Error("Calloc");
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
(void)strcpy(thisarg->choice[curchoice].label, head);
|
|
|
|
(void)strcpy(thisarg->choice[curchoice].method, tail);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argmin: Minimum value for a slider
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argmin:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
(void)sscanf(temp, "%d", &(thisarg->min));
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argmax: Maximum value for a slider
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argmax:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
(void)sscanf(temp, "%d", &(thisarg->max));
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argmethod: Command line flag associated with this
|
|
|
|
*argument. Replaces argument in itemmethod description.
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argmethod:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
thisarg->method = (char *)calloc(GBUFSIZ, strlen(temp));
|
|
|
|
if (thisarg->method == NULL) Error("Calloc");
|
|
|
|
(void)strcpy(thisarg->method, tail);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argvalue: default value for a slider
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argvalue:")) {
|
|
|
|
crop(Inline, head, temp);
|
|
|
|
if (thisarg->type == TEXT)
|
|
|
|
strcpy(thisarg->textvalue, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
2023-04-09 02:17:32 +08:00
|
|
|
(void)sscanf(temp, "%d", &(thisarg->value));
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* argoptional: Flag specifying that an arguement is
|
|
|
|
*optional
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "argoptional:"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisarg->optional = TRUE;
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* in: Input file description
|
|
|
|
*/
|
|
|
|
else if (Find(Inline, "in:")) {
|
|
|
|
crop(Inline, head, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
curinput = (thisitem->numinputs)++;
|
2023-04-09 02:17:32 +08:00
|
|
|
if (curinput == 0)
|
|
|
|
resize = (char *)calloc(1, sizeof(GfileFormat));
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
|
|
|
resize = realloc(thisitem->input,
|
2023-04-09 02:17:32 +08:00
|
|
|
(thisitem->numinputs) *
|
|
|
|
sizeof(GfileFormat));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (resize == NULL) Error("in: Realloc");
|
|
|
|
thisitem->input = (GfileFormat *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput = &(thisitem->input)[curinput];
|
|
|
|
thisinput->save = FALSE;
|
|
|
|
thisinput->overwrite = FALSE;
|
|
|
|
thisinput->maskable = FALSE;
|
|
|
|
thisinput->format = 0;
|
|
|
|
thisinput->symbol = String(temp);
|
|
|
|
thisinput->name = NULL;
|
|
|
|
thisinput->select = SELECTED;
|
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* out: Output file description
|
|
|
|
*/
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "out:")) {
|
|
|
|
crop(Inline, head, temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
curoutput = (thisitem->numoutputs)++;
|
2023-04-09 02:17:32 +08:00
|
|
|
if (curoutput == 0)
|
|
|
|
resize = (char *)calloc(1, sizeof(GfileFormat));
|
2022-03-08 04:43:05 +08:00
|
|
|
else
|
|
|
|
resize = realloc(thisitem->output,
|
2023-04-09 02:17:32 +08:00
|
|
|
(thisitem->numoutputs) *
|
|
|
|
sizeof(GfileFormat));
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (resize == NULL) Error("out: Realloc");
|
|
|
|
thisitem->output = (GfileFormat *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput = &(thisitem->output)[curoutput];
|
2023-04-09 02:17:32 +08:00
|
|
|
thisitem->output = (GfileFormat *)resize;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput = &(thisitem->output)[curoutput];
|
2023-04-09 02:17:32 +08:00
|
|
|
thisoutput->save = FALSE;
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->overwrite = FALSE;
|
|
|
|
thisoutput->format = 0;
|
2023-04-09 02:17:32 +08:00
|
|
|
thisoutput->symbol = String(temp);
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->name = NULL;
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "informat:")) {
|
|
|
|
if (thisinput == NULL) Error("Problem with .GDEmenus");
|
|
|
|
crop(Inline, head, tail);
|
|
|
|
if (Find(tail, "genbank"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = GENBANK;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "gde"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = GDE;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "na_flat"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = NA_FLAT;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "colormask"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = COLORMASK;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "flat"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = NA_FLAT;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "status"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->format = STATUS_FILE;
|
2023-04-09 02:17:32 +08:00
|
|
|
else
|
|
|
|
fprintf(stderr,
|
|
|
|
"Warning, unknown file format %s\n",
|
|
|
|
tail);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "insave:")) {
|
|
|
|
if (thisinput == NULL) Error("Problem with .GDEmenus");
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->save = TRUE;
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "inselect:")) {
|
|
|
|
if (thisinput == NULL) Error("Problem with .GDEmenus");
|
|
|
|
crop(Inline, head, tail);
|
|
|
|
if (Find(tail, "one"))
|
|
|
|
thisinput->select = SELECT_ONE;
|
|
|
|
else if (Find(tail, "region"))
|
|
|
|
thisinput->select = SELECT_REGION;
|
|
|
|
else if (Find(tail, "all"))
|
|
|
|
thisinput->select = ALL;
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "inmask:")) {
|
|
|
|
if (thisinput == NULL) Error("Problem with .GDEmenus");
|
2022-03-08 04:43:05 +08:00
|
|
|
thisinput->maskable = TRUE;
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "outformat:")) {
|
|
|
|
if (thisoutput == NULL) Error("Problem with .GDEmenus");
|
|
|
|
crop(Inline, head, tail);
|
|
|
|
if (Find(tail, "genbank"))
|
|
|
|
thisoutput->format = GENBANK;
|
|
|
|
else if (Find(tail, "gde"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->format = GDE;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "na_flat"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->format = NA_FLAT;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "flat"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->format = NA_FLAT;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "status"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->format = STATUS_FILE;
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(tail, "colormask"))
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->format = COLORMASK;
|
2023-04-09 02:17:32 +08:00
|
|
|
else
|
|
|
|
fprintf(stderr,
|
|
|
|
"Warning, unknown file format %s\n",
|
|
|
|
tail);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "outsave:")) {
|
|
|
|
if (thisoutput == NULL) Error("Problem with .GDEmenus");
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->save = TRUE;
|
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
else if (Find(Inline, "outoverwrite:")) {
|
|
|
|
if (thisoutput == NULL) Error("Problem with .GDEmenus");
|
2022-03-08 04:43:05 +08:00
|
|
|
thisoutput->overwrite = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find(): Search the target string for the given key
|
|
|
|
*/
|
2023-04-09 02:17:32 +08:00
|
|
|
Find(target, key) char *key, *target;
|
2022-03-08 04:43:05 +08:00
|
|
|
{
|
2023-04-09 02:17:32 +08:00
|
|
|
int i, j, len1, dif, flag = FALSE;
|
|
|
|
dif = (strlen(target)) - (len1 = strlen(key)) + 1;
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (len1 > 0)
|
|
|
|
for (j = 0; j < dif && flag == FALSE; j++) {
|
2022-03-08 04:43:05 +08:00
|
|
|
flag = TRUE;
|
2023-04-09 02:17:32 +08:00
|
|
|
for (i = 0; i < len1 && flag; i++)
|
|
|
|
flag = (key[i] == target[i + j]) ? TRUE : FALSE;
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
return (flag);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
Find2(target, key) char *key, *target;
|
2022-03-08 04:43:05 +08:00
|
|
|
/*
|
2023-04-09 02:17:32 +08:00
|
|
|
* Like find, but returns the index of the leftmost
|
|
|
|
* occurence, and -1 if not found.
|
|
|
|
*/
|
2022-03-08 04:43:05 +08:00
|
|
|
{
|
2023-04-09 02:17:32 +08:00
|
|
|
int i, j, len1, dif, flag = FALSE;
|
|
|
|
dif = (strlen(target)) - (len1 = strlen(key)) + 1;
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
if (len1 > 0)
|
|
|
|
for (j = 0; j < dif && flag == FALSE; j++) {
|
2022-03-08 04:43:05 +08:00
|
|
|
flag = TRUE;
|
2023-04-09 02:17:32 +08:00
|
|
|
for (i = 0; i < len1 && flag; i++)
|
|
|
|
flag = (key[i] == target[i + j]) ? TRUE : FALSE;
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
2023-04-09 02:17:32 +08:00
|
|
|
return (flag ? j - 1 : -1);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
Error(msg) char *msg;
|
2022-03-08 04:43:05 +08:00
|
|
|
{
|
2023-04-09 02:17:32 +08:00
|
|
|
(void)fprintf(stderr, "%s\n", msg);
|
2022-03-08 04:43:05 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
int gde_getline(file, string)
|
2022-03-08 04:43:05 +08:00
|
|
|
FILE *file;
|
|
|
|
char string[];
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
int i;
|
2023-04-09 02:17:32 +08:00
|
|
|
for (i = 0; ((c = getc(file)) != '\n') && (c != EOF); i++)
|
|
|
|
string[i] = c;
|
2022-03-08 04:43:05 +08:00
|
|
|
string[i] = '\0';
|
2023-04-09 02:17:32 +08:00
|
|
|
if (i == 0 && c == EOF)
|
|
|
|
return (EOF);
|
|
|
|
else
|
|
|
|
return (0);
|
2022-03-08 04:43:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Crop():
|
|
|
|
Split "this:that[:the_other]"
|
2023-04-09 02:17:32 +08:00
|
|
|
into: "this" and "that[:the_other]"
|
2022-03-08 04:43:05 +08:00
|
|
|
*/
|
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
crop(input, head, tail) char input[], head[], tail[];
|
2022-03-08 04:43:05 +08:00
|
|
|
{
|
2023-04-09 02:17:32 +08:00
|
|
|
/*
|
|
|
|
* Crop needs to be fixed so that whitespace is compressed off the
|
|
|
|
*end of tail
|
|
|
|
*/
|
|
|
|
int offset, end, i, j, length;
|
|
|
|
|
|
|
|
length = strlen(input);
|
|
|
|
for (offset = 0; offset < length && input[offset] != ':'; offset++)
|
|
|
|
head[offset] = input[offset];
|
2022-03-08 04:43:05 +08:00
|
|
|
head[offset++] = '\0';
|
2023-04-09 02:17:32 +08:00
|
|
|
for (; offset < length && input[offset] == ' '; offset++)
|
|
|
|
;
|
|
|
|
for (end = length - 1; input[end] == ' ' && end > offset; end--)
|
|
|
|
;
|
2022-03-08 04:43:05 +08:00
|
|
|
|
2023-04-09 02:17:32 +08:00
|
|
|
for (j = 0, i = offset; i <= end; i++, j++) tail[j] = input[i];
|
2022-03-08 04:43:05 +08:00
|
|
|
tail[j] = '\0';
|
|
|
|
return;
|
|
|
|
}
|