scan.h 2.69 KB
Newer Older
Richard Stallman committed
1
/* scan.h - Utility declarations for scan-decls and fix-header programs.
Kaveh Ghazi committed
2
   Copyright (C) 1993, 1998, 1999 Free Software Foundation, Inc.
Per Bothner committed
3 4 5 6 7 8 9 10 11 12 13 14 15

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Richard Kenner committed
16
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
Per Bothner committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

#include <stdio.h>

typedef struct sstring
{
  char *base;
  char *ptr;
  char *limit;
} sstring;

#define INIT_SSTRING(STR) ((STR)->base = 0, (STR)->ptr = 0, (STR)->limit = 0)
#define FREE_SSTRING(STR) do { if ((STR)->base) free (STR)->base; } while(0)
#define SSTRING_PUT(STR, C) do {\
  if ((STR)->limit <= (STR)->ptr) make_sstring_space (STR, 1); \
  *(STR)->ptr++ = (C); } while (0)
#define SSTRING_LENGTH(STR) ((STR)->ptr - (STR)->base)
#define MAKE_SSTRING_SPACE(STR, COUNT) \
  if ((STR)->limit - (STR)->ptr < (COUNT)) make_sstring_space (STR, COUNT);

#ifndef _PARAMS
37
#if defined(ANSI_PROTOTYPES) || defined(__cplusplus)
Per Bothner committed
38 39 40 41 42 43 44 45 46
#define _PARAMS(args) args
#else
#define _PARAMS(args) ()
#endif
#endif

struct partial_proto;
struct fn_decl
{
47 48 49
  const char *fname;
  const char *rtype;
  const char *params;
Per Bothner committed
50 51 52
  struct partial_proto *partial;
};

Zack Weinberg committed
53 54
struct cpp_token;

Per Bothner committed
55
extern int lineno;
Mike Stump committed
56 57 58
extern void sstring_append _PARAMS((sstring *, sstring *));
extern void make_sstring_space _PARAMS((sstring *, int));
extern int skip_spaces _PARAMS((FILE *, int));
Per Bothner committed
59
extern int scan_ident _PARAMS((FILE *, sstring *, int));
Mike Stump committed
60 61 62
extern int scan_string _PARAMS((FILE *, sstring *, int));
extern int read_upto _PARAMS((FILE *, sstring *, int));
extern unsigned long hash _PARAMS((const char *));
Neil Booth committed
63
extern void recognized_function _PARAMS((const struct cpp_token *,
64
					 unsigned int, int, int));
Zack Weinberg committed
65
extern void recognized_extern _PARAMS((const struct cpp_token *));
66
extern unsigned int hashstr _PARAMS((const char *, unsigned int));
Per Bothner committed
67

68 69 70
struct cpp_reader;
extern int scan_decls _PARAMS((struct cpp_reader *, int, char **));

Per Bothner committed
71 72 73 74 75
/* get_token is a simple C lexer. */
#define IDENTIFIER_TOKEN 300
#define CHAR_TOKEN 301
#define STRING_TOKEN 302
#define INT_TOKEN 303
Mike Stump committed
76
extern int get_token _PARAMS ((FILE *, sstring *));
Per Bothner committed
77 78 79 80 81 82

/* Current file and line numer, taking #-directives into account */
extern int source_lineno;
extern sstring source_filename;
/* Current physical line number */
extern int lineno;