forked from rofl0r/gnuboy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcfile.c
45 lines (32 loc) · 555 Bytes
/
rcfile.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "rc.h"
#include "hw.h"
#include "path.h"
char *rcpath;
int rc_sourcefile(char *filename)
{
FILE *f;
char *name;
char line[256], *p;
name = path_search(filename, "r", rcpath);
f = fopen(name, "r");
if (!f) return -1;
for (;;)
{
if (feof(f)) break;
fgets(line, sizeof line, f);
if ((p = strpbrk(line, "#\r\n")))
*p = 0;
rc_command(line);
}
fclose(f);
return 0;
}
rcvar_t rcfile_exports[] =
{
RCV_STRING("rcpath", &rcpath),
RCV_END
};