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