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

Function main

xs/tools/xsa.c:7–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5int mainXSA(int argc, char* argv[])
6#else
7int main(int argc, char* argv[])
8#endif
9{
10 txLinker _linker;
11 txLinker* linker = &_linker;
12 txLinkerResource** resourceAddress;
13 txLinkerScript** scriptAddress;
14 int argi;
15 txString base = NULL;
16 txString input = NULL;
17 txString output = NULL;
18 txString separator = NULL;
19#if mxWindows
20 txString url = "\\";
21#else
22 txString url = "/";
23#endif
24 char name[C_PATH_MAX];
25 char path[C_PATH_MAX];
26 txSize size;
27 txLinkerResource* resource;
28 txLinkerScript* script;
29 FILE* file = NULL;
30
31 fxInitializeLinker(linker);
32 if (c_setjmp(linker->jmp_buf) == 0) {
33 if ((argc == 2) && (c_strcmp(argv[1], "args.txt") == 0)) {
34 txString buffer;
35 txString string;
36 char c;
37 file = fopen(argv[1], "r");
38 mxThrowElse(file);
39 fseek(file, 0, SEEK_END);
40 size = (txSize)ftell(file);
41 fseek(file, 0, SEEK_SET);
42 buffer = fxNewLinkerChunk(linker, size + 1);
43 size = (txSize)fread(buffer, 1, size, file);
44 buffer[size] = 0;
45 fclose(file);
46 string = buffer;
47 argc = 1;
48 while ((c = *string++)) {
49 if (isspace(c))
50 argc++;
51 }
52 argv = fxNewLinkerChunk(linker, argc * sizeof(char*));
53 for (string = buffer, argc = 1; ; string = NULL, argc++) {
54 txString token = strtok(string, " \f\n\r\t\v");
55 if (token == NULL)
56 break;
57 argv[argc] = token;
58 }
59 }
60 c_strcpy(name, "mc");
61 resourceAddress = &(linker->firstResource);
62 scriptAddress = &(linker->firstScript);
63 linker->symbolModulo = 1993;
64

Callers

nothing calls this directly

Calls 15

fxInitializeLinkerFunction · 0.85
fxNewLinkerChunkFunction · 0.85
fxReportLinkerErrorFunction · 0.85
fxNewLinkerStringFunction · 0.85
fxNewLinkerScriptFunction · 0.85
fxNewLinkerResourceFunction · 0.85
fxBaseScriptFunction · 0.85
fxSlashPathFunction · 0.85
fxNewLinkerChunkClearFunction · 0.85
fxNewLinkerSymbolFunction · 0.85
fxBaseResourceFunction · 0.85
fxMapScriptFunction · 0.85

Tested by

no test coverage detected