00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifdef _FEDM_XML_SUPPORT
00036
00037
00038 #include "FEDM_XmlReaderCfgProfileModul.h"
00039 #include "FEDM_DataBase.h"
00040 #include "FEDM_Xml.h"
00041 #include <time.h>
00042
00043 #if _MSC_VER >= 1400
00044 #pragma warning(disable : 4996)
00045 #endif
00046
00047 #ifdef _FEDM_LINUX
00048 #include <string.h>
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 FEDM_XMLReaderCfgProfileModul::FEDM_XMLReaderCfgProfileModul()
00067 {
00068 m_wsDocType = L"";
00069 m_wsDocVer = L"";
00070 m_wsComment = L"";
00071 m_wsFedmVer = L"";
00072 m_wsDate = L"";
00073 m_wsTime = L"";
00074
00075 m_ReaderRequirement.Init();
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 FEDM_XMLReaderCfgProfileModul::~FEDM_XMLReaderCfgProfileModul()
00089 {
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 int FEDM_XMLReaderCfgProfileModul::SerializeIn(FEDM_DataBase* pReader, char* sFileName)
00109 {
00110 FEDM_CHK5(pReader);
00111 FEDM_CHK5(sFileName);
00112
00113 char cValue[64];
00114 int iTmp[3];
00115 unsigned int i = 0;
00116 unsigned int uiTmp;
00117 int iBack = 0;
00118 FEDM_XML_TREEITEM* root = NULL;
00119 FEDM_XML_TREEITEM* parent = NULL;
00120 FEDM_XML_TREEITEM* child = NULL;
00121
00122 memset(iTmp, 0, 3);
00123
00124
00125 iBack = OpenDoc(sFileName, "r");
00126 if(iBack)
00127 return iBack;
00128
00129
00130 if(IsXmlDoc())
00131 {
00132 CloseDoc();
00133 return m_iLastError;
00134 }
00135
00136
00137 if(HasOBIDTag())
00138 {
00139 CloseDoc();
00140 return m_iLastError;
00141 }
00142
00143
00144 if(ReadDoc())
00145 {
00146 CloseDoc();
00147 return m_iLastError;
00148 }
00149
00150 CloseDoc();
00151
00152
00153
00154 root = FindTag(FEDM_XML_TAG_OBID_UC);
00155 if(root == NULL)
00156 return m_iLastError;
00157 AddTagItem(NULL, root);
00158
00159
00160 child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
00161 if(child == NULL)
00162 {
00163 DeleteXmlTree();
00164 return m_iLastError;
00165 }
00166 AddTagItem(root, child);
00167 parent = child;
00168
00169
00170 child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
00171 if(child == NULL)
00172 {
00173 DeleteXmlTree();
00174 return m_iLastError;
00175 }
00176 if(child->sValue != FEDM_XML_STRING_DOC_TYPE_4_UC)
00177 {
00178 delete child;
00179 DeleteXmlTree();
00180 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00181 }
00182 m_wsDocType = child->sValue;
00183 AddTagItem(parent, child);
00184
00185
00186 child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
00187 if(child == NULL)
00188 {
00189 DeleteXmlTree();
00190 return m_iLastError;
00191 }
00192 if(child->sValue != FEDM_XML_STRING_PROFILE_DOC_VERSION_UC)
00193 {
00194 delete child;
00195 DeleteXmlTree();
00196 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_VERSION);
00197 }
00198 m_wsDocVer = child->sValue;
00199 AddTagItem(parent, child);
00200
00201
00202 child = FindTag(FEDM_XML_TAG_COMMENT_UC);
00203 if(child != NULL)
00204 {
00205 AddTagItem(parent, child);
00206 m_wsComment = child->sValue;
00207 }
00208
00209
00210 child = FindTag(FEDM_XML_TAG_READER_UC);
00211 if(child == NULL)
00212 {
00213 DeleteXmlTree();
00214 return m_iLastError;
00215 }
00216 AddTagItem(root, child);
00217 parent = child;
00218
00219
00220 child = FindTag(FEDM_XML_TAG_READER_TYPE_UC);
00221 if(child != NULL)
00222 {
00223 AddTagItem(parent, child);
00224 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00225 {
00226 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00227 for(i = 0; i < child->sValue.length(); i++)
00228 cValue[i] = (char)(child->sValue.c_str())[i];
00229
00230 sscanf(cValue, "%u", &uiTmp);
00231 if(uiTmp != pReader->GetReaderType())
00232 {
00233 DeleteXmlTree();
00234 FEDM_RETURN(FEDM_ERROR_WRONG_READER_TYPE);
00235 }
00236 }
00237 else
00238 {
00239 DeleteXmlTree();
00240 FEDM_RETURN(FEDM_XML_ERROR_NO_TAG_VALUE);
00241 }
00242 }
00243
00244 m_ReaderRequirement.Init();
00245
00246
00247 child = FindTag(FEDM_XML_TAG_CFG_RESET_UC);
00248 if(child != NULL)
00249 {
00250 AddTagItem(parent, child);
00251 if(child->sValue.length()>0 && child->sValue.length()<2)
00252 {
00253 memset(cValue, 0, 2);
00254 for(i = 0; i < 1; i++)
00255 cValue[i] = (char)(child->sValue.c_str())[i];
00256 sscanf(cValue, "%X", &uiTmp);
00257 if(uiTmp == 1)
00258 m_ReaderRequirement.bCfgReset = true;
00259 }
00260 }
00261
00262
00263 child = FindTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC,
00264 FEDM_XML_TAG_CONTROLLER_TYPE_UC,
00265 L"RFC",
00266 false,
00267 true);
00268 if(child != NULL)
00269 {
00270 AddTagItem(parent, child);
00271 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00272 {
00273 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00274 for(i = 0; i < child->sValue.length(); i++)
00275 cValue[i] = (char)(child->sValue.c_str())[i];
00276 sscanf(cValue, "%d.%d.%d", &iTmp[0], &iTmp[1], &iTmp[2]);
00277 uiTmp = (iTmp[0]<<16) + (iTmp[1]<<8) + iTmp[2];
00278 m_ReaderRequirement.mapControllerFW.insert(make_pair(FEDM_CNTRL_TYPE_RFC, uiTmp));
00279 m_ReaderRequirement.bHasRfcFw = true;
00280 }
00281 }
00282
00283
00284 child = FindTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC,
00285 FEDM_XML_TAG_CONTROLLER_TYPE_UC,
00286 L"ACC",
00287 false,
00288 true);
00289 if(child != NULL)
00290 {
00291 AddTagItem(parent, child);
00292 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00293 {
00294 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00295 for(i = 0; i < child->sValue.length(); i++)
00296 cValue[i] = (char)(child->sValue.c_str())[i];
00297 sscanf(cValue, "%d.%d.%d", &iTmp[0], &iTmp[1], &iTmp[2]);
00298 uiTmp = (iTmp[0]<<16) + (iTmp[1]<<8) + iTmp[2];
00299 m_ReaderRequirement.mapControllerFW.insert(make_pair(FEDM_CNTRL_TYPE_ACC, uiTmp));
00300 m_ReaderRequirement.bHasAccFw = true;
00301 }
00302 }
00303
00304
00305 child = FindTag(FEDM_XML_TAG_CUSTOMER_ID_UC);
00306 if(child != NULL)
00307 {
00308 AddTagItem(parent, child);
00309 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00310 {
00311 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00312 for(i = 0; i < child->sValue.length(); i++)
00313 cValue[i] = (char)(child->sValue.c_str())[i];
00314 sscanf(cValue, "%X", &m_ReaderRequirement.uiCumstomerID);
00315 m_ReaderRequirement.bHasCustID = true;
00316 }
00317 }
00318
00319
00320 child = FindTag(FEDM_XML_TAG_READER_FUNCTIONS_UC);
00321 if(child != NULL)
00322 {
00323 AddTagItem(parent, child);
00324 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00325 {
00326 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00327 for(i = 0; i < child->sValue.length(); i++)
00328 cValue[i] = (char)(child->sValue.c_str())[i];
00329 sscanf(cValue, "%X", &m_ReaderRequirement.uiReaderFunction);
00330 m_ReaderRequirement.bHasRdrFunc = true;
00331 }
00332 }
00333
00334
00335 child = FindTag(FEDM_XML_TAG_TRANSPONDER_DRIVER_UC);
00336 if(child != NULL)
00337 {
00338 AddTagItem(parent, child);
00339 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00340 {
00341 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00342 for(i = 0; i < child->sValue.length(); i++)
00343 cValue[i] = (char)(child->sValue.c_str())[i];
00344 sscanf(cValue, "%X", &m_ReaderRequirement.uiTransponderDriver);
00345 m_ReaderRequirement.bHasTrpDrv = true;
00346 }
00347 }
00348
00349
00350 child = FindTag(FEDM_XML_TAG_FREQUENCY_UC);
00351 if(child != NULL)
00352 {
00353 AddTagItem(parent, child);
00354 if(child->sValue.length()>0 && child->sValue.length()<FEDM_MAX_NAME_SIZE)
00355 {
00356 memset(cValue, 0, FEDM_MAX_NAME_SIZE);
00357 for(i = 0; i < child->sValue.length(); i++)
00358 cValue[i] = (char)(child->sValue.c_str())[i];
00359 sscanf(cValue, "%d", &m_ReaderRequirement.uiFrequency);
00360 m_ReaderRequirement.bHasFrequency = true;
00361 }
00362 }
00363
00364
00365
00366 iBack = pReader->SerializeProfileIn(this, root);
00367 if(iBack)
00368 {
00369 DeleteXmlTree();
00370 return iBack;
00371 }
00372
00373
00374 DeleteXmlTree();
00375
00376 FEDM_RETURN(FEDM_OK);
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 int FEDM_XMLReaderCfgProfileModul::SerializeOut(FEDM_DataBase* pReader, char* sFileName)
00392 {
00393 FEDM_CHK5(pReader);
00394 FEDM_CHK5(sFileName);
00395
00396 int iBack = 0;
00397
00398 wchar_t wcTmp[128];
00399 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00400 time_t ltime;
00401 struct tm *tmtime;
00402 #endif
00403 FEDM_XML_TREEITEM* root = NULL;
00404 FEDM_XML_TREEITEM* parent = NULL;
00405 FEDM_XML_TREEITEM* child = NULL;
00406 map<unsigned int, unsigned int>::iterator itor;
00407
00408
00409
00410 root = BuildTag(FEDM_XML_TAG_OBID_UC);
00411 if(root == NULL)
00412 {
00413 return m_iLastError;
00414 }
00415 AddTagItem(NULL, root);
00416
00417
00418 child = BuildTag(FEDM_XML_TAG_FILE_HDR_UC);
00419 if(child == NULL)
00420 {
00421 DeleteXmlTree();
00422 return m_iLastError;
00423 }
00424 AddTagItem(root, child);
00425 parent = child;
00426
00427
00428 child = BuildTag(FEDM_XML_TAG_DOC_TYPE_UC, false);
00429 if(child == NULL)
00430 {
00431 DeleteXmlTree();
00432 return m_iLastError;
00433 }
00434 AddTagValue(child, FEDM_XML_STRING_DOC_TYPE_4_UC);
00435 AddTagItem(parent, child);
00436
00437
00438 child = BuildTag(FEDM_XML_TAG_DOC_VERSION_UC, false);
00439 if(child == NULL)
00440 {
00441 DeleteXmlTree();
00442 return m_iLastError;
00443 }
00444 AddTagValue(child, FEDM_XML_STRING_PROFILE_DOC_VERSION_UC);
00445 AddTagItem(parent, child);
00446
00447
00448 child = BuildTag(FEDM_XML_TAG_FEDM_VERSION_UC, false);
00449 if(child == NULL)
00450 {
00451 DeleteXmlTree();
00452 return m_iLastError;
00453 }
00454 AddTagValue(child, FEDM_VERSION_UC);
00455 AddTagItem(parent, child);
00456
00457
00458 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00459 child = BuildTag(FEDM_XML_TAG_DATE_UC, false);
00460 if(child == NULL)
00461 {
00462 DeleteXmlTree();
00463 return m_iLastError;
00464 }
00465 time(<ime);
00466 tmtime = localtime(<ime);
00467 wcsftime(wcTmp, 128, L"%x", tmtime);
00468 AddTagValue(child, wcTmp);
00469 AddTagItem(parent, child);
00470 #endif
00471
00472
00473 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00474 child = BuildTag(FEDM_XML_TAG_TIME_UC, false);
00475 if(child == NULL)
00476 {
00477 DeleteXmlTree();
00478 return m_iLastError;
00479 }
00480 wcsftime(wcTmp, 128, L"%X", tmtime);
00481 AddTagValue(child, wcTmp);
00482 AddTagItem(parent, child);
00483 #endif
00484
00485
00486 if(m_wsComment.size() > 0)
00487 {
00488 child = BuildTag(FEDM_XML_TAG_COMMENT_UC, false);
00489 if(child == NULL)
00490 {
00491 DeleteXmlTree();
00492 return m_iLastError;
00493 }
00494 AddTagValue(child, m_wsComment);
00495 AddTagItem(parent, child);
00496 }
00497
00498
00499
00500 child = BuildTag(FEDM_XML_TAG_READER_UC);
00501 if(child == NULL)
00502 {
00503 DeleteXmlTree();
00504 return m_iLastError;
00505 }
00506 AddTagItem(root, child);
00507 parent = child;
00508
00509
00510 child = BuildTag(FEDM_XML_TAG_READER_NAME_UC, false);
00511 if(child == NULL)
00512 {
00513 DeleteXmlTree();
00514 return m_iLastError;
00515 }
00516 #if defined(__BORLANDC__) || defined(_MSC_VER)
00517 swprintf(wcTmp, L"%S", pReader->GetReaderName());
00518 #else
00519 swprintf(wcTmp, 128, L"%s", pReader->GetReaderName());
00520 #endif
00521 AddTagValue(child, wcTmp);
00522 AddTagItem(parent, child);
00523
00524
00525 child = BuildTag(FEDM_XML_TAG_READER_TYPE_UC, false);
00526 if(child == NULL)
00527 {
00528 DeleteXmlTree();
00529 return m_iLastError;
00530 }
00531 #if defined(__BORLANDC__) || defined(_MSC_VER)
00532 swprintf(wcTmp, L"%u", pReader->GetReaderType());
00533 #else
00534 swprintf(wcTmp, 128, L"%u", pReader->GetReaderType());
00535 #endif
00536 AddTagValue(child, wcTmp);
00537 AddTagItem(parent, child);
00538
00539
00540 if(m_ReaderRequirement.bCfgReset)
00541 {
00542 child = BuildTag(FEDM_XML_TAG_CFG_RESET_UC, false);
00543 if(child == NULL)
00544 {
00545 DeleteXmlTree();
00546 return m_iLastError;
00547 }
00548 #if defined(__BORLANDC__) || defined(_MSC_VER)
00549 swprintf(wcTmp, L"%d", (int)1);
00550 #else
00551 swprintf(wcTmp, 128, L"%d", (int)1);
00552 #endif
00553 AddTagValue(child, wcTmp);
00554 AddTagItem(parent, child);
00555 }
00556
00557
00558 if(m_ReaderRequirement.bHasRfcFw)
00559 {
00560 itor = m_ReaderRequirement.mapControllerFW.find(FEDM_CNTRL_TYPE_RFC);
00561 if(itor != m_ReaderRequirement.mapControllerFW.end())
00562 {
00563 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC, false);
00564 if(child == NULL)
00565 {
00566 DeleteXmlTree();
00567 return m_iLastError;
00568 }
00569 AddTagAttrib(child, FEDM_XML_TAG_CONTROLLER_TYPE_UC, L"RFC");
00570 #if defined(__BORLANDC__) || defined(_MSC_VER)
00571 swprintf(wcTmp, L"%d.%d.%d", ((itor->second&0x00FF0000)>>16), ((itor->second&0x0000FF00)>>8), (itor->second&0x000000FF));
00572 #else
00573 swprintf(wcTmp, 128, L"%d.%d.%d", ((itor->second&0x00FF0000)>>16), ((itor->second&0x0000FF00)>>8), (itor->second&0x000000FF));
00574 #endif
00575 AddTagValue(child, wcTmp);
00576 AddTagItem(parent, child);
00577 }
00578 }
00579
00580
00581 if(m_ReaderRequirement.bHasAccFw)
00582 {
00583 itor = m_ReaderRequirement.mapControllerFW.find(FEDM_CNTRL_TYPE_ACC);
00584 if(itor != m_ReaderRequirement.mapControllerFW.end())
00585 {
00586 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC, false);
00587 if(child == NULL)
00588 {
00589 DeleteXmlTree();
00590 return m_iLastError;
00591 }
00592 AddTagAttrib(child, FEDM_XML_TAG_CONTROLLER_TYPE_UC, L"ACC");
00593 #if defined(__BORLANDC__) || defined(_MSC_VER)
00594 swprintf(wcTmp, L"%d.%d.%d", ((itor->second&0x00FF0000)>>16), ((itor->second&0x0000FF00)>>8), (itor->second&0x000000FF));
00595 #else
00596 swprintf(wcTmp, 128, L"%d.%d.%d", ((itor->second&0x00FF0000)>>16), ((itor->second&0x0000FF00)>>8), (itor->second&0x000000FF));
00597 #endif
00598 AddTagValue(child, wcTmp);
00599 AddTagItem(parent, child);
00600 }
00601 }
00602
00603
00604 if(m_ReaderRequirement.bHasCustID)
00605 {
00606 child = BuildTag(FEDM_XML_TAG_CUSTOMER_ID_UC, false);
00607 if(child == NULL)
00608 {
00609 DeleteXmlTree();
00610 return m_iLastError;
00611 }
00612 #if defined(__BORLANDC__) || defined(_MSC_VER)
00613 swprintf(wcTmp, L"0x%08X", m_ReaderRequirement.uiCumstomerID);
00614 #else
00615 swprintf(wcTmp, 128, L"0x%08X", m_ReaderRequirement.uiCumstomerID);
00616 #endif
00617 AddTagValue(child, wcTmp);
00618 AddTagItem(parent, child);
00619 }
00620
00621
00622 if(m_ReaderRequirement.bHasRdrFunc)
00623 {
00624 child = BuildTag(FEDM_XML_TAG_READER_FUNCTIONS_UC, false);
00625 if(child == NULL)
00626 {
00627 DeleteXmlTree();
00628 return m_iLastError;
00629 }
00630 #if defined(__BORLANDC__) || defined(_MSC_VER)
00631 swprintf(wcTmp, L"0x%08X", m_ReaderRequirement.uiReaderFunction);
00632 #else
00633 swprintf(wcTmp, 128, L"0x%08X", m_ReaderRequirement.uiReaderFunction);
00634 #endif
00635 AddTagValue(child, wcTmp);
00636 AddTagItem(parent, child);
00637 }
00638
00639
00640 if(m_ReaderRequirement.bHasTrpDrv)
00641 {
00642 child = BuildTag(FEDM_XML_TAG_TRANSPONDER_DRIVER_UC, false);
00643 if(child == NULL)
00644 {
00645 DeleteXmlTree();
00646 return m_iLastError;
00647 }
00648 #if defined(__BORLANDC__) || defined(_MSC_VER)
00649 swprintf(wcTmp, L"0x%08X", m_ReaderRequirement.uiTransponderDriver);
00650 #else
00651 swprintf(wcTmp, 128, L"0x%08X", m_ReaderRequirement.uiTransponderDriver);
00652 #endif
00653 AddTagValue(child, wcTmp);
00654 AddTagItem(parent, child);
00655 }
00656
00657
00658 if(m_ReaderRequirement.bHasFrequency)
00659 {
00660 child = BuildTag(FEDM_XML_TAG_FREQUENCY_UC, false);
00661 if(child == NULL)
00662 {
00663 DeleteXmlTree();
00664 return m_iLastError;
00665 }
00666 #if defined(__BORLANDC__) || defined(_MSC_VER)
00667 swprintf(wcTmp, L"%d", m_ReaderRequirement.uiFrequency);
00668 #else
00669 swprintf(wcTmp, 128, L"%d", m_ReaderRequirement.uiFrequency);
00670 #endif
00671 AddTagValue(child, wcTmp);
00672 AddTagItem(parent, child);
00673 }
00674
00675
00676
00677 iBack = pReader->SerializeProfileOut(this, root);
00678 if(iBack)
00679 {
00680 DeleteXmlTree();
00681 return iBack;
00682 }
00683
00684 iBack = OpenDoc(sFileName, "w");
00685 if(iBack)
00686 {
00687 DeleteXmlTree();
00688 return iBack;
00689 }
00690 else
00691 {
00692 WriteDoc();
00693 }
00694
00695
00696 CloseDoc();
00697
00698 FEDM_RETURN(FEDM_OK);
00699 }
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719 int FEDM_XMLReaderCfgProfileModul::QueryDocType(char* sFileName, char* sDocType)
00720 {
00721 int iBack = 0;
00722 FEDM_XML_TREEITEM* root = NULL;
00723 FEDM_XML_TREEITEM* parent = NULL;
00724 FEDM_XML_TREEITEM* child = NULL;
00725
00726
00727 iBack = OpenDoc(sFileName, "r");
00728 if(iBack)
00729 return iBack;
00730
00731
00732 if(IsXmlDoc())
00733 {
00734 CloseDoc();
00735 return m_iLastError;
00736 }
00737
00738
00739 if(HasOBIDTag())
00740 {
00741 CloseDoc();
00742 return m_iLastError;
00743 }
00744
00745
00746 if(ReadDoc())
00747 {
00748 CloseDoc();
00749 return m_iLastError;
00750 }
00751
00752 CloseDoc();
00753
00754
00755 root = FindTag(FEDM_XML_TAG_OBID_UC);
00756 if(root == NULL)
00757 return m_iLastError;
00758 AddTagItem(NULL, root);
00759
00760
00761 child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
00762 if(child == NULL)
00763 {
00764 DeleteXmlTree();
00765 return m_iLastError;
00766 }
00767 AddTagItem(root, child);
00768 parent = child;
00769
00770
00771 child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
00772 if(child == NULL)
00773 {
00774 DeleteXmlTree();
00775 return m_iLastError;
00776 }
00777
00778 #if defined(__BORLANDC__) || defined(_MSC_VER)
00779 swscanf(child->sValue.c_str(), L"%S", sDocType);
00780 #elif defined(_FEDM_SUPPORT_UCLINUX)
00781 FEDM_SWSCANF(child->sValue.c_str(), sDocType);
00782 #else
00783 swscanf(child->sValue.c_str(), L"%s", sDocType);
00784 #endif
00785
00786 delete child;
00787 DeleteXmlTree();
00788
00789 FEDM_RETURN(FEDM_OK);
00790 }
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803 int FEDM_XMLReaderCfgProfileModul::QueryDocVersion(char* sFileName, char* sDocVersion)
00804 {
00805 int iBack = 0;
00806 FEDM_XML_TREEITEM* root = NULL;
00807 FEDM_XML_TREEITEM* parent = NULL;
00808 FEDM_XML_TREEITEM* child = NULL;
00809
00810
00811 iBack = OpenDoc(sFileName, "r");
00812 if(iBack)
00813 return iBack;
00814
00815
00816 if(IsXmlDoc())
00817 {
00818 CloseDoc();
00819 return m_iLastError;
00820 }
00821
00822
00823 if(HasOBIDTag())
00824 {
00825 CloseDoc();
00826 return m_iLastError;
00827 }
00828
00829
00830 if(ReadDoc())
00831 {
00832 CloseDoc();
00833 return m_iLastError;
00834 }
00835
00836 CloseDoc();
00837
00838
00839 root = FindTag(FEDM_XML_TAG_OBID_UC);
00840 if(root == NULL)
00841 return m_iLastError;
00842 AddTagItem(NULL, root);
00843
00844
00845 child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
00846 if(child == NULL)
00847 {
00848 DeleteXmlTree();
00849 return m_iLastError;
00850 }
00851 AddTagItem(root, child);
00852 parent = child;
00853
00854
00855 child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
00856 if(child == NULL)
00857 {
00858 DeleteXmlTree();
00859 return m_iLastError;
00860 }
00861 m_wsDocType = child->sValue;
00862 AddTagItem(parent, child);
00863
00864
00865 child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
00866 if(child == NULL)
00867 {
00868 DeleteXmlTree();
00869 return m_iLastError;
00870 }
00871
00872 #if defined(__BORLANDC__) || defined(_MSC_VER)
00873 swscanf(child->sValue.c_str(), L"%S", sDocVersion);
00874 #elif defined(_FEDM_SUPPORT_UCLINUX)
00875 FEDM_SWSCANF(child->sValue.c_str(), sDocVersion);
00876 #else
00877 swscanf(child->sValue.c_str(), L"%s", sDocVersion);
00878 #endif
00879
00880 delete child;
00881 DeleteXmlTree();
00882
00883 FEDM_RETURN(FEDM_OK);
00884 }
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 int FEDM_XMLReaderCfgProfileModul::QueryReaderType(char* sFileName)
00897 {
00898 char cValue[5];
00899 int iType = 0;
00900 int iBack = 0;
00901 FEDM_XML_TREEITEM* root = NULL;
00902 FEDM_XML_TREEITEM* parent = NULL;
00903 FEDM_XML_TREEITEM* child = NULL;
00904
00905
00906 iBack = OpenDoc(sFileName, "r");
00907 if(iBack)
00908 return iBack;
00909
00910
00911 if(IsXmlDoc())
00912 {
00913 CloseDoc();
00914 return m_iLastError;
00915 }
00916
00917
00918 if(HasOBIDTag())
00919 {
00920 CloseDoc();
00921 return m_iLastError;
00922 }
00923
00924
00925 if(ReadDoc())
00926 {
00927 CloseDoc();
00928 return m_iLastError;
00929 }
00930
00931 CloseDoc();
00932
00933
00934 root = FindTag(FEDM_XML_TAG_OBID_UC);
00935 if(root == NULL)
00936 return m_iLastError;
00937 AddTagItem(NULL, root);
00938
00939
00940 child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
00941 if(child == NULL)
00942 {
00943 DeleteXmlTree();
00944 return m_iLastError;
00945 }
00946 AddTagItem(root, child);
00947 parent = child;
00948
00949
00950 child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
00951 if(child == NULL)
00952 {
00953 DeleteXmlTree();
00954 return m_iLastError;
00955 }
00956 if(child->sValue != FEDM_XML_STRING_DOC_TYPE_4_UC)
00957 {
00958 delete child;
00959 DeleteXmlTree();
00960 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00961 }
00962 m_wsDocType = child->sValue;
00963 AddTagItem(parent, child);
00964
00965
00966 child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
00967 if(child == NULL)
00968 {
00969 DeleteXmlTree();
00970 return m_iLastError;
00971 }
00972 if(child->sValue != FEDM_XML_STRING_PROFILE_DOC_VERSION_UC)
00973 {
00974 delete child;
00975 DeleteXmlTree();
00976 return FEDM_XML_ERROR_DOC_FILE_VERSION;
00977 }
00978 m_wsDocVer = child->sValue;
00979 AddTagItem(parent, child);
00980
00981
00982 child = FindTag(FEDM_XML_TAG_READER_UC);
00983 if(child == NULL)
00984 {
00985 DeleteXmlTree();
00986 return m_iLastError;
00987 }
00988 AddTagItem(root, child);
00989 parent = child;
00990
00991
00992 child = FindTag(FEDM_XML_TAG_READER_TYPE_UC);
00993 if(child == NULL)
00994 {
00995 DeleteXmlTree();
00996 return m_iLastError;
00997 }
00998
00999 #if defined(__BORLANDC__) || defined(_MSC_VER)
01000 swscanf(child->sValue.c_str(), L"%S", cValue);
01001 #elif defined(_FEDM_SUPPORT_UCLINUX)
01002 FEDM_SWSCANF(child->sValue.c_str(), cValue);
01003 #else
01004 swscanf(child->sValue.c_str(), L"%s", cValue);
01005 #endif
01006 sscanf(cValue, "%d", &iType);
01007
01008 delete child;
01009 DeleteXmlTree();
01010
01011 return iType;
01012 }
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030 void FEDM_XMLReaderCfgProfileModul::GetComment(string& sComment)
01031 {
01032 char cTmp[256];
01033
01034 if(m_wsComment.size() > 256)
01035 return;
01036
01037 #if defined(__BORLANDC__) || defined(_MSC_VER)
01038 sprintf(cTmp, "%S", m_wsComment.c_str());
01039 #else
01040 sprintf(cTmp, "%s", (const char*)m_wsComment.c_str());
01041 #endif
01042
01043 sComment = cTmp;
01044 }
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 void FEDM_XMLReaderCfgProfileModul::SetComment(string sComment)
01057 {
01058 wchar_t wcTmp[256];
01059
01060 if(sComment.size() > 256)
01061 return;
01062
01063 #if defined(__BORLANDC__) || defined(_MSC_VER)
01064 swprintf(wcTmp, L"%S", sComment.c_str());
01065 #else
01066 swprintf(wcTmp, 256, L"%s", sComment.c_str());
01067 #endif
01068
01069 m_wsComment = wcTmp;
01070 }
01071
01072 #endif // #ifdef _FEDM_XML_SUPPORT
01073
01074
01075
01076
01077