Changeset 29 for trunk/ruleset.c


Ignore:
Timestamp:
Aug 20, 2008, 12:20:41 PM (6 years ago)
Author:
marius
Message:

cosmetic changes in ruleset.c and make testRuleset working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ruleset.c

    r17 r29  
    1818 */ 
    1919#include <glib.h> 
     20#include <glib/gstdio.h> 
    2021#include <time.h> 
    2122#include <expat.h> 
     
    234235 
    235236    // Local Vars 
     237    GTimer *tOsmRead = g_timer_new(); 
     238    unsigned int size; 
     239    unsigned int read = 0; 
     240    struct stat filestat; 
    236241    int         len; 
    237242    int         done; 
     
    243248        ruleStack[len] = NULL; 
    244249    } 
     250     
     251    // Test file 
     252    if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { 
     253        fprintf(stderr,"Error: \"%s\" is not a file.\n",filename); 
     254        return NULL; 
     255    } 
     256     
     257    g_stat(filename, &filestat); 
     258    size = (int) filestat.st_size; 
    245259 
    246260    // Open file 
     
    257271 
    258272    if (opts->debug > 0) { 
    259         fprintf(stdout," Ruleset parsing"); 
     273        fprintf(stdout," Ruleset parsing   0%%"); 
    260274        fflush(stdout); 
    261275    } 
    262  
    263     long start = (long)clock(); 
    264276 
    265277    // Create XML Parser 
     
    279291            return NULL;; 
    280292        } 
     293        read += len; 
     294        if (opts->debug > 0) { 
     295            fprintf(stdout,"\r Ruleset parsing % 3i%%", (int)((read*100)/size)); 
     296            fflush(stdout); 
     297        } 
    281298        done = len < sizeof(buf); 
    282299        if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { 
     
    294311 
    295312    if (opts->debug > 0) 
    296         fprintf(stdout," done. (%i/%i) [%fs]\n", 
    297                 ruleset->cntRule, ruleset->cntElse, 
    298                 ((long)clock()-start)/(double)CLOCKS_PER_SEC); 
     313        fprintf(stdout,"\r Ruleset parsing done. (%i/%i) [%fs]\n", 
     314                ruleset->cntRule,  ruleset->cntElse, 
     315                g_timer_elapsed(tOsmRead,NULL)); 
    299316 
    300317    return(ruleset); 
Note: See TracChangeset for help on using the changeset viewer.