GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include"typedef.h"12/**************************************************************************\3@---------------------------------------------------------------------------4@---------------------------------------------------------------------------5@ FILE: read_header.c6@---------------------------------------------------------------------------7@---------------------------------------------------------------------------8\**************************************************************************/910/**************************************************************************\11@---------------------------------------------------------------------------12@ void read_header(argc,argv)13@ int argc, char *argv[],14@15@ reads the filenames and options for a programm16@ the filenames are stored in: extern char **FILENAMES;17@ the numer of files is stored in: extern int *FILEANZ;18@ the options are stored in: extern char *OPTIONS;19@ the number of options is stored in: extern int *OPTIONANZ;20@ additional integers to the options in : extern int *OPTIONNUMBERS;21@ These extern variables are defined in globals.h22@23@ The option are allowed to be alphbetic letters and the function24@ distinguishes between upper and lower letters.25@ In the calling of the program, options have to be set behind a '-'.26@ If one wants read an additional integer 'i' to an option 'p', one has to27@ call this in the form: -p=i28@29@30@ Example:31@ program file1 file2 -p=10 -P -d=-132@ In this example33@ FILENAMES[1] = file134@ FILENAMES[2] = file235@ FILEANZ = 236@ OPTIONS[0] = p37@ OPTIONS[1] = P38@ OPTIONS[2] = d39@ OPTIONNUMBERS[0] = 1040@ OPTIONNUMBERS[1] = 041@ OPTIONNUMBERS[2] = -142@ OPTIONANZ = 343@44@ WARNING: a call -CF reads only C as an option, not F.45@ there are no blanks allowed in a word "-p=10"46@47@48@-------------------------------------------------------------------------49@ int is_option(c)50@ char c;51@52@ The return of this function is 1 if the character c is among the options,53@ otherwise 0.54@ A typical call of this function is: is_option('p');55@56@-------------------------------------------------------------------------57@58@ int optionnumber(c)59@ char c;60@61@ optionnumber('p') returns the additional number to the option 'p'.62@ If 'p' is no option, the return is 0.63@-------------------------------------------------------------------------64@65\**************************************************************************/6667char **FILENAMES;68int FILEANZ;69char *OPTIONS;70int *OPTIONNUMBERS;71int OPTIONANZ;72737475void read_header(argc,argv)76int argc;77char *argv[];78{79int i;80char *w;8182extern char **FILENAMES;83extern int FILEANZ;84extern char *OPTIONS;85extern int *OPTIONNUMBERS;86extern int OPTIONANZ;8788FILENAMES = (char **)malloc(argc *sizeof(char *));89FILEANZ = 0;90OPTIONS = (char *)malloc(argc *sizeof(char));91OPTIONNUMBERS = (int *)malloc(argc *sizeof(int));92OPTIONANZ = 0;93for ( i = 1; i < argc; i++)94{95switch ( argv[i][0] )96{97case '-' :98OPTIONS[OPTIONANZ] = argv[i][1];99if ( (w = strchr (argv[i], '=')) != NULL )100sscanf(w, "=%d", &OPTIONNUMBERS[OPTIONANZ]);101else102OPTIONNUMBERS[OPTIONANZ] = 0;103OPTIONANZ++;104break;105default :106FILENAMES[FILEANZ] = argv[i];107FILEANZ++;108}109}110}111112113int is_option(c)114char c;115{116int i;117for(i=0;i<OPTIONANZ;i++)118{119if(OPTIONS[i] == c)120return(TRUE);121}122return(FALSE);123}124125126int optionnumber(c)127char c;128{129int i;130for(i=0;i<OPTIONANZ;i++)131{132if(OPTIONS[i] == c)133return(OPTIONNUMBERS[i]);134}135return(0);136}137138void unread_header()139{140free(FILENAMES);141free(OPTIONS);142free(OPTIONNUMBERS);143}144145146