return;
}
- if( (fbuf = uta_fib( fname ) ) == NULL ) { // read file into a single buffer
- fprintf( stderr, "[WRN] seed route table could not be opened: %s: %s\n", fname, strerror( errno ) );
+ if( (fbuf = uta_fib( fname ) ) == NULL ) { // read file into a single buffer (nil terminated string)
+ fprintf( stderr, "[WRN] rmr read_static: seed route table could not be opened: %s: %s\n", fname, strerror( errno ) );
return;
}
- if( DEBUG ) fprintf( stderr, "[INFO] seed route table successfully opened: %s\n", fname );
+ if( DEBUG ) fprintf( stderr, "[DBUG] rmr: seed route table successfully opened: %s\n", fname );
+ for( eor = fbuf; *eor; eor++ ) { // fix broken systems that use \r or \r\n to terminate records
+ if( *eor == '\r' ) {
+ *eor = '\n'; // will look like a blank line which is ok
+ }
+ }
+
for( rec = fbuf; rec && *rec; rec = eor+1 ) {
rcount++;
if( (eor = strchr( rec, '\n' )) != NULL ) {
*eor = 0;
+ } else {
+ fprintf( stderr, "[WARN] rmr read_static: seed route table had malformed records (missing newline): %s\n", fname );
+ fprintf( stderr, "[WARN] rmr read_static: seed route table not used%s\n", fname );
+ free( fbuf );
+ return;
}
parse_rt_rec( ctx, rec, vlevel );
}
- if( DEBUG ) fprintf( stderr, "[INFO] seed route table successfully parsed: %d records\n", rcount );
+ if( DEBUG ) fprintf( stderr, "[DBUG] rmr: seed route table successfully parsed: %d records\n", rcount );
free( fbuf );
}
char* rt_stuff; // strings for the route table
rt_stuff =
+ "\r" // ensure we are not screwed by broken OSes that insist on using \r
"newrt|end\n" // end of table check before start of table found
"# comment to drive full comment test\n"
"\n" // handle blank lines