WvStreams
|
00001 /* 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Takes a string on the command line and attempts to turn it into a 00006 * hexadecimal version number. 00007 * 00008 * Mainly useful, stupidly enough, for the softupdate database. 00009 */ 00010 00011 #include "verstring.h" 00012 #include <stdio.h> 00013 #include <string.h> 00014 00015 int main(int argc, char *argv[]) 00016 { 00017 unsigned int ver = 0; 00018 if (argc == 2) 00019 { 00020 // if the given string doesn't have any dots, assume it's a 00021 // new-style version filename, and insert them where they ought to 00022 // go. 00023 char buf[20]; 00024 if (!strchr(argv[1], '.') && !strchr(argv[1], '_')) 00025 { 00026 int len = strlen(argv[1]); 00027 memset(buf, '0', 10); 00028 strcpy(buf+10-len, argv[1]); 00029 memmove(buf, buf+2, 2); 00030 buf[2]='.'; 00031 memmove(buf+3, buf+4, 2); 00032 buf[5]='.'; 00033 } 00034 else 00035 strncpy(buf, argv[1], 19); 00036 00037 ver = string_to_ver(buf); 00038 } 00039 00040 printf("0x%08x\n", ver); 00041 return 0; 00042 }