[darwinbuild-changes] [63] trunk/darwinxref/main.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 4 01:42:44 PDT 2006
Revision: 63
http://trac.macosforge.org/projects/darwinbuild/changeset/63
Author: kevin
Date: 2006-10-04 01:42:44 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
- grab the default build number from .build/build if available
Modified Paths:
--------------
trunk/darwinxref/main.c
Modified: trunk/darwinxref/main.c
===================================================================
--- trunk/darwinxref/main.c 2005-07-11 23:35:22 UTC (rev 62)
+++ trunk/darwinxref/main.c 2006-10-04 08:42:44 UTC (rev 63)
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
+#include <fcntl.h>
#include "DBPluginPriv.h"
@@ -46,6 +47,7 @@
// user environment global
extern char** environ;
+char* readBuildFile();
int main(int argc, char* argv[]) {
char* progname = argv[0];
@@ -74,6 +76,8 @@
argc -= optind;
argv += optind;
+ if (build == NULL) build = readBuildFile();
+
// special built-in command
if (argc == 1 && strcmp(argv[0], "info") == 0) {
printf("%s/%s\n", basename(progname), "" VERSION "");
@@ -93,3 +97,23 @@
return 0;
}
+char* readBuildFile() {
+ char* build = NULL;
+ int fd = open(".build/build", O_RDONLY);
+ if (fd != -1) {
+ size_t size = 1000; // should be bigger than any likely build number
+ build = malloc(size);
+ if (build) {
+ ssize_t len = read(fd, build, size-1);
+ if (len == -1) {
+ free(build);
+ build = NULL;
+ } else {
+ build[len] = 0;
+ if (build[len-1] == '\n') build[len-1] = 0;
+ }
+ }
+ }
+ close(fd);
+ return build;
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/fd2c2f9f/attachment-0001.html
More information about the darwinbuild-changes
mailing list