Bank Wizard includes the C header files that you must #include into the C source. The main file, bwihapi.h, contains the prototypes for each function as well as the#definesfor the special values referenced throughout this manual. The header also provides a typedef BWI_HANDLE that you should use to declare handle variables.
There is also a header file for each supported country, bwihcc.h (where cc is the ISO country code) which contains values used by that country.
The API functions expect values to be passed by address. This means that you cannot pass the #defined symbolic names directly to the API function because the symbolic name is a value rather than the address of the value. Therefore, a set of wrapper functions is provided so that the constant parameters can be passed by value. The wrapper calls the underlying API function passing the address of the constant. Each function has the naming convention BWICxxx where xxx is the name of the main API function.
For example, this runs a simple validation:
#include "bwihapi.h" #include "bwihuk.h" void checkUK( char* sortCode char* accountNo ) { BWI_HANDLE h; long type; long cond; long size; char mess[256]; long exist; /* Create handle and set country to UK */ BWICreateHandle(&h); BWICSetValue(&h,BWI_V_COUNTRY_CHECK,BWI_C_UK); /* Set the account details */ BWICSetString(&h,BWI_UK_SORT_CODE,sortCode) BWICSetString(&h,BWI_UK_ACCOUNT_NO,accountNo) /* Validate the details */ BWICheck(&h); /* Iterate through possible condition types */ for(type = BWI_N_FATAL; type <= BWI_N_INFORMATION; ++type) { /* Iterate the conditions of current type */ for(BWICNext(&h,type,&exist); exist; BWINext (&h, type,&exist)) { /* Get condition value */ BWICGetValue(&h,BWI_V_NEXT,&cond) /* And message string */ size = sizeof(mess); BWICGetString(&h,BWI_V_NEXT,mess,&size); /* Print */ print("%ld (%ld) - %s\n",type,cond,mess); } } BWIFree(&h); } |
|
To maintain a common style across the API, BWICNext and BWICGetValue use a parameter to return their results. |
If your coding standards allow you to use the C comma operator, you can replace theforloop with awhileloop:
... /* Iterate the conditions of current type */ while(BWICNext(&h,type,&exist),exist) { ... } ... |
The standard C example uses this because it avoids calling BWICNext twice; when initialising the iteration and when incrementing the expression.