![]() |
|
|||
0001 /** 0002 * @brief Python language support 0003 * 0004 * @file python.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 0035 /*---------------------------Includes-----------------------------------*/ 0036 0037 #include <unistd.h> 0038 #include <stdio.h> 0039 #include <errno.h> 0040 #include <stdlib.h> 0041 #include <atmi.h> 0042 0043 #include <ndrstandard.h> 0044 #include <ubf.h> 0045 #include <ubf_int.h> 0046 #include <ferror.h> 0047 #include <fieldtable.h> 0048 #include <fdatatype.h> 0049 0050 #include <ndrstandard.h> 0051 #include <ndebug.h> 0052 #include "mkfldhdr.h" 0053 /*---------------------------Externs------------------------------------*/ 0054 /*---------------------------Macros-------------------------------------*/ 0055 /*---------------------------Enums--------------------------------------*/ 0056 /*---------------------------Typedefs-----------------------------------*/ 0057 /*---------------------------Globals------------------------------------*/ 0058 /*---------------------------Statics------------------------------------*/ 0059 /*---------------------------Prototypes---------------------------------*/ 0060 0061 /** 0062 * Get the python lang output file name 0063 * @param data 0064 */ 0065 expublic void python_get_fullname(char *data) 0066 { 0067 /* For python we shall strip off the file extension 0068 * as it might cause problems with the class name... 0069 */ 0070 char *p; 0071 0072 p = strrchr(G_active_file, '.'); 0073 if (NULL!=p) 0074 { 0075 NDRX_LOG(log_debug, "Stripping of file extension for class"); 0076 *p=EXEOS; 0077 } 0078 0079 sprintf(data, "%s/%s.py", G_output_dir, G_active_file); 0080 } 0081 0082 /** 0083 * Write text line to output file 0084 * @param text 0085 * @return 0086 */ 0087 expublic int python_put_text_line (char *text) 0088 { 0089 int ret=EXSUCCEED; 0090 0091 if (0==strncmp(text, "#ifndef", 7) || 0092 0==strncmp(text, "#define", 7) || 0093 0==strncmp(text, "#endif", 6)) 0094 { 0095 /* just ignore these special C lines */ 0096 goto out; 0097 } 0098 0099 /* if line is not whitespace, add # leading comment. */ 0100 if (ndrx_isempty(text)) 0101 { 0102 fprintf(G_outf, "%s", text); 0103 } 0104 else 0105 { 0106 fprintf(G_outf, "#%s", text); 0107 } 0108 0109 /* Check errors */ 0110 if (ferror(G_outf)) 0111 { 0112 ndrx_Bset_error_fmt(BFTOPEN, "Failed to write to output file: [%s]", strerror(errno)); 0113 EXFAIL_OUT(ret); 0114 } 0115 0116 out: 0117 return ret; 0118 } 0119 0120 /** 0121 * Process the baseline 0122 * @param base 0123 * @return 0124 */ 0125 expublic int python_put_got_base_line(char *base) 0126 { 0127 0128 int ret=EXSUCCEED; 0129 0130 return ret; 0131 } 0132 0133 /** 0134 * Write definition to output file 0135 * @param def 0136 * @return 0137 */ 0138 expublic int python_put_def_line (UBF_field_def_t *def) 0139 { 0140 int ret=EXSUCCEED; 0141 int type = def->bfldid>>EFFECTIVE_BITS; 0142 BFLDID number = def->bfldid & EFFECTIVE_BITS_MASK; 0143 0144 fprintf(G_outf, "%s = %d # number: %d type: %s \n", 0145 def->fldname, def->bfldid, number, G_dtype_str_map[type].fldname); 0146 /* Check errors */ 0147 if (ferror(G_outf)) 0148 { 0149 ndrx_Bset_error_fmt(BFTOPEN, "Failed to write to output file: [%s]", 0150 strerror(errno)); 0151 ret=EXFAIL; 0152 } 0153 0154 return ret; 0155 } 0156 0157 /** 0158 * Output file have been open 0159 * @param fname 0160 * @return 0161 */ 0162 expublic int python_file_open (char *fname) 0163 { 0164 return EXSUCCEED; 0165 } 0166 0167 /** 0168 * Output file have been closed 0169 * @param fname 0170 * @return 0171 */ 0172 expublic int python_file_close (char *fname) 0173 { 0174 return EXSUCCEED; 0175 } 0176 0177 /* 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 |
![]() ![]() |