---------------------------------------------------------------------------
| 63 | } |
| 64 | //--------------------------------------------------------------------------- |
| 65 | void TMainCfg::Load(String file, TStorageFileList * sfl) |
| 66 | { |
| 67 | XMLError err; |
| 68 | try |
| 69 | { |
| 70 | tinyxml2::XMLDocument doc; |
| 71 | err = doc.LoadFile(file.c_str()); |
| 72 | if( err == XML_SUCCESS ) |
| 73 | { |
| 74 | XMLElement * hls; |
| 75 | hls = doc.RootElement(); |
| 76 | if( ! hls ) |
| 77 | throw 1; |
| 78 | if( strcmpi(hls->Name(), szSetupNode) != 0 ) |
| 79 | throw 1; |
| 80 | |
| 81 | // |
| 82 | for(XMLElementEx * p = (XMLElementEx *)hls->FirstChildElement(); |
| 83 | p; |
| 84 | p = (XMLElementEx *)p->NextSiblingElement()) |
| 85 | { |
| 86 | if( strcmpi(p->Name(), szMainNode)==0 ) |
| 87 | { |
| 88 | UdpEnable = p->rb("UdpEnable", true); |
| 89 | UdpInterface = p->rs("UdpInterface", "0.0.0.0"); |
| 90 | UdpPort = p->ri("UdpPort", 514); |
| 91 | TcpEnable = p->rb("TcpEnable", false); |
| 92 | TcpInterface = p->rs("TcpInterface", "0.0.0.0"); |
| 93 | TcpPort = p->ri("TcpPort", 514); |
| 94 | b3D = p->rb("D3", true); |
| 95 | bWriteRaw = p->rb("WriteRaw", false); |
| 96 | bReceiveUTF8 = p->rb("ReceiveUTF8", false); |
| 97 | } |
| 98 | else if( strcmpi(p->Name(), szMailNode)==0 ) |
| 99 | { |
| 100 | Letter.Load(p); |
| 101 | } |
| 102 | else if( strcmpi(p->Name(), szStorageFiles)==0 ) |
| 103 | { |
| 104 | sfl->Load(p); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | else |
| 109 | throw 0; |
| 110 | } |
| 111 | catch(int i) |
| 112 | { |
| 113 | if( i==0 ) |
| 114 | ReportError2("Error reading file: \"%s\" [%d]", file.c_str(), err); |
| 115 | else |
| 116 | ReportError2("Incorrect format of file: \"%s\"", file.c_str()); |
| 117 | } |
| 118 | } |
| 119 | //--------------------------------------------------------------------------- |
| 120 | #pragma package(smart_init) |
no test coverage detected