MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / findMod

Function findMod

xs/platforms/mc/xsHosts.c:430–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428#define findAtom(atomTypeIn, xsb, xsbSize, atomSizeOut) findNthAtom(atomTypeIn, 0, xsb, xsbSize, atomSizeOut);
429
430static uint8_t *findMod(txMachine *the, char *name, int *modSize)
431{
432 uint8_t *xsb = (uint8_t *)kModulesStart;
433 int modsSize;
434 uint8_t *mods;
435 int index = 0;
436 int nameLen;
437 char *dot;
438
439 if (!xsb || !the->archive) return NULL;
440
441 mods = findAtom(FOURCC('M', 'O', 'D', 'S'), xsb, c_read32be(xsb), &modsSize);
442 if (!mods) return NULL;
443
444 dot = c_strchr(name, '.');
445 if (dot)
446 nameLen = dot - name;
447 else
448 nameLen = c_strlen(name);
449
450 while (true) {
451 int aNameLen;
452 uint8_t *aName = findNthAtom(FOURCC('P', 'A', 'T', 'H'), ++index, mods, modsSize, &aNameLen);
453 if (!aName)
454 break;
455 if (((aNameLen - 1) == nameLen) && (0 == c_strncmp(name, aName, nameLen)))
456 return findNthAtom(FOURCC('C', 'O', 'D', 'E'), index, mods, modsSize, modSize);
457 }
458
459 return NULL;
460}
461
462char *modGetModAtom(txMachine *the, uint32_t atomTypeIn, int *atomSizeOut)
463{

Callers 2

fxFindScriptFunction · 0.70
fxLoadModuleFunction · 0.70

Calls 1

findNthAtomFunction · 0.85

Tested by

no test coverage detected