From fe7ca4b1454e01a33ed0d53791ebffdd349298b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: [PATCH] r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace --- .bzrignore | 6 +- source/dsdb/samdb/ldb_modules/config.mk | 12 +- source/heimdal/lib/com_err/lex.c | 1353 ++++++++++------- source/heimdal/lib/hdb/hdb.c | 2 +- source/heimdal_build/config.h | 2 + source/lib/ldb/Makefile.in | 24 +- source/lib/ldb/autogen.sh | 2 + source/lib/ldb/config.mk | 30 +- source/lib/ldb/configure.in | 3 + source/lib/ldb/include/includes.h | 14 +- source/lib/ldb/replace/config.m4 | 12 - source/lib/ldb/replace/replace.c | 100 -- source/lib/replace/Makefile.in | 37 + source/lib/replace/README | 9 +- source/lib/replace/autogen.sh | 10 + source/lib/replace/config.m4 | 18 + source/lib/replace/config.mk | 1 + source/lib/replace/configure.ac | 52 + source/lib/replace/dlfcn.c | 31 +- source/lib/replace/getpass.c | 35 +- source/lib/replace/repdir/repdir.c | 28 +- source/lib/replace/replace.c | 200 ++- source/lib/replace/replace.h | 105 +- source/lib/replace/replace.m4 | 58 + source/lib/replace/snprintf.c | 6 +- source/lib/replace/test/testsuite.c | 366 +++++ source/lib/{ldb => }/replace/timegm.c | 0 source/lib/talloc/config.mk | 1 + .../lib/talloc/{configure.in => configure.ac} | 0 source/lib/tdb/Makefile.in | 23 +- source/lib/tdb/{configure.in => configure.ac} | 0 31 files changed, 1688 insertions(+), 852 deletions(-) delete mode 100644 source/lib/ldb/replace/config.m4 delete mode 100644 source/lib/ldb/replace/replace.c create mode 100644 source/lib/replace/Makefile.in create mode 100755 source/lib/replace/autogen.sh create mode 100644 source/lib/replace/configure.ac create mode 100644 source/lib/replace/replace.m4 create mode 100644 source/lib/replace/test/testsuite.c rename source/lib/{ldb => }/replace/timegm.c (100%) rename source/lib/talloc/{configure.in => configure.ac} (100%) rename source/lib/tdb/{configure.in => configure.ac} (100%) diff --git a/.bzrignore b/.bzrignore index 264467687b0..853d19c3a9c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,6 @@ +source/lib/ldb/bin +*.pc +autom4te.cache *.d *.o *.x @@ -42,7 +45,8 @@ source/heimdal/lib/krb5/k524_err.? source/heimdal/lib/krb5/krb5_err.? source/heimdal/lib/roken/vis.h source/include/build.h -source/include/config.h +config.h +config.h.in source/include/config_tmp.h source/include/config_tmp.h.in source/ldap_server/proto.h diff --git a/source/dsdb/samdb/ldb_modules/config.mk b/source/dsdb/samdb/ldb_modules/config.mk index 1e3b793629e..725d98ac7e7 100644 --- a/source/dsdb/samdb/ldb_modules/config.mk +++ b/source/dsdb/samdb/ldb_modules/config.mk @@ -2,6 +2,7 @@ # Start MODULE ldb_objectguid [MODULE::ldb_objectguid] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = objectguid_module_init OBJ_FILES = \ objectguid.o @@ -14,6 +15,7 @@ PUBLIC_DEPENDENCIES = \ # Start MODULE ldb_samldb [MODULE::ldb_samldb] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = samldb_module_init OBJ_FILES = \ samldb.o @@ -26,6 +28,7 @@ OBJ_FILES = \ [MODULE::ldb_samba3sam] SUBSYSTEM = ldb INIT_FUNCTION = ldb_samba3sam_module_init +PRIVATE_DEPENDENCIES = LIBTALLOC OBJ_FILES = \ samba3sam.o # @@ -37,6 +40,7 @@ OBJ_FILES = \ [MODULE::ldb_entryUUID] SUBSYSTEM = ldb INIT_FUNCTION = ldb_entryUUID_module_init +PRIVATE_DEPENDENCIES = LIBTALLOC ENABLE = YES OBJ_FILES = \ entryUUID.o @@ -60,6 +64,7 @@ OBJ_FILES = \ # Start MODULE ldb_rootdse [MODULE::ldb_rootdse] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = rootdse_module_init OBJ_FILES = \ rootdse.o @@ -74,7 +79,7 @@ SUBSYSTEM = ldb INIT_FUNCTION = password_hash_module_init OBJ_FILES = password_hash.o PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 -PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS +PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC # # End MODULE ldb_password_hash ################################################ @@ -82,6 +87,7 @@ PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS ################################################ # Start MODULE ldb_local_password [MODULE::ldb_local_password] +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb INIT_FUNCTION = local_password_module_init OBJ_FILES = local_password.o @@ -92,6 +98,7 @@ OBJ_FILES = local_password.o ################################################ # Start MODULE ldb_kludge_acl [MODULE::ldb_kludge_acl] +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb INIT_FUNCTION = ldb_kludge_acl_init OBJ_FILES = \ @@ -106,6 +113,7 @@ PUBLIC_DEPENDENCIES = \ # Start MODULE ldb_extended_dn [MODULE::ldb_extended_dn] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_extended_dn_init OBJ_FILES = \ extended_dn.o @@ -117,6 +125,7 @@ OBJ_FILES = \ # Start MODULE ldb_partition [MODULE::ldb_partition] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_partition_init OBJ_FILES = \ partition.o @@ -128,6 +137,7 @@ OBJ_FILES = \ # Start MODULE ldb_schema [MODULE::ldb_schema] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_schema_init OBJ_FILES = \ schema.o schema_syntax.o diff --git a/source/heimdal/lib/com_err/lex.c b/source/heimdal/lib/com_err/lex.c index 925615f244c..d5d6b20a8da 100644 --- a/source/heimdal/lib/com_err/lex.c +++ b/source/heimdal/lib/com_err/lex.c @@ -1,31 +1,92 @@ -/* A lexical scanner generated by flex */ -/* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ - */ +#line 3 "lex.yy.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 33 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ +/* begin standard C headers. */ #include -#include +#include +#include +#include +/* end standard C headers. */ -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 #endif +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ -#ifdef __cplusplus +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif -#include +#endif /* ! FLEXINT_H */ -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS +#ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST @@ -34,34 +95,17 @@ #if __STDC__ -#define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include -#include -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -76,71 +120,75 @@ * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define BEGIN yy_start = 1 + 2 * +#define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START ((yy_start - 1) / 2) +#define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) +#define YY_NEW_FILE yyrestart(yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ +#ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif extern int yyleng; + extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, yytext_ptr ) +#define unput(c) yyunput( c, (yytext_ptr) ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ -typedef unsigned int yy_size_t; +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; @@ -177,12 +225,16 @@ struct yy_buffer_state */ int yy_at_bol; + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; + #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process @@ -196,28 +248,38 @@ struct yy_buffer_state * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ -static YY_BUFFER_STATE yy_current_buffer = 0; +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". + * + * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER yy_current_buffer +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; - static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ +static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches @@ -225,66 +287,92 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart YY_PROTO(( FILE *input_file )); +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ typedef unsigned char YY_CHAR; + FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + typedef int yy_state_type; + +extern int yylineno; + +int yylineno = 1; + extern char *yytext; #define yytext_ptr yytext -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; + (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 16 #define YY_END_OF_BUFFER 17 -static yyconst short int yy_accept[46] = +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[46] = { 0, 0, 0, 17, 15, 11, 12, 13, 10, 9, 14, 14, 14, 14, 10, 9, 14, 3, 14, 14, 1, @@ -293,7 +381,7 @@ static yyconst short int yy_accept[46] = 14, 4, 14, 2, 0 } ; -static yyconst int yy_ec[256] = +static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -325,14 +413,14 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[23] = +static yyconst flex_int32_t yy_meta[23] = { 0, 1, 1, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 } ; -static yyconst short int yy_base[48] = +static yyconst flex_int16_t yy_base[48] = { 0, 0, 0, 56, 57, 57, 57, 57, 0, 49, 0, 12, 13, 34, 0, 47, 0, 0, 40, 31, 0, @@ -341,7 +429,7 @@ static yyconst short int yy_base[48] = 12, 0, 14, 0, 57, 34, 23 } ; -static yyconst short int yy_def[48] = +static yyconst flex_int16_t yy_def[48] = { 0, 45, 1, 45, 45, 45, 45, 45, 46, 47, 47, 47, 47, 47, 46, 47, 47, 47, 47, 47, 47, @@ -350,7 +438,7 @@ static yyconst short int yy_def[48] = 47, 47, 47, 47, 0, 45, 45 } ; -static yyconst short int yy_nxt[80] = +static yyconst flex_int16_t yy_nxt[80] = { 0, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 11, 10, 12, 10, 10, 10, 13, 10, @@ -362,7 +450,7 @@ static yyconst short int yy_nxt[80] = 45, 45, 45, 45, 45, 45, 45, 45, 45 } ; -static yyconst short int yy_chk[80] = +static yyconst flex_int16_t yy_chk[80] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -377,6 +465,9 @@ static yyconst short int yy_chk[80] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; +extern int yy_flex_debug; +int yy_flex_debug = 0; + /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -386,7 +477,6 @@ static char *yy_last_accepting_cpos; #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "lex.l" -#define INITIAL 0 #line 2 "lex.l" /* * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan @@ -442,7 +532,23 @@ static int getstring(void); #undef ECHO -#line 446 "lex.yy.c" +#line 536 "lex.yy.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -450,65 +556,30 @@ static int getstring(void); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); +extern "C" int yywrap (void ); #else -extern int yywrap YY_PROTO(( void )); -#endif +extern int yywrap (void ); #endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif + static void yyunput (int c,char *buf_ptr ); + #ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); +static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif +#ifdef __cplusplus +static int yyinput (void ); #else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 +static int input (void ); #endif -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif #endif /* Amount of stuff to slurp up with each read. */ @@ -517,7 +588,6 @@ YY_MALLOC_DECL #endif /* Copy whatever the last rule matched to the standard output. */ - #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). @@ -530,9 +600,10 @@ YY_MALLOC_DECL */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ - int c = '*', n; \ + int c = '*'; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -542,9 +613,22 @@ YY_MALLOC_DECL YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -565,12 +649,18 @@ YY_MALLOC_DECL #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif +/* end tables serialization structures and prototypes */ + /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. @@ -587,26 +677,28 @@ YY_MALLOC_DECL #define YY_RULE_SETUP \ YY_USER_ACTION +/** The main scanner function which does all the work. + */ YY_DECL - { +{ register yy_state_type yy_current_state; - register char *yy_cp = NULL, *yy_bp = NULL; + register char *yy_cp, *yy_bp; register int yy_act; - + #line 59 "lex.l" -#line 599 "lex.yy.c" +#line 691 "lex.yy.c" - if ( yy_init ) + if ( !(yy_init) ) { - yy_init = 0; + (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! yy_start ) - yy_start = 1; /* first start state */ + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = stdin; @@ -614,34 +706,36 @@ YY_DECL if ( ! yyout ) yyout = stdout; - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } - yy_load_buffer_state(); + yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { - yy_cp = yy_c_buf_p; + yy_cp = (yy_c_buf_p); /* Support of yytext. */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; - yy_current_state = yy_start; + yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -658,24 +752,22 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; - do_action: /* This label is used only to access EOF actions. */ - switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: @@ -734,6 +826,7 @@ YY_RULE_SETUP ; YY_BREAK case 12: +/* rule 12 can match eol */ YY_RULE_SETUP #line 71 "lex.l" { lineno++; } @@ -758,33 +851,33 @@ YY_RULE_SETUP #line 75 "lex.l" ECHO; YY_BREAK -#line 762 "lex.yy.c" +#line 855 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our + * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position @@ -794,13 +887,13 @@ case YY_STATE_EOF(INITIAL): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -813,30 +906,30 @@ case YY_STATE_EOF(INITIAL): yy_next_state = yy_try_NUL_trans( yy_current_state ); - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; + yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = yy_c_buf_p; + yy_cp = (yy_c_buf_p); goto yy_find_action; } } - else switch ( yy_get_next_buffer() ) + else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { - yy_did_buffer_switch_on_eof = 0; + (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap() ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -847,7 +940,7 @@ case YY_STATE_EOF(INITIAL): * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -855,30 +948,30 @@ case YY_STATE_EOF(INITIAL): else { - if ( ! yy_did_buffer_switch_on_eof ) + if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; @@ -889,8 +982,7 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ - } /* end of yylex */ - +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -899,21 +991,20 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); - if ( yy_current_buffer->yy_fill_buffer == 0 ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. @@ -933,34 +1024,30 @@ static int yy_get_next_buffer() /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); + (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { @@ -973,8 +1060,7 @@ static int yy_get_next_buffer() b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ @@ -984,35 +1070,35 @@ static int yy_get_next_buffer() YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = yy_current_buffer->yy_buf_size - + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; -#endif + } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); - yy_current_buffer->yy_n_chars = yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } - if ( yy_n_chars == 0 ) + if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); + yyrestart(yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } @@ -1020,32 +1106,31 @@ static int yy_get_next_buffer() else ret_val = EOB_ACT_CONTINUE_SCAN; - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; - } - +} /* yy_get_previous_state - get the state just before the EOB char was reached */ -static yy_state_type yy_get_previous_state() - { + static yy_state_type yy_get_previous_state (void) +{ register yy_state_type yy_current_state; register char *yy_cp; + + yy_current_state = (yy_start); - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1057,30 +1142,23 @@ static yy_state_type yy_get_previous_state() } return yy_current_state; - } - +} /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; + register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1092,81 +1170,73 @@ yy_state_type yy_current_state; yy_is_jam = (yy_current_state == 45); return yy_is_jam ? 0 : yy_current_state; - } - +} -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > yy_current_buffer->yy_ch_buf ) + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} #ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput() + static int yyinput (void) #else -static int input() + static int input (void) #endif - { - int c; - *yy_c_buf_p = yy_hold_char; +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ - *yy_c_buf_p = '\0'; + *(yy_c_buf_p) = '\0'; else { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); - switch ( yy_get_next_buffer() ) + switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -1180,16 +1250,16 @@ static int input() */ /* Reset buffer status. */ - yyrestart( yyin ); + yyrestart(yyin ); - /* fall through */ + /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap() ) + if ( yywrap( ) ) return EOF; - if ( ! yy_did_buffer_switch_on_eof ) + if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); @@ -1199,90 +1269,92 @@ static int input() } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; + (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); return c; - } -#endif /* YY_NO_INPUT */ - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); +} +#endif /* ifndef YY_NO_INPUT */ - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); } + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) return; - if ( yy_current_buffer ) + if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } - yy_current_buffer = new_buffer; - yy_load_buffer_state(); + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } + (yy_did_buffer_switch_on_eof) = 1; +} +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1291,75 +1363,75 @@ int size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer( b, file ); + yy_init_buffer(b,file ); return b; - } - +} -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) return; - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - + yyfree((void *) b->yy_ch_buf ); -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif + yyfree((void *) b ); +} +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - { - yy_flush_buffer( b ); +{ + int oerrno = errno; + + yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} - { - if ( ! b ) +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) return; b->yy_n_chars = 0; @@ -1376,29 +1448,121 @@ YY_BUFFER_STATE b; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == yy_current_buffer ) - yy_load_buffer_state(); + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; } + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); @@ -1412,56 +1576,51 @@ yy_size_t size; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer( b ); + yy_switch_to_buffer(b ); return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif +} +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ); +} -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n ); + b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1471,148 +1630,196 @@ int len; b->yy_is_our_buffer = 1; return b; - } +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 #endif +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); +/* Accessor methods (get/set functions) to struct members. */ - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} - yy_start_stack[yy_start_stack_ptr++] = YY_START; +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} - BEGIN(new_state); - } -#endif +/** Get the current token. + * + */ +char *yyget_text (void) +{ + return yytext; +} -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif +int yyget_debug (void) +{ + return yy_flex_debug; +} -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; #else -static void yy_fatal_error( msg ) -char msg[]; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } -/* Redefine yyless() so it works in section 3 code. */ + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + return 0; +} -/* Internal utility routines. */ +/* + * Internal utility routines. + */ #ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; - } +} #endif #ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { +static int yy_flex_strlen (yyconst char * s ) +{ register int n; for ( n = 0; s[n]; ++n ) ; return n; - } +} #endif - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { +void *yyalloc (yy_size_t size ) +{ return (void *) malloc( size ); - } +} -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { +void *yyrealloc (void * ptr, yy_size_t size ) +{ /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -1621,28 +1828,19 @@ yy_size_t size; * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); - } +} -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif #line 75 "lex.l" + #ifndef yywrap /* XXX */ int yywrap () @@ -1695,3 +1893,4 @@ error_message (const char *format, ...) va_end (args); numerror++; } + diff --git a/source/heimdal/lib/hdb/hdb.c b/source/heimdal/lib/hdb/hdb.c index 5d2ce8f3bb7..555a0d53f64 100644 --- a/source/heimdal/lib/hdb/hdb.c +++ b/source/heimdal/lib/hdb/hdb.c @@ -262,7 +262,7 @@ find_dynamic_method (krb5_context context, if (prefix == NULL) krb5_errx(context, 1, "out of memory"); - if (asprintf(&path, LIBDIR "/hdb_%s.so", prefix) == -1) + if (asprintf(&path, HDBDIR "/hdb_%s.so", prefix) == -1) krb5_errx(context, 1, "out of memory"); #ifndef RTLD_NOW diff --git a/source/heimdal_build/config.h b/source/heimdal_build/config.h index 67516f01c72..5c1d55ca9ab 100644 --- a/source/heimdal_build/config.h +++ b/source/heimdal_build/config.h @@ -22,6 +22,8 @@ /* path to sysconf - should we force this to samba LIBDIR ? */ #define SYSCONFDIR "/etc" +/* HDB module dir - set to Samba LIBDIR/hdb ? */ +#define HDBDIR "/usr/heimdal/lib" /* Maximum values on all known systems */ #define MaxHostNameLen (64+4) diff --git a/source/lib/ldb/Makefile.in b/source/lib/ldb/Makefile.in index c13d3b4fe6a..bc00c6b6566 100644 --- a/source/lib/ldb/Makefile.in +++ b/source/lib/ldb/Makefile.in @@ -6,6 +6,7 @@ XSLTPROC = @XSLTPROC@ DOXYGEN = @DOXYGEN@ prefix = @prefix@ exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ includedir = @includedir@ libdir = @libdir@ bindir = @bindir@ @@ -21,20 +22,7 @@ CFLAGS=-I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \ -I$(srcdir)/../tdb/include -I$(srcdir)/../tdb -I$(srcdir)/../talloc \ -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"@SHLIBEXT@\" -DUSE_MMAP=1 @CFLAGS@ -LIB_FLAGS=-Llib -lldb @LIBS@ - -REPDIR=replace -REPLACE_OBJ=$(REPDIR)/replace.o $(REPDIR)/timegm.o - -TDBDIR=tdb -TDB_OBJ=$(TDBDIR)/common/tdb.o $(TDBDIR)/common/dump.o \ - $(TDBDIR)/common/io.o $(TDBDIR)/common/lock.o \ - $(TDBDIR)/common/open.o $(TDBDIR)/common/traverse.o \ - $(TDBDIR)/common/freelist.o $(TDBDIR)/common/error.o \ - $(TDBDIR)/common/transaction.o - -TALLOCDIR=talloc -TALLOC_OBJ=$(TALLOCDIR)/talloc.o +LIB_FLAGS=-L$(srcdir)/../tdb -L$(srcdir)/../talloc -Llib -lldb -ltdb -ltalloc @LIBS@ @REPLACE_LIB@ LDB_TDB_DIR=ldb_tdb LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \ @@ -53,7 +41,7 @@ MODULES_OBJ=$(MODDIR)/operational.o $(MODDIR)/schema.o $(MODDIR)/rdn_name.o \ $(MODDIR)/objectclass.o \ $(MODDIR)/paged_results.o $(MODDIR)/sort.o $(MODDIR)/asq.o -OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TALLOC_OBJ) $(EXTRA_OBJ) $(REPLACE_OBJ) +OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TALLOC_OBJ) $(EXTRA_OBJ) LDB_LIB = lib/libldb.a @@ -63,7 +51,7 @@ LIBS = $(LDB_LIB) EXAMPLES = examples/ldbreader examples/ldifreader -DIRS = lib bin common replace ldb_tdb ldb_ldap ldb_sqlite3 modules tools examples tdb talloc +DIRS = lib bin common ldb_tdb ldb_ldap ldb_sqlite3 modules tools examples tdb talloc all: dirs $(OBJS) $(LDB_LIB) $(BINS) $(EXAMPLES) manpages @@ -159,3 +147,7 @@ etags: ctags: ctags `find $(srcdir) -name "*.[ch]"` + +@REPLACE_LIB@: + cd @REPLACE_DIR@ && ./autogen.sh && ./configure + $(MAKE) -C @REPLACE_DIR@ diff --git a/source/lib/ldb/autogen.sh b/source/lib/ldb/autogen.sh index 89053ad9f8a..6050abce391 100755 --- a/source/lib/ldb/autogen.sh +++ b/source/lib/ldb/autogen.sh @@ -1,5 +1,7 @@ #!/bin/sh +rm -rf autom4te.cache/ + autoheader || exit 1 autoconf || exit 1 diff --git a/source/lib/ldb/config.mk b/source/lib/ldb/config.mk index 1f92cd5d62f..8dff4df2dc6 100644 --- a/source/lib/ldb/config.mk +++ b/source/lib/ldb/config.mk @@ -1,6 +1,7 @@ ################################################ # Start MODULE ldb_asq [MODULE::ldb_asq] +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_asq_init SUBSYSTEM = ldb OBJ_FILES = \ @@ -11,6 +12,7 @@ OBJ_FILES = \ ################################################ # Start MODULE ldb_server_sort [MODULE::ldb_server_sort] +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_sort_init SUBSYSTEM = ldb OBJ_FILES = \ @@ -22,6 +24,7 @@ OBJ_FILES = \ # Start MODULE ldb_paged_results [MODULE::ldb_paged_results] INIT_FUNCTION = ldb_paged_results_init +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb OBJ_FILES = \ modules/paged_results.o @@ -32,6 +35,7 @@ OBJ_FILES = \ # Start MODULE ldb_paged_results [MODULE::ldb_paged_searches] INIT_FUNCTION = ldb_paged_searches_init +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb OBJ_FILES = \ modules/paged_searches.o @@ -42,6 +46,7 @@ OBJ_FILES = \ # Start MODULE ldb_operational [MODULE::ldb_operational] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_operational_init OBJ_FILES = \ modules/operational.o @@ -52,6 +57,7 @@ OBJ_FILES = \ # Start MODULE ldb_objectclass [MODULE::ldb_objectclass] INIT_FUNCTION = ldb_objectclass_init +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb OBJ_FILES = \ modules/objectclass.o @@ -62,6 +68,7 @@ OBJ_FILES = \ # Start MODULE ldb_rdn_name [MODULE::ldb_rdn_name] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_rdn_name_init OBJ_FILES = \ modules/rdn_name.o @@ -82,6 +89,7 @@ OBJ_FILES = \ # Start MODULE ldb_ildap [MODULE::ldb_ildap] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_ildap_init ALIASES = ldapi ldaps ldap OBJ_FILES = \ @@ -94,6 +102,7 @@ PUBLIC_DEPENDENCIES = \ ################################################ # Start MODULE ldb_map [MODULE::ldb_map] +PRIVATE_DEPENDENCIES = LIBTALLOC SUBSYSTEM = ldb OBJ_FILES = \ modules/ldb_map_inbound.o \ @@ -106,6 +115,7 @@ OBJ_FILES = \ # Start MODULE ldb_skel [MODULE::ldb_skel] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_skel_init OBJ_FILES = modules/skel.o # End MODULE ldb_skel @@ -115,11 +125,12 @@ OBJ_FILES = modules/skel.o # Start MODULE ldb_sqlite3 [MODULE::ldb_sqlite3] SUBSYSTEM = ldb +PRIVATE_DEPENDENCIES = LIBTALLOC INIT_FUNCTION = ldb_sqlite3_init OBJ_FILES = \ ldb_sqlite3/ldb_sqlite3.o PUBLIC_DEPENDENCIES = \ - SQLITE3 + SQLITE3 LIBTALLOC # End MODULE ldb_sqlite3 ################################################ @@ -136,23 +147,13 @@ OBJ_FILES = \ ldb_tdb/ldb_cache.o \ ldb_tdb/ldb_tdb_wrap.o PUBLIC_DEPENDENCIES = \ - LIBTDB + LIBTDB LIBTALLOC # End MODULE ldb_tdb ################################################ -################################################ -# Start MODULE ldb_replace -[MODULE::ldb_replace] -SUBSYSTEM = ldb -OBJ_FILES = \ - replace/timegm.o \ - replace/replace.o -# End MODULE ldb_replace -################################################ - ./lib/ldb/common/ldb_modules.o: lib/ldb/common/ldb_modules.c Makefile @echo Compiling $< - @$(CC) $(CFLAGS) $(PICFLAG) -DMODULESDIR=\"$(MODULESDIR)/ldb\" -DSHLIBEXT=\"$(SHLIBEXT)\" -c $< -o $@ + @$(CC) -Iinclude $(CFLAGS) -Ilib/talloc -Ilib/ldb $(PICFLAG) -DLDBMODULESDIR=\"$(MODULESDIR)/ldb\" -DSHLIBEXT=\"$(SHLIBEXT)\" -c $< -o $@ ################################################ # Start SUBSYSTEM ldb @@ -186,6 +187,7 @@ PUBLIC_HEADERS = include/ldb.h include/ldb_errors.h ################################################ # Start SUBSYSTEM LDBSAMBA [SUBSYSTEM::LDBSAMBA] +PRIVATE_DEPENDENCIES = ldb PRIVATE_PROTO_HEADER = samba/ldif_handlers.h PUBLIC_DEPENDENCIES = LIBSECURITY SAMDB OBJ_FILES = \ @@ -199,7 +201,7 @@ OBJ_FILES = \ OBJ_FILES= \ tools/cmdline.o PUBLIC_DEPENDENCIES = ldb LIBSAMBA-UTIL LIBPOPT POPT_SAMBA POPT_CREDENTIALS -PRIVATE_DEPENDENCIES = gensec +PRIVATE_DEPENDENCIES = gensec # End SUBSYSTEM LIBLDB_CMDLINE ################################################ diff --git a/source/lib/ldb/configure.in b/source/lib/ldb/configure.in index 4f8640ec673..5ef3d1cc967 100644 --- a/source/lib/ldb/configure.in +++ b/source/lib/ldb/configure.in @@ -70,6 +70,9 @@ fi AC_SUBST(TESTS) AC_SUBST(EXTRA_OBJ) +sinclude(replace.m4) +SMB_REPLACE_FUNCS(strtoll) + sinclude(config.m4) sinclude(../talloc/config.m4) sinclude(../tdb/config.m4) diff --git a/source/lib/ldb/include/includes.h b/source/lib/ldb/include/includes.h index 31997d6008f..0a73f7728f7 100644 --- a/source/lib/ldb/include/includes.h +++ b/source/lib/ldb/include/includes.h @@ -6,19 +6,19 @@ #ifdef _SAMBA_BUILD_ -#include "system/filesys.h" -#include "system/locale.h" -#include "system/time.h" - /* tell ldb we have the internal ldap code */ #define HAVE_ILDAP 1 -#else /*_SAMBA_BUILD_*/ +#else +#include "config.h" +#endif /*_SAMBA_BUILD_*/ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include "config.h" +#ifdef HAVE_REPLACE_H +#include "replace.h" +#endif #include #include #include @@ -51,8 +51,6 @@ typedef int (*comparison_fn_t)(const void *, const void *); #include "talloc.h" -#endif /*_SAMBA_BUILD_*/ - #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" diff --git a/source/lib/ldb/replace/config.m4 b/source/lib/ldb/replace/config.m4 deleted file mode 100644 index 2d21d1b315e..00000000000 --- a/source/lib/ldb/replace/config.m4 +++ /dev/null @@ -1,12 +0,0 @@ -AC_CHECK_HEADERS([stdint.h inttypes.h]) -AC_CHECK_TYPE(uint8_t, unsigned char) -AC_CHECK_TYPE(int64_t, long long) -AC_CHECK_TYPE(uint64_t, unsigned long long) -AC_CHECK_TYPE(comparison_fn_t, -[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) - -AC_CHECK_FUNCS(strerror timegm strnlen setenv) -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) -AC_HAVE_DECL(errno, [#include ]) - -AC_CHECK_HEADERS(strings.h) diff --git a/source/lib/ldb/replace/replace.c b/source/lib/ldb/replace/replace.c deleted file mode 100644 index a63613fc105..00000000000 --- a/source/lib/ldb/replace/replace.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - replacement routines for broken systems - - Copyright (C) Andrew Tridgell 1992-2006 - - 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 of the License, 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 - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "ldb/include/includes.h" - -#if !defined(HAVE_STRNLEN) && !defined(_SAMBA_BUILD_) -/** - Some platforms don't have strnlen -**/ - size_t strnlen(const char *s, size_t n) -{ - int i; - for (i=0; s[i] && i #ifndef HAVE_DLOPEN void *dlopen(const char *name, int flags) diff --git a/source/lib/replace/getpass.c b/source/lib/replace/getpass.c index 4ffcde8dfd3..1aac7c61aba 100644 --- a/source/lib/replace/getpass.c +++ b/source/lib/replace/getpass.c @@ -18,9 +18,38 @@ Cambridge, MA 02139, USA. */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ -#include "includes.h" -#include "system/terminal.h" -#include "system/wait.h" +#include "replace.h" +#include + +#if defined(HAVE_TERMIOS_H) +/* POSIX terminal handling. */ +#include +#elif defined(HAVE_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#elif defined(HAVE_SYS_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +/* + * Define additional missing types + */ +#ifndef HAVE_SIG_ATOMIC_T_TYPE +typedef int sig_atomic_t; +#endif + +#ifndef SIGCLD +#define SIGCLD SIGCHLD +#endif + +#ifndef SIGNAL_CAST +#define SIGNAL_CAST (RETSIGTYPE (*)(int)) +#endif #ifdef REPLACE_GETPASS diff --git a/source/lib/replace/repdir/repdir.c b/source/lib/replace/repdir/repdir.c index b536ed65870..07b9568dc1a 100644 --- a/source/lib/replace/repdir/repdir.c +++ b/source/lib/replace/repdir/repdir.c @@ -2,20 +2,24 @@ Unix SMB/CIFS implementation. Copyright (C) Andrew Tridgell 2005 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - 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 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems diff --git a/source/lib/replace/replace.c b/source/lib/replace/replace.c index 4048fe558e3..5333c6a9fe4 100644 --- a/source/lib/replace/replace.c +++ b/source/lib/replace/replace.c @@ -2,38 +2,41 @@ Unix SMB/CIFS implementation. replacement routines for broken systems Copyright (C) Andrew Tridgell 1992-1998 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - 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 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "includes.h" -#include "system/locale.h" -#include "system/wait.h" -#include "system/time.h" -#include "system/network.h" -#include "system/filesys.h" -#include "system/syslog.h" +#include "replace.h" + +#include +#include +#include +#include - void replace_dummy(void); - void replace_dummy(void) {} +void replace_dummy(void); +void replace_dummy(void) {} #ifndef HAVE_FTRUNCATE /******************************************************************* ftruncate for operating systems that don't have it ********************************************************************/ - int ftruncate(int f,off_t l) +int rep_ftruncate(int f, off_t l) { #ifdef HAVE_CHSIZE return chsize(f,l); @@ -53,7 +56,7 @@ ftruncate for operating systems that don't have it #ifndef HAVE_STRLCPY /* like strncpy but does not 0 fill the buffer and always null terminates. bufsize is the size of the destination buffer */ - size_t strlcpy(char *d, const char *s, size_t bufsize) +size_t rep_strlcpy(char *d, const char *s, size_t bufsize) { size_t len = strlen(s); size_t ret = len; @@ -69,7 +72,7 @@ ftruncate for operating systems that don't have it /* like strncat but does not 0 fill the buffer and always null terminates. bufsize is the length of the buffer, which should be one more than the maximum resulting string length */ - size_t strlcat(char *d, const char *s, size_t bufsize) +size_t rep_strlcat(char *d, const char *s, size_t bufsize) { size_t len1 = strlen(d); size_t len2 = strlen(s); @@ -97,7 +100,7 @@ Corrections by richard.kettlewell@kewill.com #define HOUR 60*MINUTE #define DAY 24*HOUR #define YEAR 365*DAY - time_t mktime(struct tm *t) +time_t rep_mktime(struct tm *t) { struct tm *u; time_t epoch = 0; @@ -149,7 +152,7 @@ Corrections by richard.kettlewell@kewill.com #ifndef HAVE_RENAME /* Rename a file. (from libiberty in GNU binutils) */ - int rename(const char *zfrom, const char *zto) +int rep_rename(const char *zfrom, const char *zto) { if (link (zfrom, zto) < 0) { @@ -169,7 +172,8 @@ Corrections by richard.kettlewell@kewill.com /* * Search for a match in a netgroup. This replaces it on broken systems. */ - int innetgr(const char *group,const char *host,const char *user,const char *dom) +int rep_innetgr(const char *group, const char *host, const char *user, + const char *dom) { char *hst, *usr, *dm; @@ -194,7 +198,7 @@ Corrections by richard.kettlewell@kewill.com /**************************************************************************** some systems don't have an initgroups call ****************************************************************************/ - int initgroups(char *name, gid_t id) +int rep_initgroups(char *name, gid_t id) { #ifndef HAVE_SETGROUPS /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ @@ -246,7 +250,7 @@ Corrections by richard.kettlewell@kewill.com /* This is needed due to needing the nap() function but we don't want to include the Xenix libraries since that will break other things... BTW: system call # 0x0c28 is the same as calling nap() */ - long nap(long milliseconds) { +long nap(long milliseconds) { return syscall(0x0c28, milliseconds); } #endif @@ -259,7 +263,7 @@ this is only used if the machine does not have it's own memmove(). this is not the fastest algorithm in town, but it will do for our needs. ********************************************************************/ - void *memmove(void *dest,const void *src,int size) +void *rep_memmove(void *dest,const void *src,int size) { unsigned long d,s; int i; @@ -317,7 +321,7 @@ needs. /**************************************************************************** duplicate a string ****************************************************************************/ - char *strdup(const char *s) +char *rep_strdup(const char *s) { size_t len; char *ret; @@ -335,7 +339,7 @@ duplicate a string #ifndef WITH_PTHREADS /* REWRITE: not thread safe */ #ifdef REPLACE_INET_NTOA - char *rep_inet_ntoa(struct in_addr ip) +char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; @@ -347,7 +351,7 @@ duplicate a string #endif #ifndef HAVE_SETLINEBUF - int setlinebuf(FILE *stream) +int rep_setlinebuf(FILE *stream) { return setvbuf(stream, (char *)NULL, _IOLBF, 0); } @@ -355,7 +359,7 @@ duplicate a string #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG - void vsyslog (int facility_priority, char *format, va_list arglist) +void rep_vsyslog (int facility_priority, char *format, va_list arglist) { char *msg = NULL; vasprintf(&msg, format, arglist); @@ -388,7 +392,7 @@ duplicate a string /** Some platforms don't have strndup. **/ - char *strndup(const char *s, size_t n) +char *rep_strndup(const char *s, size_t n) { char *ret; @@ -404,14 +408,14 @@ duplicate a string #endif #ifndef HAVE_WAITPID -int waitpid(pid_t pid,int *status,int options) +int rep_waitpid(pid_t pid,int *status,int options) { return wait4(pid, status, options, NULL); } #endif #ifndef HAVE_SETEUID - int seteuid(uid_t euid) +int rep_seteuid(uid_t euid) { #ifdef HAVE_SETRESUID return setresuid(-1, euid, -1); @@ -422,7 +426,7 @@ int waitpid(pid_t pid,int *status,int options) #endif #ifndef HAVE_SETEGID - int setegid(gid_t egid) +int rep_setegid(gid_t egid) { #ifdef HAVE_SETRESGID return setresgid(-1, egid, -1); @@ -436,7 +440,7 @@ int waitpid(pid_t pid,int *status,int options) os/2 also doesn't have chroot ********************************************************************/ #ifndef HAVE_CHROOT -int chroot(const char *dname) +int rep_chroot(const char *dname) { errno = ENOSYS; return -1; @@ -460,7 +464,7 @@ int rep_mkstemp(char *template) #endif #ifndef HAVE_MKDTEMP -char * mkdtemp(char *template) +char *rep_mkdtemp(char *template) { char *dname; @@ -475,7 +479,7 @@ char * mkdtemp(char *template) #endif #ifndef HAVE_PREAD -static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -485,7 +489,7 @@ static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) #endif #ifndef HAVE_PWRITE -static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -495,7 +499,7 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs #endif #ifndef HAVE_STRCASESTR -char *strcasestr(const char *haystack, const char *needle) +char *rep_strcasestr(const char *haystack, const char *needle) { const char *s; size_t nlen = strlen(needle); @@ -511,7 +515,7 @@ char *strcasestr(const char *haystack, const char *needle) #ifndef HAVE_STRTOK_R /* based on GLIBC version, copyright Free Software Foundation */ -char *strtok_r(char *s, const char *delim, char **save_ptr) +char *rep_strtok_r(char *s, const char *delim, char **save_ptr) { char *token; @@ -535,3 +539,111 @@ char *strtok_r(char *s, const char *delim, char **save_ptr) return token; } #endif + +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ +size_t rep_strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif diff --git a/source/lib/replace/replace.h b/source/lib/replace/replace.h index e59ba432062..827777983fb 100644 --- a/source/lib/replace/replace.h +++ b/source/lib/replace/replace.h @@ -4,25 +4,39 @@ macros to go along with the lib/replace/ portability layer code Copyright (C) Andrew Tridgell 2005 + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - 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 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _replace_h #define _replace_h +#ifdef _SAMBA_BUILD_ +#include "config.h" +#else +#include "replace_config.h" +#endif /* _SAMBA_BUILD_ */ + +#include +#include + #if defined(_MSC_VER) || defined(__MINGW32__) #include "lib/replace/win32/replace.h" #endif @@ -53,59 +67,78 @@ extern int errno; #endif #ifndef HAVE_STRDUP -char *strdup(const char *s); +#define strdup rep_strdup +char *rep_strdup(const char *s); #endif #ifndef HAVE_MEMMOVE -void *memmove(void *dest,const void *src,int size); +#define memmove rep_memmove +void *rep_memmove(void *dest,const void *src,int size); #endif #ifndef HAVE_MKTIME -time_t mktime(struct tm *t); +#define mktime rep_mktime +time_t rep_mktime(struct tm *t); #endif #ifndef HAVE_STRLCPY -size_t strlcpy(char *d, const char *s, size_t bufsize); +#define strlcpy rep_strlcpy +size_t rep_strlcpy(char *d, const char *s, size_t bufsize); #endif #ifndef HAVE_STRLCAT -size_t strlcat(char *d, const char *s, size_t bufsize); +#define strlcat rep_strlcat +size_t rep_strlcat(char *d, const char *s, size_t bufsize); #endif #ifndef HAVE_STRNDUP -char *strndup(const char *s, size_t n); +#define strndup rep_strndup +char *rep_strndup(const char *s, size_t n); #endif #ifndef HAVE_STRNLEN -size_t strnlen(const char *s, size_t n); -#endif - -#ifndef HAVE_STRTOUL -unsigned long strtoul(const char *nptr, char **endptr, int base); +#define strnlen rep_strnlen +size_t rep_strnlen(const char *s, size_t n); #endif #ifndef HAVE_SETENV -int setenv(const char *name, const char *value, int overwrite); +#define setenv rep_setenv +int rep_setenv(const char *name, const char *value, int overwrite); #endif #ifndef HAVE_RENAME -int rename(const char *zfrom, const char *zto); +#define rename rep_rename +int rep_rename(const char *zfrom, const char *zto); #endif #ifndef HAVE_STRCASESTR -char *strcasestr(const char *haystack, const char *needle); +#define strcasestr rep_strcasestr +char *rep_strcasestr(const char *haystack, const char *needle); #endif #ifndef HAVE_STRTOK_R -char *strtok_r(char *s, const char *delim, char **save_ptr); +#define strtok_r rep_strtok_r +char *rep_strtok_r(char *s, const char *delim, char **save_ptr); +#endif + +#ifndef HAVE_STRTOLL +#define strtoll rep_strtoll +long long int rep_strtoll(const char *str, char **endptr, int base); +#endif + +#ifndef HAVE_STRTOULL +#define strtoull rep_strtoull +unsigned long long int rep_strtoull(const char *str, char **endptr, int base); #endif #ifndef HAVE_FTRUNCATE -int ftruncate(int f,long l); +#define ftruncate rep_ftruncate +int rep_ftruncate(int f,long l); #endif #ifndef HAVE_VASPRINTF_DECL -int vasprintf(char **ptr, const char *format, va_list ap); +#define vasprintf rep_vasprintf +int rep_vasprintf(char **ptr, const char *format, va_list ap); #endif #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) @@ -114,7 +147,8 @@ int vasprintf(char **ptr, const char *format, va_list ap); #ifndef HAVE_TIMEGM struct tm; -time_t timegm(struct tm *tm); +#define timegm rep_timegm +time_t rep_timegm(struct tm *tm); #endif #ifndef PRINTF_ATTRIBUTE @@ -131,10 +165,12 @@ time_t timegm(struct tm *tm); /* add varargs prototypes with printf checking */ #ifndef HAVE_SNPRINTF_DECL -int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); +#define snprintf rep_snprintf +int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); #endif #ifndef HAVE_ASPRINTF_DECL -int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); +#define asprintf rep_asprintf +int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #endif @@ -174,7 +210,8 @@ int rep_mkstemp(char *temp); #endif #ifndef HAVE_MKDTEMP -char *mkdtemp(char *template); +#define mkdtemp rep_mkdtemp +char *rep_mkdtemp(char *template); #endif #ifdef HAVE_LIMITS_H @@ -248,4 +285,6 @@ typedef int bool; #define __STRING(x) #x #endif + + #endif diff --git a/source/lib/replace/replace.m4 b/source/lib/replace/replace.m4 new file mode 100644 index 00000000000..829f4db6f6e --- /dev/null +++ b/source/lib/replace/replace.m4 @@ -0,0 +1,58 @@ +dnl Try to find a replacement library +dnl Will define HAVE_REPLACE_H if replace.h can be found +AC_DEFUN([SMB_LIBREPLACE], [ +AC_ARG_WITH(libreplace, +[ --with-libreplace Specify location to libreplace], +[ + # Check whether libreplace can actually be found in this location + if ! test -f "$withval/replace.h" + then + AC_MSG_ERROR([Unable to find replace.h in $withval]) + fi + replacedir=$withval +], +[ + # Check if we can find libreplace in a common location + for dir in . replace ../replace + do + AC_MSG_CHECKING([for libreplace in $dir]) + if test -f "$dir/replace.h" + then + replacedir="$dir" + AC_MSG_RESULT(yes) + break + fi + AC_MSG_RESULT(no) + done +]) + +AC_SUBST(REPLACE_LIBS) + +if test "$replacedir" != "" +then + REPLACE_LIBS="$replacedir/libreplace.a" + CFLAGS="$CFLAGS -I$replacedir" + AC_DEFINE(HAVE_REPLACE_H, 1, + [Whether replace.h is present and should be used]) +fi +]) + +dnl Try to find the specified functions in the system, or +dnl in Samba's replacement library. In the future, this may also +dnl try to find these functions in libroken or GNUlib if libreplace can't be +dnl found. +AC_DEFUN(SMB_REPLACE_FUNCS, [ + AC_REQUIRE([SMB_LIBREPLACE])dnl + + if test -z "$replacedir" || test -f "$replacedir/libreplace.a" + then + LIBS="$LIBS $REPLACE_LIBS" + for f in $1 + do + AC_CHECK_FUNC($f, [], [ + AC_MSG_ERROR([Unable to find $f in the system. Consider + specifying the path to the replacement library]) + ]) + done + fi +]) diff --git a/source/lib/replace/snprintf.c b/source/lib/replace/snprintf.c index eaa5eec4054..8182f837519 100644 --- a/source/lib/replace/snprintf.c +++ b/source/lib/replace/snprintf.c @@ -103,11 +103,11 @@ * **************************************************************/ -#ifndef NO_CONFIG_H +#ifdef _SAMBA_BUILD_ #include "config.h" #else -#define NULL 0 -#endif +#include "replace_config.h" +#endif #ifdef TEST_SNPRINTF /* need math library headers for testing */ diff --git a/source/lib/replace/test/testsuite.c b/source/lib/replace/test/testsuite.c new file mode 100644 index 00000000000..2c68fd66641 --- /dev/null +++ b/source/lib/replace/test/testsuite.c @@ -0,0 +1,366 @@ +/* + Unix SMB/CIFS implementation. + + libreplace tests + + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../replace.h" +#include + +int test_ftruncate() +{ + /* FIXME */ + return true; +} + +int test_strlcpy() +{ + /* FIXME */ + return true; +} + +int test_strlcat() +{ + /* FIXME */ + return true; +} + +int test_mktime() +{ + /* FIXME */ + return true; +} + +int test_rename() +{ + /* FIXME */ + return true; +} + +int test_innetgr() +{ + /* FIXME */ + return true; +} + +int test_initgroups() +{ + /* FIXME */ + return true; +} + +int test_memmove() +{ + /* FIXME */ + return true; +} + +int test_strdup() +{ + /* FIXME */ + return true; +} + +int test_setlinebuf() +{ + /* FIXME */ + return true; +} + +int test_vsyslog() +{ + /* FIXME */ + return true; +} + +int test_timegm() +{ + /* FIXME */ + return true; +} + +int test_setenv() +{ + /* FIXME */ + return true; +} + +int test_strndup() +{ + /* FIXME */ + return true; +} + +int test_strnlen() +{ + /* FIXME */ + return true; +} + +int test_waitpid() +{ + /* FIXME */ + return true; +} + +int test_seteuid() +{ + /* FIXME */ + return true; +} + +int test_setegid() +{ + /* FIXME */ + return true; +} + +int test_asprintf() +{ + /* FIXME */ + return true; +} + +int test_snprintf() +{ + /* FIXME */ + return true; +} + +int test_vasprintf() +{ + /* FIXME */ + return true; +} + +int test_vsnprintf() +{ + /* FIXME */ + return true; +} + +int test_opendir() +{ + /* FIXME */ + return true; +} + +int test_readdir() +{ + /* FIXME */ + return true; +} + +int test_telldir() +{ + /* FIXME */ + return true; +} + +int test_seekdir() +{ + /* FIXME */ + return true; +} + +int test_dlopen() +{ + /* FIXME: test dlopen, dlsym, dlclose, dlerror */ + return true; +} + + +int test_chroot() +{ + /* FIXME: chroot() */ + return true; +} + +int test_bzero() +{ + /* FIXME: bzero */ + return true; +} + +int test_strerror() +{ + /* FIXME */ + return true; +} + +int test_errno() +{ + /* FIXME */ + return true; +} + +int test_mkdtemp() +{ + /* FIXME */ + return true; +} + +int test_mkstemp() +{ + /* FIXME */ + return true; +} + +int test_pread() +{ + /* FIXME */ + return true; +} + +int test_pwrite() +{ + /* FIXME */ + return true; +} + +int test_getpass() +{ + /* FIXME */ + return true; +} + +int test_inet_ntoa() +{ + /* FIXME */ + return true; +} + +int test_strtoll() +{ + /* FIXME */ + return true; +} + +int test_strtoull() +{ + /* FIXME */ + return true; +} + +/* +FIXME: +Types: +bool +socklen_t +uint_t +uint{8,16,32,64}_t +int{8,16,32,64}_t +intptr_t + +Constants: +PATH_NAME_MAX +UINT{16,32,64}_MAX +INT32_MAX +*/ + +int test_va_copy() +{ + /* FIXME */ + return true; +} + +int test_FUNCTION() +{ + /* FIXME: test __FUNCTION__ macro */ + return true; +} + +int test_MIN() +{ + /* FIXME */ + return true; +} + +int test_MAX() +{ + /* FIXME */ + return true; +} + +int torture_local_replace() +{ + int ret = true; +; + ret &= test_ftruncate(); + ret &= test_strlcpy(); + ret &= test_strlcat(); + ret &= test_mktime(); + ret &= test_rename(); + ret &= test_innetgr(); + ret &= test_initgroups(); + ret &= test_memmove(); + ret &= test_strdup(); + ret &= test_setlinebuf(); + ret &= test_vsyslog(); + ret &= test_timegm(); + ret &= test_setenv(); + ret &= test_strndup(); + ret &= test_strnlen(); + ret &= test_waitpid(); + ret &= test_seteuid(); + ret &= test_setegid(); + ret &= test_asprintf(); + ret &= test_snprintf(); + ret &= test_vasprintf(); + ret &= test_vsnprintf(); + ret &= test_opendir(); + ret &= test_readdir() ; + ret &= test_telldir(); + ret &= test_seekdir(); + ret &= test_dlopen(); + ret &= test_chroot(); + ret &= test_bzero(); + ret &= test_strerror(); + ret &= test_errno(); + ret &= test_mkdtemp(); + ret &= test_mkstemp(); + ret &= test_pread(); + ret &= test_pwrite(); + ret &= test_getpass(); + ret &= test_inet_ntoa(); + ret &= test_strtoll(); + ret &= test_strtoll(); + ret &= test_strtoull(); + ret &= test_va_copy(); + ret &= test_FUNCTION(); + ret &= test_MIN(); + ret &= test_MAX(); + + return ret; +} + +#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) +int main(void) +{ + if (!torture_local_replace(NULL)) { + printf("ERROR: TESTSUITE FAILED\n"); + return -1; + } + return 0; +} +#endif diff --git a/source/lib/ldb/replace/timegm.c b/source/lib/replace/timegm.c similarity index 100% rename from source/lib/ldb/replace/timegm.c rename to source/lib/replace/timegm.c diff --git a/source/lib/talloc/config.mk b/source/lib/talloc/config.mk index 8c704520f52..dc523d4ede9 100644 --- a/source/lib/talloc/config.mk +++ b/source/lib/talloc/config.mk @@ -6,6 +6,7 @@ SO_VERSION = 0 OBJ_FILES = talloc.o PUBLIC_DEPENDENCIES = LIBREPLACE MANPAGE = talloc.3 +CFLAGS = -Ilib/talloc PUBLIC_HEADERS = talloc.h DESCRIPTION = A hierarchical pool based memory system with destructors # diff --git a/source/lib/talloc/configure.in b/source/lib/talloc/configure.ac similarity index 100% rename from source/lib/talloc/configure.in rename to source/lib/talloc/configure.ac diff --git a/source/lib/tdb/Makefile.in b/source/lib/tdb/Makefile.in index 3969995db32..e68f7eb8c37 100644 --- a/source/lib/tdb/Makefile.in +++ b/source/lib/tdb/Makefile.in @@ -40,20 +40,23 @@ install: all cp $(srcdir)/include/tdb.h $(includedir) cp tdb.pc $(libdir)/pkgconfig -bin/tdbtest: tools/tdbtest.o $(TDB_OBJ) - $(CC) $(CFLAGS) -o bin/tdbtest tools/tdbtest.o $(TDB_OBJ) -lgdbm +libtdb.a: $(TDB_OBJ) + ar -rv libtdb.a $(TDB_OBJ) -bin/tdbtool: tools/tdbtool.o $(TDB_OBJ) - $(CC) $(CFLAGS) -o bin/tdbtool tools/tdbtool.o $(TDB_OBJ) +bin/tdbtest: tools/tdbtest.o libtdb.a + $(CC) $(CFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm -bin/tdbtorture: tools/tdbtorture.o $(TDB_OBJ) - $(CC) $(CFLAGS) -o bin/tdbtorture tools/tdbtorture.o $(TDB_OBJ) +bin/tdbtool: tools/tdbtool.o libtdb.a + $(CC) $(CFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb -bin/tdbdump: tools/tdbdump.o $(TDB_OBJ) - $(CC) $(CFLAGS) -o bin/tdbdump tools/tdbdump.o $(TDB_OBJ) +bin/tdbtorture: tools/tdbtorture.o libtdb.a + $(CC) $(CFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb -bin/tdbbackup: tools/tdbbackup.o $(TDB_OBJ) - $(CC) $(CFLAGS) -o bin/tdbbackup tools/tdbbackup.o $(TDB_OBJ) +bin/tdbdump: tools/tdbdump.o libtdb.a + $(CC) $(CFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb + +bin/tdbbackup: tools/tdbbackup.o libtdb.a + $(CC) $(CFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb clean: rm -f $(PROGS) common/*.o tools/*.o *~ *.bak */*~ */*.bak *% core test.db test.tdb test.gdbm diff --git a/source/lib/tdb/configure.in b/source/lib/tdb/configure.ac similarity index 100% rename from source/lib/tdb/configure.in rename to source/lib/tdb/configure.ac -- 2.34.1