Multithreaded API clients
Here is an example of a generic API program source file:
{anchor:_Ref375052960}
#include <stdlib.h>
#include <string.h>
#include <ar.h>
#include <arextern.h>
#include <arfree.h>
int main( int argc, char* argv[] )
{
ARStatusList status;
/* read command line arguments */
if (argc < 6) exit(-1);
char* server = argv[1];
char* user = argv[2];
char* pass = argv[3];
char* schema = argv[4];
char* eid = argv[5];
/* set control parameters (server, user, etc) */
ARControlStruct control;
control.cacheId = 0;
control.sessionId = 0;
strcpy(control.user, user);
strcpy(control.password, pass);
strcpy(control.language, "");
strcpy(control.server, server);
/* Remedy Startup */
if (ARInitialization(&control, &status) >= AR_RETURN_ERROR) {
printf("\n **** initialization error ****\n");
exit(-1);
}
FreeARStatusList(&status, FALSE);
/* Verify user/password/server */
if (ARVerifyUser(&control, NULL,NULL,NULL,&status) >= AR_RETURN_ERROR) {
printf("\n **** verification failed ****\n");
exit(-1);
}
/* Set the entryid of the record we want */
AREntryIdList entryId;
entryId.numItems = 1;
entryId.entryIdList = (AREntryIdType *) calloc(1, sizeof(AREntryIdType));
strncpy( entryId.entryIdList[0], eid, AR_MAX_ENTRYID_SIZE );
entryId.entryIdList[0][AR_MAX_ENTRYID_SIZE] = '\0';
/* Get the entry */
ARFieldValueList fieldValues;
if( ARGetEntry(&control,
schema, &entryId, NULL, &fieldValues,
&status) >= AR_RETURN_ERROR) {
printf("\n **** get entry error ****\n");
exit(-1);
}
/* Clean up */
FreeARStatusList(&status, FALSE);
FreeARFieldValueList(&fieldValues, FALSE);
FreeAREntryIdList(&entryId, FALSE);
/* Terminate */
(void) ARTermination(&control, &status);
FreeARStatusList(&status, FALSE);
return 0;
}
#include <stdlib.h>
#include <string.h>
#include <ar.h>
#include <arextern.h>
#include <arfree.h>
int main( int argc, char* argv[] )
{
ARStatusList status;
/* read command line arguments */
if (argc < 6) exit(-1);
char* server = argv[1];
char* user = argv[2];
char* pass = argv[3];
char* schema = argv[4];
char* eid = argv[5];
/* set control parameters (server, user, etc) */
ARControlStruct control;
control.cacheId = 0;
control.sessionId = 0;
strcpy(control.user, user);
strcpy(control.password, pass);
strcpy(control.language, "");
strcpy(control.server, server);
/* Remedy Startup */
if (ARInitialization(&control, &status) >= AR_RETURN_ERROR) {
printf("\n **** initialization error ****\n");
exit(-1);
}
FreeARStatusList(&status, FALSE);
/* Verify user/password/server */
if (ARVerifyUser(&control, NULL,NULL,NULL,&status) >= AR_RETURN_ERROR) {
printf("\n **** verification failed ****\n");
exit(-1);
}
/* Set the entryid of the record we want */
AREntryIdList entryId;
entryId.numItems = 1;
entryId.entryIdList = (AREntryIdType *) calloc(1, sizeof(AREntryIdType));
strncpy( entryId.entryIdList[0], eid, AR_MAX_ENTRYID_SIZE );
entryId.entryIdList[0][AR_MAX_ENTRYID_SIZE] = '\0';
/* Get the entry */
ARFieldValueList fieldValues;
if( ARGetEntry(&control,
schema, &entryId, NULL, &fieldValues,
&status) >= AR_RETURN_ERROR) {
printf("\n **** get entry error ****\n");
exit(-1);
}
/* Clean up */
FreeARStatusList(&status, FALSE);
FreeARFieldValueList(&fieldValues, FALSE);
FreeAREntryIdList(&entryId, FALSE);
/* Terminate */
(void) ARTermination(&control, &status);
FreeARStatusList(&status, FALSE);
return 0;
}
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*