1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-11 20:05:02 -05:00
hexchat/src/version/version.c

154 lines
4.6 KiB
C
Raw Normal View History

2012-07-13 16:27:12 -04:00
/* HexChat
* Copyright (c) 2011-2012 Berke Viktor.
2012-06-03 06:06:06 -04:00
*
2012-07-13 16:27:12 -04:00
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
2012-06-03 06:06:06 -04:00
*
2012-07-13 16:27:12 -04:00
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
2012-06-03 06:06:06 -04:00
*/
#include <stdio.h>
#include <stdlib.h>
2012-10-18 11:54:03 -04:00
#include <string.h>
#include "../../config-win32.h"
2012-06-03 06:06:06 -04:00
char *
comma ()
{
2012-07-20 09:41:08 -04:00
# if 0 /* for WDK version numbers */
2012-06-03 06:06:06 -04:00
int major, minor;
char *version_string; /* nnnn,n,n,n format */
version_string = (char*) malloc (11);
if (sscanf (PACKAGE_VERSION, "%d-%d", &major, &minor) > 1)
{
sprintf (version_string, "%d,%d,0,0", major, minor);
2012-07-20 09:41:08 -04:00
}
else
2012-06-03 06:06:06 -04:00
{
sprintf (version_string, "%d,0,0,0", major);
}
2012-07-20 09:41:08 -04:00
#endif
int major, minor, build;
char *version_string; /* n,n,n,n format */
version_string = (char*) malloc (8);
sscanf (PACKAGE_VERSION, "%d.%d.%d", &major, &minor, &build);
sprintf (version_string, "%d,%d,%d,0", major, minor, build);
2012-06-03 06:06:06 -04:00
return version_string;
}
char *
point ()
{
int major1, major2, major3, major4, minor;
char *version_string; /* nn.nn.nn.nn format */
version_string = (char*) malloc (12);
if (sscanf (PACKAGE_VERSION, "%c%c%c%c-%d", &major1, &major2, &major3, &major4, &minor) > 4)
{
sprintf (version_string, "%c%c.%c%c.%d.0", major1, major2, major3, major4, minor);
2012-07-13 12:35:47 -04:00
}
else
2012-06-03 06:06:06 -04:00
{
sprintf (version_string, "%c%c.%c%c.0.0", major1, major2, major3, major4);
}
return version_string;
}
int
main (int argc, char *argv[])
{
if (argc > 1)
{
2012-07-11 15:33:10 -04:00
if (!strcmp (argv[1], "-r")) /* hexchat.rc/FILEVERSION, PRODUCTVERSION */
2012-06-03 06:06:06 -04:00
{
printf ("#define COMMA_VERSION %s\n", comma ());
}
2012-07-11 15:33:10 -04:00
else if (!strcmp (argv[1], "-a")) /* hexchat.iss/AppVerName */
2012-06-03 06:06:06 -04:00
{
2012-06-15 15:37:48 -04:00
#ifdef _WIN64
2012-07-11 15:33:10 -04:00
printf ("AppVerName=HexChat %s (x64)\n", PACKAGE_VERSION);
2012-06-15 15:37:48 -04:00
#else
2012-07-11 15:33:10 -04:00
printf ("AppVerName=HexChat %s (x86)\n", PACKAGE_VERSION);
2012-06-15 15:37:48 -04:00
#endif
2012-06-03 06:06:06 -04:00
}
2012-07-11 15:33:10 -04:00
else if (!strcmp (argv[1], "-v")) /* hexchat.iss/AppVersion */
2012-06-03 06:06:06 -04:00
{
2012-07-13 12:35:47 -04:00
/* printf ("AppVersion=%s\n", point ()); this was required only for nnnn[-n] version numbers */
printf ("AppVersion=%s\n", PACKAGE_VERSION);
2012-06-03 06:06:06 -04:00
}
2012-07-11 15:33:10 -04:00
else if (!strcmp (argv[1], "-i")) /* hexchat.iss/VersionInfoVersion */
2012-06-03 06:06:06 -04:00
{
2012-07-13 12:35:47 -04:00
/* printf ("VersionInfoVersion=%s\n", point ()); this was required only for nnnn[-n] version numbers */
printf ("VersionInfoVersion=%s\n", PACKAGE_VERSION);
2012-06-03 06:06:06 -04:00
}
2012-07-11 15:33:10 -04:00
else if (!strcmp (argv[1], "-o")) /* hexchat.iss/OutputBaseFilename */
2012-06-03 06:06:06 -04:00
{
2012-06-15 15:37:48 -04:00
#ifdef _WIN64
2012-07-11 15:33:10 -04:00
printf ("OutputBaseFilename=HexChat %s x64\n", PACKAGE_VERSION);
2012-06-15 15:37:48 -04:00
#else
2012-07-11 15:33:10 -04:00
printf ("OutputBaseFilename=HexChat %s x86\n", PACKAGE_VERSION);
2012-06-15 15:37:48 -04:00
#endif
2012-06-03 06:06:06 -04:00
}
else if (!strcmp (argv[1], "-v")) /* version.txt */
{
printf ("%s", PACKAGE_VERSION);
}
else
2012-06-03 06:06:06 -04:00
{
2012-07-11 15:33:10 -04:00
printf ("usage:\n\t-a\thexchat.iss/AppVerName\n\t-i\thexchat.iss/VersionInfoVersion\n\t-o\thexchat.iss/OutputBaseFilename\n\t-r\thexchat.rc/FILEVERSION, PRODUCTVERSION\n\t-v\thexchat.iss/AppVersion\n");
2012-06-03 06:06:06 -04:00
}
} else
{
2012-07-11 15:33:10 -04:00
printf ("usage:\n\t-a\thexchat.iss/AppVerName\n\t-i\thexchat.iss/VersionInfoVersion\n\t-o\thexchat.iss/OutputBaseFilename\n\t-r\thexchat.rc/FILEVERSION, PRODUCTVERSION\n\t-v\thexchat.iss/AppVersion\n");
2012-06-03 06:06:06 -04:00
}
#if 0 /* ugly hack */
switch ((int) argv[1][0])
{
2012-07-11 15:33:10 -04:00
case 'r': /* hexchat.rc/FILEVERSION, PRODUCTVERSION*/
2012-06-03 06:06:06 -04:00
printf ("#define COMMA_VERSION \"%s\"\n", comma ());
break;
2012-07-11 15:33:10 -04:00
case 'a': /* hexchat.iss/AppVerName */
printf ("AppVerName=HexChat %s\n", PACKAGE_VERSION);
2012-06-03 06:06:06 -04:00
break;
2012-07-11 15:33:10 -04:00
case 'v': /* hexchat.iss/AppVersion */
2012-06-03 06:06:06 -04:00
printf ("AppVersion=%s\n", point ());
break;
2012-07-11 15:33:10 -04:00
case 'i': /* hexchat.iss/VersionInfoVersion */
2012-06-03 06:06:06 -04:00
printf ("VersionInfoVersion=%s\n", point ());
break;
2012-07-11 15:33:10 -04:00
case 'o': /* hexchat.iss/OutputBaseFilename */
printf ("OutputBaseFilename=HexChat %s\n", PACKAGE_VERSION);
2012-06-03 06:06:06 -04:00
break;
case 'u': /* version.txt */
printf ("%s", PACKAGE_VERSION);
break;
default:
printf ("use a, i, o, r or v.\n");
break;
}
#endif
return 0;
}