fix crash when specifying --source on command line
[rofl0r-gnuboy.git] / exports.c
blobf97982fc24cd16e4a7d4aae3c0d2c999f645c129
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "rc.h"
6 extern rcvar_t rcfile_exports[], emu_exports[], loader_exports[],
7 lcd_exports[], rtc_exports[], debug_exports[], sound_exports[],
8 vid_exports[], joy_exports[], pcm_exports[], menu_exports[];
11 rcvar_t *sources[] =
13 rcfile_exports,
14 emu_exports,
15 loader_exports,
16 lcd_exports,
17 rtc_exports,
18 debug_exports,
19 sound_exports,
20 vid_exports,
21 joy_exports,
22 pcm_exports,
23 menu_exports,
24 NULL
28 void init_exports()
30 rcvar_t **s = sources;
32 while (*s)
33 rc_exportvars(*(s++));
37 void show_exports()
39 int i, j, n, *vec;
40 char value[256], tbuf[16], *v;
42 for (i = 0; sources[i]; i++)
43 for (j = 0; sources[i][j].name; j++) {
44 v = value;
45 sprintf(tbuf, "%-4s", rc_type_to_string(sources[i][j].type));
46 switch (sources[i][j].type) {
47 case rcv_bool:
48 case rcv_int:
49 sprintf(value, "%d", rc_getint(sources[i][j].name));
50 break;
51 case rcv_string:
52 v = rc_getstr(sources[i][j].name);
53 v = v ? v : "";
54 break;
55 case rcv_vector:
56 sprintf(tbuf+3, "%d", sources[i][j].len);
57 vec = rc_getvec(sources[i][j].name);
58 if (vec)
59 for (n = 0; n < sources[i][j].len; ++n) {
60 if (*vec > 999)
61 v += sprintf(v, "0x%x ", *(vec++));
62 else
63 v += sprintf(v, "%d ", *(vec++));
65 else value[0] = 0;
66 v = value;
67 break;
69 printf("%-11s %-35s %-4s %-8s\n",
70 sources[i][j].name,
71 sources[i][j].help[0] == 0 ? "-" : sources[i][j].help,
72 tbuf,