jcs's openbsd hax
openbsd
1#ifndef LOWPARSE_H
2#define LOWPARSE_H
3
4/* $OpenBSD: lowparse.h,v 1.11 2012/10/02 10:29:31 espie Exp $ */
5
6/*
7 * Copyright (c) 1999 Marc Espie.
8 *
9 * Extensive code changes for the OpenBSD project.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
24 * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32/* low-level parsing module:
33 * select input stream to parse, and do high-speed processing of
34 * lines: skipping comments, handling continuation lines, or skipping
35 * over dead conditionals.
36 *
37 * Basic template:
38 *
39 * Parse_Fromxxx(source);
40 * do {
41 * while ((line = Parse_ReadNormalLine(&buf)) != NULL) {
42 * handle line, use Parse_Fromxxx to push includes,
43 * Parse_ReadNextConditional to get over non-conditional lines.
44 * or Parse_ReadUnparsedLine to handle special cases manually.
45 * }
46 * } while (Parse_NextFile());
47 */
48
49/* Selection of input stream */
50/* Parse_FromFile(filename, filehandle);
51 * Push given filehandle on the input stack, using filename for diagnostic
52 * messages. The module assumes ownership of the filehandle and of
53 * the filename: provide copies if necessary. */
54extern void Parse_FromFile(const char *, FILE *);
55/* Parse_FromString(str, lineno);
56 * Push expanded string str on the input stack, assuming it starts at
57 * lineno in the current file. This is used to reparse .for loops
58 * after the variable has been expanded, hence no need to respecify
59 * the filename. The module assumes ownership of the string: provide a
60 * copy if necessary. */
61extern void Parse_FromString(char *, unsigned long);
62
63/* Error reporting, and tagging of read structures. */
64/* lineno = Parse_Getlineno();
65 * Returns the current lineno. */
66extern unsigned long Parse_Getlineno(void);
67/* name = Parse_Getfilename();
68 * Returns the current filename. Safe to keep without copying. */
69extern const char *Parse_Getfilename(void);
70
71/* Parse_FillLocation(origin)
72 * Fill the location pointed by origin with the current location. */
73extern void Parse_FillLocation(Location *);
74
75/* Parse_SetLocation(origin)
76 * Set the "parse location" to a given origin.
77 * Used for parse errors that occur during variable expansion at
78 * runtime.
79 */
80extern void Parse_SetLocation(Location *);
81
82/* continue = Parse_NextFile();
83 * Advance parsing to the next file in the input stack. Returns true
84 * if there is parsing left to do.
85 */
86extern bool Parse_NextFile(void);
87
88
89/* line = Parse_ReadNormalLine(buf);
90 * Reads next line into buffer and return its contents. Handles line
91 * continuation, remove extra blanks, and skip trivial comments. tabs at
92 * beginning of line are left alone, to be able to recognize target
93 * lines. */
94extern char *Parse_ReadNormalLine(Buffer);
95
96/* line = ParseReadNextConditionalLine(buf);
97 * Returns next conditional line, skipping over everything else. */
98extern char *Parse_ReadNextConditionalLine(Buffer);
99/* line = ParseReadUnparsedLine(buf, type);
100 * Reads line without parsing anything beyond continuations.
101 * Handle special cases such as conditional lines, or lines that
102 * need a reparse (loops). */
103extern char *Parse_ReadUnparsedLine(Buffer, const char *);
104/* Parse_ReportErrors();
105 * At end of parsing, report on fatal errors.
106 */
107extern void Parse_ReportErrors(void);
108
109extern void Parse_setcurdir(const char *);
110#endif