NAPA Compiler V4.50
Author: Yves Leduc, yves.leduc.be@gmail.com
Loading...
Searching...
No Matches
C:/Simulate/Napados/Source/co.c File Reference
#include "./napa.h"
#include "./proto.h"

Go to the source code of this file.

Macros

#define EXTERN   extern

Functions

void check_option_function (void)
void collect_string_of_options (void)
void collect_string_of_functions (void)

Variables

long local_idset [255L]
char local_funstr [16383L] = {'\0'}
char local_funset [255L][2047L]
char local_optstr [16383L] = {'\0'}
char local_optset [255L][2047L]
char local_valstr [16383L] = {'\0'}
char local_valset [255L][2047L]
long local_nfun
long local_nopt
long local_nval

Macro Definition Documentation

◆ EXTERN

#define EXTERN   extern

Definition at line 4 of file co.c.

Function Documentation

◆ check_option_function()

void check_option_function ( void )

Definition at line 87 of file co.c.

87 {
88 int stlen, svlen, sflen;
89 int sz = 63;
90 long fa, ia, oa, va;
91 long fb, ib;
92 int ii, jj, kk;
93 int nii, njj, nkk;
94 int*** val;
95
96 if ((!UserTool_Flag) && (!Post_Flag)) {
97 return; /* No user, tool, postprocess, thus check no option */
98 }
99
100 if (!Option_Flag) {
101 if (Post_Flag) {
102 (void) fprintf(STDOUT, "\n\n/* *** TRIVIAL CASE, NO OPTION FOUND IN USER'S, TOOL'S AND/OR POSTPROCESSOR'S CALLS");
103 (void) fprintf(STDOUT, " %s */\n\n", multiple('*', 43L));
104 } else {
105 (void) fprintf(STDOUT, "\n\n/* *** TRIVIAL CASE, NO OPTION FOUND IN USER'S AND/OR TOOL'S CALLS %s */\n\n", multiple('*', 60L));
106 }
107 } else {
108 if (Post_Flag) {
109 (void) fprintf(STDOUT, "\n\n/* *** OPTIONS IN USER'S, TOOLS'S AND/OR POSTPROCESSOR'S CALLS ");
110 (void) fprintf(STDOUT, "AS DESCRIBED IN NETLIST %s */\n\n", multiple('*', 40L));
111 } else {
112 (void) fprintf(STDOUT, "\n\n/* *** OPTIONS IN USER'S AND/OR TOOL'S CALLS ");
113 (void) fprintf(STDOUT, "AS DESCRIBED IN NETLIST %s */\n\n", multiple('*', 58L));
114 }
115 }
116 (void) fprintf(STDOUT, "double *napa_check_for_option(const char *strfun, long id, const char *stropt, int ctr) {");
117 (void) fprintf(STDOUT, " /* 'ctr' 0: a parameter, 'ctr' 1: an option */\n");
118
119 /* --- Trivial case: without option in NAPA netlist, 'napa_check_for_option' is a simple blank function ----------------------- */
120
121 if (!Option_Flag) {
122
123 (void) fprintf(STDOUT, " static double zero = 0.0;\n");
124 (void) fprintf(STDOUT, " if ( 0 == ctr ) {\n");
125 (void) fprintf(STDOUT, " return (double*) NULL;\n");
126 (void) fprintf(STDOUT, " } else {\n");
127 (void) fprintf(STDOUT, " return &zero;\n");
128 (void) fprintf(STDOUT, " }\n");
129 (void) fprintf(STDOUT, "}\n");
130 return;
131 }
132
133
134 /* --- Otherwise, write the complete 'napa_check_for_option' function --------------------------------------------------------- */
135
136 nii = 1L + Option_List.nfun;
137 njj = 1L + Option_List.maxid;
138 nkk = 1L + Option_List.nopt;
139
140 /* allocate memory for a 3D array val[0...nfun][0...nid][0...nopt] */
141 val = (int***) malloc((size_t) nii * sizeof(int**));
142 if ((int***) NULL == val) {
143 print_error_location("construction of the 3D table of options", (unsigned long*) NULL, (unsigned long*) NULL);
144 (void) fprintf(STDERR, " dynamic memory allocation error\n");
146 }
147 for (ii = 0; ii < nii; ii++) {
148 val[ii] = (int**) malloc((size_t) njj * sizeof(int*));
149 if ((int**) NULL == val[ii]) {
150 print_error_location("construction of the 3D table of options", (unsigned long*) NULL, (unsigned long*) NULL);
151 (void) fprintf(STDERR, " dynamic memory allocation error\n");
153 }
154 for (jj = 0; jj < njj; jj++) {
155 val[ii][jj] = (int*) malloc((size_t) nkk * sizeof(int));
156 if ((int*) NULL == val[ii][jj]) {
157 print_error_location("construction of the 3D table of options", (unsigned long*) NULL, (unsigned long*) NULL);
158 (void) fprintf(STDERR, " dynamic memory allocation error\n");
160 }
161 }
162 }
163
164 /* initialize the 3D array val[0...nfun][0...nid][0...nopt] */
165 for (ii = 0; ii < nii; ii++) {
166 for (jj = 0; jj < njj; jj++) {
167 for (kk = 0; kk < nkk; kk++) {
168 val[ii][jj][kk] = 0;
169 }
170 }
171 }
172
173 (void) fprintf(STDOUT, " long n;\n" );
174 (void) fprintf(STDOUT, " long o = -1L;\n");
175 if (1L < Option_List.nfun) {
176 (void) fprintf(STDOUT, " long f = -1L;\n");
177 }
178 (void) fprintf(STDOUT, " double *r0;\n" );
179 (void) fprintf(STDOUT, " static double zero = 0.0;\n");
180 (void) fprintf(STDOUT, " static double one = 1.0;\n");
181 if (102L > LENGTH(Option_List.funstr)) {
182 (void) fprintf(STDOUT, " const char *list_fun[%ld] = { %s };\n", Option_List.nfun, Option_List.funstr);
183 } else {
184 (void) fprintf(STDOUT, " const char *list_fun[%ld] =\n", Option_List.nfun );
185 (void) fprintf(STDOUT, " { %s };\n", Option_List.funstr);
186 }
187 if (102L > LENGTH(Option_List.optstr)) {
188 (void) fprintf(STDOUT, " const char *list_opt[%ld] = { %s };\n", Option_List.nopt, Option_List.optstr);
189 } else {
190 (void) fprintf(STDOUT, " const char *list_opt[%ld] =\n", Option_List.nopt );
191 (void) fprintf(STDOUT, " { %s };\n", Option_List.optstr);
192 }
193 if (102L > LENGTH(Option_List.valstr)) {
194 (void) fprintf(STDOUT, " double *list_val[%ld] = { %s };\n", Option_List.nval, Option_List.valstr);
195 } else {
196 (void) fprintf(STDOUT, " double *list_val[%ld] =\n", Option_List.nval );
197 (void) fprintf(STDOUT, " { %s };\n", Option_List.valstr);
198 }
199 (void) fprintf(STDOUT, " long nfun =%3ldL; %46s", Option_List.nfun, " " );
200 (void) fprintf(STDOUT, "/* <<< the number of different instantiated functions */\n");
201 (void) fprintf(STDOUT, " long nid =%3ldL; %46s", Option_List.maxid, " " );
202 (void) fprintf(STDOUT, "/* <<< the max number of instantiations of a same function */\n");
203 (void) fprintf(STDOUT, " long nopt =%3ldL; %46s", Option_List.nopt, " " );
204 (void) fprintf(STDOUT, "/* <<< the total number of different options in the netlist */\n");
205 (void) fprintf(STDOUT, " long nval =%3ldL; %46s", Option_List.nval, " " );
206 (void) fprintf(STDOUT, "/* <<< the total number of different values in the netlist */\n");
207 stlen = fprintf(STDOUT, " static int table_opt[%ld][%ld][%ld] = {", Option_List.nfun, Option_List.maxid, Option_List.nopt);
208 (void) fprintf(STDOUT, "%*s /* <<< table_opt[#fun][#id][#opt] %*s */\n", (66 - stlen), " ", 25, " " );
209 svlen = (9L < Option_List.nopt) ? 2 : 1; /* just for formatting the table_opt[][][] */
210 sflen = 19L;
211 for (fa = 0L; fa < Option_List.nfun; fa++) { /* just to calibrate the string format of functions */
212 sflen = MAX(sflen, (int) LENGTH(Option_List.funset[fa]));
213 }
214 /* process function after function, instance after instance, option after option to fill location val[fa][ia][oa] */
215 for (fa = 0L; fa < Option_List.nfun; fa++) {
216 for (ia = 0L; ia < Option_List.maxid; ia++) {
217 for (oa = 0L; oa < Option_List.nopt; oa++) {
218 for (fb = 0L; fb < local_nfun; fb++) {
219 /* search for the first index in local list of functions concerning the instantiation of this function */
220 if (0 != strcmp(local_funset[fb], Option_List.funset[fa])) {
221 /* this not the function that we are targetting */
222 continue;
223 }
224 ib = local_idset[fb]; /* id of this intantiated function */
225 if (ib != ia) {
226 /* this is not the instantiation of this function that we are targetting */
227 continue;
228 }
229 if (0 != strcmp(Option_List.optset[oa], local_optset[fb])) {
230 /* this not the option that we are targetting */
231 continue;
232 }
233 for (va = 0L; va < Option_List.nval; va++) {
234 if (0 == strcmp(Option_List.valset[va], local_valset[fb])) {
235 val[fa][ia][oa] = va; /* with or without value, pointing to list_val[] */
236 break;
237 }
238 }
239 }
240 }
241 }
242 }
243 /* all the values being determined, write the formatted table */
244 for (fa = 0L; fa < Option_List.nfun; fa++) { /* 'fa' is the paragraph number ******************* */
245 if (0L == fa) {
246 (void) fprintf(STDOUT, " {");
247 } else {
248 (void) fprintf(STDOUT, "\n {");
249 }
250 for (ia = 0L; ia < Option_List.maxid; ia++) {
251 if (0L == ia) {
252 (void) fprintf(STDOUT, " {" );
253 } else {
254 (void) fprintf(STDOUT, " {");
255 }
256 for (oa = 0L; oa < Option_List.nopt; oa++) {
257 if (0L == oa) {
258 (void) fprintf(STDOUT, " ");
259 }
260 fprintf(STDOUT, "%*d", svlen, val[fa][ia][oa]);
261 if ((Option_List.nopt-1L) == oa) {
262 if ((Option_List.maxid-1L) != ia) {
263 (void) fprintf(STDOUT, " },");
264 } else {
265 (void) fprintf(STDOUT, " }" );
266 }
267 } else {
268 (void) fprintf(STDOUT, ", " );
269 }
270 }
271 if ((Option_List.maxid-1L) != ia) {
272 (void) fprintf(STDOUT, "\n");
273 }
274 }
275 if ((Option_List.nfun-1L) == fa) {
276 (void) fprintf(STDOUT, " }" );
277 (void) fprintf(STDOUT, "%*s /* <<< %-*s */", 86-((int) (3L*Option_List.nopt)), " ", sflen, Option_List.funset[fa]);
278 } else {
279 if (1L == Option_List.maxid) {
280 if (1L == Option_List.nopt) {
281 (void) fprintf(STDOUT, " },");
282 } else {
283 (void) fprintf(STDOUT, " },");
284 }
285 } else {
286 (void) fprintf(STDOUT, " },");
287 }
288 (void) fprintf(STDOUT, "%*s /* <<< %-*s */", 85-((int) (3L*Option_List.nopt)), " ", sflen, Option_List.funset[fa]);
289 }
290 if ((2L < Option_List.maxid) && ((Option_List.nfun-1L) != fa)) {
291 (void) fprintf(STDOUT, "\n");
292 }
293 }
294 (void) fprintf(STDOUT, "\n };\n");
295
296 (void) fprintf(STDOUT, " r0 = ( 0 == ctr ) ? (double*) NULL : &zero;\n");
297 if (1L < Option_List.nfun) { /* Scan function names */
298 (void) fprintf(STDOUT, " for (n = 0L; n < nfun; n++) {\n");
299 (void) fprintf(STDOUT, " if ( 0 == strncmp(list_fun[n], strfun, %d) ) {\n", sz);
300 (void) fprintf(STDOUT, " f = n;\n");
301 (void) fprintf(STDOUT, " break;\n");
302 (void) fprintf(STDOUT, " }\n");
303 (void) fprintf(STDOUT, " }\n");
304 (void) fprintf(STDOUT, " if ( (-1L == f) || (0L > id) || (nid <= id) ) {\n");
305 (void) fprintf(STDOUT, " return r0;\n");
306 (void) fprintf(STDOUT, " }\n");
307 } else {
308 (void) fprintf(STDOUT, " if ( (0 != strncmp(strfun, list_fun[0L], %d)) || (0L > id) || (nid <= id) ) {\n", sz);
309 (void) fprintf(STDOUT, " return r0;\n");
310 (void) fprintf(STDOUT, " }\n");
311 }
312 (void) fprintf(STDOUT, " if ( 0 == strncmp(\"_another_\", stropt, %d) ) {\n", sz);
313 (void) fprintf(STDOUT, " if ( 0 != ctr ) {\n");
314 if (1L < Option_List.nfun) {
315 (void) fprintf(STDOUT, " for (n = 0L; n < nopt; n++) {\n");
316 (void) fprintf(STDOUT, " if ( 0 < table_opt[f][id][n] ) {\n");
317 (void) fprintf(STDOUT, " return &one;\n");
318 (void) fprintf(STDOUT, " }\n");
319 (void) fprintf(STDOUT, " }\n");
320 } else {
321 (void) fprintf(STDOUT, " for (n = 0L; n < nopt; n++) {\n");
322 (void) fprintf(STDOUT, " if ( 0 < table_opt[0][id][n] ) {\n");
323 (void) fprintf(STDOUT, " return &one;\n");
324 (void) fprintf(STDOUT, " }\n");
325 (void) fprintf(STDOUT, " }\n");
326 }
327 (void) fprintf(STDOUT, " return &zero;\n");
328 (void) fprintf(STDOUT, " } else {\n");
329 (void) fprintf(STDOUT, " return (double*) NULL;\n");
330 (void) fprintf(STDOUT, " }\n");
331 (void) fprintf(STDOUT, " }\n");
332 (void) fprintf(STDOUT, " for (n = 0L; n < nopt; n++) {\n"); /* Scan option names */
333 (void) fprintf(STDOUT, " if ( 0 == strncmp(list_opt[n], stropt, %d) ) {\n", sz);
334 (void) fprintf(STDOUT, " o = n;\n");
335 (void) fprintf(STDOUT, " break;\n");
336 (void) fprintf(STDOUT, " }\n");
337 (void) fprintf(STDOUT, " }\n");
338 (void) fprintf(STDOUT, " if ( -1L == o ) {\n");
339 (void) fprintf(STDOUT, " return r0;\n");
340 (void) fprintf(STDOUT, " }\n");
341 (void) fprintf(STDOUT, " if ( 0 != ctr ) {\n"); /* Question: is an option with or without value? */
342 if (1L < Option_List.nfun) {
343 (void) fprintf(STDOUT, " if ( 0 < table_opt[f][id][o] ) {\n");
344 (void) fprintf(STDOUT, " table_opt[f][id][o] = -table_opt[f][id][o];\n");
345 (void) fprintf(STDOUT, " return &one;\n");
346 (void) fprintf(STDOUT, " }\n");
347 } else {
348 (void) fprintf(STDOUT, " if ( 0 < table_opt[0][id][o] ) {\n");
349 (void) fprintf(STDOUT, " table_opt[0][id][o] = -table_opt[0][id][o];\n");
350 (void) fprintf(STDOUT, " return &one;\n");
351 (void) fprintf(STDOUT, " }\n");
352 }
353 (void) fprintf(STDOUT, " } else {\n"); /* Question: is an option with a value? */
354 if (1L < Option_List.nfun) {
355 (void) fprintf(STDOUT, " return list_val[ABS(table_opt[f][id][o])];\n");
356 } else {
357 (void) fprintf(STDOUT, " return list_val[ABS(table_opt[0][id][o])];\n");
358 }
359 (void) fprintf(STDOUT, " }\n");
360 (void) fprintf(STDOUT, " return r0;\n");
361 (void) fprintf(STDOUT, "}\n\n");
362
363 for (ii = 0; ii < nii; ii++) {
364 for (jj = 0; jj < njj; jj++) {
365 free(val[ii][jj]);
366 }
367 free(val[ii]);
368 }
369 free(val);
370 return;
371}
char local_funset[255L][2047L]
Definition co.c:72
long local_idset[255L]
Definition co.c:70
char local_valset[255L][2047L]
Definition co.c:76
long local_nfun
Definition co.c:77
char local_optset[255L][2047L]
Definition co.c:74
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
Definition fc.c:1476
EXTERN int Post_Flag
Definition napa.h:876
EXTERN OPTION_TYPE Option_List
Definition napa.h:976
#define LENGTH(s)
Definition napa.h:397
#define STDERR
Definition napa.h:105
#define STDOUT
Definition napa.h:104
EXTERN int Option_Flag
Definition napa.h:871
EXTERN int UserTool_Flag
Definition napa.h:888
#define MAX(x, y)
Definition napa.h:377
void print_error_banner_and_exit(void)
Definition pr.c:5482
char * multiple(char c, long n)
Definition tk.c:1801

References LENGTH, local_funset, local_idset, local_nfun, local_optset, local_valset, MAX, multiple(), Option_Flag, Option_List, Post_Flag, print_error_banner_and_exit(), print_error_location(), STDERR, STDOUT, and UserTool_Flag.

Referenced by main().

◆ collect_string_of_functions()

void collect_string_of_functions ( void )

Definition at line 561 of file co.c.

561 {
562 long p, u;
563 char tok1[STRLENGTH] = {'\0'};
564 char tok2[STRLENGTH] = {'\0'};
565 char tok3[STRLENGTH] = {'\0'};
566 char *s1 = (char*) NULL;
567 char *s2 = (char*) NULL;
568 char *s3 = (char*) NULL;
569 static int first = true;
570 int flag;
571 flag = false;
572 local_nfun = 0L;
573 Option_List.maxid = 0L;
574 (void) strcpy(local_funstr, "");
575 for (u = 0L; u < Num_UserTools; u++) {
576 s3 = UserTool_List[u].option;
577 for (;;) {
578 s3 = get_token(s3, tok3, false);
579 if (ISEMPTY(tok3)) {
580 break;
581 }
582 if (first) {
583 (void) strcat(local_funstr, "\"");
584 } else {
585 (void) strcat(local_funstr, ",\"");
586 }
587 (void) strcat(local_funstr, UserTool_List[u].function);
588 (void) strcat(local_funstr, "\", ");
589 (void) strcpy(local_funset[local_nfun], UserTool_List[u].function);
591 local_nfun++;
592 }
593 }
594 for (p = 0L; p < Num_Posts; p++) {
595 s3 = Post_List[p].option;
596 for (;;) {
597 s3 = get_token(s3, tok3, false);
598 if (ISEMPTY(tok3)) {
599 break;
600 }
601 if (first) {
602 (void) strcat(local_funstr, ",\"");
603 } else {
604 (void) strcat(local_funstr, "\"" );
605 }
606 (void) strcat(local_funstr, Post_List[p].function);
607 (void) strcat(local_funstr, "\" ");
608 (void) strcpy(local_funset[local_nfun], Post_List[p].function);
610 local_nfun++;
611 }
612 }
613 for (u = 0L; u < Num_UserTools; u++) { /* Scan the UserTool_List */
614 Option_List.maxid = MAX(Option_List.maxid, UserTool_List[u].ID);
615 (void) strcpy(tok1, UserTool_List[u].function);
616 s1 = Option_List.funstr;
617 flag = false;
618 for (;;) {
619 s1 = get_token(s1, tok2, false);
620 if (ISEMPTY(tok2)) {
621 break;
622 }
623 if (0 == strcmp(tok2, ",")) {
624 continue;
625 }
626 if (0 == strcmp(tok1, tok2)) { /* This function is already stored */
627 flag = true;
628 break;
629 }
630 }
631 if (!flag) { /* New function to be stored */
632 if (first) {
633 first = false;
634 } else {
635 (void) strcat(Option_List.funstr, ", ");
636 }
637 (void) strcat(Option_List.funstr, " " );
638 (void) strcat(Option_List.funstr, tok1);
639 (void) strcat(Option_List.funstr, " " );
640 (void) strcpy(Option_List.funset[Option_List.nfun], tok1);
641 Option_List.nfun++;
642 }
643 }
644 for (p = 0L; p < Num_Posts; p++) { /* Scan the Post_List */
645 Option_List.maxid = MAX(Option_List.maxid, Post_List[p].ID);
646 (void) strcpy(tok1, Post_List[p].function);
647 s1 = Option_List.funstr;
648 for (;;) {
649 flag = false;
650 s1 = get_token(s1, tok2, false); /* Don't change to lower case here */
651 if (ISEMPTY(tok2)) {
652 break;
653 }
654 if (0 == strcmp(tok2, ",")) {
655 continue;
656 }
657 if (0 == strcmp(tok1, tok2)) { /* This function is already stored */
658 flag = true;
659 break;
660 }
661 }
662 if (!flag) { /* New function to be stored */
663 if (first) {
664 first = false;
665 } else {
666 (void) strcat(Option_List.funstr, ", ");
667 }
668 (void) strcat(Option_List.funstr, " " );
669 (void) strcat(Option_List.funstr, tok1);
670 (void) strcat(Option_List.funstr, " " );
671 (void) strcpy(Option_List.funset[Option_List.nfun], tok1);
672 Option_List.nfun++;
673 }
674 }
675 /* Format the list by adding double quotes around identifiers, */
676 /* they were not added, to simplify the comparison of token during the list building */
677 s2 = Option_List.funstr;
678 for (;;) {
679 if ('\0' == *s2) {
680 break;
681 }
682 if ((' ' == *s2) && (' ' != *(s2+1))) {
683 *s2 = '\"';
684 }
685 s2++;
686 }
687 /* Correct the number of id to match the code of 'napa_check_for_option()' */
688 Option_List.maxid++;
689
690 return;
691}
char local_funstr[16383L]
Definition co.c:71
EXTERN POST_TYPE Post_List[63L]
Definition napa.h:964
EXTERN long Num_UserTools
Definition napa.h:835
EXTERN USERTOOL_TYPE UserTool_List[511L]
Definition napa.h:969
EXTERN long Num_Posts
Definition napa.h:827
#define STRLENGTH
Definition napa.h:217
#define ISEMPTY(s)
Definition napa.h:394
char * get_token(char *str, char *tok, long keep_quotes)
Definition tk.c:1210

References get_token(), ISEMPTY, local_funset, local_funstr, local_idset, local_nfun, MAX, Num_Posts, Num_UserTools, Option_List, Post_List, STRLENGTH, and UserTool_List.

Referenced by main().

◆ collect_string_of_options()

void collect_string_of_options ( void )

Definition at line 379 of file co.c.

379 {
380 long i, o, p, u;
381 long count;
382 char tok[STRLENGTH] = {'\0'};
383 char toko[STRLENGTH] = {'\0'};
384 char tokv[STRLENGTH] = {'\0'};
385 char *s1 = (char*) NULL;
386 char *s2 = (char*) NULL;
387 char *s3 = (char*) NULL;
388 char *s4 = (char*) NULL;
389 int flag;
390 int first1;
391 int first2;
392 first1 = true;
393 first2 = true;
394 local_nopt = 0L;
395 local_nval = 0L;
396 (void) strcpy(local_optstr, "");
397 (void) strcpy(local_valstr, "");
398 for (u = 0L; u < Num_UserTools; u++) { /* Scan the UserTool_List */
399 s1 = UserTool_List[u].option;
400 for (;;) { /* Scan the option(s) of a user or tool */
401 s1 = get_token(s1, tok, true);
402 if (ISEMPTY(tok)) {
403 break;
404 }
405 (void) strcpy(toko, tok);
406 (void) strcpy(tokv, tok);
407 s3 = toko;
408 s4 = strstr(s3, "::");
409 if ((char*) NULL != s4) {
410 *s4 = '\0';
411 }
412 /* toko contains the option without any value */
413 if (!first1) {
414 (void) strcat(local_optstr, ", \"");
415 } else {
416 first1 = false;
417 (void) strcat(local_optstr, "\"");
418 }
419 (void) strcat(local_optstr, toko);
420 (void) strcat(local_optstr, "\"");
421 (void) strcpy(local_optset[local_nopt], toko);
422 local_nopt++;
423 s2 = strstr(tokv, "::");
424 if ((char*) NULL != s2) {
425 (void) strcpy(tokv, s2 + 2);
426 } else {
427 (void) strcpy(tokv, "NULL");
428 }
429 build_name("", tokv, RIGHT_VALUE);
430 /* tokv contains only the value of the option only or 'NULL' */
431 if (!first2) {
432 (void) strcat(local_valstr, ", ");
433 } else {
434 first2 = false;
435 }
436 (void) strcat(local_valstr, tokv);
437 if (0 == strcmp("NULL", tokv)) {
438 (void) strcpy(local_valset[local_nval], "NULL" );
439 } else {
440 if (0 == strncmp("dconst__", tokv, 8)) {
441 (void) sprintf(local_valset[local_nval], "&%s", tokv);
442 } else {
443 print_error_location("option", UserTool_List[u].mline, UserTool_List[u].mfile);
444 (void) fprintf(STDERR, " (%s::%s) : the value must be a constant number\n", toko, tokv);
446 }
447 }
448 local_nval++;
449 }
450 }
451 for (p = 0L; p < Num_Posts; p++) { /* Scan the Post_List */
452 s1 = Post_List[p].option;
453 for (;;) { /* Scan the option(s) of a user or tool */
454 s1 = get_token(s1, tok, true);
455 if (ISEMPTY(tok)) {
456 break;
457 }
458 (void) strcpy(toko, tok);
459 (void) strcpy(tokv, tok);
460 s3 = toko;
461 s4 = strstr(s3, "::");
462 if ((char*) NULL != s4) {
463 *s4 = '\0';
464 }
465 /* toko contains the option without any value */
466 if (!first1) {
467 (void) strcat(local_optstr, ", \"");
468 } else {
469 first1 = false;
470 (void) strcat(local_optstr, "\"");
471 }
472 (void) strcat(local_optstr, toko);
473 (void) strcat(local_optstr, "\"");
474 (void) strcpy(local_optset[local_nopt], toko);
475 local_nopt++;
476 s2 = strstr(tokv, "::");
477 if ((char*) NULL != s2) {
478 (void) strcpy(tokv, s2 + 2);
479 } else {
480 (void) strcpy(tokv, "NULL");
481 }
482 build_name("", tokv, RIGHT_VALUE);
483 /* tokv contains the value of the option only or 'NULL' */
484 if (!first2) {
485 (void) strcat(local_valstr, ", ");
486 } else {
487 first2 = false;
488 }
489 (void) strcat(local_valstr, tokv);
490 if (0 == strcmp("NULL", tokv)) {
491 (void) strcpy(local_valset[local_nval], "NULL" );
492 } else {
493 if (0 == strncmp("dconst__", tokv, 8)) {
494 (void) sprintf(local_valset[local_nval], "&%s", tokv);
495 } else {
496 print_error_location("option", Post_List[p].mline, Post_List[p].mfile);
497 (void) fprintf(STDERR, " (%s::%s) : the value must be a constant number\n", toko, tokv);
499 }
500 }
501 local_nval++;
502 }
503 }
504
505 if (0 < local_nopt) { /* At least one option has been instantiated */
506 Option_Flag = true;
507 }
508 /* load strings Option_List_opstr and Option_List_optset[], removing duplicate entries, adding double quotes */
509 (void) strcpy(Option_List.optset[0], local_optset[0]);
510 (void) strcpy(Option_List.optstr, "\"");
511 (void) strcat(Option_List.optstr, local_optset[0]);
512 (void) strcat(Option_List.optstr, "\"");
513 count = 1L;
514 for (i = 1L; i < local_nopt; i++) {
515 flag = false;
516 for (o = 0L; o < count; o++) {
517 if (0 == strcmp(local_optset[i], Option_List.optset[o])) { /* If strings are equal, it is already stored */
518 flag = true;
519 break;
520 }
521 }
522 if (!flag) { /* Not yet recorded ! */
523 (void) strcpy(Option_List.optset[count], local_optset[i]);
524 (void) strcat(Option_List.optstr, ", \"");
525 (void) strcat(Option_List.optstr, local_optset[i]);
526 (void) strcat(Option_List.optstr, "\"");
527 count++;
528 }
529 }
530 Option_List.nopt = count;
531
532 /* load strings Option_List_valstr and Option_List_valset[], removing duplicate entries */
533 (void) strcpy(Option_List.valset[0], "NONE"); /* First NULL to indicate it is not an option */
534 (void) strcpy(Option_List.valstr, "NULL" );
535 count = 1L;
536 for (i = 0L; i < local_nval; i++) {
537 flag = false;
538 for (o = 0L; o < count; o++) {
539 if (0 == strcmp(local_valset[i], Option_List.valset[o])) { /* If strings are equal, it is already stored */
540 flag = true;
541 break;
542 }
543 }
544 if (!flag) { /* Not yet recorded ! */
545 (void) strcpy(Option_List.valset[count], local_valset[i]);
546 (void) strcat(Option_List.valstr, ", " );
547 (void) strcat(Option_List.valstr, local_valset[i]);
548 count++;
549 }
550 }
551 Option_List.nval = count;
552 return;
553}
long local_nval
Definition co.c:79
char local_valstr[16383L]
Definition co.c:75
long local_nopt
Definition co.c:78
char local_optstr[16383L]
Definition co.c:73
#define RIGHT_VALUE
Definition napa.h:416
char * build_name(const char *sgn, char *tok, long lr_type)
Definition tk.c:69

References build_name(), get_token(), ISEMPTY, local_nopt, local_nval, local_optset, local_optstr, local_valset, local_valstr, Num_Posts, Num_UserTools, Option_Flag, Option_List, Post_List, print_error_banner_and_exit(), print_error_location(), RIGHT_VALUE, STDERR, STRLENGTH, and UserTool_List.

Referenced by main().

Variable Documentation

◆ local_funset

char local_funset[255L][2047L]

Definition at line 72 of file co.c.

Referenced by check_option_function(), and collect_string_of_functions().

◆ local_funstr

char local_funstr[16383L] = {'\0'}

Definition at line 71 of file co.c.

71{'\0'};

Referenced by collect_string_of_functions().

◆ local_idset

long local_idset[255L]

Definition at line 70 of file co.c.

Referenced by check_option_function(), and collect_string_of_functions().

◆ local_nfun

long local_nfun

Definition at line 77 of file co.c.

Referenced by check_option_function(), and collect_string_of_functions().

◆ local_nopt

long local_nopt

Definition at line 78 of file co.c.

Referenced by collect_string_of_options().

◆ local_nval

long local_nval

Definition at line 79 of file co.c.

Referenced by collect_string_of_options().

◆ local_optset

char local_optset[255L][2047L]

Definition at line 74 of file co.c.

Referenced by check_option_function(), and collect_string_of_options().

◆ local_optstr

char local_optstr[16383L] = {'\0'}

Definition at line 73 of file co.c.

73{'\0'};

Referenced by collect_string_of_options().

◆ local_valset

char local_valset[255L][2047L]

Definition at line 76 of file co.c.

Referenced by check_option_function(), and collect_string_of_options().

◆ local_valstr

char local_valstr[16383L] = {'\0'}

Definition at line 75 of file co.c.

75{'\0'};

Referenced by collect_string_of_options().