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