[GLUE] Rsync SAMBA_3_0 SVN r25598 in order to create the v3-0-test branch.
[Samba.git] / source / include / debugparse.h
blobfb7f00f77922e8f20786ed877ffb46502102cb88
1 #ifndef DEBUGPARSE_H
2 #define DEBUGPARSE_H
3 /* ========================================================================== **
4 * debugparse.c
6 * Copyright (C) 1998 by Christopher R. Hertel
8 * Email: crh@ubiqx.mn.org
10 * -------------------------------------------------------------------------- **
11 * This module is a very simple parser for Samba debug log files.
12 * -------------------------------------------------------------------------- **
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Library General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with this library; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * -------------------------------------------------------------------------- **
29 * The important function in this module is dbg_char2token(). The rest is
30 * basically fluff. (Potentially useful fluff, but still fluff.)
31 * ========================================================================== **
34 #include "includes.h"
36 /* This module compiles quite nicely outside of the Samba environment.
37 * You'll need the following headers:
38 #include <ctype.h>
39 #include <stdio.h>
40 #include <string.h>
43 /* -------------------------------------------------------------------------- **
44 * These are the tokens returned by dbg_char2token().
47 typedef enum
49 dbg_null = 0,
50 dbg_ignore,
51 dbg_header,
52 dbg_timestamp,
53 dbg_level,
54 dbg_sourcefile,
55 dbg_function,
56 dbg_lineno,
57 dbg_message,
58 dbg_eof
59 } dbg_Token;
61 /* -------------------------------------------------------------------------- **
62 * Function prototypes...
65 const char *dbg_token2string( dbg_Token tok );
66 /* ------------------------------------------------------------------------ **
67 * Given a token, return a string describing the token.
69 * Input: tok - One of the set of dbg_Tokens defined in debugparse.h.
71 * Output: A string identifying the token. This is useful for debugging,
72 * etc.
74 * Note: If the token is not known, this function will return the
75 * string "<unknown>".
77 * ------------------------------------------------------------------------ **
80 dbg_Token dbg_char2token( dbg_Token *state, int c );
81 /* ------------------------------------------------------------------------ **
82 * Parse input one character at a time.
84 * Input: state - A pointer to a token variable. This is used to
85 * maintain the parser state between calls. For
86 * each input stream, you should set up a separate
87 * state variable and initialize it to dbg_null.
88 * Pass a pointer to it into this function with each
89 * character in the input stream. See dbg_test()
90 * for an example.
91 * c - The "current" character in the input stream.
93 * Output: A token.
94 * The token value will change when delimiters are found,
95 * which indicate a transition between syntactical objects.
96 * Possible return values are:
98 * dbg_null - The input character was an end-of-line.
99 * This resets the parser to its initial state
100 * in preparation for parsing the next line.
101 * dbg_eof - Same as dbg_null, except that the character
102 * was an end-of-file.
103 * dbg_ignore - Returned for whitespace and delimiters.
104 * These lexical tokens are only of interest
105 * to the parser.
106 * dbg_header - Indicates the start of a header line. The
107 * input character was '[' and was the first on
108 * the line.
109 * dbg_timestamp - Indicates that the input character was part
110 * of a header timestamp.
111 * dbg_level - Indicates that the input character was part
112 * of the debug-level value in the header.
113 * dbg_sourcefile - Indicates that the input character was part
114 * of the sourcefile name in the header.
115 * dbg_function - Indicates that the input character was part
116 * of the function name in the header.
117 * dbg_lineno - Indicates that the input character was part
118 * of the DEBUG call line number in the header.
119 * dbg_message - Indicates that the input character was part
120 * of the DEBUG message text.
122 * ------------------------------------------------------------------------ **
126 /* -------------------------------------------------------------------------- */
127 #endif /* DEBUGPARSE_H */