WvStreams
ver.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Takes a string on the command line and attempts to turn it into a
6 * hexadecimal version number.
7 *
8 * Mainly useful, stupidly enough, for the softupdate database.
9 */
10
11#include "verstring.h"
12#include <stdio.h>
13#include <string.h>
14
15int main(int argc, char *argv[])
16{
17 unsigned int ver = 0;
18 if (argc == 2)
19 {
20 // if the given string doesn't have any dots, assume it's a
21 // new-style version filename, and insert them where they ought to
22 // go.
23 char buf[20];
24 if (!strchr(argv[1], '.') && !strchr(argv[1], '_'))
25 {
26 int len = strlen(argv[1]);
27 memset(buf, '0', 10);
28 strcpy(buf+10-len, argv[1]);
29 memmove(buf, buf+2, 2);
30 buf[2]='.';
31 memmove(buf+3, buf+4, 2);
32 buf[5]='.';
33 }
34 else
35 strncpy(buf, argv[1], 19);
36
37 ver = string_to_ver(buf);
38 }
39
40 printf("0x%08x\n", ver);
41 return 0;
42}