Personal tools
User menu


From Francois Louw

Jump to: navigation, search

Back To All Projects Page

Back To Main Page

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

buildrev.exe <filename.h>

The format for the header file is as follows:

#define BUILD 1

The #define and the BUILD is not important and can be changed to

int build= 1

The code looks for the third field (separated by space) and increases that value.

Here is the code released under the GPL 3 license

//Build Revision
//Copyright 2012 Francois Louw
//A copy of the licence can be found at
#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);
		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
	fprintf(f, "%s %s %d\n", d, b, i);
	printf("Build number %d\n", i);
	return 0;	

The code is pretty straightforward and does not need much explanation.

Please read here for more information on copyrights of my projects.