1 /*************************************************************************** 2 $RCSfile$ 3 ------------------- 4 cvs : $Id$ 5 begin : Fri Jul 04 2003 6 copyright : (C) 2003 by Martin Preuss 7 email : martin@libchipcard.de 8 9 *************************************************************************** 10 * * 11 * This library is free software; you can redistribute it and/or * 12 * modify it under the terms of the GNU Lesser General Public * 13 * License as published by the Free Software Foundation; either * 14 * version 2.1 of the License, or (at your option) any later version. * 15 * * 16 * This library is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 19 * Lesser General Public License for more details. * 20 * * 21 * You should have received a copy of the GNU Lesser General Public * 22 * License along with this library; if not, write to the Free Software * 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 24 * MA 02111-1307 USA * 25 * * 26 ***************************************************************************/ 27 28 #ifndef GWENHYWFAR_MSGENGINE_P_H 29 #define GWENHYWFAR_MSGENGINE_P_H 30 31 #include <gwenhywfar/gwenhywfarapi.h> 32 #include <gwenhywfar/msgengine.h> 33 #include <gwenhywfar/db.h> 34 #include <gwenhywfar/stringlist.h> 35 #include <gwenhywfar/buffer.h> 36 #include <gwenhywfar/inherit.h> 37 38 39 #define GWEN_MSGENGINE_CHARSTOESCAPE ":+\'" 40 #define GWEN_MSGENGINE_DEFAULT_GROUPDELIM ":" 41 #define GWEN_MSGENGINE_DEFAULT_DELIMITERS ":+\'" 42 #define GWEN_MSGENGINE_VARNAME_WIDTH 30 43 #define GWEN_MSGENGINE_TYPENAME_WIDTH 10 44 45 #define GWEN_MSGENGINE_SHOW_FLAGS_OPTIONAL 0x00010000 46 #define GWEN_MSGENGINE_TRUSTEDDATA_MAXPOS 32 47 48 49 struct GWEN__MSGENGINE { 50 GWEN_INHERIT_ELEMENT(GWEN_MSGENGINE) 51 GWEN_XMLNODE *defs; 52 int ownDefs; 53 char escapeChar; 54 char *charsToEscape; 55 char *delimiters; 56 /*char *secMode; */ 57 /*unsigned int protocolVersion; */ 58 GWEN_DB_NODE *globalValues; 59 60 GWEN_MSGENGINE_TYPEREAD_PTR typeReadPtr; 61 GWEN_MSGENGINE_TYPEWRITE_PTR typeWritePtr; 62 GWEN_MSGENGINE_TYPECHECK_PTR typeCheckPtr; 63 64 GWEN_MSGENGINE_BINTYPEREAD_PTR binTypeReadPtr; 65 GWEN_MSGENGINE_BINTYPEWRITE_PTR binTypeWritePtr; 66 67 GWEN_MSGENGINE_GETCHARVALUE_PTR getCharValuePtr; 68 GWEN_MSGENGINE_GETINTVALUE_PTR getIntValuePtr; 69 70 GWEN_MSGENGINE_GETGLOBALVALUES_PTR getGlobalValuesPtr; 71 72 GWEN_MSGENGINE_FREEDATA_PTR freeDataPtr; 73 74 GWEN_MSGENGINE_TRUSTEDDATA *trustInfos; 75 void *inheritorData; 76 77 uint32_t usage; 78 }; 79 80 81 int GWEN_MsgEngine__WriteValue(GWEN_MSGENGINE *e, 82 GWEN_BUFFER *gbuf, 83 GWEN_BUFFER *data, 84 GWEN_XMLNODE *node); 85 86 int GWEN_MsgEngine__WriteElement(GWEN_MSGENGINE *e, 87 GWEN_BUFFER *gbuf, 88 GWEN_XMLNODE *node, 89 GWEN_DB_NODE *gr, 90 int loopNr, 91 int isOptional, 92 GWEN_XMLNODE_PATH *nodePath); 93 94 int GWEN_MsgEngine__WriteGroup(GWEN_MSGENGINE *e, 95 GWEN_BUFFER *gbuf, 96 GWEN_XMLNODE *node, /** format node */ 97 GWEN_XMLNODE *rnode, /** reference node */ 98 GWEN_DB_NODE *gr, 99 int groupIsOptional, 100 GWEN_XMLNODE_PATH *nodePath); 101 102 int GWEN_MsgEngine__ShowElement(GWEN_MSGENGINE *e, 103 const char *path, 104 GWEN_XMLNODE *node, 105 GWEN_STRINGLIST *sl, 106 uint32_t flags); 107 108 int GWEN_MsgEngine__ShowGroup(GWEN_MSGENGINE *e, 109 const char *path, 110 GWEN_XMLNODE *node, 111 GWEN_STRINGLIST *sl, 112 uint32_t flags); 113 114 int GWEN_MsgEngine__ListElement(GWEN_MSGENGINE *e, 115 const char *path, 116 GWEN_XMLNODE *node, 117 GWEN_STRINGLIST *sl, 118 GWEN_XMLNODE *listNode, 119 uint32_t flags); 120 121 int GWEN_MsgEngine__ListGroup(GWEN_MSGENGINE *e, 122 const char *path, 123 GWEN_XMLNODE *node, 124 GWEN_STRINGLIST *sl, 125 GWEN_XMLNODE *listNode, 126 uint32_t flags); 127 128 int GWEN_MsgEngine__ReadValue(GWEN_MSGENGINE *e, 129 GWEN_BUFFER *msgbuf, 130 GWEN_XMLNODE *node, 131 GWEN_XMLNODE *rnode, 132 GWEN_BUFFER *vbuf, 133 const char *delimiters, 134 uint32_t flags); 135 136 int GWEN_MsgEngine__ReadGroup(GWEN_MSGENGINE *e, 137 GWEN_BUFFER *msgbuf, 138 GWEN_XMLNODE *node, 139 GWEN_XMLNODE *rnode, 140 GWEN_DB_NODE *gr, 141 const char *delimiters, 142 uint32_t flags); 143 144 /** 145 * @param dnode node of the element to transform 146 */ 147 const char *GWEN_MsgEngine__findInValues(GWEN_MSGENGINE *e, 148 GWEN_XMLNODE *node, 149 GWEN_XMLNODE *dnode, 150 const char *name, 151 unsigned int *datasize); 152 153 const char *GWEN_MsgEngine__TransformValue(GWEN_MSGENGINE *e, 154 const char *pvalue, 155 GWEN_XMLNODE *node, 156 GWEN_XMLNODE *dnode, 157 unsigned int *datasize); 158 const char *GWEN_MsgEngine__SearchForValue(GWEN_MSGENGINE *e, 159 GWEN_XMLNODE *node, 160 GWEN_XMLNODE_PATH *nodePath, 161 const char *name, 162 unsigned int *datasize); 163 int GWEN_MsgEngine__IsCharTyp(GWEN_MSGENGINE *e, const char *type); 164 int GWEN_MsgEngine__IsIntTyp(GWEN_MSGENGINE *e, const char *type); 165 int GWEN_MsgEngine__IsBinTyp(GWEN_MSGENGINE *e, const char *type); 166 167 int GWEN_MsgEngine_GetHighestTrustLevel(GWEN_XMLNODE *node, 168 GWEN_XMLNODE *refnode); 169 170 GWEN_DB_NODE *GWEN_MsgEngine__GetGlobalValues(GWEN_MSGENGINE *e); 171 172 GWEN_XMLNODE *GWEN_MsgEngine__GetGroup(GWEN_MSGENGINE *e, 173 GWEN_XMLNODE *node, 174 const char *t, 175 int version, 176 const char *pvalue); 177 GWEN_XMLNODE *GWEN_MsgEngine_GetGroup(GWEN_MSGENGINE *e, 178 GWEN_XMLNODE *node, 179 const GWEN_XMLNODE_PATH *nodePath, 180 const char *t, 181 int version, 182 const char *pvalue); 183 184 int GWEN_MsgEngine__GetInline(GWEN_MSGENGINE *e, 185 GWEN_XMLNODE *node, 186 GWEN_BUFFER *mbuf); 187 188 189 190 struct GWEN_MSGENGINE_TRUSTEDDATA { 191 GWEN_MSGENGINE_TRUSTEDDATA *next; 192 char *data; 193 unsigned int size; 194 char *description; 195 unsigned int trustLevel; 196 char *replacement; 197 unsigned int positions[GWEN_MSGENGINE_TRUSTEDDATA_MAXPOS]; 198 unsigned int posCount; 199 unsigned int posPointer; 200 }; 201 202 203 204 #endif 205 206