PERFORCE change 79936 for review
soc-victor
soc-victor at FreeBSD.org
Sun Jul 10 20:31:22 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=79936
Change 79936 by soc-victor at soc-victor_82.76.158.176 on 2005/07/10 20:30:56
Cosmetic changes in the gensnmptree tool so as the <prefix>_tree.h
generated/ output file to contain the #ifndef...#define... #endif
clauses in order to prevent multiple inclusions.
Affected files ...
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.c#2 edit
Differences ...
==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.c#2 (text+ko) ====
@@ -898,6 +898,8 @@
int opt;
struct node *root;
char fname[MAXPATHLEN + 1];
+ char include_fname[MAXPATHLEN + 128 +1];
+ int idx;
int tok;
while ((opt = getopt(argc, argv, "help:t")) != EOF)
@@ -955,13 +957,24 @@
return (0);
}
sprintf(fname, "%stree.h", file_prefix);
+
+ /*prepare the ifndef directive*/
+ memset(include_fname,'\0',sizeof(include_fname));
+ snprintf(include_fname, MAXPATHLEN + 128, "_%sTREE_H_INCLUDED__",file_prefix);
+ for(idx = 0; idx < strlen(include_fname); idx++){
+ include_fname[idx] = toupper(include_fname[idx]);
+ }
+
if ((fp = fopen(fname, "w")) == NULL)
err(1, "%s: ", fname);
+
+ fprintf(fp, "#ifndef %s\n",include_fname);
+ fprintf(fp, "#define %s\n",include_fname);
gen_header(root, PREFIX_LEN, NULL);
fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size);
fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix);
-
+ fprintf(fp, "#endif /* %s */\n",include_fname);
fclose(fp);
sprintf(fname, "%stree.c", file_prefix);
More information about the p4-projects
mailing list