Changeset 3446
- Timestamp:
- 08/08/07 16:55:33 (1 year ago)
- Files:
-
- branches/common-nfo/tools/nfotiser/parser.c (modified) (2 diffs)
- branches/common-nfo/tools/sqlite/dbif.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/common-nfo/tools/nfotiser/parser.c
r3444 r3446 31 31 32 32 #include <sys/param.h> 33 #include <sys/mman.h> 34 #include <sys/stat.h> 33 35 34 36 #include <err.h> … … 41 43 42 44 #include "nfotiser.h" 45 46 struct parser_result * 47 nfo_parse(int fd, const struct parser_keywords *kws) 48 { 49 struct parser_result *res; 50 struct parser_res *entry; 51 char ch, *cp, *t, *buf; 52 size_t len, n; 53 struct stat sb; 54 55 res = xmalloc(sizeof (struct parser_result)); 56 CIRCLEQ_INIT(res); 57 58 if (fstat(fd, &sb)) 59 err(255, "cannot stat"); 60 61 buf = mmap(NULL, (len = sb.st_size), PROT_READ, MAP_FILE, fd, 0); 62 if (buf == MAP_FAILED) 63 err(255, "cannot mmap %zu bytes", len); 64 branches/common-nfo/tools/sqlite/dbif.h
r3441 r3446 50 50 } while (0) 51 51 52 __BEGIN_DECLS 52 53 EXTERN int debug I__(0); 53 54 EXTERN sqlite3 *db I__(NULL); … … 79 80 #endif 80 81 #endif 82 __END_DECLS 83 84 /* useful stuff */ 85 #define xmalloc(size) ({ \ 86 void *xmalloc_ptr; \ 87 size_t xmalloc_sz = (size); \ 88 \ 89 if ((xmalloc_ptr = malloc(xmalloc_sz)) == NULL) \ 90 err(255, "cannot allocate %zu bytes", \ 91 xmalloc_sz); \ 92 (xmalloc_ptr); \ 93 }) 81 94 82 95 #endif


