bversion.cpp

This is an example of version use.

#include <stdio.h>
#include "btrieveCpp.h"
loginDatabaseURI(const char *databaseURI, BtrieveClient *btrieveClient)
{
// If Login() fails.
if ((status = btrieveClient->Login(databaseURI)) != Btrieve::STATUS_CODE_NO_ERROR)
{
printf("Error: BtrieveClient::Login():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
leave:
return status;
}
logoutDatabaseURI(const char *databaseURI, BtrieveClient *btrieveClient)
{
// If Logout() fails.
if ((status = btrieveClient->Logout(databaseURI)) != Btrieve::STATUS_CODE_NO_ERROR)
{
printf("Error: BtrieveClient::Logout():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
leave:
return status;
}
printVersion(BtrieveClient *btrieveClient)
{
BtrieveVersion btrieveVersion;
Btrieve::VersionType btrieveVersionType;
int i;
// If GetVersion() fails.
if ((status = btrieveClient->GetVersion(&btrieveVersion)) != Btrieve::STATUS_CODE_NO_ERROR)
{
printf("Error: BtrieveClient::GetVersion():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
// If GetClientRevisionNumber() fails.
if ((i = btrieveVersion.GetClientRevisionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetClientRevisionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("ClientRevisionNumber = %d\n", i);
// If GetClientVersionNumber() fails.
if ((i = btrieveVersion.GetClientVersionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetClientVersionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("ClientVersionNumber = %d\n", i);
// If GetClientVersionType() fails.
if ((btrieveVersionType = btrieveVersion.GetClientVersionType()) == Btrieve::VERSION_TYPE_UNKNOWN)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetClientVersionType():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("ClientVersionType = %s\n", Btrieve::VersionTypeToString(btrieveVersionType));
// If GetLocalRevisionNumber() fails.
if ((i = btrieveVersion.GetLocalRevisionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetLocalRevisionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("LocalRevisionNumber = %d\n", i);
// If GetLocalVersionNumber() fails.
if ((i = btrieveVersion.GetLocalVersionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetLocalVersionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("LocalVersionNumber = %d\n", i);
// If GetLocalVersionType() fails.
if ((btrieveVersionType = btrieveVersion.GetLocalVersionType()) == Btrieve::VERSION_TYPE_UNKNOWN)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetLocalVersionType():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("LocalVersionType = %s\n", Btrieve::VersionTypeToString(btrieveVersionType));
// If GetRemoteRevisionNumber() fails.
if ((i = btrieveVersion.GetRemoteRevisionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetRemoteRevisionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("RemoteRevisionNumber = %d\n", i);
// If GetRemoteVersionNumber() fails.
if ((i = btrieveVersion.GetRemoteVersionNumber()) < 0)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetRemoteVersionNumber():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("RemoteVersionNumber = %d\n", i);
// If GetRemoteVersionType() fails.
if ((btrieveVersionType = btrieveVersion.GetRemoteVersionType()) == Btrieve::VERSION_TYPE_UNKNOWN)
{
status = btrieveVersion.GetLastStatusCode();
printf("Error: BtrieveVersion::GetRemoteVersionType():%d:%s.\n", status, Btrieve::StatusCodeToString(status));
goto leave;
}
printf("RemoteVersionType = %s\n", Btrieve::VersionTypeToString(btrieveVersionType));
leave:
return status;
}
int
main(int argc, char *argv[])
{
static const char *usage = "Usage: %s databaseURI\n";
BtrieveClient btrieveClient;
char *databaseURI;
// If the incorrect number of arguments were given.
if (argc != 2)
{
printf(usage, argv[0]);
goto leave;
}
databaseURI = argv[1];
// If loginDatabaseURI() fails.
if ((status = loginDatabaseURI(databaseURI, &btrieveClient)) != Btrieve::STATUS_CODE_NO_ERROR)
{
goto leave;
}
// If printVersion() fails.
if ((status = printVersion(&btrieveClient)) != Btrieve::STATUS_CODE_NO_ERROR)
{
goto leave;
}
// If logoutDatabaseURI() fails.
if ((status = logoutDatabaseURI(databaseURI, &btrieveClient)) != Btrieve::STATUS_CODE_NO_ERROR)
{
goto leave;
}
leave:
// If there wasn't a failure.
return 0;
return 1;
}