File: mkversion.c

package info (click to toggle)
vic 2.8ucl4-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,864 kB
  • ctags: 9,033
  • sloc: ansic: 56,989; cpp: 44,560; tcl: 5,550; sh: 1,382; perl: 1,329; makefile: 357
file content (29 lines) | stat: -rw-r--r-- 423 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * mkversion.c
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main(int argc, char **argv)
{
	char s[256];
	int l;
	const char* fmt = "const char version[] = \"%s\";";

	if (argc > 1)
		fmt = argv[1];

	if (fgets(s, sizeof(s), stdin) == NULL) {
		perror("fgets");
		exit(1);
	}

	for (l = strlen(s) - 1; s[l] == '\n' || s[l] == '\r'; --l)
	    s[l] = '\0';
	
	printf(fmt, s);
	printf("\n");
	exit(0);
}