Debian Codegraph @

src/modules/app_python/utils/app_python_ctl

raw symbols SCIP
1 #!/bin/bash
2
3 # generate the .h file
4
5 KEMI_MAX_SIZE=1024
6
7 cat > ../apy_kemi_export.h <<EOF
8 /**
9 * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
10 *
11 * This file is part of Kamailio, a free SIP server.
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * Kamailio is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version
19 *
20 * Kamailio is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 *
29 */
30
31 /**
32 * this file is generated - do not edit
33 */
34
35 #ifndef __APY_KEMI_FLIB_H__
36 #define __APY_KEMI_FLIB_H__
37
38 #include <Python.h>
39 #include "../../core/kemi.h"
40
41 #define SR_APY_KEMI_EXPORT_SIZE ${KEMI_MAX_SIZE}
42
43 typedef struct sr_apy_kemi_export {
44 PyCFunction pfunc;
45 sr_kemi_t *ket;
46 } sr_apy_kemi_export_t;
47
48 sr_kemi_t *sr_apy_kemi_export_get(int idx);
49 PyCFunction sr_apy_kemi_export_associate(sr_kemi_t *ket);
50
51 #endif
52 EOF
53
54 # generate the .c file
55
56 cat > ../apy_kemi_export.c <<EOF
57 /**
58 * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
59 *
60 * This file is part of Kamailio, a free SIP server.
61 *
62 * SPDX-License-Identifier: GPL-2.0-or-later
63 *
64 * Kamailio is free software; you can redistribute it and/or modify
65 * it under the terms of the GNU General Public License as published by
66 * the Free Software Foundation; either version 2 of the License, or
67 * (at your option) any later version
68 *
69 * Kamailio is distributed in the hope that it will be useful,
70 * but WITHOUT ANY WARRANTY; without even the implied warranty of
71 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72 * GNU General Public License for more details.
73 *
74 * You should have received a copy of the GNU General Public License
75 * along with this program; if not, write to the Free Software
76 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
77 *
78 */
79
80 /**
81 * this file is generated - do not edit
82 */
83
84 #include <stdio.h>
85 #include <unistd.h>
86 #include <stdlib.h>
87
88 #include <Python.h>
89
90 #include "../../core/dprint.h"
91
92 #include "apy_kemi.h"
93 #include "apy_kemi_export.h"
94
95 EOF
96
97 CEND=${KEMI_MAX_SIZE}
98
99 for (( c=0; c<CEND; c++ )); do
100 echo >>../apy_kemi_export.c
101 echo "/**" >>../apy_kemi_export.c
102 echo " *" >>../apy_kemi_export.c
103 echo " */" >>../apy_kemi_export.c
104 echo "static PyObject *sr_apy_kemi_exec_func_${c}(PyObject *self, PyObject *args)" >>../apy_kemi_export.c
105 echo "{" >>../apy_kemi_export.c
106 echo " return sr_apy_kemi_exec_func(self, args, ${c});" >>../apy_kemi_export.c
107 echo "}" >>../apy_kemi_export.c
108 done
109
110 echo >>../apy_kemi_export.c
111 echo "/**" >>../apy_kemi_export.c
112 echo " *" >>../apy_kemi_export.c
113 echo " */" >>../apy_kemi_export.c
114
115 echo "static sr_apy_kemi_export_t _sr_apy_kemi_export_list[] = {" >>../apy_kemi_export.c
116 for (( c=0; c<CEND; c++ )); do
117 echo " { sr_apy_kemi_exec_func_${c}, NULL}," >>../apy_kemi_export.c
118 done
119 echo " {NULL, NULL}" >>../apy_kemi_export.c
120 echo "};" >>../apy_kemi_export.c
121
122 cat >> ../apy_kemi_export.c <<EOF
123
124 /**
125 *
126 */
127 sr_kemi_t *sr_apy_kemi_export_get(int idx)
128 {
129 if(idx<0 || idx>=SR_APY_KEMI_EXPORT_SIZE)
130 return NULL;
131 return _sr_apy_kemi_export_list[idx].ket;
132 }
133
134 /**
135 *
136 */
137 PyCFunction sr_apy_kemi_export_associate(sr_kemi_t *ket)
138 {
139 int i;
140 for(i=0; i<SR_APY_KEMI_EXPORT_SIZE; i++) {
141 if(_sr_apy_kemi_export_list[i].ket==NULL) {
142 _sr_apy_kemi_export_list[i].ket = ket;
143 return _sr_apy_kemi_export_list[i].pfunc;
144 }
145 if(_sr_apy_kemi_export_list[i].ket==ket) {
146 return _sr_apy_kemi_export_list[i].pfunc;
147 }
148 }
149 LM_ERR("no more indexing slots\n");
150 return NULL;
151 }
152 EOF