Changeset 1175:cae6ab372398
- Timestamp:
- 02/28/09 15:24:11 (3 years ago)
- Branch:
- default
- Location:
- trunk
- Files:
-
- 10 edited
-
include/libdodo/dataFormatJsonNode.h (modified) (1 diff)
-
include/libdodo/dataFormatJsonProcessor.h (modified) (1 diff)
-
include/libdodo/dataFormatXmlNode.h (modified) (1 diff)
-
include/libdodo/dataFormatXmlProcessor.h (modified) (12 diffs)
-
include/libdodo/dataMemoryShared.h (modified) (3 diffs)
-
src/dataFormatJsonNode.cc (modified) (1 diff)
-
src/dataFormatJsonProcessor.cc (modified) (1 diff)
-
src/dataFormatXmlNode.cc (modified) (1 diff)
-
src/dataFormatXmlProcessor.cc (modified) (43 diffs)
-
src/dataMemoryShared.cc (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/libdodo/dataFormatJsonNode.h
r1160 r1175 34 34 35 35 #include <libdodo/types.h> 36 #include <libdodo/toolsString.h>37 #include <libdodo/dataFormatJsonNodeEx.h>38 36 39 37 namespace dodo -
trunk/include/libdodo/dataFormatJsonProcessor.h
r1160 r1175 34 34 35 35 #include <libdodo/types.h> 36 #include <libdodo/toolsString.h>37 #include <libdodo/toolsFilesystem.h>38 #include <libdodo/dataFormatJsonProcessorEx.h>39 36 #include <libdodo/dataFormatJsonNode.h> 40 37 -
trunk/include/libdodo/dataFormatXmlNode.h
r1166 r1175 33 33 #include <libdodo/directives.h> 34 34 35 #include <algorithm>36 37 35 #include <libdodo/types.h> 38 #include <libdodo/toolsMisc.h>39 36 40 37 namespace dodo -
trunk/include/libdodo/dataFormatXmlProcessor.h
r1166 r1175 33 33 #include <libdodo/directives.h> 34 34 35 #ifdef LIBXML2_EXT 36 37 #include <libxml/parser.h> 38 #include <libxml/xmlmemory.h> 39 40 #endif 41 42 #include <libdodo/dataFormatXmlProcessorEx.h> 35 #include <libdodo/types.h> 43 36 #include <libdodo/dataFormatXmlNode.h> 44 #include <libdodo/types.h>45 37 46 38 namespace dodo … … 53 45 { 54 46 /** 47 * @struct __node 48 * @brief defines XML node properties 49 */ 50 struct __node; 51 52 /** 53 * @struct __document 54 * @brief defines XML document properties 55 */ 56 struct __doc; 57 58 /** 59 * @struct __attribute 60 * @brief defines XML attribute properties 61 */ 62 struct __attr; 63 64 /** 55 65 * @struct __nodeDef 56 66 * @brief defines processor tree definition … … 172 182 * @param file defines path to XML file 173 183 */ 174 virtual__info getFileInfo(const dodoString &file);184 static __info getFileInfo(const dodoString &file); 175 185 176 186 /** … … 178 188 * @param buffer defines XML buffer 179 189 */ 180 virtual__info getBufferInfo(const dodoString &buffer);190 static __info getBufferInfo(const dodoString &buffer); 181 191 182 192 /** … … 223 233 224 234 #ifdef LIBXML2_EXT 225 226 235 /** 227 236 * @return true if content is in CDATA 228 237 * @param xnode defines XML tree node 229 238 */ 230 bool isCDATA( xmlNodePtrxnode);239 bool isCDATA(const __node &xnode); 231 240 232 241 /** … … 235 244 * @param xnode defines XML tree node 236 245 */ 237 virtual dodoArray<node> parse( xmlNodePtrxnode);246 virtual dodoArray<node> parse(__node xnode); 238 247 239 248 /** … … 243 252 * @param chNode defines XML tree node 244 253 */ 245 virtual dodoArray<node> parse(const __nodeDef &definition,246 const xmlNodePtr chNode);254 virtual dodoArray<node> parse(const __nodeDef &definition, 255 const __node &xnode); 247 256 248 257 /** … … 251 260 * @param attributes defines buffer for attributes 252 261 */ 253 virtual void getAttributes(const xmlNodePtrxnode,262 virtual void getAttributes(const __node &xnode, 254 263 dodoStringMap &attributes); 255 264 … … 261 270 */ 262 271 virtual void getAttributes(const __nodeDef &definition, 263 const xmlNodePtrxnode,272 const __node &xnode, 264 273 dodoStringMap &attributes); 265 274 … … 269 278 * @param sample defines buffer for node 270 279 */ 271 virtual void getNodeInfo(const xmlNodePtr xnode, 272 node &sample); 273 280 virtual void getNodeInfo(const __node &xnode, 281 node &sample); 274 282 #endif 275 283 … … 277 285 278 286 #ifdef LIBXML2_EXT 279 280 /** 281 * @typedef xcharCmp 287 /** 288 * @typedef strCmp 282 289 * @brief defines name compare function 283 290 * @param one defines string to compare 284 291 * @param two defines string to compare 285 292 */ 286 typedef int (*xcharCmp)(const xmlChar *one, const xmlChar *two); 287 288 xcharCmp cmpFunc; ///< name compare function 293 typedef int (*strCmp)(const unsigned char *one, const unsigned char *two); 294 strCmp cmpFunc; ///< name compare function 289 295 290 296 /** … … 293 299 * @param node defines node content 294 300 */ 295 xmlNodePtr findNode(const __nodeDef &definition, 296 xmlNodePtr node); 297 298 xmlDocPtr document; ///< XML Document 299 xmlAttr *attribute; ///< XML attributes 300 301 /** 302 * catche libprocessor2 warnings 303 * @param data defines user-defined data 304 * @param error defines error descriptor 305 */ 306 static void errHandler(void *data, 307 xmlErrorPtr error); 308 301 __node findNode(const __nodeDef &definition, 302 const __node &node); 303 304 __doc *document; ///< XML Document 309 305 #endif 310 306 -
trunk/include/libdodo/dataMemoryShared.h
r1160 r1175 33 33 #include <libdodo/directives.h> 34 34 35 #include <sys/types.h>36 #include <sys/mman.h>37 38 #ifdef XSI_IPC39 40 #include <sys/ipc.h>41 #include <sys/shm.h>42 43 #else /*POSIX_SEMAPHORES*/44 45 #include <fcntl.h>46 47 #endif48 49 #include <libdodo/dataMemorySharedEx.h>50 #include <libdodo/toolsMisc.h>51 #include <libdodo/toolsCode.h>52 53 35 namespace dodo 54 36 { … … 57 39 namespace memory 58 40 { 41 /** 42 * @struct __key 43 * @brief defines shared memory key 44 */ 45 struct __key; 46 59 47 /** 60 48 * @class shared … … 143 131 int shm; ///< shared data descriptor 144 132 void *mshared; ///< shared data 133 #ifndef XSI_IPC 134 unsigned long size; ///< size of shared data 135 #endif 145 136 146 #ifdef XSI_IPC 147 148 int key; ///< key for the shared data 149 150 #else 151 152 dodoString key; ///< key for the shared data 153 unsigned long size; ///< size of shared data 154 155 #endif 137 __key *key; ///< key for the shared data 156 138 157 139 bool autogenerated; ///< true if key was autogenerated -
trunk/src/dataFormatJsonNode.cc
r1162 r1175 28 28 */ 29 29 30 #include <libdodo/directives.h> 31 32 #include <libdodo/types.h> 33 #include <libdodo/toolsString.h> 34 #include <libdodo/dataFormatJsonNodeEx.h> 30 35 #include <libdodo/dataFormatJsonNode.h> 31 36 -
trunk/src/dataFormatJsonProcessor.cc
r1166 r1175 28 28 */ 29 29 30 #include <libdodo/directives.h> 31 32 #include <libdodo/types.h> 33 #include <libdodo/toolsString.h> 34 #include <libdodo/toolsFilesystem.h> 35 #include <libdodo/dataFormatJsonProcessorEx.h> 36 #include <libdodo/dataFormatJsonNode.h> 30 37 #include <libdodo/dataFormatJsonProcessor.h> 31 38 -
trunk/src/dataFormatXmlNode.cc
r1162 r1175 28 28 */ 29 29 30 31 30 #include <libdodo/dataFormatXmlNode.h> 31 #include <libdodo/toolsMisc.h> 32 #include <libdodo/types.h> 32 33 33 34 using namespace dodo::data::format::xml; -
trunk/src/dataFormatXmlProcessor.cc
r1162 r1175 28 28 */ 29 29 30 30 #include <libdodo/directives.h> 31 32 #ifdef LIBXML2_EXT 33 34 #include <libxml/parser.h> 35 #include <libxml/xmlmemory.h> 36 37 namespace dodo 38 { 39 namespace data 40 { 41 namespace format 42 { 43 namespace xml 44 { 45 struct __node 46 { 47 /** 48 * constructor 49 */ 50 __node(); 51 52 53 /** 54 * constructor 55 */ 56 __node(xmlNodePtr node); 57 58 xmlNodePtr node; ///< represents internal libxml2 node data 59 }; 60 61 struct __doc 62 { 63 xmlDocPtr document; ///< represents internal libxml2 document data 64 }; 65 }; 66 }; 67 }; 68 }; 69 70 #endif 71 72 #include <libdodo/dataFormatXmlProcessorEx.h> 31 73 #include <libdodo/dataFormatXmlProcessor.h> 32 74 33 75 using namespace dodo::data::format::xml; 34 76 35 __info::__info(const dodoString &a_version, 36 const dodoString &a_encoding, 37 const dodoString &a_root, 38 int a_compression) : version(a_version), 39 encoding(a_encoding), 40 root(a_root), 41 compression(a_compression) 77 __node::__node(xmlNodePtr node) : node(node) 78 { 79 } 80 81 //------------------------------------------------------------------- 82 83 __node::__node() 84 { 85 } 86 87 //------------------------------------------------------------------- 88 89 __info::__info(const dodoString &version, 90 const dodoString &encoding, 91 const dodoString &root, 92 int compression) : version(version), 93 encoding(encoding), 94 root(root), 95 compression(compression) 42 96 { 43 97 } … … 85 139 //------------------------------------------------------------------- 86 140 141 #ifdef LIBXML2_EXT 142 143 void 144 errHandler(void *data, 145 xmlErrorPtr error) 146 { 147 } 148 149 #endif 150 151 //------------------------------------------------------------------- 152 153 87 154 processor::processor(processor &xt) 88 155 { … … 92 159 93 160 processor::processor() : icaseNames(false) 94 95 #ifdef LIBXML2_EXT 96 161 #ifdef LIBXML2_EXT 97 162 , 98 document(NULL) 99 100 #endif 101 102 { 103 #ifdef LIBXML2_EXT 104 163 document(new __doc) 164 #endif 165 { 166 #ifdef LIBXML2_EXT 105 167 xmlPedanticParserDefault(0); 106 168 xmlInitParser(); 107 xmlSetStructuredErrorFunc(NULL, processor::errHandler); 108 169 xmlSetStructuredErrorFunc(NULL, errHandler); 109 170 #endif 110 171 } … … 115 176 { 116 177 #ifdef LIBXML2_EXT 117 118 xmlFreeDoc(document); 119 178 xmlFreeDoc(document->document); 120 179 xmlCleanupParser(); 121 180 181 delete document; 122 182 #endif 123 183 } … … 128 188 129 189 bool 130 processor::isCDATA( xmlNodePtr chNode)131 { 132 xmlNodePtr xnode = chNode->children;190 processor::isCDATA(const __node &a_xnode) 191 { 192 xmlNodePtr xnode = a_xnode.node->children; 133 193 while (xnode != NULL) 134 194 { … … 153 213 { 154 214 #ifdef LIBXML2_EXT 155 156 xmlFreeDoc(document); 157 158 document = xmlParseFile(file.c_str()); 159 if (document == NULL) 215 xmlFreeDoc(document->document); 216 217 document->document = xmlParseFile(file.c_str()); 218 if (document->document == NULL) 160 219 { 161 220 xmlErrorPtr error = xmlGetLastError(); … … 170 229 } 171 230 } 172 173 231 #endif 174 232 … … 183 241 { 184 242 #ifdef LIBXML2_EXT 185 186 xmlFreeDoc(document); 187 188 document = xmlParseMemory(buffer.c_str(), buffer.size()); 189 if (document == NULL) 243 xmlFreeDoc(document->document); 244 245 document->document = xmlParseMemory(buffer.c_str(), buffer.size()); 246 if (document->document == NULL) 190 247 { 191 248 xmlErrorPtr error = xmlGetLastError(); … … 200 257 } 201 258 } 202 203 259 #endif 204 260 … … 212 268 { 213 269 #ifdef LIBXML2_EXT 214 215 xmlNodePtr xnode = xmlDocGetRootElement(document); 216 if (xnode == NULL) 270 __node xnode = xmlDocGetRootElement(document->document); 271 if (xnode.node == NULL) 217 272 { 218 273 xmlErrorPtr error = xmlGetLastError(); … … 230 285 xnode = findNode(definition, xnode); 231 286 287 if (xnode.node == NULL) 288 { 289 return node(); 290 } 291 232 292 node sample; 233 234 if (xnode == NULL) 293 getNodeInfo(xnode, sample); 294 295 getAttributes(definition, xnode, sample.attributes); 296 297 if (xnode.node->children == NULL) 235 298 { 236 299 return sample; 237 300 } 238 301 239 getNodeInfo(xnode, sample);240 241 getAttributes(definition, xnode, sample.attributes);242 243 if (xnode->children == NULL)244 {245 return sample;246 }247 248 302 sample.CDATA = isCDATA(xnode); 249 303 250 304 if (definition.allChildren) 251 305 { 252 xnode = xnode->children;306 xnode.node = xnode.node->children; 253 307 254 308 node one; … … 257 311 dodoArray<node>::iterator i, j; 258 312 259 while (xnode != NULL)260 { 261 if (xnode ->type != XML_ELEMENT_NODE)262 { 263 xnode = xnode->next;313 while (xnode.node != NULL) 314 { 315 if (xnode.node->type != XML_ELEMENT_NODE) 316 { 317 xnode.node = xnode.node->next; 264 318 265 319 continue; … … 272 326 one.CDATA = isCDATA(xnode); 273 327 274 if (xnode ->children != NULL)275 { 276 children = parse( xnode->children);328 if (xnode.node->children != NULL) 329 { 330 children = parse(__node(xnode.node->children)); 277 331 i = children.begin(); 278 332 j = children.end(); … … 283 337 } 284 338 285 sample.children[(char *)xnode ->name].push_back(one);339 sample.children[(char *)xnode.node->name].push_back(one); 286 340 287 341 initNode(one); 288 342 289 xnode = xnode->next;343 xnode.node = xnode.node->next; 290 344 } 291 345 } … … 297 351 for (; i != j; ++i) 298 352 { 299 sample.children.insert(make_pair(i->first, parse(i->second, xnode ->children)));353 sample.children.insert(make_pair(i->first, parse(i->second, xnode.node->children))); 300 354 } 301 355 } … … 303 357 304 358 return sample; 305 306 359 #else 307 308 360 return node(); 309 310 361 #endif 311 362 } … … 316 367 317 368 dodoArray<node> 318 processor::parse(const __nodeDef &definition,319 const xmlNodePtr chNode)320 { 321 xmlNodePtr xnode = chNode, subNode;369 processor::parse(const __nodeDef &definition, 370 const __node &a_xnode) 371 { 372 xmlNodePtr xnode = a_xnode.node, subNode; 322 373 323 374 node sample; 324 375 dodoArray<node> sampleArr; 325 376 326 if (icaseNames) 327 { 328 cmpFunc = xmlStrcasecmp; 329 } 330 else 331 { 332 cmpFunc = xmlStrcmp; 333 } 377 cmpFunc = icaseNames?xmlStrcasecmp:xmlStrcmp; 334 378 335 379 do … … 351 395 } 352 396 353 if (cmpFunc(xnode->ns->prefix, ( xmlChar *)definition.ns.c_str()) != 0)397 if (cmpFunc(xnode->ns->prefix, (unsigned char *)definition.ns.c_str()) != 0) 354 398 { 355 399 xnode = xnode->next; … … 359 403 } 360 404 361 if (cmpFunc(xnode->name, ( xmlChar *)definition.name.c_str()) != 0)405 if (cmpFunc(xnode->name, (unsigned char *)definition.name.c_str()) != 0) 362 406 { 363 407 xnode = xnode->next; … … 442 486 443 487 void 444 processor::errHandler(void *data,445 xmlErrorPtr error)446 {447 }448 449 //-------------------------------------------------------------------450 451 void452 488 processor::getAttributes(const __nodeDef &definition, 453 const xmlNodePtrxnode,489 const __node &xnode, 454 490 dodoStringMap &attributes) 455 491 { 456 attribute = xnode->properties;492 xmlAttrPtr attribute = xnode.node->properties; 457 493 458 494 if (definition.allAttributes) … … 460 496 while (attribute != NULL) 461 497 { 462 xmlChar *xChar = xmlGetProp(xnode, attribute->name);498 unsigned char *xChar = xmlGetProp(xnode.node, attribute->name); 463 499 if (xChar != NULL) 464 500 { … … 482 518 for (; iAttr != jAttr; ++iAttr) 483 519 { 484 if (xmlStrcmp(attribute->name, ( xmlChar *)iAttr->c_str()) == 0)520 if (xmlStrcmp(attribute->name, (unsigned char *)iAttr->c_str()) == 0) 485 521 { 486 xmlChar *xChar = xmlGetProp(xnode, attribute->name);522 unsigned char *xChar = xmlGetProp(xnode.node, attribute->name); 487 523 if (xChar != NULL) 488 524 { … … 501 537 for (; iAttr != jAttr; ++iAttr) 502 538 { 503 xmlChar *xChar = xmlGetProp(xnode, (xmlChar *)iAttr->c_str());539 unsigned char *xChar = xmlGetProp(xnode.node, (unsigned char *)iAttr->c_str()); 504 540 if (xChar != NULL) 505 541 { … … 516 552 517 553 void 518 processor::getAttributes(const xmlNodePtrxnode,554 processor::getAttributes(const __node &xnode, 519 555 dodoStringMap &attributes) 520 556 { 521 attribute = xnode->properties;557 xmlAttrPtr attribute = xnode.node->properties; 522 558 523 559 while (attribute != NULL) 524 560 { 525 xmlChar *xChar = xmlGetProp(xnode, attribute->name);561 unsigned char *xChar = xmlGetProp(xnode.node, attribute->name); 526 562 if (xChar != NULL) 527 563 { … … 537 573 538 574 void 539 processor::getNodeInfo(const xmlNodePtrxnode,540 node &resNode)541 { 542 if (xnode ->ns != NULL)543 { 544 resNode.ns.prefix = (char *)xnode ->ns->prefix;545 resNode.ns.href = (char *)xnode ->ns->href;546 } 547 548 if (xnode ->nsDef != NULL)549 { 550 resNode.nsDef.prefix = (char *)xnode ->nsDef->prefix;551 resNode.nsDef.href = (char *)xnode ->nsDef->href;552 } 553 554 if (xnode ->name != NULL)555 { 556 resNode.name.assign((char *)xnode ->name);557 } 558 559 xmlChar *xChar = xmlNodeListGetString(document, xnode->children, 1);575 processor::getNodeInfo(const __node &xnode, 576 node &resNode) 577 { 578 if (xnode.node->ns != NULL) 579 { 580 resNode.ns.prefix = (char *)xnode.node->ns->prefix; 581 resNode.ns.href = (char *)xnode.node->ns->href; 582 } 583 584 if (xnode.node->nsDef != NULL) 585 { 586 resNode.nsDef.prefix = (char *)xnode.node->nsDef->prefix; 587 resNode.nsDef.href = (char *)xnode.node->nsDef->href; 588 } 589 590 if (xnode.node->name != NULL) 591 { 592 resNode.name.assign((char *)xnode.node->name); 593 } 594 595 unsigned char *xChar = xmlNodeListGetString(document->document, xnode.node->children, 1); 560 596 if (xChar != NULL) 561 597 { … … 573 609 { 574 610 #ifdef LIBXML2_EXT 611 xmlDocPtr document = xmlParseFile(file.c_str()); 612 if (document == NULL) 613 { 614 xmlErrorPtr error = xmlGetLastError(); 615 616 if (error == NULL) 617 { 618 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETFILEINFO, exception::ERRNO_LIBDODO, PROCESSOREX_EMPTYDOCUMENT, DATAFORMATXMLPROCESSOREX_EMPTYDOCUMENT_STR, __LINE__, __FILE__, file); 619 } 620 else 621 { 622 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETFILEINFO, exception::ERRNO_LIBXML2, error->code, error->message, __LINE__, __FILE__, file); 623 } 624 } 625 626 __info i(document->version != NULL ? (char *)document->version : __dodostring__, 627 document->encoding != NULL ? (char *)document->encoding : __dodostring__, 628 (document->children != NULL && document->children->name != NULL) ? (char *)document->children->name : __dodostring__, 629 document->compression); 575 630 576 631 xmlFreeDoc(document); 577 632 578 document = xmlParseFile(file.c_str()); 579 if (document == NULL) 580 { 581 xmlErrorPtr error = xmlGetLastError(); 582 583 if (error == NULL) 584 { 585 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETFILEINFO, exception::ERRNO_LIBDODO, PROCESSOREX_EMPTYDOCUMENT, DATAFORMATXMLPROCESSOREX_EMPTYDOCUMENT_STR, __LINE__, __FILE__, file); 586 } 587 else 588 { 589 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETFILEINFO, exception::ERRNO_LIBXML2, error->code, error->message, __LINE__, __FILE__, file); 590 } 591 } 592 593 return __info(document->version != NULL ? (char *)document->version : __dodostring__, 594 document->encoding != NULL ? (char *)document->encoding : __dodostring__, 595 (document->children != NULL && document->children->name != NULL) ? (char *)document->children->name : __dodostring__, 596 document->compression); 597 633 return i; 598 634 #else 599 600 635 return __info(); 601 602 636 #endif 603 637 } … … 609 643 { 610 644 #ifdef LIBXML2_EXT 645 xmlDocPtr document = xmlParseMemory(buffer.c_str(), buffer.size()); 646 if (document == NULL) 647 { 648 xmlErrorPtr error = xmlGetLastError(); 649 650 if (error == NULL) 651 { 652 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETBUFFERINFO, exception::ERRNO_LIBDODO, PROCESSOREX_EMPTYDOCUMENT, DATAFORMATXMLPROCESSOREX_EMPTYDOCUMENT_STR, __LINE__, __FILE__); 653 } 654 else 655 { 656 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETBUFFERINFO, exception::ERRNO_LIBXML2, error->code, error->message, __LINE__, __FILE__); 657 } 658 } 659 660 __info i(document->version != NULL ? (char *)document->version : __dodostring__, 661 document->encoding != NULL ? (char *)document->encoding : __dodostring__, 662 (document->children != NULL && document->children->name != NULL) ? (char *)document->children->name : __dodostring__, 663 document->compression); 611 664 612 665 xmlFreeDoc(document); 613 666 614 document = xmlParseMemory(buffer.c_str(), buffer.size()); 615 if (document == NULL) 616 { 617 xmlErrorPtr error = xmlGetLastError(); 618 619 if (error == NULL) 620 { 621 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETBUFFERINFO, exception::ERRNO_LIBDODO, PROCESSOREX_EMPTYDOCUMENT, DATAFORMATXMLPROCESSOREX_EMPTYDOCUMENT_STR, __LINE__, __FILE__); 622 } 623 else 624 { 625 throw exception::basic(exception::ERRMODULE_DATAFORMATXMLPROCESSOR, PROCESSOREX_GETBUFFERINFO, exception::ERRNO_LIBXML2, error->code, error->message, __LINE__, __FILE__); 626 } 627 } 628 629 return __info(document->version != NULL ? (char *)document->version : __dodostring__, 630 document->encoding != NULL ? (char *)document->encoding : __dodostring__, 631 (document->children != NULL && document->children->name != NULL) ? (char *)document->children->name : __dodostring__, 632 document->compression); 633 667 return i; 634 668 #else 635 636 669 return __info(); 637 638 670 #endif 639 671 } … … 644 676 645 677 dodoArray<node> 646 processor::parse( xmlNodePtrxnode)678 processor::parse(__node xnode) 647 679 { 648 680 dodoArray<node> sample; … … 653 685 dodoArray<node>::iterator i, j; 654 686 655 while (xnode != NULL)656 { 657 if (xnode ->type != XML_ELEMENT_NODE)658 { 659 xnode = xnode->next;687 while (xnode.node != NULL) 688 { 689 if (xnode.node->type != XML_ELEMENT_NODE) 690 { 691 xnode.node = xnode.node->next; 660 692 661 693 continue; … … 668 700 one.CDATA = isCDATA(xnode); 669 701 670 if (xnode ->children != NULL)671 { 672 children = parse( xnode->children);702 if (xnode.node->children != NULL) 703 { 704 children = parse(__node(xnode.node->children)); 673 705 i = children.begin(); 674 706 j = children.end(); … … 683 715 initNode(one); 684 716 685 xnode = xnode->next;717 xnode.node = xnode.node->next; 686 718 } 687 719 … … 712 744 { 713 745 #ifdef LIBXML2_EXT 714 715 xmlFreeDoc(document); 716 717 document = xmlParseFile(file.c_str()); 718 if (document == NULL) 746 xmlFreeDoc(document->document); 747 748 document->document = xmlParseFile(file.c_str()); 749 if (document->document == NULL) 719 750 { 720 751 xmlErrorPtr error = xmlGetLastError(); … … 730 761 } 731 762 732 xmlNodePtr xnode = xmlDocGetRootElement(document );763 xmlNodePtr xnode = xmlDocGetRootElement(document->document); 733 764 if (xnode == NULL) 734 765 { … … 745 776 } 746 777 747 return *(parse(xnode).begin()); 748 778 return *(parse(__node(xnode)).begin()); 749 779 #else 750 751 780 return node(); 752 753 781 #endif 754 782 } … … 760 788 { 761 789 #ifdef LIBXML2_EXT 762 763 xmlFreeDoc(document); 764 765 document = xmlParseMemory(buffer.c_str(), buffer.size()); 766 if (document == NULL) 790 xmlFreeDoc(document->document); 791 792 document->document = xmlParseMemory(buffer.c_str(), buffer.size()); 793 if (document->document == NULL) 767 794 { 768 795 xmlErrorPtr error = xmlGetLastError(); … … 778 805 } 779 806 780 xmlNodePtr xnode = xmlDocGetRootElement(document );807 xmlNodePtr xnode = xmlDocGetRootElement(document->document); 781 808 if (xnode == NULL) 782 809 { … … 793 820 } 794 821 795 return *(parse(xnode).begin()); 796 822 return *(parse(__node(xnode)).begin()); 797 823 #else 798 799 824 return node(); 800 801 825 #endif 802 826 } … … 817 841 #ifdef LIBXML2_EXT 818 842 819 xmlNodePtr 843 __node 820 844 processor::findNode(const __nodeDef &definition, 821 xmlNodePtrxnode)822 { 823 xmlNodePtr one ;845 const __node &a_xnode) 846 { 847 xmlNodePtr one, xnode = a_xnode.node; 824 848 bool skip; 825 849 826 if (icaseNames) 827 { 828 cmpFunc = xmlStrcasecmp; 829 } 830 else 831 { 832 cmpFunc = xmlStrcmp; 833 } 850 cmpFunc = icaseNames?xmlStrcasecmp:xmlStrcmp; 834 851 835 852 while (xnode != NULL) … … 850 867 skip = true; 851 868 } 852 else if (cmpFunc(xnode->ns->prefix, ( xmlChar *)definition.ns.c_str()) != 0)869 else if (cmpFunc(xnode->ns->prefix, (unsigned char *)definition.ns.c_str()) != 0) 853 870 { 854 871 skip = true; … … 858 875 if (!skip && xnode->name != NULL) 859 876 { 860 if (cmpFunc(xnode->name, ( xmlChar *)definition.name.c_str()) == 0)877 if (cmpFunc(xnode->name, (unsigned char *)definition.name.c_str()) == 0) 861 878 { 862 879 return xnode; … … 864 881 } 865 882 866 one = findNode(definition, xnode->children);883 one = findNode(definition, __node(xnode->children)).node; 867 884 868 885 if (one != NULL) … … 874 891 } 875 892 876 return NULL;893 return __node(NULL); 877 894 } 878 895 … … 885 902 { 886 903 #ifdef LIBXML2_EXT 887 888 xmlFreeDoc(document); 889 document = NULL; 890 904 xmlFreeDoc(document->document); 905 document->document = NULL; 891 906 #endif 892 907 } -
trunk/src/dataMemoryShared.cc
r1162 r1175 28 28 */ 29 29 30 30 #include <libdodo/directives.h> 31 #include <libdodo/types.h> 32 33 #include <sys/types.h> 34 #include <sys/mman.h> 35 36 #ifdef XSI_IPC 37 #include <sys/ipc.h> 38 #include <sys/shm.h> 39 #else /*POSIX_SEMAPHORES*/ 40 #include <fcntl.h> 41 #endif 42 43 namespace dodo 44 { 45 namespace data 46 { 47 namespace memory 48 { 49 struct __key 50 { 51 #ifdef XSI_IPC 52 int key; ///< key for the shared data 53 #else 54 dodoString key; ///< key for the shared data 55 #endif 56 }; 57 }; 58 }; 59 }; 60 61 #include <libdodo/toolsMisc.h> 62 #include <libdodo/toolsCode.h> 31 63 #include <libdodo/dataMemoryShared.h> 64 #include <libdodo/dataMemorySharedEx.h> 32 65 33 66 using namespace dodo::data::memory; … … 41 74 shared::shared() : mshared(NULL), 42 75 autogenerated(false), 43 76 key(new __key), 44 77 #ifndef XSI_IPC 45 46 78 size(0), 47 48 #endif 49 79 #endif 50 80 shm(-1) 51 81 { … … 56 86 shared::shared(int a_key) : mshared(NULL), 57 87 autogenerated(false), 58 88 key(new __key), 59 89 #ifndef XSI_IPC 60 61 90 size(0), 62 63 #endif 64 91 #endif 65 92 shm(-1) 66 93 { 67 94 #ifdef XSI_IPC 68 69 95 if (a_key == 0) 70 96 { 71 key = tools::misc::iRandom();97 key->key = tools::misc::iRandom(); 72 98 73 99 autogenerated = true; … … 75 101 else 76 102 { 77 key = a_key; 78 } 79 103 key->key = a_key; 104 } 80 105 #else 81 106 82 107 #ifdef __FreeBSD__ 83 84 key = "/tmp/"; 85 86 #else 87 88 key = '/'; 89 108 key->key = "/tmp/"; 109 #else 110 key->key = '/'; 90 111 #endif 91 112 … … 95 116 tools::misc::random(_key, SH_KEY_SIZE / 2 - 1); 96 117 97 key .append(tools::code::binToHex(dodoString(_key, SH_KEY_SIZE / 2 - 1)));118 key->key.append(tools::code::binToHex(dodoString(_key, SH_KEY_SIZE / 2 - 1))); 98 119 99 120 autogenerated = true; … … 104 125 memcpy(_key, &a_key, 4); 105 126 106 key .append(tools::code::binToHex(dodoString(_key, 4)));107 } 108 109 shm = shm_open(key .c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);127 key->key.append(tools::code::binToHex(dodoString(_key, 4))); 128 } 129 130 shm = shm_open(key->key.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); 110 131 if (shm == -1) 111 132 { 112 133 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_SHARED, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 113 134 } 114 115 135 #endif 116 136 } … … 121 141 { 122 142 #ifdef XSI_IPC 123 124 143 if (shm != -1 && autogenerated) 125 144 { 126 145 shmctl(shm, IPC_RMID, NULL); 127 146 } 128 129 #else 130 147 #else 131 148 if (shm != -1) 132 149 { … … 138 155 if (autogenerated) 139 156 { 140 shm_unlink(key.c_str()); 141 } 142 } 143 #endif 157 shm_unlink(key->key.c_str()); 158 } 159 } 160 #endif 161 162 delete key; 144 163 } 145 164 … … 152 171 153 172 #ifdef XSI_IPC 154 155 173 if (a_key == 0) 156 174 { 157 key = tools::misc::iRandom();175 key->key = tools::misc::iRandom(); 158 176 159 177 autogenerated = true; … … 163 181 key = a_key; 164 182 } 165 166 183 #else 167 184 168 185 #ifdef __FreeBSD__ 169 170 key = "/tmp/"; 171 172 #else 173 174 key = '/'; 175 186 key->key = "/tmp/"; 187 #else 188 key->key = '/'; 176 189 #endif 177 190 … … 181 194 tools::misc::random(_key, SH_KEY_SIZE / 2 - 1); 182 195 183 key .append(tools::code::binToHex(dodoString(_key, SH_KEY_SIZE / 2 - 1)));196 key->key.append(tools::code::binToHex(dodoString(_key, SH_KEY_SIZE / 2 - 1))); 184 197 185 198 autogenerated = true; … … 190 203 memcpy(_key, &a_key, 4); 191 204 192 key .append(tools::code::binToHex(dodoString(_key, 4)));193 } 194 195 shm = shm_open(key .c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);205 key->key.append(tools::code::binToHex(dodoString(_key, 4))); 206 } 207 208 shm = shm_open(key->key.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); 196 209 if (shm == -1) 197 210 { 198 211 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_OPEN, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 199 212 } 200 201 213 #endif 202 214 } … … 208 220 { 209 221 #ifdef XSI_IPC 210 211 222 if (shm != -1 && autogenerated) 212 223 { … … 216 227 } 217 228 } 218 219 #else 220 229 #else 221 230 if (shm != -1) 222 231 { … … 231 240 if (autogenerated) 232 241 { 233 if (shm_unlink(key .c_str()) == -1)242 if (shm_unlink(key->key.c_str()) == -1) 234 243 { 235 244 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_CLOSE, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); … … 246 255 { 247 256 #ifdef XSI_IPC 248 249 257 int shm = shmget(a_key, 0, O_RDWR); 250 258 if (shm == -1) … … 257 265 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_REMOVE, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 258 266 } 259 260 267 #else 261 268 262 269 #ifdef __FreeBSD__ 263 264 270 dodoString key = "/tmp/"; 265 266 #else 267 271 #else 268 272 dodoString key = "/"; 269 270 273 #endif 271 274 … … 279 282 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_REMOVE, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 280 283 } 281 282 284 #endif 283 285 } … … 291 293 292 294 #ifdef XSI_IPC 293 294 295 if (a_size == 0) 295 296 { 296 shm = shmget(key , 0, O_RDWR);297 shm = shmget(key->key, 0, O_RDWR); 297 298 if (shm == -1) 298 299 { … … 302 303 else 303 304 { 304 shm = shmget(key , a_size, IPC_CREAT | O_RDWR);305 shm = shmget(key->key, a_size, IPC_CREAT | O_RDWR); 305 306 if (shm == -1) 306 307 { … … 314 315 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_MAP, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 315 316 } 316 317 #else 318 317 #else 319 318 if (a_size == 0) 320 319 { … … 343 342 throw exception::basic(exception::ERRMODULE_DATAMEMORYSHARED, SHAREDEX_MAP, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 344 343 } 345 346 344 #endif 347 345 … … 357 355 { 358 356 #ifdef XSI_IPC 359 360 357 if (shmdt(mshared) == -1) 361 362 #else 363 358 #else 364 359 if (munmap(mshared, size) == -1) 365 366 360 #endif 367 361 { … … 387 381 { 388 382 #ifdef XSI_IPC 389 390 383 if (shm == -1) 391 384 { 392 shm = shmget(key , 0, O_RDWR);385 shm = shmget(key->key, 0, O_RDWR); 393 386 if (shm == -1) 394 387 { … … 405 398 406 399 return ds.shm_segsz; 407 408 #else 409 400 #else 410 401 struct stat st; 411 402 … … 416 407 417 408 return st.st_size; 418 419 #endif 420 } 421 422 //------------------------------------------------------------------- 423 409 #endif 410 } 411 412 //------------------------------------------------------------------- 413
Note: See TracChangeset
for help on using the changeset viewer.
