3232#endif
3333#include "dmf.h"
3434
35- // These strings are embedded into <nut> tags to show their schema version
36- // Strings must verbatim match the XSD (no trailing slash etc.)
35+ /* These strings are embedded into <nut> tags to show their schema version */
36+ /* Strings must verbatim match the XSD (no trailing slash etc.) */
3737#ifndef XSD_DMFNUTSCAN_VERSION
3838#define XSD_DMFNUTSCAN_VERSION "1.0.0"
3939#endif
@@ -62,10 +62,10 @@ int main(int argc, char *argv[])
6262 int opt_ret ;
6363 int result = 0 ;
6464 int ret_code = EXIT_SUCCESS ;
65- int proceed_on_errors = 1 ; // By default, do as much as we can
66- char * dir_name = NULL ; // TODO: Make configurable the dir and/or list of files
65+ int proceed_on_errors = 1 ; /* By default, do as much as we can */
66+ char * dir_name = NULL ; /* TODO: Make configurable the dir and/or list of files */
6767 int dir_name_dynamic = 0 ;
68- // TODO: Consider DEFAULT_DMFNUTSCAN_DIR for automatic output mode into a file?
68+ /* TODO: Consider DEFAULT_DMFNUTSCAN_DIR for automatic output mode into a file? */
6969#ifdef DEFAULT_DMFSNMP_DIR_OVERRIDE
7070#ifdef DEFAULT_DMFSNMP_DIR
7171#undef DEFAULT_DMFSNMP_DIR
@@ -79,8 +79,8 @@ int main(int argc, char *argv[])
7979 dir_name = "./" ;
8080#endif
8181
82- // TODO: Usage (help), Command-line args
83- // option to append just a few (new) files to existing (large) index
82+ /* TODO: Usage (help), Command-line args */
83+ /* option to append just a few (new) files to existing (large) index */
8484
8585 while ((opt_ret = getopt_long (argc , argv , optstring , longopts , NULL ))!= -1 ) {
8686
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
133133 mibdmf_parser_t * dmp = mibdmf_parser_new ();
134134 if (!dmp ) {
135135 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not allocate the DMF parsing structures\n" );
136- // TODO: Can we pass this code to fatalx?
136+ /* TODO: Can we pass this code to fatalx? */
137137 return ENOMEM ;
138138 }
139139
@@ -142,35 +142,35 @@ int main(int argc, char *argv[])
142142 if ( (result != 0 ) &&
143143 (result == ERR || proceed_on_errors != 1 )
144144 ) {
145- // TODO: Error-checking? Faults in some parses should be fatal or not?
145+ /* TODO: Error-checking? Faults in some parses should be fatal or not? */
146146 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Could not find or parse some files (return code %i)\n" , result );
147- // TODO: Can we pass this code to fatalx?
147+ /* TODO: Can we pass this code to fatalx? */
148148 return result ;
149149 }
150150
151- // Loop through discovered device_table and print it back as DMF markup
151+ /* Loop through discovered device_table and print it back as DMF markup */
152152 upsdebugx (2 , "=== DMF-Reindex: Print DMF subset for snmp_device_table[]...\n\n" );
153153
154154 snmp_device_id_t * devtab = mibdmf_get_device_table (dmp );
155155 if (!devtab )
156156 {
157157 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not access the parsed device_table\n" );
158- // TODO: Can we pass this code to fatalx?
158+ /* TODO: Can we pass this code to fatalx? */
159159 return ENOMEM ;
160160 }
161161
162- // Below we sprintf the index into a memory string, parse the result as
163- // a DMF with a new alist and tables (to validate) and test the same data
164- // is found. And only then output the stdout text.
165- // TODO: uniquify output, so that an old index that was read in does not
166- // pollute the parsed results (at least not for completely same items as
167- // already exist in the table)? What to do about partial hits ~ updates?
162+ /* Below we sprintf the index into a memory string, parse the result as
163+ * a DMF with a new alist and tables (to validate) and test the same data
164+ * is found. And only then output the stdout text. */
165+ /* TODO: uniquify output, so that an old index that was read in does not
166+ * pollute the parsed results (at least not for completely same items as
167+ * already exist in the table)? What to do about partial hits ~ updates? */
168168 size_t i ;
169169 size_t newdmf_len = 0 , newdmf_size = 1024 ;
170170 char * newdmf = (char * )calloc (newdmf_size , sizeof (char ));
171171 if (!newdmf ) {
172172 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not allocate the buffer for parsed DMF\n" );
173- // TODO: Can we pass this code to fatalx?
173+ /* TODO: Can we pass this code to fatalx? */
174174 return ENOMEM ;
175175 }
176176 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
@@ -181,14 +181,14 @@ int main(int argc, char *argv[])
181181 {
182182 upsdebugx (2 ,"[num=%zu (lenbefore=%zu)]" , i , newdmf_len );
183183
184- // ASSUMPTION: String increments would not exceed these few bytes
184+ /* ASSUMPTION: String increments would not exceed these few bytes */
185185 if ( (newdmf_size - newdmf_len ) < 256 )
186186 {
187187 newdmf_size += 1024 ;
188188 newdmf = (char * )realloc (newdmf , newdmf_size * sizeof (char ));
189189 if (!newdmf ) {
190190 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not extend the buffer for parsed DMF\n" );
191- // TODO: Can we pass this code to fatalx?
191+ /* TODO: Can we pass this code to fatalx? */
192192 return ENOMEM ;
193193 }
194194 upsdebugx (2 , "\nExtended the buffer to %zu bytes\n" , newdmf_size );
@@ -197,17 +197,17 @@ int main(int argc, char *argv[])
197197 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
198198 "\t<mib2nut " );
199199
200- // This attr is always present, even if as an empty string:
200+ /* This attr is always present, even if as an empty string: */
201201 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
202- "auto_check=\"%s\" " , devtab [i ].oid ? devtab [i ].oid : "" ); // [3 oid_auto_check] oid
202+ "auto_check=\"%s\" " , devtab [i ].oid ? devtab [i ].oid : "" ); /* [3 oid_auto_check] oid */
203203
204204 if (devtab [i ].mib != NULL )
205205 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
206- "mib_name=\"%s\" " , devtab [i ].mib ); // [0 mib_name] mib
206+ "mib_name=\"%s\" " , devtab [i ].mib ); /* [0 mib_name] mib */
207207
208208 if (devtab [i ].sysoid != NULL )
209209 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
210- "oid=\"%s\" " , devtab [i ].sysoid ); // [5 sysOID] sysoid/NULL
210+ "oid=\"%s\" " , devtab [i ].sysoid ); /* [5 sysOID] sysoid/NULL */
211211
212212 newdmf_len += snprintf (newdmf + newdmf_len , (newdmf_size - newdmf_len ),
213213 "/>\n" );
@@ -221,37 +221,37 @@ int main(int argc, char *argv[])
221221 mibdmf_parser_t * newdmp = mibdmf_parser_new ();
222222 if (!newdmp ) {
223223 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not allocate the DMF verification parsing structures\n\n" );
224- // TODO: Can we pass this code to fatalx?
224+ /* TODO: Can we pass this code to fatalx? */
225225 return ENOMEM ;
226226 }
227227
228228 upsdebugx (1 , "=== DMF-Reindex: Loading DMF structures from prepared string (verification)\n\n" );
229229 ret_code = mibdmf_parse_str (newdmf , newdmp );
230- // Error checking for one (just made) document makes sense and is definite
230+ /* Error checking for one (just made) document makes sense and is definite */
231231 if ( result != 0 ) {
232232 fatalx (EXIT_FAILURE , "=== DMF-Reindex: The generated document FAILED syntax verification (return code %d)\n\n" , ret_code );
233- // TODO: Can we pass this code to fatalx?
233+ /* TODO: Can we pass this code to fatalx? */
234234 return ret_code ;
235235 }
236236
237- // Loop through reparsed device_table and compare to original one
237+ /* Loop through reparsed device_table and compare to original one */
238238 upsdebugx (1 , "=== DMF-Reindex: Verify reparsed content for snmp_device_table[]...\n\n" );
239239 snmp_device_id_t * newdevtab = mibdmf_get_device_table (newdmp );
240240 if (!newdevtab )
241241 {
242242 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: FATAL: Can not access the reparsed device_table\n" );
243- // TODO: Can we pass this code to fatalx?
243+ /* TODO: Can we pass this code to fatalx? */
244244 return ENOMEM ;
245245 }
246246
247247 size_t j = -1 , k = -1 ;
248248 result = 0 ;
249- // Make sure that all values we've considered are present in re-parse
249+ /* Make sure that all values we've considered are present in re-parse */
250250 for (k = 0 ; devtab [k ].oid != NULL || devtab [k ].mib != NULL || devtab [k ].sysoid != NULL ; k ++ )
251251 {
252252 int r = 0 ;
253253 for (j = 0 ; newdevtab [j ].oid != NULL || newdevtab [j ].mib != NULL || newdevtab [j ].sysoid != NULL ; j ++ )
254- { // Note: OID attribute may be empty or NULL, these are assumed equal
254+ { /* Note: OID attribute may be empty or NULL, these are assumed equal */
255255 if ( (dmf_streq (newdevtab [j ].oid , devtab [k ].oid )
256256 || dmf_streq (newdevtab [j ].oid , "" )
257257 || dmf_streq (newdevtab [j ].oid , NULL ) )
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
287287 if ( result != 0 )
288288 {
289289 fatalx (EXIT_FAILURE ,"=== DMF-Reindex: The generated document FAILED content verification (%d issues)\n\n" , result );
290- // TODO: Can we pass this code to fatalx?
290+ /* TODO: Can we pass this code to fatalx? */
291291 return result ;
292292 }
293293
0 commit comments