Reads the platform configuration file and initializes the environment so that calls can be made to a Core Driver. This function or ASC_INIT() must be called before any other API function. ASC_INIT_EXT() differs from ASC_INIT() in that you can provide a buffer into which the API places error messages if the API environment cannot be initialized.
#include <ascauth.h>
ASCENV *ASC_INIT_EXT(char *filename, char *error_msg, size_t size);
filename |
The name of the platform configuration file. If you call ASC_INIT_EXT() with a NULL in place of the filename parameter as in ASC_INIT_EXT(NULL, buffer, BUFSIZE), the default is /usr/local/ASAM/data/asamplat.conf |
error_msg |
A buffer you provide into which an error message can be placed if the environment cannot be initialized. |
size |
The size of the error_msg buffer you have provided. |
Returns a pointer to the environment item created upon success. If an error has occurred, NULL is returned, and a descriptive error message is placed into the error_msg buffer.
#include <stdio.h> #include <stdlib.h> #include <ascauth.h> #define BUFSIZE 256 main() { ASCENV *asce; /* initialize the authentication environment */ /* allocate buffer */ buffer = (char *) malloc(BUFSIZE); asce = ASC_INIT_EXT(NULL, buffer, BUFSIZE); if (asce == NULL) { fprintf(stderr, "Error: cannot initialize authentication environment\n"); fprintf(stderr, " %s \n", buffer); exit(EXIT_FAILURE); } /* now you can make additional authentication calls here */ /* now terminate the authentication environment */ ASC_TERM(asce); return 0; }