File: ver.cc

package info (click to toggle)
wvstreams 4.6.1-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,420 kB
  • sloc: cpp: 64,196; ansic: 4,154; sh: 4,025; makefile: 546; perl: 402
file content (42 lines) | stat: -rw-r--r-- 1,060 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
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
 * 
 * Takes a string on the command line and attempts to turn it into a
 * hexadecimal version number.
 *
 * Mainly useful, stupidly enough, for the softupdate database.
 */

#include "verstring.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    unsigned int ver = 0;
    if (argc == 2)
    {
        // if the given string doesn't have any dots, assume it's a
        // new-style version filename, and insert them where they ought to
        // go.
        char buf[20];
        if (!strchr(argv[1], '.') && !strchr(argv[1], '_'))
        {
            int len = strlen(argv[1]);
            memset(buf, '0', 10);
            strcpy(buf+10-len, argv[1]);
            memmove(buf, buf+2, 2);
            buf[2]='.';
            memmove(buf+3, buf+4, 2);
            buf[5]='.';
        }
        else
            strncpy(buf, argv[1], 19);

        ver = string_to_ver(buf);
    }

    printf("0x%08x\n", ver);
    return 0;
}