diff options
Diffstat (limited to 'src/pj_gc_reader.c')
| -rw-r--r-- | src/pj_gc_reader.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/pj_gc_reader.c b/src/pj_gc_reader.c index ef9479ff..e22aa993 100644 --- a/src/pj_gc_reader.c +++ b/src/pj_gc_reader.c @@ -33,7 +33,7 @@ #include <string.h> static int pj_gc_readentry( projCtx ctx, FILE *fp, PJ_GridCatalogEntry *entry ); - +static void pj_gc_sortcatalog( projCtx ctx, PJ_GridCatalog *catalog ); /************************************************************************/ /* pj_gc_readcatalog() */ @@ -46,11 +46,15 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) FILE *fp; PJ_GridCatalog *catalog; int entry_max, err; + char line[302]; fp = pj_open_lib( ctx, (char *) catalog_name, "r" ); if (fp == NULL) return NULL; - + + /* discard title line */ + fgets(line, sizeof(line)-1, fp); + catalog = (PJ_GridCatalog *) calloc(1,sizeof(PJ_GridCatalog)); if( !catalog ) return NULL; @@ -77,9 +81,22 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) } } + pj_gc_sortcatalog( ctx, catalog ); + return catalog; } +/************************************************************************/ +/* pj_gc_sortcatalog() */ +/* */ +/* Sort all the entries in ascending date and within a date in */ +/* descending priority order. */ +/************************************************************************/ + +static void pj_gc_sortcatalog( projCtx ctx, PJ_GridCatalog *catalog ) + +{ +} /************************************************************************/ /* pj_gc_read_csv_line() */ @@ -105,7 +122,7 @@ static int pj_gc_read_csv_line( projCtx ctx, FILE *fp, if( next[0] == '#' || next[0] == '\0' ) continue; - while( token_count < max_tokens && next != '\0' ) + while( token_count < max_tokens && *next != '\0' ) { const char *start = next; @@ -176,7 +193,8 @@ static int pj_gc_readentry( projCtx ctx, FILE *fp, PJ_GridCatalogEntry *entry ) if( token_count < 5 ) { error = 1; /* TODO: need real error codes */ - pj_log( ctx, PJ_LOG_ERROR, "Short line in grid catalog." ); + if( token_count != 0 ) + pj_log( ctx, PJ_LOG_ERROR, "Short line in grid catalog." ); } else { |
