| 490 | #define FOURCC(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4)) |
| 491 | |
| 492 | static uint8_t *findMod(txMachine *the, char *name, int *modSize) |
| 493 | { |
| 494 | uint8_t *xsb = (uint8_t *)kModulesStart; |
| 495 | int modsSize; |
| 496 | uint8_t *mods; |
| 497 | int index = 0; |
| 498 | int nameLen; |
| 499 | char *dot; |
| 500 | |
| 501 | if (!xsb || !gHasMods) return NULL; |
| 502 | |
| 503 | mods = findAtom(FOURCC('M', 'O', 'D', 'S'), xsb, c_read32be(xsb), &modsSize); |
| 504 | if (!mods) return NULL; |
| 505 | |
| 506 | dot = c_strchr(name, '.'); |
| 507 | if (dot) |
| 508 | nameLen = dot - name; |
| 509 | else |
| 510 | nameLen = c_strlen(name); |
| 511 | |
| 512 | while (true) { |
| 513 | uint8_t *aName = findNthAtom(FOURCC('P', 'A', 'T', 'H'), ++index, mods, modsSize, NULL); |
| 514 | if (!aName) |
| 515 | break; |
| 516 | if (0 == c_strncmp(name, aName, nameLen)) { |
| 517 | if (0 == c_strcmp(".xsb", aName + nameLen)) |
| 518 | return findNthAtom(FOURCC('C', 'O', 'D', 'E'), index, mods, modsSize, modSize); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | return NULL; |
| 523 | } |
| 524 | #endif |
| 525 | |
| 526 | static txBoolean fxFindScript(txMachine* the, txSlot* realm, txString path, txID* id) |
no test coverage detected