gnuboy-for-dfi/rcfile.c

46 lines
555 B
C
Raw Normal View History

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "rc.h"
#include "hw.h"
2012-06-23 14:46:01 +00:00
#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
};