source: trunk/ICeCoffEE/ICeCoffEE/GetNumericBundleVersion.c @ 421

Last change on this file since 421 was 421, checked in by Nicholas Riley, 12 years ago

Use VERSION.xcconfig to generate ui.plist

File size: 1.0 KB
Line 
1/*
2 *  GetNumericBundleVersion.c
3 *  ICeCoffEE
4 *
5 *  Created by Nicholas Riley on 2/29/08.
6 *  Copyright 2008 Nicholas Riley. All rights reserved.
7 *
8 */
9
10#include <crt_externs.h>
11#include <CoreFoundation/CoreFoundation.h>
12
13void usage(const char *fmt, ...) {
14    char *progname = **_NSGetArgv();
15    if (fmt != NULL) {
16        va_list ap;
17        va_start(ap, fmt);
18        fprintf(stderr, "%s: ", progname);
19        vfprintf(stderr, fmt, ap);
20        fputs("\n", stderr);
21    }
22    fprintf(stderr, "usage: %s bundle_path\n", progname);
23    exit(1);
24}
25
26int main(int argc, char *argv[]) {
27    if (argc != 2)
28        usage(NULL);
29   
30    CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (UInt8 *)argv[1], strlen(argv[1]), true);
31    if (url == NULL)
32        usage(NULL);
33   
34    CFBundleRef bundle = CFBundleCreate(NULL, url);
35    if (bundle == NULL)
36        usage("can't create CFBundleRef from %s", argv[1]);
37   
38    UInt32 version = CFBundleGetVersionNumber(bundle);
39    if (version == 0)
40        usage("can't get version from %s", argv[1]);
41   
42    printf("%d\n", version);
43   
44    return 0;
45}
Note: See TracBrowser for help on using the repository browser.