unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

config.c (1229B)

      1 
      2 #include <stdio.h>
      3 #include <string.h>
      4 int main() {
      5 	FILE *fd = fopen("Changes", "r");
      6 	FILE *fd2;
      7 	char buf[1024];
      8 	int i = 0, space = 0, j = 0;
      9 	char releaseid[512];
     10 	int generation = 0;
     11 
     12 	*releaseid = '\0';
     13 
     14 	i = 0;
     15 	fd = fopen("src/version.c", "r");
     16 	if (!fd)
     17 		generation = 1;
     18 	else {
     19 		while (fgets(buf, 1023, fd)) {
     20 			if (!strstr(buf, "char *generation"))
     21 				continue;
     22 			while (!isdigit(buf[i]))
     23 					i++;
     24 			j = i;
     25 			while (isdigit(buf[j])) 
     26 				j++;
     27 			buf[j] = 0;
     28 			generation = (atoi(&buf[i])+1);
     29 		}
     30 	}
     31 	fd = fopen("src/version.c.sh", "r");
     32 	if (!fd)
     33 		return 0;
     34 	fd2 = fopen("src/version.c", "w");
     35 	if (!fd2)
     36 		return 0;
     37 	while (fgets(buf, 1023, fd)) {
     38 		if (!strncmp("cat >version.c <<!SUB!THIS!",buf,27)) {
     39 			while (fgets(buf, 1023, fd)) {
     40 				if (!strncmp("!SUB!THIS!",buf,10))
     41 					break;
     42 				if (!strncmp("char *creation = \"$creation\";",buf,29)) 
     43 					fprintf(fd2,"char *creation = __TIMESTAMP__;\n");
     44 				else if (!strncmp("char *generation = \"$generation\";",buf,33))
     45 					fprintf(fd2,"char *generation = \"%d\";\n",generation);
     46 				else if (!strncmp("char *buildid = \"$id\";",buf,22))
     47 					fprintf(fd2,"char *buildid = \"%s\";\n",releaseid);
     48 				else
     49 					fprintf(fd2,"%s", buf);
     50 			}
     51 		}
     52 	}
     53 
     54 
     55 }
     56