Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
make_env.c
Go to the documentation of this file.
1 /*
2 Copyright 2021 Arizona Board of Regents on behalf of the University of Arizona.
3 
4 For commercial uses, to obtain a license to sell and or sublicense copies of
5 the Software please contact the University of Arizona at Tech Launch Arizona:
6 lewish@tla.arizona.edu.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction for non-commercial use educational and
11 research purposes, including without limitation the rights to use, copy,
12 modify, merge, publish, distribute, and to permit persons to whom the Software
13 is furnished to do so, subject to the following conditions:
14 
15 The entire above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 
26 1. Additional Required Provisions
27 
28 1.1. Arbitration. The parties agree that if a dispute arises between them
29 concerning this Agreement, the parties may be required to submit the matter to
30 arbitration pursuant to Arizona law.
31 
32 1.2. Applicable Law and Venue. This Agreement shall be interpreted pursuant
33 to the laws of the State of Arizona. Any arbitration or litigation between the
34 Parties shall be conducted in Pima County, ARIZONA, and LICENSEE hereby
35 submits to venue and jurisdiction in Pima County, ARIZONA.
36 
37 1.3. Non-Discrimination. The Parties agree to be bound by state and federal
38 laws and regulations governing equal opportunity and non-discrimination and
39 immigration.
40 
41 1.4. Appropriation of Funds. The Parties recognize that performance by
42 ARIZONA may depend upon appropriation of funds by the State Legislature of
43 ARIZONA. If the Legislature fails to appropriate the necessary funds, or if
44 ARIZONA’S appropriation is reduced during the fiscal year, ARIZONA may cancel
45 this Agreement without further duty or obligation. ARIZONA will notify
46 LICENSEE as soon as reasonably possible after it knows of the loss of funds.
47 
48 1.5. Conflict of Interest. This Agreement is subject to the provisions of
49 A.R.S. 38-511 and other conflict of interest regulations. Within three years
50 of the EFFECTIVE DATE, ARIZONA may cancel this Agreement if any person
51 significantly involved in initiating, negotiating, drafting, securing, or
52 creating this Agreement for or on behalf of ARIZONA becomes an employee or
53 consultant in any capacity of LICENSEE with respect to the subject matter of
54 this Agreement.
55 
56  */
57 
58 
59 #include <stdlib.h>
60 #include <stdio.h>
61 #include <strings.h>
62 #include <string.h>
63 
64 #include "caclib_proto.h"
65 #include "defines.h"
66 
68 
69 int get_tok(edit)
70 char *edit;
71 {
72  int c = 0;
73  char *token;
74 
75  bzero((char *)&tok, sizeof(tok));
76 
77  token = strtok(edit, " \t\r\n;");
78  while(token != (char *)NULL)
79  {
80  sprintf(tok[c++], "%s", token);
81  token = strtok((char *)NULL, " \t\r\n;");
82  }
83 
84  return(c);
85 }
86 
87 
88 int makePreamble(fout)
89 FILE *fout;
90 {
91  fprintf(fout, "#ifndef NGS_HELP_H\n");
92  fprintf(fout, "#define NGS_HELP_H\n");
93 
94  fprintf(fout, "\n\n");
95 
96  fprintf(fout, "#include <stdlib.h>\n");
97  fprintf(fout, "#include <stdio.h>\n");
98  fprintf(fout, "#include <strings.h>\n");
99  fprintf(fout, "#include <string.h>\n");
100 
101  fprintf(fout, "\n\n");
102 
103  fprintf(fout, "struct NGS_HELP_STRINGS {\n");
104  fprintf(fout, " char *type;\n");
105  fprintf(fout, " char *variable;\n");
106  fprintf(fout, " char *help;\n");
107  fprintf(fout, "};\n");
108 
109  fprintf(fout, "\n\n");
110 
111  fprintf(fout, "struct NGS_HELP_STRINGS ngs_help[] = {\n");
112 
113  return(0);
114 }
115 
116 
117 int makeEnd(fout, j)
118 FILE *fout;
119 int j;
120 {
121  fprintf(fout, "};\n");
122  fprintf(fout, "#define MAX_NGS_HELP %d\n", j);
123  fprintf(fout, "\n\n");
124  fprintf(fout, "int fetchNGSHelp(name, buf)\n");
125  fprintf(fout, "char *name, *buf;\n");
126  fprintf(fout, "{\n");
127  fprintf(fout, " int i;\n");
128  fprintf(fout, "\n");
129  fprintf(fout, " for(i=0;i<MAX_NGS_HELP;i++)\n");
130  fprintf(fout, " {\n");
131  fprintf(fout, " if(!strncmp(ngs_help[i].variable, name, strlen(name)))\n");
132  fprintf(fout, " {\n");
133  fprintf(fout, " strcpy(buf, ngs_help[i].help);\n");
134  fprintf(fout, " return(0);\n");
135  fprintf(fout, " }\n");
136  fprintf(fout, " }\n");
137  fprintf(fout, "\n");
138  fprintf(fout, " strcpy(buf, \" \");\n");
139  fprintf(fout, "\n");
140  fprintf(fout, " return(1);\n");
141  fprintf(fout, "}\n");
142  fprintf(fout, "\n\n");
143  fprintf(fout, "#endif\n");
144  fprintf(fout, "\n\n");
145 
146  return(0);
147 }
148 
149 
150 
151 int printRest(fout, n)
152 FILE *fout;
153 int n;
154 {
155  int i;
156 
157  fprintf(fout, ", \t\"");
158 
159  for(i=2;i<n;i++)
160  {
161  if(!strcmp(tok[i], "/*!<") || !strcmp(tok[i], "/*") || !strcmp(tok[i], "*/") || !strcmp(tok[i], "//"))
162  {
163  continue;
164  }
165  else
166  {
167  fprintf(fout, " %s", tok[i]);
168  }
169  }
170 
171  fprintf(fout, "\"\t},\n");
172 
173  return(0);
174 }
175 
176 
177 
178 
179 
180 int main()
181 {
182  int n, j=0;
183  char *string, line[256], fname[256];
184  FILE *fp, *fout;
185 
186  strcpy(fname, "../include/env.h");
187 
188  if((fp = fopen(fname, "r") ) <= (FILE *)0)
189  {
190  fprintf(stderr, "Unable to open file %s\n", fname);
191  return(0);
192  }
193 
194  if((fout = fopen("env_help.c", "w") ) <= (FILE *)0)
195  {
196  fprintf(stderr, "Unable to open file 'env_help.c'\n");
197  return(0);
198  }
199 
200  makePreamble(fout);
201 
202  while((string = fgets(line, sizeof(line), fp)) != NULL)
203  {
204  if(line[0] == '#')
205  {
206  continue;
207  }
208 
209  n = get_tok(line);
210 
211 // printf("N = %d; tok[0] = %s, %s, %s\n", n, tok[0], tok[1], tok[2]);
212 
213  strcmprs(tok[0]);
214 
215  if(!strcmp(tok[0], "char") || !strcmp(tok[0], "int") || !strcmp(tok[0], "double"))
216  {
217  fprintf(fout, "\t{ \"%s\", \t\"%s\"", tok[0], tok[1]);
218  if(n > 2)
219  {
220  printRest(fout, n);
221  }
222  else
223  {
224  fprintf(fout, ", \" \" \t},\n");
225  }
226 
227  j++;
228  }
229  else
230  {
231 // printf("Skipping %s\n", tok[0]);
232  }
233  }
234 
235  fclose(fp);
236 
237  makeEnd(fout, j);
238 
239  return(0);
240 }
241 
int main(void)
Definition: gsl_try_2.c:176
int makeEnd(FILE *fout, int j)
Definition: make_env.c:117
char * strcmprs(char *str)
#define MAX_TOKENS
Definition: defines.h:40
FILE * fp
Definition: linuxpops.c:70
char tok[MAX_TOKENS][MAX_TOKENS]
Definition: make_env.c:67
int printRest(FILE *fout, int n)
Definition: make_env.c:151
int get_tok(char *edit)
Definition: make_env.c:69
int strcmp()
int makePreamble(FILE *fout)
Definition: make_env.c:88