1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-03 02:23:12 +02:00
Files
unrealircd/velcro/part2.c
T
stskeeps 5849092137 - Adding Velcro (the build system from unreal4), for some experimentation
with a new module API. Is currently not autoconf'ied, makefile'ed, etc.
  May the screaming commence.
2007-06-04 21:05:36 +00:00

47 lines
960 B
C

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
void parse(char *path, char *from, char *to)
{
FILE *f = fopen(path, "r");
if (f == NULL)
{
fprintf(stderr, "Error opening file %s: %s\n", path, strerror(errno));
exit(-5);
}
char buf[2048], *s;
int line = 0;
while ((s = fgets(buf, 2047, f)) != NULL)
{
line++;
if (strncmp(from, buf, strlen(from)) == 0)
{
// start pumping
while ((s = fgets(buf, 2047, f)) != NULL)
{
line++;
if (to != NULL && (strncmp(to, buf, strlen(to)) == 0))
{
exit(0);
}
printf("%s", s);
}
if (to != NULL)
{
fprintf(stderr, "EOF reached trying to find %s in %s\n",
to, path);
exit(-2);
}
exit(0);
}
}
}
int main(int argc, char **argv)
{
parse(argv[1], argv[2], argv[3]);
return 0;
}