equal
deleted
inserted
replaced
|
1 /* |
|
2 * $Id: tokenizer.c 94 2008-04-05 01:27:30Z mbroeker $ |
|
3 * $URL: http://localhost/svn/c/lsflib/trunk/src/tokenizer.c $ |
|
4 * |
|
5 */ |
|
6 |
|
7 #include <stdio.h> |
|
8 #include <stdlib.h> |
|
9 #include <unistd.h> |
|
10 #include <sys/types.h> |
|
11 #include <sys/stat.h> |
|
12 #include <fcntl.h> |
|
13 #include <ctype.h> |
|
14 #include <string.h> |
|
15 |
|
16 #include <lsf.h> |
|
17 |
|
18 Node *tokenizer (FILE * f, const char *delim) |
|
19 { |
|
20 |
|
21 /* |
|
22 * the main routine of the tokenizer |
|
23 * |
|
24 */ |
|
25 |
|
26 Node *aktuell, *begin; |
|
27 |
|
28 char line[LINE_LENGTH]; |
|
29 char *token; |
|
30 int tokens; |
|
31 |
|
32 *line = tokens = 0; |
|
33 |
|
34 aktuell = begin = addnode (NULL, "NULL"); |
|
35 |
|
36 while ((fgets (line, LINE_LENGTH, f)) != NULL) { |
|
37 token = strtok (line, delim); |
|
38 while (token) { |
|
39 aktuell = addnode (aktuell, token); |
|
40 token = strtok (NULL, delim); |
|
41 } |
|
42 *line = 0; |
|
43 } |
|
44 |
|
45 rewind (f); |
|
46 |
|
47 aktuell = begin->next; |
|
48 free (begin->data); |
|
49 free (begin); |
|
50 |
|
51 return aktuell; |
|
52 } |