Debian Codegraph @

src/modules/app_ruby_proc/utils/app_ruby_ctl

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # generate the .h file
4
5 KEMI_MAX_SIZE=1536
6
7 catscip-shell system . . cat. > ../app_ruby_kemi_export.h <<EOF
8 /**
9 * Copyright (C) 2018 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 __APP_RUBY_KEMI_EXPORT_H__
36 #define __APP_RUBY_KEMI_EXPORT_H__
37
38 #include <ruby.h>
39
40 #include "../../core/kemi.h"
41
42 #define SR_KEMI_RUBY_EXPORT_SIZE ${KEMI_MAX_SIZE}
43
44 typedef struct sr_kemi_ruby_export {
45 app_ruby_function pfunc;
46 sr_kemi_t *ket;
47 } sr_kemi_ruby_export_t;
48
49 sr_kemi_t *sr_kemi_ruby_export_get(int idx);
50 app_ruby_function sr_kemi_ruby_export_associate(sr_kemi_t *ket);
51
52 #endif
53 EOF
54
55 # generate the .c file
56
57 catscip-shell system . . cat. > ../app_ruby_kemi_export.c <<EOF
58 /**
59 * Copyright (C) 2018 Daniel-Constantin Mierla (asipto.com)
60 *
61 * This file is part of Kamailio, a free SIP server.
62 *
63 * SPDX-License-Identifier: GPL-2.0-or-later
64 *
65 * Kamailio is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
67 * the Free Software Foundation; either version 2 of the License, or
68 * (at your option) any later version
69 *
70 * Kamailio is distributed in the hope that it will be useful,
71 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73 * GNU General Public License for more details.
74 *
75 * You should have received a copy of the GNU General Public License
76 * along with this program; if not, write to the Free Software
77 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
78 *
79 */
80
81 /**
82 * this file is generated - do not edit
83 */
84
85 #include <stdio.h>
86 #include <unistd.h>
87 #include <stdlib.h>
88
89 #include "../../core/dprint.h"
90
91 #include "app_ruby_api.h"
92 #include "app_ruby_kemi_export.h"
93
94 EOF
95
96 CEND=${KEMI_MAX_SIZE}
97
98 for (( c=0; c<CEND; c++ )); do
99 echo >>../app_ruby_kemi_export.c
100 echo "/**" >>../app_ruby_kemi_export.c
101 echo " *" >>../app_ruby_kemi_export.c
102 echo " */" >>../app_ruby_kemi_export.c
103 echo "static VALUE sr_kemi_ruby_exec_func_${c}(int argc, VALUE* argv, VALUE self)" >>../app_ruby_kemi_export.c
104 echo "{" >>../app_ruby_kemi_export.c
105 echo " return sr_kemi_ruby_exec_func(NULL, ${c}, argc, argv, self);" >>../app_ruby_kemi_export.c
106 echo "}" >>../app_ruby_kemi_export.c
107 done
108
109 echoscip-shell system . . echo. >>../app_ruby_kemi_export.c
110 echoscip-shell system . . echo. "/**" >>../app_ruby_kemi_export.c
111 echoscip-shell system . . echo. " *" >>../app_ruby_kemi_export.c
112 echoscip-shell system . . echo. " */" >>../app_ruby_kemi_export.c
113
114 echoscip-shell system . . echo. "static sr_kemi_ruby_export_t _sr_kemi_ruby_export_list[] = {" >>../app_ruby_kemi_export.c
115 for (( c=0; c<CEND; c++ )); do
116 echo " { sr_kemi_ruby_exec_func_${c}, NULL}," >>../app_ruby_kemi_export.c
117 done
118 echoscip-shell system . . echo. " {NULL, NULL}" >>../app_ruby_kemi_export.c
119 echoscip-shell system . . echo. "};" >>../app_ruby_kemi_export.c
120
121 catscip-shell system . . cat. >> ../app_ruby_kemi_export.c <<EOF
122
123 /**
124 *
125 */
126 sr_kemi_t *sr_kemi_ruby_export_get(int idx)
127 {
128 if(idx<0 || idx>=SR_KEMI_RUBY_EXPORT_SIZE)
129 return NULL;
130 return _sr_kemi_ruby_export_list[idx].ket;
131 }
132
133 /**
134 *
135 */
136 app_ruby_function sr_kemi_ruby_export_associate(sr_kemi_t *ket)
137 {
138 int i;
139 for(i=0; i<SR_KEMI_RUBY_EXPORT_SIZE; i++) {
140 if(_sr_kemi_ruby_export_list[i].ket==NULL) {
141 _sr_kemi_ruby_export_list[i].ket = ket;
142 return _sr_kemi_ruby_export_list[i].pfunc;
143 }
144 if(_sr_kemi_ruby_export_list[i].ket==ket) {
145 return _sr_kemi_ruby_export_list[i].pfunc;
146 }
147 }
148 LM_ERR("no more indexing slots\n");
149 return NULL;
150 }
151 EOF