| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# generate the .h file |
| 4 |
|
| 5 |
KEMI_MAX_SIZE=1536 |
| 6 |
|
| 7 |
cat > ../app_jsdt_kemi_export.h <<EOF |
| 8 |
/** |
| 9 |
* Copyright (C) 2017 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_JSDT_KEMI_EXPORT_H__ |
| 36 |
#define __APP_JSDT_KEMI_EXPORT_H__ |
| 37 |
|
| 38 |
#include "../../core/kemi.h" |
| 39 |
#include "duktape.h" |
| 40 |
|
| 41 |
#define SR_KEMI_JSDT_EXPORT_SIZE ${KEMI_MAX_SIZE} |
| 42 |
|
| 43 |
typedef struct sr_kemi_jsdt_export { |
| 44 |
duk_c_function pfunc; |
| 45 |
sr_kemi_t *ket; |
| 46 |
} sr_kemi_jsdt_export_t; |
| 47 |
|
| 48 |
sr_kemi_t *sr_kemi_jsdt_export_get(int idx); |
| 49 |
duk_c_function sr_kemi_jsdt_export_associate(sr_kemi_t *ket); |
| 50 |
|
| 51 |
#endif |
| 52 |
EOF |
| 53 |
|
| 54 |
# generate the .c file |
| 55 |
|
| 56 |
cat > ../app_jsdt_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 "../../core/dprint.h" |
| 89 |
|
| 90 |
#include "app_jsdt_api.h" |
| 91 |
#include "app_jsdt_kemi_export.h" |
| 92 |
|
| 93 |
EOF |
| 94 |
|
| 95 |
CEND=${KEMI_MAX_SIZE} |
| 96 |
|
| 97 |
for (( c=0; c<CEND; c++ )); do |
| 98 |
echo >>../app_jsdt_kemi_export.c |
| 99 |
echo "/**" >>../app_jsdt_kemi_export.c |
| 100 |
echo " *" >>../app_jsdt_kemi_export.c |
| 101 |
echo " */" >>../app_jsdt_kemi_export.c |
| 102 |
echo "static int sr_kemi_jsdt_exec_func_${c}(duk_context *J)" >>../app_jsdt_kemi_export.c |
| 103 |
echo "{" >>../app_jsdt_kemi_export.c |
| 104 |
echo " return sr_kemi_jsdt_exec_func(J, ${c});" >>../app_jsdt_kemi_export.c |
| 105 |
echo "}" >>../app_jsdt_kemi_export.c |
| 106 |
done |
| 107 |
|
| 108 |
echo >>../app_jsdt_kemi_export.c |
| 109 |
echo "/**" >>../app_jsdt_kemi_export.c |
| 110 |
echo " *" >>../app_jsdt_kemi_export.c |
| 111 |
echo " */" >>../app_jsdt_kemi_export.c |
| 112 |
|
| 113 |
echo "static sr_kemi_jsdt_export_t _sr_kemi_jsdt_export_list[] = {" >>../app_jsdt_kemi_export.c |
| 114 |
for (( c=0; c<CEND; c++ )); do |
| 115 |
echo " { sr_kemi_jsdt_exec_func_${c}, NULL}," >>../app_jsdt_kemi_export.c |
| 116 |
done |
| 117 |
echo " {NULL, NULL}" >>../app_jsdt_kemi_export.c |
| 118 |
echo "};" >>../app_jsdt_kemi_export.c |
| 119 |
|
| 120 |
cat >> ../app_jsdt_kemi_export.c <<EOF |
| 121 |
|
| 122 |
/** |
| 123 |
* |
| 124 |
*/ |
| 125 |
sr_kemi_t *sr_kemi_jsdt_export_get(int idx) |
| 126 |
{ |
| 127 |
if(idx<0 || idx>=SR_KEMI_JSDT_EXPORT_SIZE) |
| 128 |
return NULL; |
| 129 |
return _sr_kemi_jsdt_export_list[idx].ket; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* |
| 134 |
*/ |
| 135 |
duk_c_function sr_kemi_jsdt_export_associate(sr_kemi_t *ket) |
| 136 |
{ |
| 137 |
int i; |
| 138 |
for(i=0; i<SR_KEMI_JSDT_EXPORT_SIZE; i++) { |
| 139 |
if(_sr_kemi_jsdt_export_list[i].ket==NULL) { |
| 140 |
_sr_kemi_jsdt_export_list[i].ket = ket; |
| 141 |
return _sr_kemi_jsdt_export_list[i].pfunc; |
| 142 |
} |
| 143 |
if(_sr_kemi_jsdt_export_list[i].ket==ket) { |
| 144 |
return _sr_kemi_jsdt_export_list[i].pfunc; |
| 145 |
} |
| 146 |
} |
| 147 |
LM_ERR("no more indexing slots\n"); |
| 148 |
return NULL; |
| 149 |
} |
| 150 |
EOF |