source: branches/samba-3.0/source/include/debugparse.h@ 431

Last change on this file since 431 was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 5.3 KB
Line 
1#ifndef DEBUGPARSE_H
2#define DEBUGPARSE_H
3/* ========================================================================== **
4 * debugparse.c
5 *
6 * Copyright (C) 1998 by Christopher R. Hertel
7 *
8 * Email: crh@ubiqx.mn.org
9 *
10 * -------------------------------------------------------------------------- **
11 * This module is a very simple parser for Samba debug log files.
12 * -------------------------------------------------------------------------- **
13 *
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.
18 *
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.
23 *
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.
27 *
28 * -------------------------------------------------------------------------- **
29 * The important function in this module is dbg_char2token(). The rest is
30 * basically fluff. (Potentially useful fluff, but still fluff.)
31 * ========================================================================== **
32 */
33
34#include "includes.h"
35
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>
41 */
42
43/* -------------------------------------------------------------------------- **
44 * These are the tokens returned by dbg_char2token().
45 */
46
47typedef enum
48 {
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;
60
61/* -------------------------------------------------------------------------- **
62 * Function prototypes...
63 */
64
65 const char *dbg_token2string( dbg_Token tok );
66 /* ------------------------------------------------------------------------ **
67 * Given a token, return a string describing the token.
68 *
69 * Input: tok - One of the set of dbg_Tokens defined in debugparse.h.
70 *
71 * Output: A string identifying the token. This is useful for debugging,
72 * etc.
73 *
74 * Note: If the token is not known, this function will return the
75 * string "<unknown>".
76 *
77 * ------------------------------------------------------------------------ **
78 */
79
80 dbg_Token dbg_char2token( dbg_Token *state, int c );
81 /* ------------------------------------------------------------------------ **
82 * Parse input one character at a time.
83 *
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.
92 *
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:
97 *
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.
121 *
122 * ------------------------------------------------------------------------ **
123 */
124
125
126/* -------------------------------------------------------------------------- */
127#endif /* DEBUGPARSE_H */
Note: See TracBrowser for help on using the repository browser.