Debian Codegraph @

src/platform.c

raw symbols SCIP
1 // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
2 // Copyright (C) 1998-2025 Marco Baye
3 // Have a look at "acme.c" for further info
4 //
5 // Platform specific stuff
6 #include "platform.h"
7 #include "global.h" // for config
8
9
10 // Amiga
11 #ifdef _AMIGA
12 #include "_amiga.c"
13 #endif
14
15 // DOS, OS/2 and Windows
16 #if defined(__DJGPP__) || defined(__OS2__) || defined(__Windows__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__MINGW32__) || defined(__MINGW64__)
17 #include "_dos.c"
18 #endif
19
20 // RISC OS
21 #ifdef __riscos__
22 #include "_riscos.c"
23 #endif
24
25 // add further platform files here
26
27 // Unix/Linux/others (also works on newer versions of Windows)
28 #ifndef platform_C
29 #include "_std.c"
30 #endif
31
32
33 // set or change library path
34 void platform_set_lib_path(const char new_path[])
35 {
36 if (config.platform_lib_prefix) {
37 // this is mostly for debugging so people can check if their env var setup works:
38 printf("Changing library path from \"%s\" to \"%s\".\n", config.platform_lib_prefix, new_path);
39 fflush(stdout); // force output before any subsequent errors
40 }
41 config.platform_lib_prefix = new_path;
42 }
43
44
45 // stuff shared by some, but not all platforms:
46 #if PLATFORM_USE_ENV_VAR
47
48 #include <stdlib.h> // for getenv()
49 #include "dynabuf.h"
50
51 // function to setup pointer to library tree from env var
52 void platform_read_env_var(void)
53 {
54 char *env_var;
55
56 // find out the path of ACME's library
57 env_var = getenv("ACME");
58 // if environment variable was found, make a copy
59 if (env_var) {
60 dynabuf_clear(GlobalDynaBuf);
61 // copy environment variable to global dynamic buffer
62 dynabuf_add_string(GlobalDynaBuf, env_var);
63 dynabuf_append(GlobalDynaBuf, '\0'); // add terminator
64 platform_set_lib_path(dynabuf_get_copy(GlobalDynaBuf));
65 }
66 }
67
68 #endif