fix: April 2023 archlinux

This commit is contained in:
kuoi 2023-04-09 02:17:32 +08:00
parent a25316aa9e
commit 15feb1c6c9
4 changed files with 2341 additions and 2587 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,12 @@
#include <sys/time.h>
#include <stdio.h>
#include <malloc.h>
#include <xview/xview.h>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <xview/panel.h>
#include "menudefs.h"
#include <xview/xview.h>
#include "defines.h"
#include "menudefs.h"
/*
Copyright (c) 1989-1990, University of Illinois board of trustees. All
@ -19,223 +21,220 @@ Copyright (c) 1993, Steven Smith, all rights reserved.
*/
ReadGen(filename,dataset,type)
char *filename;
ReadGen(filename, dataset, type) char *filename;
NA_Alignment *dataset;
int type;
{
register int done = FALSE,len = 0, j=0;
int count,IS_REALLY_AA = FALSE;
char Inline[GBUFSIZ],c;
char *buffer,*gencomments = NULL,fields[8][GBUFSIZ];
int buflen = 0,genclen = 0,curelem = 0,n = 0,flag = 0;
register int done = FALSE, len = 0, j = 0;
int count, IS_REALLY_AA = FALSE;
char Inline[GBUFSIZ], c;
char *buffer, *gencomments = NULL, fields[8][GBUFSIZ];
int buflen = 0, genclen = 0, curelem = 0, n = 0, flag = 0;
int start_col = -1;
NA_Sequence *this_elem;
FILE *file;
extern int Default_DNA_Trans[], Default_RNA_Trans[];
extern int Default_NA_RTrans[];
extern int Default_PROColor_LKUP[],Default_NAColor_LKUP[];
extern int Default_PROColor_LKUP[], Default_NAColor_LKUP[];
ErrorOut("No such file",file = fopen(filename,"r"));
ErrorOut("No such file", file = fopen(filename, "r"));
for(;fgets(Inline,GBUFSIZ,file) != 0;)
{
if(Inline[strlen(Inline)-1] == '\n')
Inline[strlen(Inline)-1] = '\0';
if(Find(Inline,"LOCUS"))
{
for (; fgets(Inline, GBUFSIZ, file) != 0;) {
if (Inline[strlen(Inline) - 1] == '\n')
Inline[strlen(Inline) - 1] = '\0';
if (Find(Inline, "LOCUS")) {
curelem = dataset->numelements++;
if(curelem == 0)
{
dataset->element=(NA_Sequence*)
Calloc(5,sizeof(NA_Sequence));
if (curelem == 0) {
dataset->element = (NA_Sequence *)Calloc(
5, sizeof(NA_Sequence));
dataset->maxnumelements = 5;
}
else if (curelem==dataset->maxnumelements)
{
else if (curelem == dataset->maxnumelements) {
(dataset->maxnumelements) *= 2;
dataset->element =(NA_Sequence*)
Realloc(dataset->element,
dataset->maxnumelements * sizeof(NA_Sequence));
dataset->element = (NA_Sequence *)Realloc(
dataset->element, dataset->maxnumelements *
sizeof(NA_Sequence));
}
this_elem = &(dataset->element[curelem]);
n = sscanf(Inline,"%s %s %s %s %s %s %s %s",
fields[0],fields[1],fields[2],fields[3],fields[4],
fields[5],fields[6],fields[7]);
if(IS_REALLY_AA)
{
InitNASeq(this_elem,PROTEIN);
n = sscanf(Inline, "%s %s %s %s %s %s %s %s", fields[0],
fields[1], fields[2], fields[3], fields[4],
fields[5], fields[6], fields[7]);
if (IS_REALLY_AA) {
InitNASeq(this_elem, PROTEIN);
}
else if(Find(Inline,"DNA"))
{
InitNASeq(this_elem,DNA);
else if (Find(Inline, "DNA")) {
InitNASeq(this_elem, DNA);
}
else if(Find(Inline,"RNA"))
{
InitNASeq(this_elem,RNA);
else if (Find(Inline, "RNA")) {
InitNASeq(this_elem, RNA);
}
else if(Find(Inline,"MASK"))
{
InitNASeq(this_elem,MASK);
else if (Find(Inline, "MASK")) {
InitNASeq(this_elem, MASK);
}
else if(Find(Inline,"TEXT"))
{
InitNASeq(this_elem,TEXT);
else if (Find(Inline, "TEXT")) {
InitNASeq(this_elem, TEXT);
}
else if(Find(Inline,"PROT"))
{
InitNASeq(this_elem,PROTEIN);
else if (Find(Inline, "PROT")) {
InitNASeq(this_elem, PROTEIN);
}
else
InitNASeq(this_elem,DNA);
InitNASeq(this_elem, DNA);
strncpy(this_elem->short_name,fields[1],31);
AsciiTime(&(this_elem->t_stamp.origin),fields[n-1]);
strncpy(this_elem->short_name, fields[1], 31);
AsciiTime(&(this_elem->t_stamp.origin), fields[n - 1]);
this_elem->attr = DEFAULT_X_ATTR;
if( Find(Inline, "Circular") )
if (Find(Inline, "Circular"))
this_elem->attr |= IS_CIRCULAR;
gencomments = NULL;
genclen = 0;
}
else if(Find(Inline,"DEFINITION"))
strncpy(this_elem->description,&(Inline[12]),79);
else if (Find(Inline, "DEFINITION"))
strncpy(this_elem->description, &(Inline[12]), 79);
else if(Find(Inline,"AUTHOR"))
strncpy(this_elem->authority,&(Inline[12]),79);
else if (Find(Inline, "AUTHOR"))
strncpy(this_elem->authority, &(Inline[12]), 79);
else if(Find(Inline," ORGANISM"))
strncpy(this_elem->seq_name,&(Inline[12]),79);
else if (Find(Inline, " ORGANISM"))
strncpy(this_elem->seq_name, &(Inline[12]), 79);
else if(Find(Inline,"ACCESSION"))
strncpy(this_elem->id,&(Inline[12]),79);
else if (Find(Inline, "ACCESSION"))
strncpy(this_elem->id, &(Inline[12]), 79);
else if(Find(Inline,"ORIGIN"))
{
else if (Find(Inline, "ORIGIN")) {
done = FALSE;
len = 0;
for(;done == FALSE && fgets(Inline,GBUFSIZ,file) != 0;)
{
if(Inline[0] != '/')
{
if(buflen == 0)
{
for (; done == FALSE &&
fgets(Inline, GBUFSIZ, file) != 0;) {
if (Inline[0] != '/') {
if (buflen == 0) {
buflen = GBUFSIZ;
buffer = Calloc(sizeof(char) ,
buflen);
buffer = Calloc(sizeof(char),
buflen);
}
else if (len+strlen(Inline) >= buflen)
{
else if (len + strlen(Inline) >=
buflen) {
buflen += GBUFSIZ;
buffer = Realloc(buffer,
sizeof(char)*buflen);
for(j=buflen-GBUFSIZ
;j<buflen;j++)
buffer = Realloc(
buffer,
sizeof(char) * buflen);
for (j = buflen - GBUFSIZ;
j < buflen; j++)
buffer[j] = '\0';
}
/*
* Search for the fist column of data (whitespace-number-whitespace)data
*/
if(start_col == -1)
{
for(start_col=0; Inline[start_col] == ' ' ||
Inline[start_col] == '\t';start_col++);
/*
* Search for the fist column of
*data
*(whitespace-number-whitespace)data
*/
if (start_col == -1) {
for (start_col = 0;
Inline[start_col] == ' ' ||
Inline[start_col] == '\t';
start_col++)
;
for(start_col++;strchr("1234567890",
Inline[start_col]) != NULL;start_col++);
for(start_col++; Inline[start_col] == ' ' ||
Inline[start_col] == '\t';start_col++);
for (start_col++;
strchr(
"1234567890",
Inline[start_col]) !=
NULL;
start_col++)
;
for (start_col++;
Inline[start_col] == ' ' ||
Inline[start_col] == '\t';
start_col++)
;
}
for(j=start_col;(c = Inline[j]) != '\0';j++)
{
if((c != '\n') &&
((j-start_col + 1) % 11 !=0))
for (j = start_col;
(c = Inline[j]) != '\0'; j++) {
if ((c != '\n') &&
((j - start_col + 1) % 11 !=
0))
buffer[len++] = c;
}
}
else
{
AppendNA(buffer,len,&(dataset->
element[curelem]));
for(j=0;j<len;j++)
else {
AppendNA(buffer, len,
&(dataset->element[curelem]));
for (j = 0; j < len; j++)
buffer[j] = '\0';
len = 0;
done = TRUE;
dataset->element[curelem].comments
= gencomments;
dataset->element[curelem].comments_len=
dataset->element[curelem].comments =
gencomments;
dataset->element[curelem].comments_len =
genclen - 1;
dataset->element[curelem].
comments_maxlen = genclen;
dataset->element[curelem]
.comments_maxlen = genclen;
gencomments = NULL;
genclen = 0;
}
}
/*
* Test if sequence should be converted by the translation table
* If it looks like a protein...
*/
if(dataset->element[curelem].rmatrix &&
IS_REALLY_AA == FALSE)
{
IS_REALLY_AA = CheckType(dataset->element[curelem].
sequence,dataset->element[curelem].seqlen);
/*
* Test if sequence should be converted by
*the translation table If it looks like a protein...
*/
if (dataset->element[curelem].rmatrix &&
IS_REALLY_AA == FALSE) {
IS_REALLY_AA = CheckType(
dataset->element[curelem].sequence,
dataset->element[curelem].seqlen);
if(IS_REALLY_AA == FALSE)
Ascii2NA(dataset->element[curelem].sequence,
if (IS_REALLY_AA == FALSE)
Ascii2NA(
dataset->element[curelem].sequence,
dataset->element[curelem].seqlen,
dataset->element[curelem].rmatrix);
else
/*
* Force the sequence to be AA
*/
/*
* Force the sequence to be AA
*/
{
dataset->element[curelem].elementtype = PROTEIN;
dataset->element[curelem].rmatrix = NULL;
dataset->element[curelem].tmatrix = NULL;
dataset->element[curelem].elementtype =
PROTEIN;
dataset->element[curelem].rmatrix =
NULL;
dataset->element[curelem].tmatrix =
NULL;
dataset->element[curelem].col_lut =
Default_PROColor_LKUP;
}
}
}
else if (Find(Inline,"ZZZZZ"))
{
else if (Find(Inline, "ZZZZZ")) {
Cfree(gencomments);
genclen = 0;
}
else
{
if (gencomments == NULL)
{
else {
if (gencomments == NULL) {
gencomments = String(Inline);
genclen = strlen(gencomments)+1;
genclen = strlen(gencomments) + 1;
}
else
{
genclen += strlen(Inline)+1;
gencomments = Realloc(gencomments,genclen *
sizeof(char));
strncat(gencomments,Inline,GBUFSIZ);
strncat(gencomments,"\n",GBUFSIZ);
else {
genclen += strlen(Inline) + 1;
gencomments = Realloc(gencomments,
genclen * sizeof(char));
strncat(gencomments, Inline, GBUFSIZ);
strncat(gencomments, "\n", GBUFSIZ);
}
}
}
Cfree(buffer);
fclose(file);
for(j=0;j<dataset->numelements;j++)
dataset->maxlen = MAX(dataset->maxlen,
dataset->element[j].seqlen+dataset->element[j].offset);
for (j = 0; j < dataset->numelements; j++)
dataset->maxlen =
MAX(dataset->maxlen, dataset->element[j].seqlen +
dataset->element[j].offset);
return;
}
typedef struct mya {
int yy;
int mm;
@ -245,7 +244,7 @@ typedef struct mya {
int sc;
} sA;
AsciiTime(sA *a,char *asciitime)
AsciiTime(sA *a, char *asciitime)
{
int j;
char temp[GBUFSIZ];
@ -254,186 +253,229 @@ AsciiTime(sA *a,char *asciitime)
a->dd = 0;
a->yy = 0;
a->mm = 0;
sscanf(asciitime,"%d%5c%d",&(a->dd),temp,&(a->yy));
sscanf(asciitime, "%d%5c%d", &(a->dd), temp, &(a->yy));
temp[5] = '\0';
for(j=0;j<12;j++)
if(strcmp(temp,month[j]) == 0)
a->mm = j+1;
if(a->dd <0 || a->dd > 31 || a->yy < 0 || a->mm > 11)
SetTime(a);
for (j = 0; j < 12; j++)
if (strcmp(temp, month[j]) == 0) a->mm = j + 1;
if (a->dd < 0 || a->dd > 31 || a->yy < 0 || a->mm > 11) SetTime(a);
return;
}
WriteGen(aln,filename,method,maskable)
NA_Alignment *aln;
WriteGen(aln, filename, method, maskable) NA_Alignment *aln;
char *filename;
int method,maskable;
int method, maskable;
{
int i,j,k,mask = -1;
int i, j, k, mask = -1;
FILE *file;
NA_Sequence *this_elem;
extern char month[12][6];
char c;
if(aln == NULL)
return;
if(aln->na_ddata == NULL)
return;
if (aln == NULL) return;
if (aln->na_ddata == NULL) return;
file = fopen(filename,"w");
if(file == NULL)
{
file = fopen(filename, "w");
if (file == NULL) {
Warning("Cannot open file for output");
return(1);
return (1);
}
if(maskable && method != SELECT_REGION)
for(j=0;j<aln->numelements;j++)
if(aln->element[j].elementtype == MASK &&
if (maskable && method != SELECT_REGION)
for (j = 0; j < aln->numelements; j++)
if (aln->element[j].elementtype == MASK &&
aln->element[j].selected)
mask = j;
for(j=0;j<aln->numelements;j++)
{
if((aln->element[j].selected && j!=mask && method != SELECT_REGION)
||(aln->element[j].subselected && method == SELECT_REGION)
|| (method == ALL))
{
for (j = 0; j < aln->numelements; j++) {
if ((aln->element[j].selected && j != mask &&
method != SELECT_REGION) ||
(aln->element[j].subselected && method == SELECT_REGION) ||
(method == ALL)) {
this_elem = &(aln->element[j]);
fprintf(file,
fprintf(
file,
"LOCUS %10s%8d bp %4s %10s %2d%5s%4d\n",
this_elem->short_name,this_elem->seqlen+this_elem->offset,
(this_elem->elementtype == DNA) ? "DNA":
(this_elem->elementtype ==RNA)?"RNA":
(this_elem->elementtype == MASK)?"MASK":
(this_elem->elementtype == PROTEIN)?"PROT":"TEXT",
this_elem->attr & IS_CIRCULAR?"Circular":"",
this_elem->short_name,
this_elem->seqlen + this_elem->offset,
(this_elem->elementtype == DNA) ? "DNA"
: (this_elem->elementtype == RNA) ? "RNA"
: (this_elem->elementtype == MASK) ? "MASK"
: (this_elem->elementtype == PROTEIN) ? "PROT"
: "TEXT",
this_elem->attr & IS_CIRCULAR ? "Circular" : "",
this_elem->t_stamp.origin.dd,
month[this_elem->t_stamp.origin.mm-1],
this_elem->t_stamp.origin.yy>1900?this_elem->t_stamp.origin.yy:
this_elem->t_stamp.origin.yy+1900);
if(this_elem->description[0])
fprintf(file,"DEFINITION %s\n",this_elem->description);
if(this_elem->seq_name[0])
fprintf(file," ORGANISM %s\n",this_elem->seq_name);
if(this_elem->id[0])
fprintf(file," ACCESSION %s\n",this_elem->id);
if(this_elem->authority[0])
fprintf(file," AUTHORS %s\n",this_elem->authority);
if(this_elem->comments)
fprintf(file,"%s\n",this_elem->comments);
fprintf(file,"ORIGIN");
if(this_elem->tmatrix)
{
if(mask == -1)
{
for(i=0,k=0;k<this_elem->seqlen+this_elem->offset;k++)
{
if(method == SELECT_REGION)
{
if(aln->selection_mask[k] == '1')
{
if(i%60 == 0)
fprintf(file,"\n%9d",i+1);
if(i%10 == 0)
fprintf(file," ");
fprintf(file,"%c",this_elem->tmatrix
[getelem(this_elem,k)]);
month[this_elem->t_stamp.origin.mm - 1],
this_elem->t_stamp.origin.yy > 1900
? this_elem->t_stamp.origin.yy
: this_elem->t_stamp.origin.yy + 1900);
if (this_elem->description[0])
fprintf(file, "DEFINITION %s\n",
this_elem->description);
if (this_elem->seq_name[0])
fprintf(file, " ORGANISM %s\n",
this_elem->seq_name);
if (this_elem->id[0])
fprintf(file, " ACCESSION %s\n",
this_elem->id);
if (this_elem->authority[0])
fprintf(file, " AUTHORS %s\n",
this_elem->authority);
if (this_elem->comments)
fprintf(file, "%s\n", this_elem->comments);
fprintf(file, "ORIGIN");
if (this_elem->tmatrix) {
if (mask == -1) {
for (i = 0, k = 0;
k < this_elem->seqlen +
this_elem->offset;
k++) {
if (method == SELECT_REGION) {
if (aln->selection_mask
[k] == '1') {
if (i % 60 == 0)
fprintf(
file,
"\n"
"%9"
"d",
i + 1);
if (i % 10 == 0)
fprintf(
file,
" ");
fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
i++;
}
}
else
{
if(i%60 == 0)
fprintf(file,"\n%9d",i+1);
if(i%10 == 0)
fprintf(file," ");
fprintf(file,"%c",this_elem->tmatrix
[getelem(this_elem,k)]);
else {
if (i % 60 == 0)
fprintf(file,
"\n%9d",
i + 1);
if (i % 10 == 0)
fprintf(file,
" ");
fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
i++;
}
}
}
else
{
for(k=0;k<this_elem->seqlen+this_elem->offset;k++)
{
c =(char)getelem(&(aln->element[mask]),k);
if(c != '0' && c!= '-')
{
if(k%60 == 0)
fprintf(file,"\n%9d",k+1);
if(k%10 == 0)
fprintf(file," ");
fprintf(file,"%c",this_elem->tmatrix
[getelem(this_elem,k)]);
else {
for (k = 0; k < this_elem->seqlen +
this_elem->offset;
k++) {
c = (char)getelem(
&(aln->element[mask]), k);
if (c != '0' && c != '-') {
if (k % 60 == 0)
fprintf(file,
"\n%9d",
k + 1);
if (k % 10 == 0)
fprintf(file,
" ");
fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
}
}
}
}
else
{
if(mask == -1)
{
for(i=0,k=0;k<this_elem->seqlen+this_elem->offset;k++)
{
if(method == SELECT_REGION)
{
if(aln->selection_mask[k] == '1')
{
if(i%60 == 0)
fprintf(file,"\n%9d",i+1);
if(i%10 == 0)
fprintf(file," ");
fprintf(file,"%c", getelem(this_elem,k));
else {
if (mask == -1) {
for (i = 0, k = 0;
k < this_elem->seqlen +
this_elem->offset;
k++) {
if (method == SELECT_REGION) {
if (aln->selection_mask
[k] == '1') {
if (i % 60 == 0)
fprintf(
file,
"\n"
"%9"
"d",
i + 1);
if (i % 10 == 0)
fprintf(
file,
" ");
fprintf(
file, "%c",
getelem(
this_elem,
k));
i++;
}
}
else
{
if(i%60 == 0)
fprintf(file,"\n%9d",i+1);
if(i%10 == 0)
fprintf(file," ");
fprintf(file,"%c",getelem(this_elem,k));
else {
if (i % 60 == 0)
fprintf(file,
"\n%9d",
i + 1);
if (i % 10 == 0)
fprintf(file,
" ");
fprintf(
file, "%c",
getelem(this_elem,
k));
i++;
}
}
}
else
{
for(k=0;k<this_elem->seqlen+this_elem->offset;k++)
{
c =(char)getelem(&(aln->element[mask]),k);
if(c != '0' && c!= '-')
{
if(k%60 == 0)
fprintf(file,"\n%9d",k+1);
if(k%10 == 0)
fprintf(file," ");
fprintf(file,"%c",getelem(this_elem,k));
else {
for (k = 0; k < this_elem->seqlen +
this_elem->offset;
k++) {
c = (char)getelem(
&(aln->element[mask]), k);
if (c != '0' && c != '-') {
if (k % 60 == 0)
fprintf(file,
"\n%9d",
k + 1);
if (k % 10 == 0)
fprintf(file,
" ");
fprintf(
file, "%c",
getelem(this_elem,
k));
}
}
}
}
fprintf(file,"\n//\n");
fprintf(file, "\n//\n");
}
}
fclose(file);
return;
}
SetTime(sA *a)
{
struct tm *tim,*localtime();
struct tm *tim, *localtime();
long clock;
clock = time(0);
tim = localtime(&clock);
a->yy = tim->tm_year;
a->mm = tim->tm_mon+1;
a->mm = tim->tm_mon + 1;
a->dd = tim->tm_mday;
a->hr = tim->tm_hour;
a->mn = tim->tm_min;
@ -442,24 +484,20 @@ SetTime(sA *a)
}
/*
* CheckType: Check base composition to see if the sequence
* appears to be an amino acid sequence. If it is, pass back
* TRUE, else FALSE.
*/
CheckType(seq,len)
char *seq;
* CheckType: Check base composition to see if the sequence
* appears to be an amino acid sequence. If it is, pass back
* TRUE, else FALSE.
*/
CheckType(seq, len) char *seq;
int len;
{
int j, count1 = 0, count2 = 0;
int j,count1 = 0,count2 = 0;
for(j=0;j<len;j++)
if(((seq[j]|32) < 'z') && ((seq[j]|32) > 'a'))
{
for (j = 0; j < len; j++)
if (((seq[j] | 32) < 'z') && ((seq[j] | 32) > 'a')) {
count1++;
if(index("ACGTUNacgtun",seq[j]) == NULL)
count2++;
if (index("ACGTUNacgtun", seq[j]) == NULL) count2++;
}
return( (count2 > count1/4)?TRUE:FALSE);
return ((count2 > count1 / 4) ? TRUE : FALSE);
}

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,10 @@
#include <stdio.h>
#include <malloc.h>
#include <xview/xview.h>
#include <stdio.h>
#include <xview/panel.h>
#include "menudefs.h"
#include <xview/xview.h>
#include "defines.h"
#include "menudefs.h"
/*
ParseMenus(): Read in the menu config file, and generate the internal
@ -24,106 +25,98 @@ int num_menus;
ParseMenu()
{
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;
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;
Gmenu *thismenu;
GmenuItem *thisitem;
GmenuItemArg *thisarg;
GfileFormat *thisinput,*thisoutput;
GfileFormat *thisinput, *thisoutput;
FILE *file;
char *resize;
/*
* 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");
/*
* 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");
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");
}
if(file == NULL)
Error(
".GDEmenus file not in the home, local, or $GDE_HELP_DIR directory");
if (file == NULL)
Error(
".GDEmenus file not in the home, local, or "
"$GDE_HELP_DIR directory");
}
}
/*
* Read the .GDEmenus file, and assemble an internal representation
* of the menu/menu-item hierarchy.
*/
/*
* Read the .GDEmenus file, and assemble an internal representation
* of the menu/menu-item hierarchy.
*/
for(;getline(file,Inline) != EOF;)
{
/*
* menu: chooses menu to use
*/
if(Inline[0] == '#');
else if(Find(Inline,"menu:"))
{
crop(Inline,head,temp);
for (; gde_getline(file, Inline) != EOF;) {
/*
* menu: chooses menu to use
*/
if (Inline[0] == '#')
;
else if (Find(Inline, "menu:")) {
crop(Inline, head, temp);
curmenu = -1;
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)
{
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) {
curmenu = num_menus++;
thismenu = &menu[curmenu];
thismenu->label =
(char*)calloc(strlen(temp)+1,sizeof(char));
thismenu->label = (char *)calloc(
strlen(temp) + 1, sizeof(char));
if(thismenu->label == NULL)
Error("Calloc");
(void)strcpy(thismenu->label,temp);
thismenu->numitems = 0;
if (thismenu->label == NULL) Error("Calloc");
(void)strcpy(thismenu->label, temp);
thismenu->numitems = 0;
}
}
/*
* item: chooses menu item to use
*/
else if(Find(Inline,"item:"))
{
/*
* item: chooses menu item to use
*/
else if (Find(Inline, "item:")) {
curarg = -1;
curinput = -1;
curoutput = -1;
crop(Inline,head,temp);
crop(Inline, head, temp);
curitem = thismenu->numitems++;
/*
* Resize the item list for this menu (add one item);
*/
if(curitem == 0)
resize = (char*)calloc(1,sizeof(GmenuItem));
/*
* Resize the item list for this menu (add one
*item);
*/
if (curitem == 0)
resize = (char *)calloc(1, sizeof(GmenuItem));
else
resize = realloc(thismenu->item,
thismenu -> numitems*sizeof(GmenuItem) );
resize = realloc(
thismenu->item,
thismenu->numitems * sizeof(GmenuItem));
if(resize == NULL)
Error ("Calloc");
thismenu->item =(GmenuItem*)resize;
if (resize == NULL) Error("Calloc");
thismenu->item = (GmenuItem *)resize;
thisitem = &(thismenu->item[curitem]);
thisitem->label = (char*)calloc(strlen(temp)+1,
sizeof(char));
thisitem->label =
(char *)calloc(strlen(temp) + 1, sizeof(char));
thisitem->meta = '\0';
thisitem->numinputs = 0;
thisitem->numoutputs = 0;
@ -131,74 +124,66 @@ ParseMenu()
thisitem->X = 0;
thisitem->help = NULL;
/*
* Create new item
*/
/*
* Create new item
*/
if(thisitem->label == NULL)
Error("Calloc");
(void)strcpy(thisitem->label,temp);
if (thisitem->label == NULL) Error("Calloc");
(void)strcpy(thisitem->label, temp);
}
/*
* itemmethod: generic command line generated by this item
*/
else if(Find(Inline,"itemmethod:"))
{
crop(Inline,head,temp);
/*
* 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);
(char *)calloc(strlen(temp) + 1, sizeof(char));
if (thisitem->method == NULL) Error("Calloc");
(void)strcpy(thisitem->method, temp);
}
/*
* Help file
*/
else if(Find(Inline,"itemhelp:"))
{
crop(Inline,head,temp);
/*
* Help file
*/
else if (Find(Inline, "itemhelp:")) {
crop(Inline, head, temp);
thisitem->help =
(char*)calloc(strlen(temp)+1,sizeof(char));
if(thisitem->method == NULL)
Error("Calloc");
(void)strcpy(thisitem->help,temp);
(char *)calloc(strlen(temp) + 1, sizeof(char));
if (thisitem->method == NULL) Error("Calloc");
(void)strcpy(thisitem->help, temp);
}
/*
* Meta key equiv
*/
else if(Find(Inline,"itemmeta:"))
{
crop(Inline,head,temp);
/*
* Meta key equiv
*/
else if (Find(Inline, "itemmeta:")) {
crop(Inline, head, temp);
thisitem->meta = temp[0];
}
/*
* arg: defines the symbol for a command line arguement.
* this is used for substitution into the itemmethod
* definition.
*/
/*
* 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));
else if (Find(Inline, "arg:")) {
crop(Inline, head, temp);
curarg = thisitem->numargs++;
if (curarg == 0)
resize =
(char *)calloc(1, sizeof(GmenuItemArg));
else
resize = realloc(thisitem->arg,
thisitem->numargs*sizeof(GmenuItemArg) );
resize = realloc(
thisitem->arg,
thisitem->numargs * sizeof(GmenuItemArg));
if (resize == NULL) Error("arg: Realloc");
if(resize == NULL)
Error("arg: Realloc");
(thisitem->arg) = (GmenuItemArg*)resize;
(thisitem->arg) = (GmenuItemArg *)resize;
thisarg = &(thisitem->arg[curarg]);
thisarg->symbol = (char*)calloc(strlen(temp)+1,
sizeof(char));
if(thisarg->symbol == NULL)
Error("Calloc");
(void)strcpy(thisarg->symbol,temp);
thisarg->symbol =
(char *)calloc(strlen(temp) + 1, sizeof(char));
if (thisarg->symbol == NULL) Error("Calloc");
(void)strcpy(thisarg->symbol, temp);
thisarg->optional = FALSE;
thisarg->type = 0;
thisarg->min = 0;
@ -208,153 +193,145 @@ ParseMenu()
thisarg->textvalue = NULL;
thisarg->value = 0;
}
/*
* 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;
/*
* 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;
thisarg->textvalue =
(char*)calloc(GBUFSIZ,sizeof(char));
if(thisarg->textvalue == NULL)
Error("Calloc");
(char *)calloc(GBUFSIZ, sizeof(char));
if (thisarg->textvalue == NULL) Error("Calloc");
}
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;
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;
else
Error(sprintf(head,"Unknown argtype %s",temp));
Error(
sprintf(head, "Unknown argtype %s", temp));
}
/*
* 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);
/*
* 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);
}
/*
* 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);
/*
* 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);
}
/*
* 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);
/*
* 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);
curchoice = thisarg->numchoices++;
if(curchoice == 0)
resize = (char*)calloc(1,sizeof(GargChoice));
if (curchoice == 0)
resize = (char *)calloc(1, sizeof(GargChoice));
else
resize = realloc(thisarg->choice,
thisarg->numchoices*sizeof(GargChoice));
resize = realloc(
thisarg->choice,
thisarg->numchoices * sizeof(GargChoice));
if(resize == NULL)
Error("argchoice: Realloc");
thisarg->choice = (GargChoice*)resize;
if (resize == NULL) Error("argchoice: Realloc");
thisarg->choice = (GargChoice *)resize;
(thisarg->choice[curchoice].label) = NULL;
(thisarg->choice[curchoice].method) = NULL;
(thisarg->choice[curchoice].label) =
(char*)calloc(strlen(head)+1,sizeof(char));
(char *)calloc(strlen(head) + 1, sizeof(char));
(thisarg->choice[curchoice].method) =
(char*)calloc(strlen(tail)+1,sizeof(char));
(char *)calloc(strlen(tail) + 1, sizeof(char));
if(thisarg->choice[curchoice].method == NULL ||
thisarg->choice[curchoice].label == NULL)
if (thisarg->choice[curchoice].method == NULL ||
thisarg->choice[curchoice].label == NULL)
Error("Calloc");
(void)strcpy(thisarg->choice[curchoice].label,head);
(void)strcpy(thisarg->choice[curchoice].method,tail);
(void)strcpy(thisarg->choice[curchoice].label, head);
(void)strcpy(thisarg->choice[curchoice].method, tail);
}
/*
* argmin: Minimum value for a slider
*/
else if(Find(Inline,"argmin:"))
{
crop(Inline,head,temp);
(void)sscanf(temp,"%d",&(thisarg->min));
/*
* argmin: Minimum value for a slider
*/
else if (Find(Inline, "argmin:")) {
crop(Inline, head, temp);
(void)sscanf(temp, "%d", &(thisarg->min));
}
/*
* argmax: Maximum value for a slider
*/
else if(Find(Inline,"argmax:"))
{
crop(Inline,head,temp);
(void)sscanf(temp,"%d",&(thisarg->max));
/*
* argmax: Maximum value for a slider
*/
else if (Find(Inline, "argmax:")) {
crop(Inline, head, temp);
(void)sscanf(temp, "%d", &(thisarg->max));
}
/*
* 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);
/*
* 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);
}
/*
* argvalue: default value for a slider
*/
else if(Find(Inline,"argvalue:"))
{
crop(Inline,head,temp);
if(thisarg->type == TEXT)
strcpy(thisarg->textvalue,temp);
/*
* argvalue: default value for a slider
*/
else if (Find(Inline, "argvalue:")) {
crop(Inline, head, temp);
if (thisarg->type == TEXT)
strcpy(thisarg->textvalue, temp);
else
(void)sscanf(temp,"%d",&(thisarg->value));
(void)sscanf(temp, "%d", &(thisarg->value));
}
/*
* argoptional: Flag specifying that an arguement is optional
*/
else if(Find(Inline,"argoptional:"))
/*
* argoptional: Flag specifying that an arguement is
*optional
*/
else if (Find(Inline, "argoptional:"))
thisarg->optional = TRUE;
/*
* in: Input file description
*/
else if(Find(Inline,"in:"))
{
crop(Inline,head,temp);
/*
* in: Input file description
*/
else if (Find(Inline, "in:")) {
crop(Inline, head, temp);
curinput = (thisitem->numinputs)++;
if(curinput == 0)
resize = (char*)calloc(1,sizeof(GfileFormat));
if (curinput == 0)
resize = (char *)calloc(1, sizeof(GfileFormat));
else
resize = realloc(thisitem->input,
(thisitem->numinputs)*sizeof(GfileFormat));
(thisitem->numinputs) *
sizeof(GfileFormat));
if(resize == NULL)
Error("in: Realloc");
thisitem->input = (GfileFormat*)resize;
if (resize == NULL) Error("in: Realloc");
thisitem->input = (GfileFormat *)resize;
thisinput = &(thisitem->input)[curinput];
thisinput->save = FALSE;
thisinput->overwrite = FALSE;
@ -365,176 +342,155 @@ ParseMenu()
thisinput->select = SELECTED;
}
/*
* out: Output file description
*/
/*
* out: Output file description
*/
else if(Find(Inline,"out:"))
{
crop(Inline,head,temp);
else if (Find(Inline, "out:")) {
crop(Inline, head, temp);
curoutput = (thisitem->numoutputs)++;
if(curoutput == 0)
resize = (char*)calloc(1,sizeof(GfileFormat));
if (curoutput == 0)
resize = (char *)calloc(1, sizeof(GfileFormat));
else
resize = realloc(thisitem->output,
(thisitem->numoutputs)*sizeof(GfileFormat));
(thisitem->numoutputs) *
sizeof(GfileFormat));
if(resize == NULL)
Error("out: Realloc");
thisitem->output = (GfileFormat*)resize;
if (resize == NULL) Error("out: Realloc");
thisitem->output = (GfileFormat *)resize;
thisoutput = &(thisitem->output)[curoutput];
thisitem->output = (GfileFormat*)resize;
thisitem->output = (GfileFormat *)resize;
thisoutput = &(thisitem->output)[curoutput];
thisoutput->save = FALSE;
thisoutput->overwrite = FALSE;
thisoutput->format = 0;
thisoutput->symbol= String(temp);
thisoutput->symbol = String(temp);
thisoutput->name = NULL;
}
else if(Find(Inline,"informat:"))
{
if(thisinput == NULL)
Error("Problem with .GDEmenus");
crop(Inline,head,tail);
if(Find(tail,"genbank"))
else if (Find(Inline, "informat:")) {
if (thisinput == NULL) Error("Problem with .GDEmenus");
crop(Inline, head, tail);
if (Find(tail, "genbank"))
thisinput->format = GENBANK;
else if(Find(tail,"gde"))
else if (Find(tail, "gde"))
thisinput->format = GDE;
else if(Find(tail,"na_flat"))
else if (Find(tail, "na_flat"))
thisinput->format = NA_FLAT;
else if(Find(tail,"colormask"))
else if (Find(tail, "colormask"))
thisinput->format = COLORMASK;
else if(Find(tail,"flat"))
else if (Find(tail, "flat"))
thisinput->format = NA_FLAT;
else if(Find(tail,"status"))
else if (Find(tail, "status"))
thisinput->format = STATUS_FILE;
else fprintf(stderr,"Warning, unknown file format %s\n"
,tail);
else
fprintf(stderr,
"Warning, unknown file format %s\n",
tail);
}
else if(Find(Inline,"insave:"))
{
if(thisinput == NULL)
Error("Problem with .GDEmenus");
else if (Find(Inline, "insave:")) {
if (thisinput == NULL) Error("Problem with .GDEmenus");
thisinput->save = TRUE;
}
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;
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;
}
else if(Find(Inline,"inmask:"))
{
if(thisinput == NULL)
Error("Problem with .GDEmenus");
else if (Find(Inline, "inmask:")) {
if (thisinput == NULL) Error("Problem with .GDEmenus");
thisinput->maskable = TRUE;
}
else if(Find(Inline,"outformat:"))
{
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
crop(Inline,head,tail);
if(Find(tail,"genbank"))
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"))
else if (Find(tail, "gde"))
thisoutput->format = GDE;
else if(Find(tail,"na_flat"))
else if (Find(tail, "na_flat"))
thisoutput->format = NA_FLAT;
else if(Find(tail,"flat"))
else if (Find(tail, "flat"))
thisoutput->format = NA_FLAT;
else if(Find(tail,"status"))
else if (Find(tail, "status"))
thisoutput->format = STATUS_FILE;
else if(Find(tail,"colormask"))
else if (Find(tail, "colormask"))
thisoutput->format = COLORMASK;
else fprintf(stderr,"Warning, unknown file format %s\n"
,tail);
else
fprintf(stderr,
"Warning, unknown file format %s\n",
tail);
}
else if(Find(Inline,"outsave:"))
{
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
else if (Find(Inline, "outsave:")) {
if (thisoutput == NULL) Error("Problem with .GDEmenus");
thisoutput->save = TRUE;
}
else if(Find(Inline,"outoverwrite:"))
{
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
else if (Find(Inline, "outoverwrite:")) {
if (thisoutput == NULL) Error("Problem with .GDEmenus");
thisoutput->overwrite = TRUE;
}
}
return;
}
/*
Find(): Search the target string for the given key
*/
Find(target,key)
char *key,*target;
Find(target, key) char *key, *target;
{
int i,j,len1,dif,flag = FALSE;
dif = (strlen(target)) - (len1 = strlen(key)) +1;
int i, j, len1, dif, flag = FALSE;
dif = (strlen(target)) - (len1 = strlen(key)) + 1;
if(len1>0)
for(j=0;j<dif && flag == FALSE;j++)
{
if (len1 > 0)
for (j = 0; j < dif && flag == FALSE; j++) {
flag = TRUE;
for(i=0;i<len1 && flag;i++)
flag = (key[i] == target[i+j])?TRUE:FALSE;
for (i = 0; i < len1 && flag; i++)
flag = (key[i] == target[i + j]) ? TRUE : FALSE;
}
return(flag);
return (flag);
}
Find2(target,key)
char *key,*target;
Find2(target, key) char *key, *target;
/*
* Like find, but returns the index of the leftmost
* occurence, and -1 if not found.
*/
* Like find, but returns the index of the leftmost
* occurence, and -1 if not found.
*/
{
int i,j,len1,dif,flag = FALSE;
dif = (strlen(target)) - (len1 = strlen(key)) +1;
int i, j, len1, dif, flag = FALSE;
dif = (strlen(target)) - (len1 = strlen(key)) + 1;
if(len1>0)
for(j=0;j<dif && flag == FALSE;j++)
{
if (len1 > 0)
for (j = 0; j < dif && flag == FALSE; j++) {
flag = TRUE;
for(i=0;i<len1 && flag;i++)
flag = (key[i] == target[i+j])?TRUE:FALSE;
for (i = 0; i < len1 && flag; i++)
flag = (key[i] == target[i + j]) ? TRUE : FALSE;
}
return(flag?j-1:-1);
return (flag ? j - 1 : -1);
}
Error(msg)
char *msg;
Error(msg) char *msg;
{
(void)fprintf(stderr,"%s\n",msg);
(void)fprintf(stderr, "%s\n", msg);
exit(1);
}
int getline(file,string)
int gde_getline(file, string)
FILE *file;
char string[];
{
char c;
int i;
for(i=0;((c=getc(file))!='\n') && (c!=EOF);i++)
string[i]=c;
for (i = 0; ((c = getc(file)) != '\n') && (c != EOF); i++)
string[i] = c;
string[i] = '\0';
if (i==0 && c==EOF) return (EOF);
else return (0);
if (i == 0 && c == EOF)
return (EOF);
else
return (0);
}
/*
@ -543,24 +499,24 @@ Crop():
into: "this" and "that[:the_other]"
*/
crop(input,head,tail)
char input[],head[],tail[];
crop(input, head, tail) char input[], head[], tail[];
{
/*
* Crop needs to be fixed so that whitespace is compressed off the end
* of tail
*/
int offset,end,i,j,length;
/*
* 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];
length = strlen(input);
for (offset = 0; offset < length && input[offset] != ':'; offset++)
head[offset] = input[offset];
head[offset++] = '\0';
for(;offset<length && input[offset] == ' ';offset++);
for(end=length-1;input[end] ==' ' && end>offset;end--);
for (; offset < length && input[offset] == ' '; offset++)
;
for (end = length - 1; input[end] == ' ' && end > offset; end--)
;
for(j=0,i=offset;i<=end;i++,j++)
tail[j]=input[i];
for (j = 0, i = offset; i <= end; i++, j++) tail[j] = input[i];
tail[j] = '\0';
return;
}