File: rtest2.cc

package info (click to toggle)
word2x 1.5-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 228 kB
  • ctags: 326
  • sloc: cpp: 3,076; ansic: 350; makefile: 64
file content (72 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* $Id: rtest2.cc,v 1.3 1997/03/21 20:39:36 dps Exp $ */
/* Reader test program */

#include <stdio.h>
#include <stdlib.h>
#include "interface.h"

/* Dummy to just read the files out */
void reader_test_raw(FILE *f)
{
    const char *s;
    const tok_seq::tok *d;
    tok_seq rd(f);
    static const char null[]={ '\0' };

    while ((d=rd.read_token())!=NULL)
    {

	printf((d->end==tok_seq::tok::TOK_START) ? "<" : "</");
	if (d->tok!=T_TABLE)
	{
	    s=(d->data.d==NULL) ? null : d->data.d;
	}

	switch(d->tok)
	{
	case T_TABLE:
	    printf("TABLE %d x %d>\n", d->data.table.cols, d->data.table.rows);
	    break;

	case T_PARAGRAPH:
	    printf("PARAGRAPH>%s\n\n", s);
	    break;

	case T_FIELD:
	    printf("FIELD>%s", s);
	    break;

	case T_ROW:
	    printf("ROW>%s\n", s);
	    break;

	case T_SPEC:
	    printf("SPEC>%s", s);
	    break;

	case T_DOC:
	    printf("DOCUMENT>%s", s);
	    break;

	default:
	    printf("?>%s\n",  s);
	}
    }
}


int main(int argc, const char **argv)
{
    FILE *f;

    argc=argc;
    f=fopen(argv[1],"r");
    if (f==NULL)
    {
	fprintf(stderr,"%s not found\n", argv[1]);
	exit(1);
    }
    reader_test_raw(f);
    return 0;
}