xref: /openbsd/usr.bin/lex/tables.h (revision 73471bf0)
1 /* $OpenBSD: tables.h,v 1.2 2015/11/19 22:16:43 tedu Exp $ */
2 
3 /*  tables.h - tables serialization code
4  *
5  *  Copyright (c) 1990 The Regents of the University of California.
6  *  All rights reserved.
7  *
8  *  This code is derived from software contributed to Berkeley by
9  *  Vern Paxson.
10  *
11  *  The United States Government has rights in this work pursuant
12  *  to contract no. DE-AC03-76SF00098 between the United States
13  *  Department of Energy and the University of California.
14  *
15  *  This file is part of flex.
16  *
17  *  Redistribution and use in source and binary forms, with or without
18  *  modification, are permitted provided that the following conditions
19  *  are met:
20  *
21  *  1. Redistributions of source code must retain the above copyright
22  *     notice, this list of conditions and the following disclaimer.
23  *  2. Redistributions in binary form must reproduce the above copyright
24  *     notice, this list of conditions and the following disclaimer in the
25  *     documentation and/or other materials provided with the distribution.
26  *
27  *  Neither the name of the University nor the names of its contributors
28  *  may be used to endorse or promote products derived from this software
29  *  without specific prior written permission.
30  *
31  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
32  *  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
33  *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34  *  PURPOSE.
35  */
36 
37 #ifndef TABLES_H
38 #define TABLES_H
39 
40 #ifdef __cplusplus
41 /* *INDENT-OFF* */
42 extern  "C" {
43 /* *INDENT-ON* */
44 #endif
45 
46 /* Tables serialization API declarations. */
47 #include "tables_shared.h"
48 struct yytbl_writer {
49 	FILE   *out;
50 	flex_uint32_t total_written;
51 			    /**< bytes written so far */
52 	fpos_t  th_ssize_pos;
53 			    /**< position of th_ssize */
54 };
55 
56 /* These are used by main.c, gen.c, etc.
57  * tablesext - if true, create external tables
58  * tablesfilename - filename for external tables
59  * tablesname - name that goes in serialized data, e.g., "yytables"
60  * tableswr -  writer for external tables
61  * tablesverify - true if tables-verify option specified
62  * gentables - true if we should spit out the normal C tables
63  */
64 extern bool tablesext, tablesverify,gentables;
65 extern char *tablesfilename, *tablesname;
66 extern struct yytbl_writer tableswr;
67 
68 int     yytbl_writer_init (struct yytbl_writer *, FILE *);
69 int     yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
70 			const char *name);
71 int     yytbl_data_init (struct yytbl_data *tbl, enum yytbl_id id);
72 int     yytbl_data_destroy (struct yytbl_data *td);
73 int     yytbl_hdr_fwrite (struct yytbl_writer *wr,
74 			  const struct yytbl_hdr *th);
75 int     yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td);
76 void    yytbl_data_compress (struct yytbl_data *tbl);
77 struct yytbl_data *mkftbl (void);
78 
79 
80 #ifdef __cplusplus
81 /* *INDENT-OFF* */
82 }
83 /* *INDENT-ON* */
84 #endif
85 #endif
86