diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 10 | ||||
-rw-r--r-- | source3/include/includes.h | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/include/smb.h | 21 | ||||
-rw-r--r-- | source3/lib/debug.c | 160 | ||||
-rw-r--r-- | source3/script/mkproto.awk | 2 | ||||
-rw-r--r-- | source3/utils/debug2html.c | 29 |
7 files changed, 184 insertions, 41 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 421084bff4..bddc221a6d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -109,7 +109,7 @@ LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \ UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \ - ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o ubiqx/debugparse.o + ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o PARAM_OBJ = param/loadparm.o param/params.o @@ -275,8 +275,6 @@ RPCTORTURE_OBJ = utils/rpctorture.o \ $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \ $(PASSDB_OBJ) -DEBUG2HTML_OBJ = utils/debug2html.o ubiqx/debugparse.o - PROTO_OBJ = $(SMBD_OBJ) $(NMBD_OBJ) $(SWAT_OBJ) $(CLIENT_OBJ) \ $(RPCCLIENT_OBJ) $(SMBWRAPPER_OBJ) @@ -295,8 +293,6 @@ smbtorture : CHECK bin/smbtorture rpctorture : CHECK bin/rpctorture -debug2html : CHECK bin/debug2html - .SUFFIXES: .SUFFIXES: .c .o .po .po32 @@ -434,10 +430,6 @@ bin/rpctorture: $(RPCTORTURE_OBJ) bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(RPCTORTURE_OBJ) $(LDFLAGS) $(LIBS) -bin/debug2html: $(DEBUG2HTML_OBJ) bin/.dummy - @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(LIBS) - bin/smbwrapper.so: $(PICOBJS) @echo Linking shared library $@ @$(LD) @LDSHFLAGS@ -o $@ $(PICOBJS) $(LIBS) diff --git a/source3/include/includes.h b/source3/include/includes.h index 824a5bde5d..a70de0b3a9 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -552,8 +552,6 @@ extern int errno; #include "ubi_Cache.h" #endif /* UBI_BINTREE_H */ -#include "debugparse.h" - #include "version.h" #include "smb.h" #include "smbw.h" diff --git a/source3/include/proto.h b/source3/include/proto.h index 8d966c6177..fc1e2926a8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -172,6 +172,7 @@ void reopen_logs( void ); void force_check_log_size( void ); void dbgflush( void ); BOOL dbghdr( int level, char *file, char *func, int line ); +dbg_Token dbg_char2token( dbg_Token *state, int c ); /*The following definitions come from lib/domain_namemap.c */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 9c699fc423..9cd74dd865 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -67,7 +67,8 @@ typedef int BOOL; */ /* I know the __attribute__ stuff is ugly, but it does ensure we get the arguemnts to DEBUG() right. We have got them wrong too often in the - past */ + past. + */ #ifdef HAVE_STDARG_H int Debug1( char *, ... ) #ifdef __GNUC__ @@ -127,6 +128,24 @@ BOOL dbgtext(); #define DEBUGADD( level, body ) \ (void)( (DEBUGLEVEL >= (level)) && (dbgtext body) ) +/* -------------------------------------------------------------------------- ** + * These are the tokens returned by dbg_char2token(). + */ + +typedef enum + { + dbg_null = 0, + dbg_ignore, + dbg_header, + dbg_timestamp, + dbg_level, + dbg_sourcefile, + dbg_function, + dbg_lineno, + dbg_message, + dbg_eof + } dbg_Token; + /* End Debugging code section. * -------------------------------------------------------------------------- ** */ diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 3a90da2f3d..ab11d81a21 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -125,7 +125,6 @@ static int format_pos = 0; * tells us if interactive logging was requested * ************************************************************************** ** */ - BOOL dbg_interactive(void) { return stdout_logging; @@ -597,4 +596,163 @@ BOOL dbghdr( int level, char *file, char *func, int line ) #endif +dbg_Token dbg_char2token( dbg_Token *state, int c ) + /* ************************************************************************ ** + * Parse input one character at a time. + * + * Input: state - A pointer to a token variable. This is used to + * maintain the parser state between calls. For + * each input stream, you should set up a separate + * state variable and initialize it to dbg_null. + * Pass a pointer to it into this function with each + * character in the input stream. See dbg_test() + * for an example. + * c - The "current" character in the input stream. + * + * Output: A token. + * The token value will change when delimiters are found, + * which indicate a transition between syntactical objects. + * Possible return values are: + * + * dbg_null - The input character was an end-of-line. + * This resets the parser to its initial state + * in preparation for parsing the next line. + * dbg_eof - Same as dbg_null, except that the character + * was an end-of-file. + * dbg_ignore - Returned for whitespace and delimiters. + * These lexical tokens are only of interest + * to the parser. + * dbg_header - Indicates the start of a header line. The + * input character was '[' and was the first on + * the line. + * dbg_timestamp - Indicates that the input character was part + * of a header timestamp. + * dbg_level - Indicates that the input character was part + * of the debug-level value in the header. + * dbg_sourcefile - Indicates that the input character was part + * of the sourcefile name in the header. + * dbg_function - Indicates that the input character was part + * of the function name in the header. + * dbg_lineno - Indicates that the input character was part + * of the DEBUG call line number in the header. + * dbg_message - Indicates that the input character was part + * of the DEBUG message text. + * + * ************************************************************************ ** + */ + { + /* The terminating characters that we see will greatly depend upon + * how they are read. For example, if gets() is used instead of + * fgets(), then we will not see newline characters. A lot also + * depends on the calling function, which may handle terminators + * itself. + * + * '\n', '\0', and EOF are all considered line terminators. The + * dbg_eof token is sent back if an EOF is encountered. + * + * Warning: only allow the '\0' character to be sent if you are + * using gets() to read whole lines (thus replacing '\n' + * with '\0'). Sending '\0' at the wrong time will mess + * up the parsing. + */ + switch( c ) + { + case EOF: + *state = dbg_null; /* Set state to null (initial state) so */ + return( dbg_eof ); /* that we can restart with new input. */ + case '\n': + case '\0': + *state = dbg_null; /* A newline or eoln resets to the null state. */ + return( dbg_null ); + } + + /* When within the body of the message, only a line terminator + * can cause a change of state. We've already checked for line + * terminators, so if the current state is dbg_msgtxt, simply + * return that as our current token. + */ + if( dbg_message == *state ) + return( dbg_message ); + + /* If we are at the start of a new line, and the input character + * is an opening bracket, then the line is a header line, otherwise + * it's a message body line. + */ + if( dbg_null == *state ) + { + if( '[' == c ) + { + *state = dbg_timestamp; + return( dbg_header ); + } + *state = dbg_message; + return( dbg_message ); + } + + /* We've taken care of terminators, text blocks and new lines. + * The remaining possibilities are all within the header line + * itself. + */ + + /* Within the header line, whitespace can be ignored *except* + * within the timestamp. + */ + if( isspace( c ) ) + { + /* Fudge. The timestamp may contain space characters. */ + if( (' ' == c) && (dbg_timestamp == *state) ) + return( dbg_timestamp ); + /* Otherwise, ignore whitespace. */ + return( dbg_ignore ); + } + + /* Okay, at this point we know we're somewhere in the header. + * Valid header *states* are: dbg_timestamp, dbg_level, + * dbg_sourcefile, dbg_function, and dbg_lineno. + */ + switch( c ) + { + case ',': + if( dbg_timestamp == *state ) + { + *state = dbg_level; + return( dbg_ignore ); + } + break; + case ']': + if( dbg_level == *state ) + { + *state = dbg_sourcefile; + return( dbg_ignore ); + } + break; + case ':': + if( dbg_sourcefile == *state ) + { + *state = dbg_function; + return( dbg_ignore ); + } + break; + case '(': + if( dbg_function == *state ) + { + *state = dbg_lineno; + return( dbg_ignore ); + } + break; + case ')': + if( dbg_lineno == *state ) + { + *state = dbg_null; + return( dbg_ignore ); + } + break; + } + + /* If the previous block did not result in a state change, then + * return the current state as the current token. + */ + return( *state ); + } /* dbg_char2token */ + /* ************************************************************************** */ diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk index e54984e4e5..3309e89a0f 100644 --- a/source3/script/mkproto.awk +++ b/source3/script/mkproto.awk @@ -98,7 +98,7 @@ END { gotstart = 1; } - if( $0 ~ /^long|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT/ ) { + if( $0 ~ /^long|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT|dbg_Token/ ) { gotstart = 1; } if(!gotstart) { diff --git a/source3/utils/debug2html.c b/source3/utils/debug2html.c index fa2be41336..d5d8fb872c 100644 --- a/source3/utils/debug2html.c +++ b/source3/utils/debug2html.c @@ -28,37 +28,12 @@ * does a decent job of converting Samba logs into HTML. * -------------------------------------------------------------------------- ** * - * $Log: debug2html.c,v $ - * Revision 1.4 1998/11/13 03:37:01 tridge - * fixes for OSF1 compilation - * - * Revision 1.3 1998/10/28 20:33:35 crh - * I've moved the debugparse module files into the ubiqx directory because I - * know that 'make proto' will ignore them there. The debugparse.h header - * file is included in includes.h, and includes.h is included in debugparse.c, - * so all of the pieces "see" each other. I've compiled and tested this, - * and it does seem to work. It's the same compromise model I used when - * adding the ubiqx modules into the system, which is why I put it all into - * the same directory. - * - * Chris -)----- - * - * Revision 1.1 1998/10/26 23:21:37 crh - * Here is the simple debug parser and the debug2html converter. Still to do: - * - * * Debug message filtering. - * * I need to add all this to Makefile.in - * (If it looks at all strange I'll ask for help.) - * - * If you want to compile debug2html, you'll need to do it by hand until I - * make the changes to Makefile.in. Sorry. - * - * Chris -)----- + * $Revision: 1.5 $ * * ========================================================================== ** */ -#include "debugparse.h" +#include "include.h" /* -------------------------------------------------------------------------- ** * The size of the read buffer. |