User Exits
End users can construct CONNX user exits that will be called during Adabas processing. User exits can be call before each Adabas call, after each Adabas call, or both. CONNX User exists are only available on Open Systems.
The User exist must be constructed as DLL on Windows systems or a shared library on UNIX.
To enable a user exit, the following configuration settings must be enabled on the Adabas server either by being added to the connxserver script as additional environment variables (UNIX) or using the CONNX Configuration Manager under the CONNX\ADABAS key (Windows).
USEREXITFLAGS (to determine when the user exit is called):
1 = PRECALL - Call before every Adabas call
2 = POSTCALL - Call after every Adabas call
3 = PRECALL and POSTCALL - Call before and after every Adabas call
USEREXITNAME64 (if the CONNX server is configured as 64-bit)
USEREXITNAME32 (if the CONNX server is configured as 32-bit)
The only requirement of the user exit DLL is that it must have a C entry point with the name of UserExitFunc. The UserExitFunc function has the following signature:
extern "C" int UserExitFunc(unsigned int threadid, // unique session number
const char *userid, // user name passed to the CONNX Adabas server
const char * clientid, // clientid (if any) passed to the CONNX Adabas server
void * AdabasControlBlock, // the Adabas control block
void * szFormatBuffer, // the Adabas format buffer
void * szRecordBuffer, // the Adabas record buffer
void *szSearchBuffer, // the Adabas search buffer
void *szValueBuffer, // the Adabas value buffer
void *szISNBuffer, // the Adabas ISN buffer
int nPrePost ) // integer flag to indicate whether this is a pre (0) or post (1) call.
The following is a C++ example of a user exit DLL function:
// adauserexit.cpp : Defines the exported functions for the DLL application
//
#include "stdafx.h"
#include "adauserexit.h"
#include <stdio.h>
#include <stdlib.h>
#pragma pack(1)
typedef struct _ADABASCONTROLBLOCK
{
char cb_cmd_res[2]; // Reserved
char cb_cmd_code[2]; // Command Code
char cb_cmd_id[4]; // COMMAND ID
short cb_file_nr;
short cb_return_code;
int cb_isn;
int cb_isn_l1;
int cb_isn_quantity;
unsigned short cb_fmt_buf_lng;
unsigned short cb_rec_buf_lng;
unsigned short cb_sea_buf_lng;
unsigned short cb_val_buf_lng;
unsigned short cb_isn_buf_lng;
char cb_cop1;
char cb_cop2;
char cb_add1[8];
char cb_add2[4];
char cb_add3[8];
char cb_add4[8];
char cb_add5[8];
int cb_cmd_time;
char cb_user_area[4];
} ADABASCONTROLBLOCK;
#pragma pack()
// This is an example of an exported function.
extern "C" ADAUSEREXIT_API int UserExitFunc(unsigned int threadid,
const char *userid,
const char * clientid,
void * AdabasControlBlock,
void * szFormatBuffer,
void * szRecordBuffer,
void *szSearchBuffer,
void *szValueBuffer,
void *szISNBuffer,
int nPrePost )
{
FILE * fp;
fp = fopen("c:\\adaexit.log", "a+");
ADABASCONTROLBLOCK * pBlock = (ADABASCONTROLBLOCK *)AdabasControlBlock;
fprintf(fp, "thread (%d), user(%s), clientid(%s), adabas command(%2.2s)\n",
threadid, userid, clientid, pBlock->cb_cmd_code);
fclose(fp);
return 0;
}