Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / doc / util / dbtoman / instant / translate.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 /* $XConsortium: translate.h /main/1 1996/07/23 19:44:35 rws $ */
24 /*
25  *  Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
26  *  All rights reserved.
27  */
28 /*
29  * Copyright (c) 1994  
30  * Open Software Foundation, Inc. 
31  *  
32  * Permission is hereby granted to use, copy, modify and freely distribute 
33  * the software in this file and its documentation for any purpose without 
34  * fee, provided that the above copyright notice appears in all copies and 
35  * that both the copyright notice and this permission notice appear in 
36  * supporting documentation.  Further, provided that the name of Open 
37  * Software Foundation, Inc. ("OSF") not be used in advertising or 
38  * publicity pertaining to distribution of the software without prior 
39  * written permission from OSF.  OSF makes no representations about the 
40  * suitability of this software for any purpose.  It is provided "as is" 
41  * without express or implied warranty. 
42  */
43 /*
44  * Copyright (c) 1996 X Consortium
45  * Copyright (c) 1995, 1996 Dalrymple Consulting
46  * 
47  * Permission is hereby granted, free of charge, to any person obtaining a copy
48  * of this software and associated documentation files (the "Software"), to deal
49  * in the Software without restriction, including without limitation the rights
50  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51  * copies of the Software, and to permit persons to whom the Software is
52  * furnished to do so, subject to the following conditions:
53  * 
54  * The above copyright notice and this permission notice shall be included in
55  * all copies or substantial portions of the Software.
56  * 
57  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
60  * X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
61  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
62  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
63  * OTHER DEALINGS IN THE SOFTWARE.
64  * 
65  * Except as contained in this notice, the names of the X Consortium and
66  * Dalrymple Consulting shall not be used in advertising or otherwise to
67  * promote the sale, use or other dealings in this Software without prior
68  * written authorization.
69  */
70 /* ________________________________________________________________________
71  *
72  *  Program to manipulate SGML instances.
73  *
74  *  These are data definitions for the "translating" portion of the program.
75  *
76  * ________________________________________________________________________
77  */
78
79 #define L_CURLY         '{'
80 #define R_CURLY         '}'
81
82 /* things to ignore when processing an element */
83 #define IGN_NONE        0
84 #define IGN_ALL         1
85 #define IGN_DATA        2
86 #define IGN_CHILDREN    3
87
88 /* for CheckRelation() */
89 typedef enum { RA_Current, RA_Related } RelAction_t;
90
91 typedef struct {
92     char        *name;          /* attribute name string */
93     char        *val;           /* attribute value string */
94     regexp      *rex;           /* attribute value reg expr (compiled) */
95 } AttPair_t;
96
97 typedef struct _Trans {
98     /* criteria */
99     char        *gi;            /* element name of tag under consideration */
100     char        **gilist;       /* list of element names (multiple gi's) */
101     char        *context;       /* context in tree - looking depth levels up */
102     regexp      *context_re;    /* tree heirarchy looking depth levels up */
103     int         depth;          /* number of levels to look up the tree */
104     AttPair_t   *attpair;       /* attr name-value pairs */
105     int         nattpairs;      /* number of name-value pairs */
106     char        *parent;        /* GI has this element as parent */
107     int         nth_child;      /* GI is Nth child of this of parent element */
108     char        *content;       /* element has this string in content */
109     regexp      *content_re;    /* content reg expr (compiled) */
110     char        *pattrset;      /* is this attr set (any value) in parent? */
111     char        *var_name;      /* variable name */
112     char        *var_value;     /* variable value */
113     char        *var_RE_name;   /* variable name (for VarREValue) */
114     regexp      *var_RE_value;  /* variable value (compiled, for VarREValue) */
115     Map_t       *relations;     /* various relations to check */
116
117     /* actions */
118     char        *starttext;     /* string to output at the start tag */
119     char        *endtext;       /* string to output at the end tag */
120     char        *replace;       /* string to replace this subtree with */
121     char        *message;       /* message for stderr, if element encountered */
122     int         ignore;         /* flag - ignore content or data of element? */
123     int         verbatim;       /* flag - pass content verbatim or do cmap? */
124     char        *var_reset;
125     char        *increment;     /* increment these variables */
126     Map_t       *set_var;       /* set these variables */
127     Map_t       *incr_var;      /* increment these variables */
128     char        *quit;          /* print message and exit */
129
130     /* pointers and bookkeeping */
131     int         my_id;          /* unique (hopefully) ID of this transpec */
132     int         use_id;         /* use transpec whose ID is this */
133     struct _Trans *use_trans;   /* pointer to other transpec */
134     struct _Trans *next;        /* linked list */
135     int         lineno;         /* line number of end of transpec */
136 } Trans_t;
137
138 #ifdef def
139 #undef def
140 #endif
141 #ifdef STORAGE
142 # define def
143 #else
144 # define def    extern
145 #endif
146
147 def Trans_t     *TrSpecs;
148 def Mapping_t   *CharMap;
149 def int         nCharMap;
150
151 /* prototypes for things defined in translate.c */
152 int     CheckRelation(Element_t *, char *, char *, char *, FILE*, RelAction_t);
153 Trans_t *FindTrans(Element_t *, int);
154 Trans_t *FindTransByName(char *);
155 Trans_t *FindTransByID(int);
156 void    PrepTranspecs(Element_t *);
157 void    ProcessOneSpec(char *, Element_t *, FILE *, int);
158 void    TransElement(Element_t *, FILE *, Trans_t *);
159 void    TranByAction(Element_t *, int, FILE *);
160 void    TranTByAction(Element_t *, char *, FILE *);
161
162 /* prototypes for things defined in tranvar.c */
163 void    ExpandSpecialVar(char *, Element_t *, FILE *, int);
164
165 /* prototypes for things defined in tables.c */
166 void    OSFtable(Element_t *, FILE *, char **, int);
167
168 /* ______________________________________________________________________ */
169