Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#include"typedef.h"
2
3
/**************************************************************************\
4
@---------------------------------------------------------------------------
5
@---------------------------------------------------------------------------
6
@ FILE: read_header.c
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
\**************************************************************************/
10
11
/**************************************************************************\
12
@---------------------------------------------------------------------------
13
@ void read_header(argc,argv)
14
@ int argc, char *argv[],
15
@
16
@ reads the filenames and options for a programm
17
@ the filenames are stored in: extern char **FILENAMES;
18
@ the numer of files is stored in: extern int *FILEANZ;
19
@ the options are stored in: extern char *OPTIONS;
20
@ the number of options is stored in: extern int *OPTIONANZ;
21
@ additional integers to the options in : extern int *OPTIONNUMBERS;
22
@ These extern variables are defined in globals.h
23
@
24
@ The option are allowed to be alphbetic letters and the function
25
@ distinguishes between upper and lower letters.
26
@ In the calling of the program, options have to be set behind a '-'.
27
@ If one wants read an additional integer 'i' to an option 'p', one has to
28
@ call this in the form: -p=i
29
@
30
@
31
@ Example:
32
@ program file1 file2 -p=10 -P -d=-1
33
@ In this example
34
@ FILENAMES[1] = file1
35
@ FILENAMES[2] = file2
36
@ FILEANZ = 2
37
@ OPTIONS[0] = p
38
@ OPTIONS[1] = P
39
@ OPTIONS[2] = d
40
@ OPTIONNUMBERS[0] = 10
41
@ OPTIONNUMBERS[1] = 0
42
@ OPTIONNUMBERS[2] = -1
43
@ OPTIONANZ = 3
44
@
45
@ WARNING: a call -CF reads only C as an option, not F.
46
@ there are no blanks allowed in a word "-p=10"
47
@
48
@
49
@-------------------------------------------------------------------------
50
@ int is_option(c)
51
@ char c;
52
@
53
@ The return of this function is 1 if the character c is among the options,
54
@ otherwise 0.
55
@ A typical call of this function is: is_option('p');
56
@
57
@-------------------------------------------------------------------------
58
@
59
@ int optionnumber(c)
60
@ char c;
61
@
62
@ optionnumber('p') returns the additional number to the option 'p'.
63
@ If 'p' is no option, the return is 0.
64
@-------------------------------------------------------------------------
65
@
66
\**************************************************************************/
67
68
char **FILENAMES;
69
int FILEANZ;
70
char *OPTIONS;
71
int *OPTIONNUMBERS;
72
int OPTIONANZ;
73
74
75
76
void read_header(argc,argv)
77
int argc;
78
char *argv[];
79
{
80
int i;
81
char *w;
82
83
extern char **FILENAMES;
84
extern int FILEANZ;
85
extern char *OPTIONS;
86
extern int *OPTIONNUMBERS;
87
extern int OPTIONANZ;
88
89
FILENAMES = (char **)malloc(argc *sizeof(char *));
90
FILEANZ = 0;
91
OPTIONS = (char *)malloc(argc *sizeof(char));
92
OPTIONNUMBERS = (int *)malloc(argc *sizeof(int));
93
OPTIONANZ = 0;
94
for ( i = 1; i < argc; i++)
95
{
96
switch ( argv[i][0] )
97
{
98
case '-' :
99
OPTIONS[OPTIONANZ] = argv[i][1];
100
if ( (w = strchr (argv[i], '=')) != NULL )
101
sscanf(w, "=%d", &OPTIONNUMBERS[OPTIONANZ]);
102
else
103
OPTIONNUMBERS[OPTIONANZ] = 0;
104
OPTIONANZ++;
105
break;
106
default :
107
FILENAMES[FILEANZ] = argv[i];
108
FILEANZ++;
109
}
110
}
111
}
112
113
114
int is_option(c)
115
char c;
116
{
117
int i;
118
for(i=0;i<OPTIONANZ;i++)
119
{
120
if(OPTIONS[i] == c)
121
return(TRUE);
122
}
123
return(FALSE);
124
}
125
126
127
int optionnumber(c)
128
char c;
129
{
130
int i;
131
for(i=0;i<OPTIONANZ;i++)
132
{
133
if(OPTIONS[i] == c)
134
return(OPTIONNUMBERS[i]);
135
}
136
return(0);
137
}
138
139
void unread_header()
140
{
141
free(FILENAMES);
142
free(OPTIONS);
143
free(OPTIONNUMBERS);
144
}
145
146