| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 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 3 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, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/dmfc/dmfccfg.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003/08/26 03:57:20 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Functions for a D3M config file |
| 26 | * |
| 27 | * $Log: dmfccfg.cpp,v $ |
| 28 | * Revision 1.1.1.1 2003/08/26 03:57:20 kevinb |
| 29 | * initial 1.5 import |
| 30 | * |
| 31 | * |
| 32 | * 7 9/12/99 12:06a Jeff |
| 33 | * fixed atoxi bug (stupid bug) |
| 34 | * |
| 35 | * 6 5/17/99 2:34p Ardussi |
| 36 | * changed to compile on Mac |
| 37 | * |
| 38 | * 5 5/13/99 4:55p Ardussi |
| 39 | * changes for compiling on the Mac |
| 40 | * |
| 41 | * 4 3/17/99 12:23p Jeff |
| 42 | * converted DMFC to be COM interface |
| 43 | * |
| 44 | * 3 9/21/98 7:11p Jeff |
| 45 | * made InputCommand interface API and moved existing input commands to |
| 46 | * the interface. Changed mprintf/ASSERT so they are valid in DMFC |
| 47 | * |
| 48 | * $NoKeywords: $ |
| 49 | */ |
| 50 | |
| 51 | #include "gamedll_header.h"cxx . . $ `<file>/netgames/includes/gamedll_header.h`/ |
| 52 | #include "DMFC.h"cxx . . $ `<file>/netgames/includes/DMFC.h`/ |
| 53 | #include "dmfcinternal.h"cxx . . $ `<file>/netgames/dmfc/dmfcinternal.h`/ |
| 54 | |
| 55 | |
| 56 | CRegistrycxx . . $ CRegistry# *regcxx . . $ reg. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 57 | |
| 58 | // DMFCBase::CFGOpen |
| 59 | // |
| 60 | // Opens the registry/cfg information for the DMFC game, see error codes for return values |
| 61 | int DMFCBasecxx . . $ DMFCBase#::CFGOpencxx . . $ DMFCBase#CFGOpen(1ef8e6ec083aabb9).(char *filename) { |
| 62 | if (!filename) |
| 63 | return CFG_NOCFGFILEcxx . . $ `netgames/includes/DMFC.h:507:9`!; |
| 64 | |
| 65 | if (regcxx . . $ reg.) |
| 66 | return CFG_ALREADYOPENcxx . . $ `netgames/includes/DMFC.h:505:9`!; |
| 67 | |
| 68 | regcxx . . $ reg. = new CRegistrycxx . . $ CRegistry#(filename); |
| 69 | if (!regcxx . . $ reg.) |
| 70 | return CFG_OUTOFMEMORYcxx . . $ `netgames/includes/DMFC.h:506:9`!; |
| 71 | |
| 72 | regcxx . . $ reg.->Importcxx . . $ CRegistry#Import(c9857a73d68e59ba).(); |
| 73 | |
| 74 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 75 | } |
| 76 | |
| 77 | // DMFCBase::CFGClose |
| 78 | // |
| 79 | // Closes the registry information for the game. |
| 80 | void DMFCBasecxx . . $ DMFCBase#::CFGClosecxx . . $ DMFCBase#CFGClose(49f6e7a06ebc5aa8).(void) { |
| 81 | if (regcxx . . $ reg.) { |
| 82 | regcxx . . $ reg.->Exportcxx . . $ CRegistry#Export(49f6e7a06ebc5aa8).(); |
| 83 | delete regcxx . . $ reg.; |
| 84 | regcxx . . $ reg. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // DMFCBase::CFGFlush |
| 89 | // |
| 90 | // Flushes out the registry information to fall |
| 91 | int DMFCBasecxx . . $ DMFCBase#::CFGFlushcxx . . $ DMFCBase#CFGFlush(b126dc7c1de90089).(void) { |
| 92 | if (regcxx . . $ reg.) { |
| 93 | regcxx . . $ reg.->Exportcxx . . $ CRegistry#Export(49f6e7a06ebc5aa8).(); |
| 94 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 95 | } else |
| 96 | return CFG_NOTOPENcxx . . $ `netgames/includes/DMFC.h:508:9`!; |
| 97 | } |
| 98 | |
| 99 | // DMFCBase::CFGCreateKey |
| 100 | // |
| 101 | // Creates a key in the registry |
| 102 | int DMFCBasecxx . . $ DMFCBase#::CFGCreateKeycxx . . $ DMFCBase#CFGCreateKey(1ef8e6ec083aabb9).(char *name) { |
| 103 | if (regcxx . . $ reg.) { |
| 104 | regcxx . . $ reg.->CreateKeycxx . . $ CRegistry#CreateKey(85c52e162fed56f9).(name); |
| 105 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 106 | } else |
| 107 | return CFG_NOTOPENcxx . . $ `netgames/includes/DMFC.h:508:9`!; |
| 108 | } |
| 109 | |
| 110 | // DMFCBase::CFGLookupKey |
| 111 | // |
| 112 | // Sets the active key in the registry |
| 113 | int DMFCBasecxx . . $ DMFCBase#::CFGLookupKeycxx . . $ DMFCBase#CFGLookupKey(1ef8e6ec083aabb9).(char *name) { |
| 114 | if (regcxx . . $ reg.) { |
| 115 | if (regcxx . . $ reg.->LookupKeycxx . . $ CRegistry#LookupKey(c5f7da30cbc0f4e9).(name)) |
| 116 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 117 | else |
| 118 | return CFG_KEYNOTFOUNDcxx . . $ `netgames/includes/DMFC.h:509:9`!; |
| 119 | } else |
| 120 | return CFG_NOTOPENcxx . . $ `netgames/includes/DMFC.h:508:9`!; |
| 121 | } |
| 122 | |
| 123 | // DMFCBase::CFGLookupRecord |
| 124 | // |
| 125 | // Looks up a record in the active key |
| 126 | int DMFCBasecxx . . $ DMFCBase#::CFGLookupRecordcxx . . $ DMFCBase#CFGLookupRecord(3eb1fdce138500d5).(char *record, void *data) { |
| 127 | if (regcxx . . $ reg.) { |
| 128 | if (regcxx . . $ reg.->LookupRecordcxx . . $ CRegistry#LookupRecord(f758117682a82874).(record, data)) |
| 129 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 130 | else |
| 131 | return CFG_RECORDNOTFOUNDcxx . . $ `netgames/includes/DMFC.h:510:9`!; |
| 132 | } else |
| 133 | return CFG_NOTOPENcxx . . $ `netgames/includes/DMFC.h:508:9`!; |
| 134 | } |
| 135 | |
| 136 | // DMFCBase::CFGCreateRecord |
| 137 | // |
| 138 | // Create/overwrites a record in the active key. Type is either REGT_DWORD or REGT_STRING |
| 139 | int DMFCBasecxx . . $ DMFCBase#::CFGCreateRecordcxx . . $ DMFCBase#CFGCreateRecord(c0790496e06ad349).(char *name, char type, void *data) { |
| 140 | if (regcxx . . $ reg.) { |
| 141 | if (regcxx . . $ reg.->CreateRecordcxx . . $ CRegistry#CreateRecord(5438c15cf96d2f9c).(name, type, data)) |
| 142 | return CFG_NOERRORcxx . . $ `netgames/includes/DMFC.h:504:9`!; |
| 143 | else |
| 144 | return CFG_CANTCREATEcxx . . $ `netgames/includes/DMFC.h:511:9`!; |
| 145 | } else |
| 146 | return CFG_NOTOPENcxx . . $ `netgames/includes/DMFC.h:508:9`!; |
| 147 | } |
| 148 | |
| 149 | // Convert a string that represents a hex value into an int |
| 150 | int |
| 151 | axtoicxx . . $ axtoi(1ef8e6ec083aabb9).(char *p) { |
| 152 | int value = 0; |
| 153 | while ((p) && (*p)) { |
| 154 | *p = toupper(*p); |
| 155 | if ((*p >= '0') && (*p <= '9')) |
| 156 | value = (value * 16) + ((*p) - '0'); |
| 157 | else if ((*p >= 'A') && (*p <= 'F')) |
| 158 | value = (value * 16) + (((*p) - 'A') + 10); |
| 159 | else |
| 160 | return 0; |
| 161 | p++; |
| 162 | } |
| 163 | return value; |
| 164 | } |
| 165 | |
| 166 | // Removes whitespace from the start of the given string. |
| 167 | // Returns a pointer to the first non-white character |
| 168 | char *CRegistrycxx . . $ CRegistry#::SkipWhitecxx . . $ CRegistry#SkipWhite(7a9722d75b371431).(char *p) { |
| 169 | while (isspace(*p)) |
| 170 | p++; |
| 171 | return p; |
| 172 | } |
| 173 | |
| 174 | // Parses a quoted string |
| 175 | // Returns true if got string ok, else false |
| 176 | char *CRegistrycxx . . $ CRegistry#::ParseStringcxx . . $ CRegistry#ParseString(16cab7bd68b2d8b0).(char *p, char *buf, int bufsize, char sdelim, char edelim) { |
| 177 | char *save_p; |
| 178 | |
| 179 | p = SkipWhitecxx . . $ CRegistry#SkipWhite(7a9722d75b371431).(p); |
| 180 | |
| 181 | save_p = p; |
| 182 | |
| 183 | if (*p != sdelim) { |
| 184 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 185 | } else { |
| 186 | p++; // skip initial quote |
| 187 | } |
| 188 | |
| 189 | // Copy chars until endquote or out of space |
| 190 | while (*p && (*p != edelim) && --bufsize) |
| 191 | *buf++ = *p++; |
| 192 | |
| 193 | // Check for buffer overflow |
| 194 | if (bufsize <= 0) { |
| 195 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 196 | } |
| 197 | |
| 198 | // Check for missing endquote |
| 199 | if (!*p) { |
| 200 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 201 | } |
| 202 | |
| 203 | // Write terminator |
| 204 | *buf = 0; |
| 205 | |
| 206 | // Return new pointer (move over a char for end quote) |
| 207 | return p + 1; |
| 208 | } |
| 209 | |
| 210 | // Parses a sequence of non-space characters |
| 211 | char *CRegistrycxx . . $ CRegistry#::ParseTokencxx . . $ CRegistry#ParseToken(4b1661a75e253f1d).(char *p, char *buf, int bufsize) { |
| 212 | char *save_p; |
| 213 | p = SkipWhitecxx . . $ CRegistry#SkipWhite(7a9722d75b371431).(p); |
| 214 | save_p = p; |
| 215 | |
| 216 | while (!isspace(*p) && (*p != ',') && *p && --bufsize) |
| 217 | *buf++ = *p++; |
| 218 | |
| 219 | *buf = 0; |
| 220 | |
| 221 | // Check for buffer overflow |
| 222 | if (bufsize <= 0) { |
| 223 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 224 | } |
| 225 | |
| 226 | return p; |
| 227 | } |
| 228 | |
| 229 | #define PARSE_KEYcxx . . $ `netgames/dmfc/dmfccfg.cpp:229:9`!(buf) \ |
| 230 | do { \ |
| 231 | ptr = ParseString(ptr, buf, sizeof(buf), '[', ']'); \ |
| 232 | } while (0) |
| 233 | #define PARSE_STRINGcxx . . $ `netgames/dmfc/dmfccfg.cpp:233:9`!(buf) \ |
| 234 | do { \ |
| 235 | ptr = ParseString(ptr, buf, sizeof(buf), '"', '"'); \ |
| 236 | } while (0) |
| 237 | #define PARSE_TOKENcxx . . $ `netgames/dmfc/dmfccfg.cpp:237:9`!(buf) \ |
| 238 | do { \ |
| 239 | ptr = ParseToken(ptr, buf, sizeof(buf)); \ |
| 240 | } while (0) |
| 241 | |
| 242 | CRegistrycxx . . $ CRegistry#::CRegistrycxx . . $ CRegistry#CRegistry(85c52e162fed56f9).(const char *str) { |
| 243 | currentkeycxx . . $ CRegistry#currentkey. = rootcxx . . $ CRegistry#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 244 | strcpy(namecxx . . $ CRegistry#name., str); |
| 245 | } |
| 246 | |
| 247 | CRegistrycxx . . $ CRegistry#::~cxx . . $ CRegistry#`~CRegistry`(ced63f7c635d850d).CRegistrycxx . . $ CRegistry#() { Destroycxx . . $ CRegistry#Destroy(49f6e7a06ebc5aa8).(); } |
| 248 | |
| 249 | void CRegistrycxx . . $ CRegistry#::Destroycxx . . $ CRegistry#Destroy(49f6e7a06ebc5aa8).(void) { |
| 250 | tKeycxx . . $ tKey# *curr, *next; |
| 251 | curr = next = rootcxx . . $ CRegistry#root.; |
| 252 | |
| 253 | while (curr) { |
| 254 | next = curr->nextcxx . . $ tKey#next.; |
| 255 | DestroyKeycxx . . $ CRegistry#DestroyKey(75fb02095f21236d).(curr); |
| 256 | curr = next; |
| 257 | } |
| 258 | rootcxx . . $ CRegistry#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 259 | } |
| 260 | |
| 261 | void CRegistrycxx . . $ CRegistry#::DestroyKeycxx . . $ CRegistry#DestroyKey(75fb02095f21236d).(tKeycxx . . $ tKey# *key) { |
| 262 | tRecordcxx . . $ tRecord# *curr, *next; |
| 263 | curr = next = key->recordscxx . . $ tKey#records.; |
| 264 | |
| 265 | while (curr) { |
| 266 | next = curr->nextcxx . . $ tRecord#next.; |
| 267 | DestroyRecordcxx . . $ CRegistry#DestroyRecord(a197468c659cdcd8).(curr); |
| 268 | curr = next; |
| 269 | } |
| 270 | |
| 271 | free(key); |
| 272 | } |
| 273 | |
| 274 | void CRegistrycxx . . $ CRegistry#::DestroyRecordcxx . . $ CRegistry#DestroyRecord(a197468c659cdcd8).(tRecordcxx . . $ tRecord# *record) { |
| 275 | if (record->datacxx . . $ tRecord#data.) { |
| 276 | free(record->datacxx . . $ tRecord#data.); |
| 277 | record->datacxx . . $ tRecord#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 278 | } |
| 279 | free(record); |
| 280 | } |
| 281 | |
| 282 | void CRegistrycxx . . $ CRegistry#::Exportcxx . . $ CRegistry#Export(49f6e7a06ebc5aa8).() { |
| 283 | tKeycxx . . $ tKey# *curr, *next; |
| 284 | curr = next = rootcxx . . $ CRegistry#root.; |
| 285 | CFILEcxx . . $ CFILE# *file; |
| 286 | DLLOpenCFILE(&file, namecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "wt"); |
| 287 | |
| 288 | if (!file) |
| 289 | return; |
| 290 | |
| 291 | while (curr) { |
| 292 | next = curr->nextcxx . . $ tKey#next.; |
| 293 | ExportKeycxx . . $ CRegistry#ExportKey(92c7fc897522a687).(curr, file); |
| 294 | curr = next; |
| 295 | } |
| 296 | DLLcfclose(file); |
| 297 | } |
| 298 | |
| 299 | void CRegistrycxx . . $ CRegistry#::ExportKeycxx . . $ CRegistry#ExportKey(92c7fc897522a687).(tKeycxx . . $ tKey# *key, CFILEcxx . . $ CFILE# *file) { |
| 300 | tRecordcxx . . $ tRecord# *curr, *next; |
| 301 | curr = next = key->recordscxx . . $ tKey#records.; |
| 302 | |
| 303 | // write out name |
| 304 | char buffer[258]; |
| 305 | snprintf(buffer, sizeof(buffer), "[%s]", key->namecxx . . $ tKey#name.); |
| 306 | DLLcf_WriteString(file, buffer); |
| 307 | while (curr) { |
| 308 | next = curr->nextcxx . . $ tRecord#next.; |
| 309 | ExportRecordcxx . . $ CRegistry#ExportRecord(6063bfd1cdb4bc41).(curr, file); |
| 310 | curr = next; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | void CRegistrycxx . . $ CRegistry#::ExportRecordcxx . . $ CRegistry#ExportRecord(6063bfd1cdb4bc41).(tRecordcxx . . $ tRecord# *record, CFILEcxx . . $ CFILE# *file) { |
| 315 | int *dw; |
| 316 | char *st; |
| 317 | char buffer[512]; |
| 318 | switch (record->typecxx . . $ tRecord#type.) { |
| 319 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: { |
| 320 | st = (char *)record->datacxx . . $ tRecord#data.; |
| 321 | snprintf(buffer, sizeof(buffer), "\"%s\"=\"%s\"", record->namecxx . . $ tRecord#name., st); |
| 322 | } break; |
| 323 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: { |
| 324 | dw = (int *)record->datacxx . . $ tRecord#data.; |
| 325 | snprintf(buffer, sizeof(buffer), "\"%s\"=dword:%X", record->namecxx . . $ tRecord#name., *dw); |
| 326 | } break; |
| 327 | }; |
| 328 | DLLcf_WriteString(file, buffer); |
| 329 | } |
| 330 | |
| 331 | bool CRegistrycxx . . $ CRegistry#::Importcxx . . $ CRegistry#Import(c9857a73d68e59ba).() { |
| 332 | char buffer[500]; |
| 333 | char newbuff[500]; |
| 334 | CFILEcxx . . $ CFILE# *file; |
| 335 | char *ptr; |
| 336 | |
| 337 | DLLOpenCFILE(&file, namecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rt"); |
| 338 | |
| 339 | if (!file) { |
| 340 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Unable to import %s\n", name); |
| 341 | return false; |
| 342 | } |
| 343 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Importing %s\n", name); |
| 344 | Destroycxx . . $ CRegistry#Destroy(49f6e7a06ebc5aa8).(); |
| 345 | |
| 346 | bool oktocreate; |
| 347 | // loop till we are done |
| 348 | while (!DLLcfeof(file)) { |
| 349 | oktocreate = true; |
| 350 | char type = REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!; |
| 351 | |
| 352 | // read in the string |
| 353 | DLLcf_ReadString(buffer, 500, file); |
| 354 | if (strlen(buffer) <= 1) |
| 355 | continue; |
| 356 | |
| 357 | ptr = buffer; |
| 358 | if (DLLcfeof(file)) // we are at the end of the file so there isn't data to continue |
| 359 | oktocreate = false; |
| 360 | |
| 361 | // see what we read, a key or record, if the first character is a [ than a key " is record |
| 362 | if (oktocreate) { |
| 363 | if (buffer[0] == '[') { |
| 364 | // Create a key! |
| 365 | PARSE_KEYcxx . . $ `netgames/dmfc/dmfccfg.cpp:229:9`!(newbuff); |
| 366 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Found Key: |%s|\n", newbuff); |
| 367 | CreateKeycxx . . $ CRegistry#CreateKey(85c52e162fed56f9).(newbuff); |
| 368 | } else if (buffer[0] == '\"') { |
| 369 | // Create a record |
| 370 | // see what type of record by looking at whats after the = |
| 371 | char *p; |
| 372 | p = buffer; |
| 373 | bool done = false; |
| 374 | type = REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!; |
| 375 | while (!done) { |
| 376 | if ((!p) || (!*p)) |
| 377 | done = true; |
| 378 | if ((p) && (*p == '=')) { |
| 379 | if (*(p + 1) == 'd') |
| 380 | type = REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!; |
| 381 | else |
| 382 | type = REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!; |
| 383 | done = true; |
| 384 | } |
| 385 | p++; |
| 386 | } |
| 387 | |
| 388 | // now we "SHOULD" know the type, parse the info |
| 389 | char data[300]; |
| 390 | int idata; |
| 391 | |
| 392 | switch (type) { |
| 393 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: |
| 394 | PARSE_STRINGcxx . . $ `netgames/dmfc/dmfccfg.cpp:233:9`!(newbuff); |
| 395 | ptr++; // blow by = |
| 396 | PARSE_STRINGcxx . . $ `netgames/dmfc/dmfccfg.cpp:233:9`!(data); |
| 397 | if (!CreateRecordcxx . . $ CRegistry#CreateRecord(5438c15cf96d2f9c).(newbuff, REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!, data)) { |
| 398 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Unable to create String record: %s\n", newbuff); |
| 399 | } else { |
| 400 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Created String record %s = %s\n", newbuff, data); |
| 401 | } |
| 402 | break; |
| 403 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: |
| 404 | PARSE_STRINGcxx . . $ `netgames/dmfc/dmfccfg.cpp:233:9`!(newbuff); |
| 405 | ptr += 7; // blow by =dword: |
| 406 | PARSE_TOKENcxx . . $ `netgames/dmfc/dmfccfg.cpp:237:9`!(data); |
| 407 | idata = axtoicxx . . $ axtoi(1ef8e6ec083aabb9).(data); |
| 408 | |
| 409 | if (!CreateRecordcxx . . $ CRegistry#CreateRecord(5438c15cf96d2f9c).(newbuff, REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!, &idata)) { |
| 410 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Unable to create dword record: %s\n", newbuff); |
| 411 | } else { |
| 412 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Created dword record %s = %X\n", newbuff, idata); |
| 413 | } |
| 414 | break; |
| 415 | } |
| 416 | } else { |
| 417 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Expected [ or \"\n"); |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | DLLcfclose(file); |
| 422 | return true; |
| 423 | } |
| 424 | |
| 425 | void CRegistrycxx . . $ CRegistry#::CreateKeycxx . . $ CRegistry#CreateKey(85c52e162fed56f9).(const char *name) { |
| 426 | tKeycxx . . $ tKey# *curr; |
| 427 | if (LookupKeycxx . . $ CRegistry#LookupKey(c5f7da30cbc0f4e9).(name)) { |
| 428 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Key: %s already exists\n", name); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | if (!rootcxx . . $ CRegistry#root.) { |
| 433 | rootcxx . . $ CRegistry#root. = (tKeycxx . . $ tKey# *)malloc(sizeof(tKeycxx . . $ tKey#)); |
| 434 | if (!rootcxx . . $ CRegistry#root.) |
| 435 | return; |
| 436 | curr = rootcxx . . $ CRegistry#root.; |
| 437 | } else { |
| 438 | curr = rootcxx . . $ CRegistry#root.; |
| 439 | while (curr->nextcxx . . $ tKey#next.) { |
| 440 | curr = curr->nextcxx . . $ tKey#next.; |
| 441 | } |
| 442 | |
| 443 | curr->nextcxx . . $ tKey#next. = (tKeycxx . . $ tKey# *)malloc(sizeof(tKeycxx . . $ tKey#)); |
| 444 | if (!curr->nextcxx . . $ tKey#next.) |
| 445 | return; |
| 446 | curr = curr->nextcxx . . $ tKey#next.; |
| 447 | } |
| 448 | |
| 449 | curr->nextcxx . . $ tKey#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 450 | strcpy(curr->namecxx . . $ tKey#name., name); |
| 451 | curr->recordscxx . . $ tKey#records. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 452 | currentkeycxx . . $ CRegistry#currentkey. = curr; |
| 453 | } |
| 454 | |
| 455 | bool CRegistrycxx . . $ CRegistry#::LookupKeycxx . . $ CRegistry#LookupKey(c5f7da30cbc0f4e9).(const char *name) { |
| 456 | tKeycxx . . $ tKey# *curr; |
| 457 | curr = rootcxx . . $ CRegistry#root.; |
| 458 | while (curr) { |
| 459 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, curr->name)) { |
| 460 | // found a match |
| 461 | currentkeycxx . . $ CRegistry#currentkey. = curr; |
| 462 | return true; |
| 463 | } |
| 464 | curr = curr->nextcxx . . $ tKey#next.; |
| 465 | } |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | tRecordcxx . . $ tRecord# *CRegistrycxx . . $ CRegistry#::LookupRecordcxx . . $ CRegistry#LookupRecord(f758117682a82874).(const char *record, void *data) { |
| 470 | if (!currentkeycxx . . $ CRegistry#currentkey.) |
| 471 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 472 | |
| 473 | tRecordcxx . . $ tRecord# *curr; |
| 474 | curr = currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.; |
| 475 | while (curr) { |
| 476 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(record, curr->name)) { |
| 477 | // found the record |
| 478 | switch (curr->typecxx . . $ tRecord#type.) { |
| 479 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: |
| 480 | char *st; |
| 481 | st = (char *)curr->datacxx . . $ tRecord#data.; |
| 482 | strcpy((char *)data, st); |
| 483 | break; |
| 484 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: |
| 485 | int *dw; |
| 486 | dw = (int *)curr->datacxx . . $ tRecord#data.; |
| 487 | *((int *)data) = *dw; |
| 488 | break; |
| 489 | }; |
| 490 | return curr; |
| 491 | } |
| 492 | curr = curr->nextcxx . . $ tRecord#next.; |
| 493 | } |
| 494 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 495 | } |
| 496 | |
| 497 | int CRegistrycxx . . $ CRegistry#::GetDataSizecxx . . $ CRegistry#GetDataSize(5c4306d8553b3696).(const char *record) { |
| 498 | if (!currentkeycxx . . $ CRegistry#currentkey.) |
| 499 | return false; |
| 500 | tRecordcxx . . $ tRecord# *curr; |
| 501 | curr = currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.; |
| 502 | while (curr) { |
| 503 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(record, curr->name)) { |
| 504 | // found the record |
| 505 | switch (curr->typecxx . . $ tRecord#type.) { |
| 506 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: |
| 507 | return strlen((char *)curr->datacxx . . $ tRecord#data.) + 1; |
| 508 | break; |
| 509 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: |
| 510 | return sizeof(int); |
| 511 | break; |
| 512 | }; |
| 513 | return 0; |
| 514 | } |
| 515 | curr = curr->nextcxx . . $ tRecord#next.; |
| 516 | } |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | bool CRegistrycxx . . $ CRegistry#::CreateRecordcxx . . $ CRegistry#CreateRecord(5438c15cf96d2f9c).(const char *name, char type, void *data) { |
| 521 | if (!currentkeycxx . . $ CRegistry#currentkey.) |
| 522 | return false; |
| 523 | tRecordcxx . . $ tRecord# *curr; |
| 524 | |
| 525 | // first see if the record exists under this key |
| 526 | int datasize = GetDataSizecxx . . $ CRegistry#GetDataSize(5c4306d8553b3696).(name); |
| 527 | if (datasize) { |
| 528 | char *olddata = (char *)malloc(datasize); |
| 529 | if (olddata) { |
| 530 | curr = LookupRecordcxx . . $ CRegistry#LookupRecord(f758117682a82874).(name, olddata); |
| 531 | if (curr) { |
| 532 | // ok we have an old value, replace it! |
| 533 | mprintfcxx . . $ `netgames/dmfc/dmfcinternal.h:275:9`!(0, "Replacing %s\n", name); |
| 534 | if (curr->datacxx . . $ tRecord#data.) |
| 535 | free(curr->datacxx . . $ tRecord#data.); |
| 536 | free(olddata); |
| 537 | curr->typecxx . . $ tRecord#type. = type; |
| 538 | |
| 539 | switch (type) { |
| 540 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: |
| 541 | curr->datacxx . . $ tRecord#data. = malloc(strlen((char *)data) + 1); |
| 542 | strcpy((char *)curr->datacxx . . $ tRecord#data., (char *)data); |
| 543 | break; |
| 544 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: |
| 545 | curr->datacxx . . $ tRecord#data. = malloc(sizeof(int)); |
| 546 | *((int *)curr->datacxx . . $ tRecord#data.) = *((int *)data); |
| 547 | break; |
| 548 | } |
| 549 | return true; |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | // it is a new record |
| 555 | if (currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.) { |
| 556 | curr = currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.; |
| 557 | while (curr->nextcxx . . $ tRecord#next.) |
| 558 | curr = curr->nextcxx . . $ tRecord#next.; |
| 559 | |
| 560 | curr->nextcxx . . $ tRecord#next. = (tRecordcxx . . $ tRecord# *)malloc(sizeof(tRecordcxx . . $ tRecord#)); |
| 561 | if (!curr->nextcxx . . $ tRecord#next.) |
| 562 | return false; |
| 563 | curr = curr->nextcxx . . $ tRecord#next.; |
| 564 | } else { |
| 565 | currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records. = (tRecordcxx . . $ tRecord# *)malloc(sizeof(tRecordcxx . . $ tRecord#)); |
| 566 | if (!currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.) |
| 567 | return false; |
| 568 | curr = currentkeycxx . . $ CRegistry#currentkey.->recordscxx . . $ tKey#records.; |
| 569 | } |
| 570 | |
| 571 | curr->nextcxx . . $ tRecord#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 572 | strcpy(curr->namecxx . . $ tRecord#name., name); |
| 573 | switch (type) { |
| 574 | case REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!: |
| 575 | curr->datacxx . . $ tRecord#data. = malloc(strlen((char *)data) + 1); |
| 576 | curr->typecxx . . $ tRecord#type. = REGT_STRINGcxx . . $ `netgames/includes/DMFC.h:502:9`!; |
| 577 | strcpy((char *)curr->datacxx . . $ tRecord#data., (char *)data); |
| 578 | break; |
| 579 | case REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!: |
| 580 | curr->datacxx . . $ tRecord#data. = malloc(sizeof(int)); |
| 581 | curr->typecxx . . $ tRecord#type. = REGT_DWORDcxx . . $ `netgames/includes/DMFC.h:503:9`!; |
| 582 | *((int *)curr->datacxx . . $ tRecord#data.) = *((int *)data); |
| 583 | break; |
| 584 | }; |
| 585 | return true; |
| 586 | } |