fix crash when specifying --source on command line
[rofl0r-gnuboy.git] / rcfile.c
blob9945f52138d3e5d8a4d2943295443be1026ea5fa
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
8 #include "defs.h"
9 #include "rc.h"
10 #include "hw.h"
11 #include "path.h"
14 char *rcpath;
16 int rc_sourcefile(char *filename)
18 FILE *f;
19 char *name;
20 char line[256], *p;
22 name = path_search(filename, "r", rcpath);
23 f = fopen(name, "r");
24 if (!f) return -1;
26 for (;;)
28 if (feof(f)) break;
29 fgets(line, sizeof line, f);
30 if ((p = strpbrk(line, "#\r\n")))
31 *p = 0;
32 rc_command(line);
34 fclose(f);
35 return 0;
39 rcvar_t rcfile_exports[] =
41 RCV_STRING("rcpath", &rcpath, "path to look for gnuboy.rc"),
42 RCV_END