English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/common-nfo/tools/nfotiser/pfile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3456 by tg, Wed Aug 8 14:32:17 2007 UTC revision 3457 by tg, Thu Aug 9 13:40:07 2007 UTC
# Line 33  Line 33 
33    
34  #include <err.h>  #include <err.h>
35  #include <errno.h>  #include <errno.h>
36    #include <fcntl.h>
37  #include <stdint.h>  #include <stdint.h>
38  #include <stdio.h>  #include <stdio.h>
39  #include <stdlib.h>  #include <stdlib.h>
# Line 115  static const struct parser_keywords kwor Line 116  static const struct parser_keywords kwor
116          { "VERSION", K_VERSION, KWT_NORMAL, ARGT_STRING },          { "VERSION", K_VERSION, KWT_NORMAL, ARGT_STRING },
117          { NULL, 0, 0, 0 }          { NULL, 0, 0, 0 }
118  };  };
119    
120    void
121    pfile(const char *fn)
122    {
123            struct parser_result *parsed;
124            struct parser_res *entry;
125            int fd;
126            size_t nument;
127    
128            if ((fd = open(fn, O_RDONLY)) < 0)
129                    err(255, "cannot open input file '%s'", fn);
130            printf("parsing %s…", fn);
131            parsed = nfo_parse(fd, kwords);
132            close(fd);
133            if (CIRCLEQ_EMPTY(parsed))
134                    errx(1, "error, no entries in the file!");
135            nument = 0;
136            CIRCLEQ_FOREACH(entry, parsed, e)
137                    ++nument;
138            printf("ok, %zu entries\n", nument);
139    
140            /* do something with ‘parsed’ */
141            nument = 0;
142            CIRCLEQ_FOREACH(entry, parsed, e) {
143                    printf("entry #%03zu: ", nument++);
144                    parser_dump(entry, kwords);
145            }
146    
147            parser_free(parsed);
148    }

Legend:
Removed from v.3456  
changed lines
  Added in v.3457

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20