From 03fbc7d281f5039a97c851970dea3cd8cfaefd64 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Jun 2010 20:00:21 -0400 Subject: Changed the versioning system to use git --- include/version.sh.c | 248 --------------------------------------------------- 1 file changed, 248 deletions(-) delete mode 100644 include/version.sh.c (limited to 'include/version.sh.c') diff --git a/include/version.sh.c b/include/version.sh.c deleted file mode 100644 index 83dc2b9cd..000000000 --- a/include/version.sh.c +++ /dev/null @@ -1,248 +0,0 @@ -/* version file handler for win32. - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for furhter details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * Written by Dominick Meglio - */ - -/* Needed due to Windows lack of a decent interpreter */ - -#include -#include -#include -#include - -long version_major, version_minor, version_patch, version_build, build; -char *version_extra = NULL; -char version[1024]; -char version_dotted[1024]; - -void load_ctrl(FILE *); -long get_value(char *); -char *get_value_str(char *); -char *strip(char *); -void parse_version(FILE *); -void write_version(FILE *, const char *); -void parse_line(FILE *, char *); - -int main(int argc, char *argv[]) -{ - if (argc < 4) - { - fprintf(stderr, "Syntax: %s \n", argv[0]); - exit(1); - } - FILE *fd = fopen(argv[1], "r"); - - if (!fd) - { - fprintf(stderr, "Error: Unable to find control file: %s\n", argv[1]); - exit(0); - } - - load_ctrl(fd); - fclose(fd); - - _snprintf(version, 1024, "%ld.%ld.%ld%s (%ld)", version_major, version_minor, version_patch, version_extra ? version_extra : "", version_build); - - _snprintf(version_dotted, 1024, "%ld.%ld.%ld%s.%ld", version_major, version_minor, version_patch, version_extra ? version_extra : "", version_build); - - fd = fopen(argv[3], "r"); - - if (fd) - { - parse_version(fd); - fclose(fd); - } - else - build = 1; - - fd = fopen(argv[3], "w"); - write_version(fd, argv[2]); - fclose(fd); - - if (version_extra) - free(version_extra); -} - -void load_ctrl(FILE * fd) -{ - char buf[512]; - while (fgets(buf, 511, fd)) - { - char *var; - - strip(buf); - - var = strtok(buf, "="); - if (!var) - continue; - if (!strcmp(var, "VERSION_MAJOR")) - version_major = get_value(strtok(NULL, "")); - else if (!strcmp(var, "VERSION_MINOR")) - version_minor = get_value(strtok(NULL, "")); - else if (!strcmp(var, "VERSION_PATCH")) - version_patch = get_value(strtok(NULL, "")); - else if (!strcmp(var, "VERSION_BUILD")) - version_build = get_value(strtok(NULL, "")); - else if (!strcmp(var, "VERSION_EXTRA")) - version_extra = get_value_str(strtok(NULL, "")); - } -} - -char *strip(char *str) -{ - char *c; - if ((c = strchr(str, '\n'))) - *c = 0; - if ((c = strchr(str, '\r'))) - *c = 0; - return str; -} - -long get_value(char *string) -{ - // XXX : if the fields in version.log are empty strtok returns a double quote, dont try to atol it then - if (string[1] != '"') - return atol(get_value_str(string)); - else - return 0; -} - -char *get_value_str(char *string) -{ - int len; - char *newstr; - - if (*string == '"') - ++string; - - len = strlen(string); - - if (string[len - 1] == '"') - string[len - 1] = 0; - if (!*string) - return NULL; - newstr = (char *)malloc(len + 1); - strcpy(newstr, string); - return newstr; - //return strdup(string); -} - -void parse_version(FILE * fd) -{ - char buf[1024]; - - while (fgets(buf, 1023, fd)) - { - char *para1; - - strip(buf); - para1 = strtok(buf, " \t"); - - if (!para1) - continue; - - if (!strcmp(para1, "#define")) - { - char *para2 = strtok(NULL, " \t"); - - if (!para2) - continue; - - if (!strcmp(para2, "BUILD")) - { - char *value = strtok(NULL, ""); - build = get_value(value); - build++; - return; - } - } - } - build = 1; -} - -void write_version(FILE *fd, const char *input) -{ - FILE *fdin = fopen(input, "r"); - char buf[1024]; - short until_eof = 0; - - while (fgets(buf, 1023, fdin)) - { - strip(buf); - - if (until_eof) - { - if (!strcmp(buf, "EOF")) - break; - else - parse_line(fd, buf); - } - - if (!strcmp(buf, "cat >$VERSIONH <