Btrieve 2
Loading...
Searching...
No Matches
bversion.cpp

This is an example of version use written in C++.

#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;
}
The Btrieve client class.
Definition btrieveCpp.h:1388
Btrieve::StatusCode Logout(const char *databaseURI)
Logout.
Btrieve::StatusCode GetVersion(BtrieveVersion *btrieveVersion, BtrieveFile *btrieveFile=NULL)
Get the version.
Btrieve::StatusCode Login(const char *databaseURI)
Login.
The Btrieve version class.
Definition btrieveCpp.h:4027
int GetClientRevisionNumber()
Get the client revision number.
Btrieve::VersionType GetRemoteVersionType()
Get the remote version type.
int GetLocalRevisionNumber()
Get the local revision number.
int GetLocalVersionNumber()
Get the local version number.
int GetRemoteRevisionNumber()
Get the remote revision number.
int GetRemoteVersionNumber()
Get the remote version number.
Btrieve::VersionType GetLocalVersionType()
Get the local version type.
int GetClientVersionNumber()
Get the client version number.
Btrieve::StatusCode GetLastStatusCode()
Get the last status code.
Btrieve::VersionType GetClientVersionType()
Get the client version type.
static const char * StatusCodeToString(StatusCode statusCode)
Return a status code as a string.
StatusCode
The Btrieve status codes.
Definition btrieveCpp.h:713
@ STATUS_CODE_UNKNOWN
-7 - Unknown.
Definition btrieveCpp.h:1194
@ STATUS_CODE_NO_ERROR
0 - No error.
Definition btrieveCpp.h:715
static const char * VersionTypeToString(VersionType versionType)
Return a version type as a string.
VersionType
The Btrieve version types.
Definition btrieveCpp.h:1252
@ VERSION_TYPE_UNKNOWN
Unknown.
Definition btrieveCpp.h:1270