/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1986-2009 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* preprocessor library private definitions
*/
#ifndef _PPLIB_H
#define _PPLIB_H
/*
* the first definitions control optional code -- 0 disables
*/
#ifndef ARCHIVE
#endif
#ifndef CATSTRINGS
#endif
#ifndef CHECKPOINT
#endif
#ifndef COMPATIBLE
#endif
#ifndef MACKEYARGS
#endif
#ifndef POOL
#endif
#ifndef PROTOTYPE
#endif
#if _BLD_DEBUG
#else
#ifndef DEBUG
#endif
#endif
/*
* the lower tests are transient
*/
struct ppsymbol;
struct ppindex;
typedef char* (*PPBUILTIN)(char*, const char*, const char*);
typedef void (*PPCOMMENT)(const char*, const char*, const char*, int);
typedef void (*PPINCREF)(const char*, const char*, int, int);
typedef void (*PPLINESYNC)(int, const char*);
typedef int (*PPOPTARG)(int, int, const char*);
typedef void (*PPPRAGMA)(const char*, const char*, const char*, const char*, int);
{
#if CHECKPOINT
#endif
};
#if MACKEYARGS
{
};
#endif
{
};
{
};
{
};
{
};
{
};
{
};
{
};
{
};
{
};
#define SAMEID(a,b) ((a)->st_ino==(unsigned long)(b)->st_ino&&(a)->st_dev==(unsigned long)(b)->st_dev)
long state; /* pp state flags */ \
long mode; /* uncoupled pp state flags */ \
long option; /* option flags */ \
long test; /* implementation tests */ \
struct \
{ \
long flags; /* PP_FILEDEPS flags */ \
} filedeps; /* FILEDEPS info */ \
int hide; /* current include hide index */ \
int column; /* FILEDEPS column */ \
int pending; /* ppline() pending output */ \
char* firstfile; /* ppline() first file */ \
char* lastfile; /* ppline() most recent file */ \
char* ignore; /* include ignore list file */ \
char* probe; /* ppdefault probe key */ \
char* date; /* start date string */ \
char* time; /* start time string */ \
char* maps; /* directive maps */ \
long ro_state; /* readonly state */ \
long ro_mode; /* readonly mode */ \
long ro_option; /* readonly option */ \
char* ppdefault; /* arg default info file */ \
unsigned char arg_file; /* arg file index */ \
unsigned char arg_mode; /* arg mode */ \
unsigned char arg_style; /* arg style */ \
unsigned char c; /* arg C state */ \
unsigned char hosted; /* arg hosted state */ \
unsigned char ignoresrc; /* arg ignore source state */ \
unsigned char initialized; /* arg initialized state */ \
unsigned char standalone; /* arg standalone state */ \
unsigned char spare_1; /* padding spare */
char* checkpoint; /* checkpoint version */ \
char* addp; /* addbuf pointer */ \
char* args; /* predicate args */ \
char* addbuf; /* ADD buffer */ \
char* catbuf; /* catenation buffer */ \
char* hdrbuf; /* HEADEREXPAND buffer */ \
char* hidebuf; /* pp:hide buffer */ \
char* path; /* full path of last #include */ \
char* tmpbuf; /* very temporary buffer */ \
char* valbuf; /* builtin macro value buffer */ \
char* optflags; /* OPT_* flags indexed by X_* */ \
int lastout; /* last output char */ \
/* the rest are implicitly initialized */ \
char* include; /* saved path of last #include */ \
char* prefix; /* current directory prefix */ \
int hidden; /* hidden newline count */ \
int hiding; /* number of symbols in hiding */ \
int level; /* pplex() recursion level */ \
struct \
{ \
int input; /* pool input */ \
int output; /* pool output */ \
} pool; /* loop on input,output,error */ \
struct \
{ \
long ro_state; /* original pp.ro_state */ \
long ro_mode; /* original pp.ro_mode */ \
long ro_option; /* original pp.ro_option */ \
int on; /* PP_RESET enabled */ \
} reset; /* PP_RESET state */ \
int truncate; /* identifier truncation length */ \
char* maxmac; /* maximum size of macro stack */ \
char* mactop; /* top of current macro frame */ \
long* control; /* control block flags pointer */ \
long* maxcon; /* max control block frame */ \
int vendor; /* vendor includes only */ \
PPPRAGMA pragma; /* pass along unknown pragmas */ \
#if MACKEYARGS
union \
{ \
char* formal; /* normal formals list */ \
} args; /* macro args info */ \
int size; /* body size */
#else
char* formals; /* formal argument list */ \
int size; /* body size */
#endif
unsigned char c; /* files here are C language */ \
unsigned char index; /* prefix,local,standard index */ \
unsigned char type; /* dir type */ \
union \
{ \
char* buffer; /* TYPE_BUFFER buffer */ \
} info; /* type info */ \
#if !PROTOMAIN
#include <ast.h>
#include <error.h>
#endif
#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
#include "pp.h"
#include "ppdef.h"
#include "ppkey.h"
/*
* DEBUG is encoded with the following bits
*/
#else
#endif
#if DEBUG & TRACE_count
#else
#define count(x)
#endif
#if DEBUG & TRACE_message
#else
#define message(x)
#endif
#if DEBUG & TRACE_debug
#else
#define debug(x)
#endif
/*
* note that MEMCPY advances the associated pointers
*/
do switch(n) \
case 0 : break; \
} while (0)
#define ppsetfile(x) ((struct ppfile*)hashlook(pp.filtab,x,HASH_CREATE|HASH_SIZE(sizeof(struct ppfile)),NiL))
#define ppkeyset(t,n) (struct ppsymkey*)hashlook(t,n,HASH_CREATE|HASH_SIZE(sizeof(struct ppsymkey)),NiL)
#define STRAPP(p,v,r) do{r=(v);while((*p++)=(*r++));}while(0)
#define STRCOPY(p,v,r) do{r=(v);while((*p++)=(*r++));p--;}while(0)
#define STRCOPY2(p,r) do{while((*p++)=(*r++));p--;}while(0)
#define INC_PREFIX 0
#define PUSH(t,p) \
do \
{ \
{ \
} \
p->type = t; \
p->flags = 0; \
} while (0)
#define PUSH_BUFFER(f,p,n) \
#define PUSH_COPY(p,n) \
do \
{ \
error_info.line = n; \
} while (0)
#define PUSH_EXPAND(p,n) \
do \
{ \
error_info.line = n; \
} while (0)
#define PUSH_FILE(f,d) \
#define PUSH_INIT(f,p) \
#define PUSH_MACRO(p) \
do \
{ \
p->flags |= SYM_DISABLED; \
} while (0)
#define PUSH_TUPLE(p,v) \
do \
{ \
p->flags |= SYM_DISABLED; \
} while (0)
#define PUSH_MULTILINE(p) \
do \
{ \
register int n; \
pushcontrol(); \
} while (0)
#define PUSH_QUOTE(p,n) \
do \
{ \
error_info.line = n; \
} while (0)
#define PUSH_RESCAN(p) \
#define PUSH_SQUOTE(p,n) \
do \
{ \
error_info.line = n; \
} while (0)
#define PUSH_STRING(p) \
do \
{ \
} while (0)
#define PUSH_LINE(p) \
do \
{ \
} while (0)
#define POP_LINE() \
do \
{ \
} while (0)
{
};
{
};
#if CHECKPOINT
{
};
#endif
{
};
#if PROTOMAIN && PROTO_STANDALONE
#define NiL 0
#else
#define NiL ((char*)0)
#define NoP(x)
#endif
#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
#define _PP_DELAY_ #
_PP_DELAY_ ifdef __STDC__
_PP_DELAY_ include <stdlib.h>
_PP_DELAY_ include <unistd.h>
_PP_DELAY_ include <time.h>
_PP_DELAY_ include <string.h>
_PP_DELAY_ else
_PP_DELAY_ define size_t int
extern void free(void*);
_PP_DELAY_ ifndef O_RDONLY
extern int access(const char*, int);
extern int close(int);
extern int creat(const char*, int);
extern void exit(int);
extern int link(const char*, const char*);
extern int open(const char*, int, ...);
extern int read(int, void*, int);
extern int unlink(const char*);
extern int write(int, const void*, int);
_PP_DELAY_ endif
_PP_DELAY_ endif
#else
/*
* library implementation globals
*/
#define ppassert _pp_assert
#define ppbuiltin _pp_builtin
#define ppcontrol _pp_control
#define ppexpand _pp_expand
#define ppkeyname _pp_keyname
#define pplexmap _pp_lexmap
#define pplexstr _pp_lexstr
#define ppmodestr _pp_modestr
#define ppmultiple _pp_multiple
#define ppoption _pp_option
#define ppoptionstr _pp_optionstr
#define pppclose _pp_pclose
#define pppredargs _pp_predargs
#define pprefmac _pp_refmac
#define ppsearch _pp_search
#define ppstatestr _pp_statestr
#define pptokstr _pp_tokstr
#endif
extern void ppassert(int, char*, char*);
extern void ppbuiltin(void);
extern int ppcontrol(void);
extern void ppdump(void);
extern char* ppexpand(char*);
extern long ppexpr(int*);
extern void ppfsm(int, char*);
extern char* ppkeyname(int, int);
extern char* pplexstr(int);
extern void ppload(char*);
extern void ppmapinclude(char*, char*);
extern char* ppmodestr(long);
extern void ppnest(void);
extern int ppoption(char*);
extern char* ppoptionstr(long);
extern void pppclose(char*);
extern int pppdrop(char*);
extern char* pppopen(char*, int, char*, char*, char*, char*, int);
extern int pppread(char*);
extern int pppredargs(void);
extern void pppush(int, char*, char*, int);
extern int ppsearch(char*, int, int);
extern char* ppstatestr(long);
extern char* pptokstr(char*, int);
extern void pptrace(int);
#if _std_malloc
#include <vmalloc.h>
#endif
#endif