User guide
106 Chapter 11
External authorization module
Version 3.1
Basic example of external authorization module
AuthModuleTestLib.h
extern "C"
{
bool ESSRequestAuthorization(char* inURL, char* inIPAddress, char* inQueryString);
}
AuthModuleTestLib.cpp
#include "AuthModuleTestLib.h"
#include <stdio.h>
bool ESSRequestAuthorization(char* inURL, char* inIPAddress, char* inQueryString)
{
char buf[256];
bool authorize = false;
if(inQueryString != NULL) {
sprintf(buf, "IP Address : %s\nRequested URL: %s\nQuery String: %s\nAuthorize ?",
inIPAddress, inURL, inQueryString);
} else {
sprintf(buf, "IP Address : %s\nRequested URL: %s\nAuthorize ?", inIPAddress, inURL);
}
char c;
int result;
printf( "%s (y)es (n)o ?", buf);
do {
c = getchar();
} while ( c!='y' && c!='n' );
if ( c == 'y') {
authorize = true;
}
else {
authorize = false;
}
return authorize;
}