Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / tt / lib / util / tt_trace_parser.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: tt_trace_parser.h /main/3 1995/10/23 10:46:45 rswiston $                                                     */
28 /* -*-C++-*-
29  *
30  * @(#)tt_trace_parser.h        1.8 93/11/04
31  * 
32  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
33  */
34 #ifndef _TT_TRACE_PARSER_H
35 #define _TT_TRACE_PARSER_H
36  
37 #include        "api/c/tt_c.h"
38 #include        "util/tt_object.h"
39 #include        "util/tt_string.h"
40 #include        "util/tt_int_rec.h"
41 #include        "mp/mp_message.h"
42 #include        "util/tt_entry_pt.h"
43 #include        "util/tt_trace_parse.h"
44
45 // Function handling constants
46
47 const int       _TT_FUNS_ALLNONE = 2;
48 const int       _TT_FUNS_EXPLICIT = 1;
49 const int       _TT_FUNS_NOTSET = 0;
50
51 typedef enum {
52         None,
53         Edge,
54         Dispatch,
55         Deliver
56 } _Tt_dispatch_stage;
57
58 class _Tt_trace_parser : public virtual _Tt_allocated {
59     public:
60
61         // Constructor / Destructor
62                 
63         _Tt_trace_parser();
64         _Tt_trace_parser(_Tt_trace_parser& templ);
65         _Tt_trace_parser(int fd);
66         _Tt_trace_parser(const char* script);
67         ~_Tt_trace_parser();
68
69         // Parse function
70                 
71         int                             parse();
72
73         // Is any tracing being done?
74
75         int                             any_tracing();
76         
77         // Retrieval functions -- used by client and server tracing
78                 
79         int                             follow_val();
80         _Tt_string&                     sink_val();
81         const char*                     mode_val();     // sink file open mode
82
83         // ifunction_val returns one of the consts defined above --
84         // _TT_FUNS_ALLNONE, _TT_FUNS_EXPLICIT, or _TT_FUNS_NOTSET.  If
85         // _TT_FUNS_NOTSET is returned, there still may be a value
86         // returned from sfunction_val
87         
88         int                             ifunction_val();
89
90         // sfunction_val returns the list ov functions to trace if an explicit
91         // list was given in the config info.  If no such list was specified,
92         // an empty _Tt_string will be returned.
93                 
94         _Tt_string_list_ptr             sfunction_val();
95         int                             attributes_val() const;
96
97         // states can be set to multiple values in the config file,
98         // so states_val returns the list of values specified.
99                 
100         _Tt_int_rec_list_ptr            states_val();
101         _Tt_string_list_ptr             ops_val();
102         _Tt_string_list_ptr             sender_ptypes_val();
103         _Tt_string_list_ptr             handler_ptypes_val();
104 #ifdef _OPT_TIMERS_SUNOS
105         int                             timers_val();
106 #endif
107
108         // Utility functions used by parser -- not intended
109         // for use by any other code
110                 
111         // Field setting functions
112                 
113         // Follow
114         void    set_follow(int fval);
115         
116         // sink
117         void    set_sink(const _Tt_string& sinkfile, int mode);
118         
119         // functions
120         void    clear_functions();
121         void    add_function(const _Tt_string& fun);
122         void    set_function(int fun);
123         
124         // attributes
125         void    set_attributes(int attr);
126         
127         // states
128         void    clear_states();
129         int     add_state(int state_val);
130         
131         // ops
132         void    clear_ops();
133         void    add_op(const _Tt_string& newop);
134         
135         // sender_ptypes
136         void    clear_sender_ptypes();
137         void    add_sender_ptype(const _Tt_string& sp);
138         
139         // handler_ptypes
140         void    clear_handler_ptypes();
141         void    add_handler_ptype(const _Tt_string& hp);
142
143         // API timers
144 #ifdef _OPT_TIMERS_SUNOS
145         void                            set_timers(int tval);
146 #endif
147
148         // Tracing filters -- used by the tracing admin class
149                 
150         // message tracing filter
151         int is_traced(const _Tt_message& msg) const;
152         int is_traced(const _Tt_message& msg,
153                       _Tt_dispatch_stage stage) const;
154         int is_traced(_Tt_entry_pt fun) const;
155
156     private:
157
158         // config file or inline config stream -- used by YACC and Lex
159                 
160         _Tt_string                      trace_stream;
161
162         int                             follow;
163         _Tt_string                      sink;
164         int                             mode;   // Sink file open mode
165         int                             ifunctions;
166         _Tt_string_list_ptr             sfunctions;
167
168         // discriminator for function values -- either _TT_FUNS_ALLNONE
169         // or _TT_FUNS_EXPLICIT
170         
171         int                             _funcd;
172         
173         int                             attributes;
174         _Tt_int_rec_list_ptr            states;
175         _Tt_string_list_ptr             ops;
176         _Tt_string_list_ptr             sender_ptypes;
177         _Tt_string_list_ptr             handler_ptypes;
178 #ifdef _OPT_TIMERS_SUNOS
179         int                             timers;
180 #endif
181
182         // does initialization common to all constructors
183                 
184         void    tracer_init();
185
186         // Code common to the two is_traced methods that take a message arg
187
188         int     _is_traced(const _Tt_message& msg) const;
189 };
190
191 #endif