Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Enduro/X Plugin Architecture
0003  *
0004  * @file expluginbase.h
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012  * See LICENSE file for full text.
0013  * -----------------------------------------------------------------------------
0014  * AGPL license:
0015  *
0016  * This program is free software; you can redistribute it and/or modify it under
0017  * the terms of the GNU Affero General Public License, version 3 as published
0018  * by the Free Software Foundation;
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023  * for more details.
0024  *
0025  * You should have received a copy of the GNU Affero General Public License along 
0026  * with this program; if not, write to the Free Software Foundation, Inc.,
0027  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028  *
0029  * -----------------------------------------------------------------------------
0030  * A commercial use license is available from Mavimax, Ltd
0031  * contact@mavimax.com
0032  * -----------------------------------------------------------------------------
0033  */
0034 #ifndef EXPLUGINBASE_H_
0035 #define EXPLUGINBASE_H_
0036 /*------------------------------Includes--------------------------------------*/
0037 #include "ndrx_config.h"
0038 #include <stdio.h>
0039 /*------------------------------Externs---------------------------------------*/
0040 /*------------------------------Macros----------------------------------------*/
0041 
0042 #define NDRX_PLUGIN_PROVIDERSTR_BUFSZ        64
0043 
0044 
0045 /**
0046  * Function: provides ndrx_plugin_crypto_getkey  
0047  */
0048 #define NDRX_PLUGIN_FUNC_ENCKEY                     0x00000001
0049 #define NDRX_PLUGIN_FUNC_TPLOGPRINTUBF_HOOK         0x00000002
0050 
0051 
0052 /* symbols: */
0053 #define NDRX_PLUGIN_INIT_SYMB                   "ndrx_plugin_init"
0054 
0055 /** Cryptography key functionality available: */
0056 #define NDRX_PLUGIN_CRYPTO_GETKEY_SYMB          "ndrx_plugin_crypto_getkey"
0057 
0058 /** Load hooking functionality expoed */
0059 #define NDRX_PLUGIN_TPLOGPRINTUBF_HOOK_SYMB     "ndrx_plugin_tplogprintubf_hook"
0060 /*------------------------------Enums-----------------------------------------*/
0061 /*------------------------------Typedefs--------------------------------------*/
0062 
0063 /**
0064  * Init plugin function
0065  */
0066 typedef long (*ndrx_plugin_init_t)(char *provider_name, int provider_name_bufsz);
0067 
0068 /**
0069  * Plugin encryption key func:
0070  * @param keybuf NUL terminated key
0071  * @param keybuf_bufsz
0072  */
0073 typedef int (*ndrx_plugin_crypto_getkey_t)(char *keybuf, int keybuf_bufsz);
0074 
0075 /**
0076  * Plugin for field printing to debug file of the UBF buffer
0077  * @param [in,out] buffer buffer which contains <field_name>\t<print_data>\n
0078  *  the buffer may be reallocated (the invoker does free)
0079  * @param [in] string length including EOS
0080  * @param [in] dataptr1 RFU
0081  * @param [in] do_write if set to TRUE, will print the given buffer in log file
0082  * @param [in] outf output file stream currently set
0083  * @param [in] fid UBF buffer field id
0084  * @return EXSUCCEED/EXFAIL
0085  */
0086 typedef int (*ndrx_plugin_tplogprintubf_hook_t)(char **buffer, long datalen, void *dataptr1, 
0087         int *do_write, FILE * outf, int fid);
0088 
0089 
0090 /* Have some global variable with pointer to callbacks */
0091 
0092 struct ndrx_pluginbase {
0093     int plugins_loaded;
0094     
0095     /** pointer to get encryption key function */
0096     ndrx_plugin_crypto_getkey_t p_ndrx_crypto_getkey;
0097     /** provider string of crypto */
0098     char ndrx_crypto_getkey_provider[NDRX_PLUGIN_PROVIDERSTR_BUFSZ];
0099     
0100     /** UBF buffer dump to log file pre-processing function */
0101     ndrx_plugin_tplogprintubf_hook_t p_ndrx_tplogprintubf_hook;
0102     /** Provider string for the UBF dump pre-processing */
0103     char ndrx_tplogprintubf_hook_provider[NDRX_PLUGIN_PROVIDERSTR_BUFSZ];
0104 };
0105 
0106 typedef struct ndrx_pluginbase ndrx_pluginbase_t;
0107 
0108 /*------------------------------Globals---------------------------------------*/
0109 extern ndrx_pluginbase_t ndrx_G_plugins;
0110 /*------------------------------Statics---------------------------------------*/
0111 /*------------------------------Prototypes------------------------------------*/
0112 
0113 
0114 extern NDRX_API int ndrx_plugins_load(void);
0115 
0116 #endif /* EXPLUGINBASE_H_ */
0117 
0118 /* vim: set ts=4 sw=4 et smartindent: */