1 |
38 |
julius |
/* scan.h - Utility declarations for scan-decls and fix-header programs.
|
2 |
|
|
Copyright (C) 1993, 1998, 1999, 2003, 2004, 2007 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This program is free software; you can redistribute it and/or modify it
|
5 |
|
|
under the terms of the GNU General Public License as published by the
|
6 |
|
|
Free Software Foundation; either version 3, or (at your option) any
|
7 |
|
|
later version.
|
8 |
|
|
|
9 |
|
|
This program is distributed in the hope that it will be useful,
|
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
GNU General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU General Public License
|
15 |
|
|
along with this program; see the file COPYING3. If not see
|
16 |
|
|
<http://www.gnu.org/licenses/>. */
|
17 |
|
|
|
18 |
|
|
#include <stdio.h>
|
19 |
|
|
|
20 |
|
|
typedef struct sstring
|
21 |
|
|
{
|
22 |
|
|
char *base;
|
23 |
|
|
char *ptr;
|
24 |
|
|
char *limit;
|
25 |
|
|
} sstring;
|
26 |
|
|
|
27 |
|
|
#define INIT_SSTRING(STR) ((STR)->base = 0, (STR)->ptr = 0, (STR)->limit = 0)
|
28 |
|
|
#define FREE_SSTRING(STR) do { if ((STR)->base) free (STR)->base; } while(0)
|
29 |
|
|
#define SSTRING_PUT(STR, C) do {\
|
30 |
|
|
if ((STR)->limit <= (STR)->ptr) make_sstring_space (STR, 1); \
|
31 |
|
|
*(STR)->ptr++ = (C); } while (0)
|
32 |
|
|
#define SSTRING_LENGTH(STR) ((STR)->ptr - (STR)->base)
|
33 |
|
|
#define MAKE_SSTRING_SPACE(STR, COUNT) \
|
34 |
|
|
if ((STR)->limit - (STR)->ptr < (COUNT)) make_sstring_space (STR, COUNT);
|
35 |
|
|
|
36 |
|
|
struct partial_proto;
|
37 |
|
|
struct fn_decl
|
38 |
|
|
{
|
39 |
|
|
const char *fname;
|
40 |
|
|
const char *rtype;
|
41 |
|
|
const char *params;
|
42 |
|
|
struct partial_proto *partial;
|
43 |
|
|
};
|
44 |
|
|
|
45 |
|
|
struct cpp_token;
|
46 |
|
|
|
47 |
|
|
extern void sstring_append (sstring *, sstring *);
|
48 |
|
|
extern void make_sstring_space (sstring *, int);
|
49 |
|
|
extern int skip_spaces (FILE *, int);
|
50 |
|
|
extern int scan_ident (FILE *, sstring *, int);
|
51 |
|
|
extern int scan_string (FILE *, sstring *, int);
|
52 |
|
|
extern int read_upto (FILE *, sstring *, int);
|
53 |
|
|
extern unsigned long hash (const char *);
|
54 |
|
|
extern void recognized_function (const struct cpp_token *,
|
55 |
|
|
unsigned int, int, int);
|
56 |
|
|
extern void recognized_extern (const struct cpp_token *);
|
57 |
|
|
extern unsigned int hashstr (const char *, unsigned int);
|
58 |
|
|
|
59 |
|
|
extern int scan_decls (struct cpp_reader *, int, char **);
|
60 |
|
|
|
61 |
|
|
/* get_token is a simple C lexer. */
|
62 |
|
|
#define IDENTIFIER_TOKEN 300
|
63 |
|
|
#define CHAR_TOKEN 301
|
64 |
|
|
#define STRING_TOKEN 302
|
65 |
|
|
#define INT_TOKEN 303
|
66 |
|
|
extern int get_token (FILE *, sstring *);
|
67 |
|
|
|
68 |
|
|
/* Current file and line numer, taking #-directives into account */
|
69 |
|
|
extern int source_lineno;
|
70 |
|
|
extern sstring source_filename;
|
71 |
|
|
/* Current physical line number */
|
72 |
|
|
extern int lineno;
|
73 |
|
|
|
74 |
|
|
extern struct line_maps line_table;
|