home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cidsam.zip
/
CHKLVL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-28
|
4KB
|
98 lines
/*********************************/
/* NOTE */
/* */
/* This sample code has been */
/* provided by IBM. It is not */
/* warranted for any particular */
/* use or purpose. */
/* */
/* IBM releases this code into */
/* the public domain. You may */
/* use it, modify it, or */
/* incorporate it into other */
/* products without restriction. */
/*********************************/
/* Check the IBMLVL.INI file for the application and level. Return 2 if */
/* a later level of the application is installed. Return 1 if the same */
/* level is installed. Return 0 if an earlier level or no level is */
/* installed.
/* */
/* Command line syntax is */
/* chklvl product release.version */
/* Example: */
/* chklvl IBM_UPM 2.00 */
/* */
/*********************************************************************/
#pragma page (1)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define INCL_WIN
#include <os2.h>
char *srelease = "RELEASE";
char *sversion = "VERSION";
#define STRSIZE 20
int main(int argc, char **argv)
{
HAB hab;
HINI hini;
USHORT rc;
ULONG bufsize = STRSIZE;
char cInstRelease[STRSIZE]; /* should be plenty big enough */
char cInstVersion[STRSIZE];
int iInstRelease, iInstVersion;
int iTestRelease, iTestVersion;
ULONG lenfound, instchk, testchk;
char *p;
if (argc < 4)
{
printf("Usage: getcfcfg inifile product version.release\n");
return(0);
}
p = argv[3];
iTestRelease = atoi(p);
for (; *p && *p != '.'; p++);
if (*p)
p++;
iTestVersion = atoi(p);
rc = 0;
hab = WinInitialize(0);
hini = PrfOpenProfile(hab, argv[1]);
if (hini)
{
lenfound = PrfQueryProfileString(hini, argv[2], srelease, NULL,
cInstRelease, (ULONG)bufsize);
if (lenfound > 0)
{
strcpy(cInstVersion, "00");
lenfound = PrfQueryProfileString(hini, argv[2], sversion, NULL,
cInstVersion, (ULONG)bufsize);
printf("Version %s.%s of %s is installed.\n",
cInstRelease,
cInstVersion,
argv[2]);
iInstRelease = atoi(cInstRelease);
iInstVersion = atoi(cInstVersion);
testchk = iTestRelease * 100 + iTestVersion;
instchk = iInstRelease * 100 + iInstVersion;
if (instchk > testchk)
rc = 2;
else
if (instchk == testchk)
rc = 1;
}
else
printf("%s is not in profile %s\n", argv[2], argv[1]);
PrfCloseProfile(hini);
}
if (hab)
WinTerminate(hab);
return(rc);
}