Program structure
The following code fragment provides an example of the generic program structure. Because almost every AR System C API function has a control parameter as its first input argument, the template includes code for loading the ARControlStruct structure (see Login-and-session-information).
In this example, the login information is loaded into the control structure after issuing the ARInitialization call:
{
ARControlStruct control;
ARStatusList status;
intrtn;
...
...
/****************************************************************/
/* Perform Startup */
/****************************************************************/
if (ARInitialization(&control, &status) >= AR_RETURN_ERROR){
printf("\n **** initialization error ****\n");
PrintARStatusList(&status);
exit(3);
}
FreeARStatusList(&status, FALSE);
/****************************************************************/
/* Load ARControlStruct */
/****************************************************************/
strncpy(control.user, "Demo", AR_MAX_ACCESS_NAME_SIZE);
/* use Demo user */
control.user[AR_MAX_ACCESS_NAME_SIZE] = '\0';
strcpy(control.password, ""); /* could load from file */
memset(&control.localeinfo, 0, sizeof(ARLocalizationInfo));
/* use default locale */
strncpy(control.server, argv[1], AR_MAX_SERVER_SIZE);
control.server[AR_MAX_SERVER_SIZE] = '\0';
strcpy(control.authString, ""); /* could load from file */
/****************************************************************/
/* Perform System Work */
/****************************************************************/
rtn = ARGetEntry(&control, ..., &status);
if( rtn ... )
...
...
/****************************************************************/
/* Perform Cleanup */
/****************************************************************/
(&control, &status);
FreeARStatusList(&status, FALSE);
ARControlStruct control;
ARStatusList status;
intrtn;
...
...
/****************************************************************/
/* Perform Startup */
/****************************************************************/
if (ARInitialization(&control, &status) >= AR_RETURN_ERROR){
printf("\n **** initialization error ****\n");
PrintARStatusList(&status);
exit(3);
}
FreeARStatusList(&status, FALSE);
/****************************************************************/
/* Load ARControlStruct */
/****************************************************************/
strncpy(control.user, "Demo", AR_MAX_ACCESS_NAME_SIZE);
/* use Demo user */
control.user[AR_MAX_ACCESS_NAME_SIZE] = '\0';
strcpy(control.password, ""); /* could load from file */
memset(&control.localeinfo, 0, sizeof(ARLocalizationInfo));
/* use default locale */
strncpy(control.server, argv[1], AR_MAX_SERVER_SIZE);
control.server[AR_MAX_SERVER_SIZE] = '\0';
strcpy(control.authString, ""); /* could load from file */
/****************************************************************/
/* Perform System Work */
/****************************************************************/
rtn = ARGetEntry(&control, ..., &status);
if( rtn ... )
...
...
/****************************************************************/
/* Perform Cleanup */
/****************************************************************/
(&control, &status);
FreeARStatusList(&status, FALSE);
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*