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

SCM Repository

ViewVC logotype

Contents of /branches/common-nfo/tools/nfotiser/parser.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3446 - (show annotations) (download)
Wed Aug 8 14:55:33 2007 UTC (6 years, 6 months ago) by tg
File MIME type: text/plain
File size: 2209 byte(s)
more, but I'm hungry now and unable to concentrate

1 /* $FreeWRT: src/share/misc/licence.template,v 1.20 2006/12/11 21:04:56 tg Rel $ */
2
3 /*-
4 * Copyright (c) 2007
5 * Thorsten Glaser <tg@mirbsd.de>
6 *
7 * Provided that these terms and disclaimer and all copyright notices
8 * are retained or reproduced in an accompanying document, permission
9 * is granted to deal in this work without restriction, including un-
10 * limited rights to use, publicly perform, distribute, sell, modify,
11 * merge, give away, or sublicence.
12 *
13 * Advertising materials mentioning features or use of this work must
14 * display the following acknowledgement:
15 * This product includes material provided by Thorsten Glaser.
16 * This acknowledgement does not need to be reprinted if this work is
17 * linked into a bigger work whose licence does not allow such clause
18 * and the author of this work is given due credit in the bigger work
19 * or its accompanying documents, where such information is generally
20 * kept, provided that said credits are retained.
21 *
22 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
23 * the utmost extent permitted by applicable law, neither express nor
24 * implied; without malicious intent or gross negligence. In no event
25 * may a licensor, author or contributor be held liable for indirect,
26 * direct, other damage, loss, or other issues arising in any way out
27 * of dealing in the work, even if advised of the possibility of such
28 * damage or existence of a defect, except proven that it results out
29 * of said person's immediate fault when using the work as intended.
30 */
31
32 #include <sys/param.h>
33 #include <sys/mman.h>
34 #include <sys/stat.h>
35
36 #include <err.h>
37 #include <errno.h>
38 #include <stdint.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <unistd.h>
43
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

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