0001
0002
0003
0004
0005
0006
0007 use Getopt::Std;
0008
0009
0010 our ($opt_i, $opt_o, $opt_h);
0011 $opt_i = 0;
0012 $opt_o = 0;
0013 $opt_h = 0;
0014 my $opt_ret = getopts ('i:o:h');
0015
0016 if (!$opt_ret || $opt_h || !$opt_i || !$opt_o)
0017 {
0018 print STDERR "Usage: $0 -i <input file, c header> -o <output prefix>\n ";
0019 exit 1;
0020 }
0021
0022 my $M_name_upper = uc $opt_o;
0023 $M_name_upper = "O$M_name_upper";
0024 $M_name = "o$opt_o";
0025
0026
0027
0028
0029 sub remove_white_space {
0030
0031 my $ret = shift;
0032
0033
0034 $ret =~ s/^\s+//;
0035 $ret =~ s/\s+$//;
0036
0037 return $ret;
0038 }
0039
0040 sub split_by_comma_but_not_parenthesis {
0041
0042 my $string=shift;
0043 my @array = ($string =~ /(
0044 [^,]*\([^)]*\)
0045 |
0046 [^,]*)
0047 (?:,|$)/gx);
0048
0049 return @array;
0050 }
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 sub open_h {
0068
0069 $M_h_name = "${M_name}.h";
0070 print "Opening [$M_h_name]\n";
0071 open($M_h_fd, '>', $M_h_name) or die "Could not open file '$M_h_name' $!";
0072
0073 my $title = "";
0074 my $defs = "";
0075
0076 if ($M_name=~/^oatmisrv_integra/)
0077 {
0078 $title = "ATMI Server integration level Object API header (auto-generated)";
0079 }
0080 elsif ($M_name=~/^oatmisrv$/)
0081 {
0082 $title = "ATMI Server level Object API header (auto-generated)";
0083 }
0084 elsif ($M_name=~/^oatmi$/)
0085 {
0086 $title = "ATMI Object API header (auto-generated)";
0087
0088 $defs = "\n#define Otperrno(P_CTXT) (*O_exget_tperrno_addr(P_CTXT))\n".
0089 "#define Otpurcode(P_CTXT) (*O_exget_tpurcode_addr(P_CTXT))";
0090 }
0091 elsif($M_name=~/oubf/)
0092 {
0093 $title = "UBF Object API header (auto-generated)";
0094
0095 $defs = "\n#define OBerror(P_CTXT) (*O_Bget_Ferror_addr(P_CTXT))";
0096 }
0097 elsif($M_name=~/ondebug/)
0098 {
0099 $title = "Standard library debug routines";
0100 }
0101 elsif($M_name=~/onerror/)
0102 {
0103 $title = "Standard library error handler";
0104 $defs = "\n#define ONerror(P_CTXT) (*O_Nget_Nerror_addr(P_CTXT))";
0105 }
0106
0107 my $message = <<"END_MESSAGE";
0108 /**
0109 * \@brief $title
0110 *
0111 * \@file ${M_name}.h
0112 */
0113 /* -----------------------------------------------------------------------------
0114 * Enduro/X Middleware Platform for Distributed Transaction Processing
0115 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0116 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0117 * This software is released under one of the following licenses:
0118 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0119 * See LICENSE file for full text.
0120 * -----------------------------------------------------------------------------
0121 * AGPL license:
0122 *
0123 * This program is free software; you can redistribute it and/or modify it under
0124 * the terms of the GNU Affero General Public License, version 3 as published
0125 * by the Free Software Foundation;
0126 *
0127 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0128 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0129 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0130 * for more details.
0131 *
0132 * You should have received a copy of the GNU Affero General Public License along
0133 * with this program; if not, write to the Free Software Foundation, Inc.,
0134 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0135 *
0136 * -----------------------------------------------------------------------------
0137 * A commercial use license is available from Mavimax, Ltd
0138 * contact\@mavimax.com
0139 * -----------------------------------------------------------------------------
0140 */
0141 #ifndef __${M_name_upper}_H
0142 #define __${M_name_upper}_H
0143
0144 #ifdef __cplusplus
0145 extern "C" {
0146 #endif
0147 /*---------------------------Includes-----------------------------------*/
0148 #include <stdint.h>
0149 #include <ubf.h>
0150 #include <atmi.h>
0151 /*---------------------------Externs------------------------------------*/
0152 /*---------------------------Macros-------------------------------------*/${defs}
0153 /*---------------------------Enums--------------------------------------*/
0154 /*---------------------------Typedefs-----------------------------------*/
0155 /*---------------------------Globals------------------------------------*/
0156 /*---------------------------Statics------------------------------------*/
0157 /*---------------------------Prototypes---------------------------------*/
0158 END_MESSAGE
0159
0160 print $M_h_fd $message;
0161
0162 }
0163
0164 ################################################################################
0165 # Open C source file
0166 ################################################################################
0167 sub open_c {
0168
0169
0170 $M_c_name = "${M_name}.c";
0171 print "Opening [$M_c_name]\n";
0172 open($M_c_fd, '>', $M_c_name) or die "Could not open file '$M_c_name' $!";
0173
0174 my $title = "";
0175
0176 if ($M_name=~/^oatmisrv$/)
0177 {
0178 $title = "ATMI Server Level Object API code (auto-generated)";
0179 }
0180 if ($M_name=~/^oatmisrv_integra$/)
0181 {
0182 $title = "ATMI Server Integration Level Object API code (auto-generated)";
0183 }
0184 if ($M_name=~/^oatmi$/)
0185 {
0186 $title = "ATMI Object API code (auto-generated)";
0187 }
0188 elsif($M_name=~/oubf/)
0189 {
0190 $title = "UBF Object API code (auto-generated)";
0191 }
0192 elsif($M_name=~/ondebug/)
0193 {
0194 $title = "Standard library debugging object API code (auto-generated)";
0195 }
0196 elsif($M_name=~/onerror/)
0197 {
0198 $title = "Standard library error handling";
0199 }
0200
0201 my $message = <<"END_MESSAGE";
0202 /**
0203 * \@brief $title
0204 *
0205 * \@file ${M_name}.c
0206 */
0207 /* -----------------------------------------------------------------------------
0208 * Enduro/X Middleware Platform for Distributed Transaction Processing
0209 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0210 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0211 * This software is released under one of the following licenses:
0212 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0213 * See LICENSE file for full text.
0214 * -----------------------------------------------------------------------------
0215 * AGPL license:
0216 *
0217 * This program is free software; you can redistribute it and/or modify it under
0218 * the terms of the GNU Affero General Public License, version 3 as published
0219 * by the Free Software Foundation;
0220 *
0221 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0222 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0223 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0224 * for more details.
0225 *
0226 * You should have received a copy of the GNU Affero General Public License along
0227 * with this program; if not, write to the Free Software Foundation, Inc.,
0228 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0229 *
0230 * -----------------------------------------------------------------------------
0231 * A commercial use license is available from Mavimax, Ltd
0232 * contact\@mavimax.com
0233 * -----------------------------------------------------------------------------
0234 */
0235 #include <string.h