Personal tools
Log in
User menu
Main page
All Projects
Recommended Tools
Research
Resume/CV
Links
View source for Buildrev
From Francois Louw
Jump to:
navigation
,
search
[http://aeif.info/files/buildrev/BuildRevision20121120.zip Download Windows executable with source] This application is quite handy and small. It is coded in simple C. Every time it runs it reads the given header file and increments the build number. Please note that this program is very basic, and apart from file checking it does not do any other checking. Usage of the program is <source lang="dos"> buildrev.exe <filename.h> </source> The format for the header file is as follows: <source lang="c"> #define BUILD 1 </source> The #define and the BUILD is not important and can be changed to <source lang="c"> int build= 1 </source> '''The code looks for the third field (separated by space) and increases that value.''' Here is the code released under the [http://aeif.info/gpl-3.0.txt GPL 3 license] <source lang="c"> //Build Revision //2012-11-20 //Published under GNU GENERAL PUBLIC LICENSE V3 //Copyright 2012 Francois Louw //A copy of the licence can be found at http://aeif.info/gpl-3.0.txt #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { FILE *f; int i = 0; char d[20] = {0}; char b[20] = {0}; if (argc != 2) { printf("Usage is %s <filename.h>\n", argv[0]); return -1; } f = NULL; f = fopen(argv[1], "r"); if (f != NULL) { fscanf(f, "%s %s %d", d, b, &i); fclose(f); f = NULL; } else { printf("Build file not found, creating default\n"); strcpy(d, "#define"); strcpy(b, "BUILD"); } f = fopen(argv[1], "w"); if (f == NULL) { printf("ERROR: Cannot open output file for writing\n"); return -1; } //increase build number i++; fprintf(f, "%s %s %d\n", d, b, i); printf("Build number %d\n", i); fclose(f); return 0; } </source> The code is pretty straightforward and does not need much explanation. Please read [[Francois_Louw:Copyrights|here]] for more information on copyrights of my projects.
Return to
Buildrev
.