1 /*************************************************************************** 2 * Copyright (C) 2007 by Jesus Arias Fisteus * 3 * jaf@it.uc3m.es * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 ***************************************************************************/ 20 21 /* 22 * types.h 23 * 24 */ 25 26 #ifndef TYPES_H 27 #define TYPES_H 28 29 30 31 #define DTD_MASK(x) (1<<(x)) 32 33 34 35 36 /* defaultDecl */ 37 typedef enum { 38 DEFDECL_DEFAULT, 39 DEFDECL_REQUIRED, 40 DEFDECL_IMPLIED, 41 DEFDECL_FIXED 42 } defaultDecl_t; 43 44 45 /* attType */ 46 #define ATTTYPE_CDATA -2 47 #define ATTTYPE_ID -3 48 #define ATTTYPE_IDREF -4 49 #define ATTTYPE_IDREFS -5 50 #define ATTTYPE_ENTITY -6 51 #define ATTTYPE_ENTITIES -7 52 #define ATTTYPE_NMTOKEN -8 53 #define ATTTYPE_NMTOKENS -9 54 #define ATTTYPE_ENUMERATED -10 55 #define ATTTYPE_NOTATION -11 56 57 58 /* contentspec type */ 59 typedef enum { 60 CONTTYPE_NONE, /* no v�lido: elemento no definido en el DTD */ 61 CONTTYPE_EMPTY, 62 CONTTYPE_ANY, 63 CONTTYPE_MIXED, 64 CONTTYPE_CHILDREN 65 } contentType_t; 66 67 68 69 struct _att_data { 70 char name[ATT_NAME_LEN]; 71 int attType; 72 defaultDecl_t defaultDecl; 73 int defaults; 74 int environment; 75 }; 76 77 typedef struct _att_data att_data_t; 78 79 80 81 82 struct _elm_data { 83 char name[ELM_NAME_LEN]; 84 contentType_t contenttype[DTD_NUM]; 85 int contentspec[DTD_NUM]; 86 int attlist[DTD_NUM][ELM_ATTLIST_LEN]; 87 int environment; 88 }; 89 90 typedef struct _elm_data elm_data_t; 91 92 93 94 95 96 97 98 99 /* para codificar contentspec en el buffer */ 100 #define CSPEC_PAR_O 0x01 /* 0000 00 01 '(' */ 101 #define CSPEC_PAR_C 0x02 /* 0000 00 10 ')' */ 102 103 #define CSPEC_AST 0x04 /* 0000 01 00 '*' */ 104 #define CSPEC_MAS 0x08 /* 0000 10 00 '+' */ 105 #define CSPEC_INT 0x0c /* 0000 11 00 '?' */ 106 107 #define CSPEC_CHOICE 0x10 /* 0001 00 00 '|' */ 108 109 #define CSPEC_ELM_MASK 0x80 /* 1000 00 00 */ 110 #define CSPEC_PAR_MASK 0x03 /* 0000 00 11 */ 111 #define CSPEC_NUM_MASK 0x0C /* 0000 11 00 */ 112 113 #define CSPEC_ISPAR(x) (!((x) & CSPEC_ELM_MASK) && ((x) & CSPEC_PAR_MASK)) 114 #define CSPEC_PAR(x) ((x) & CSPEC_PAR_MASK) 115 #define CSPEC_ISCHOICE(x) ((x) & CSPEC_CHOICE) 116 #define CSPEC_NUM(x) (((x) & CSPEC_NUM_MASK)) 117 #define CSPEC_ISELM(x) ((x) & CSPEC_ELM_MASK) 118 #define CSPEC_ELM(x) ((x) & ~CSPEC_ELM_MASK) 119 120 #endif 121 122 123