![]() |
|
|||
0001 /** 0002 * @brief Custom LCF Command 0003 * 0004 * @file custom_lcf.c 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 #include <string.h> 0035 #include <stdio.h> 0036 #include <stdlib.h> 0037 0038 #include <ndrstandard.h> 0039 #include <ndebug.h> 0040 #include <nstdutil.h> 0041 #include <expluginbase.h> 0042 #include <sys_unix.h> 0043 #include <test.fd.h> 0044 #include <lcf.h> 0045 /*---------------------------Externs------------------------------------*/ 0046 /*---------------------------Macros-------------------------------------*/ 0047 /*---------------------------Enums--------------------------------------*/ 0048 /*---------------------------Typedefs-----------------------------------*/ 0049 /*---------------------------Globals------------------------------------*/ 0050 /*---------------------------Statics------------------------------------*/ 0051 /*---------------------------Prototypes---------------------------------*/ 0052 0053 /** 0054 * Depending on args will provided OK or NOK or Feedback 0055 */ 0056 exprivate int custom_command(ndrx_lcf_command_t *cmd, long *p_flags) 0057 { 0058 NDRX_LOG(log_error, "**************** %s *********************", cmd->arg_a); 0059 0060 /* set feedback */ 0061 cmd->fbackcode=987; 0062 NDRX_STRCPY_SAFE(cmd->fbackmsg, cmd->arg_b); 0063 *p_flags|=(NDRX_LCF_FLAG_FBACK_CODE|NDRX_LCF_FLAG_FBACK_MSG); 0064 0065 if (0==strcmp(cmd->arg_b, "FAIL")) 0066 { 0067 cmd->fbackcode=741; 0068 return -1; 0069 } 0070 0071 return 0; 0072 } 0073 0074 /** 0075 * Initialize the plugin 0076 * @param provider_name plugin name/provider string 0077 * @param provider_name_bufsz provider string buffer size 0078 * @return FAIL (in case of error) or OR'ed function flags 0079 */ 0080 expublic long ndrx_plugin_init(char *provider_name, int provider_name_bufsz) 0081 { 0082 int ret = EXSUCCEED; 0083 ndrx_lcf_reg_func_t cfunc; 0084 ndrx_lcf_reg_xadmin_t xfunc; 0085 0086 memset(&cfunc, 0, sizeof(cfunc)); 0087 0088 NDRX_STRCPY_SAFE(cfunc.cmdstr, "customz"); 0089 cfunc.command=1001; 0090 cfunc.version=NDRX_LCF_CCMD_VERSION; 0091 cfunc.pf_callback=custom_command; 0092 0093 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc)) 0094 { 0095 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror)); 0096 EXFAIL_OUT(ret); 0097 } 0098 0099 memset(&xfunc, 0, sizeof(xfunc)); 0100 NDRX_STRCPY_SAFE(xfunc.cmdstr, "customz"); 0101 xfunc.command=1001; 0102 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION; 0103 NDRX_STRCPY_SAFE(xfunc.helpstr, "Test command"); 0104 xfunc.dfltflags=(NDRX_LCF_FLAG_DOSTARTUPEXP | NDRX_LCF_FLAG_ARGA | NDRX_LCF_FLAG_ARGB); 0105 xfunc.dfltslot=3; 0106 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc)) 0107 { 0108 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror)); 0109 EXFAIL_OUT(ret); 0110 } 0111 0112 out: 0113 /* No functions provided */ 0114 return ret; 0115 } 0116 0117 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |