Skip to content

Commit

Permalink
app_java: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent 64a2e2d commit 70ac94f
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 212 deletions.
50 changes: 23 additions & 27 deletions src/modules/app_java/app_java_mod.c
Expand Up @@ -57,49 +57,45 @@ jmethodID KamailioID;
sip_msg_t *_aj_msg = NULL;

/** module parameters */
static param_export_t params[] = {
{"class_name", PARAM_STRING, &class_name},
{"child_init_method", PARAM_STRING, &child_init_mname}, /* unused? */
{"java_options", PARAM_STRING, &java_options_str},
{"force_cmd_exec", INT_PARAM, &force_cmd_exec},
{0, 0, 0}
};
static param_export_t params[] = {{"class_name", PARAM_STRING, &class_name},
{"child_init_method", PARAM_STRING, &child_init_mname}, /* unused? */
{"java_options", PARAM_STRING, &java_options_str},
{"force_cmd_exec", INT_PARAM, &force_cmd_exec}, {0, 0, 0}};


/*
* Exported functions
*/
static cmd_export_t cmds[] = {
{"java_method_exec", (cmd_function)j_nst_exec_0, 2, NULL, 0, ANY_ROUTE},
{"java_method_exec", (cmd_function)j_nst_exec_1, 3, NULL, 0, ANY_ROUTE},
{"java_s_method_exec", (cmd_function)j_s_nst_exec_0, 2, NULL, 0,
{"java_method_exec", (cmd_function)j_nst_exec_0, 2, NULL, 0, ANY_ROUTE},
{"java_method_exec", (cmd_function)j_nst_exec_1, 3, NULL, 0, ANY_ROUTE},
{"java_s_method_exec", (cmd_function)j_s_nst_exec_0, 2, NULL, 0,
ANY_ROUTE},
{"java_s_method_exec", (cmd_function)j_s_nst_exec_1, 3, NULL, 0,
{"java_s_method_exec", (cmd_function)j_s_nst_exec_1, 3, NULL, 0,
ANY_ROUTE},
{"java_staticmethod_exec", (cmd_function)j_st_exec_0, 2, NULL, 0,
{"java_staticmethod_exec", (cmd_function)j_st_exec_0, 2, NULL, 0,
ANY_ROUTE},
{"java_staticmethod_exec", (cmd_function)j_st_exec_1, 3, NULL, 0,
{"java_staticmethod_exec", (cmd_function)j_st_exec_1, 3, NULL, 0,
ANY_ROUTE},
{"java_s_staticmethod_exec", (cmd_function)j_s_st_exec_0, 2, NULL, 0,
{"java_s_staticmethod_exec", (cmd_function)j_s_st_exec_0, 2, NULL, 0,
ANY_ROUTE},
{"java_s_staticmethod_exec", (cmd_function)j_s_st_exec_1, 3, NULL, 0,
{"java_s_staticmethod_exec", (cmd_function)j_s_st_exec_1, 3, NULL, 0,
ANY_ROUTE},

{0, 0, 0, 0, 0, 0}
};
{0, 0, 0, 0, 0, 0}};

/** module exports */
struct module_exports exports = {
APP_NAME, /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* exported functions */
params, /* exported parameters */
0, /* exported RPC methods */
0, /* exported pseudo-variables */
0, /* response handling function */
mod_init, /* module initialization function */
child_init, /* per-child init function */
mod_destroy /* destroy function */
APP_NAME, /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* exported functions */
params, /* exported parameters */
0, /* exported RPC methods */
0, /* exported pseudo-variables */
0, /* response handling function */
mod_init, /* module initialization function */
child_init, /* per-child init function */
mod_destroy /* destroy function */
};

static int mod_init(void)
Expand Down
25 changes: 11 additions & 14 deletions src/modules/app_java/java_iface.c
Expand Up @@ -149,13 +149,13 @@ int java_exec(struct sip_msg *msgp, int is_static, int is_synchronized,

cslen = strlen(signature) + 2 + 1
+ 1; // '(' + 'signature' + ')' + 'return signature' + null terminator
cs = (char *)pkg_malloc((cslen+1) * sizeof(char));
cs = (char *)pkg_malloc((cslen + 1) * sizeof(char));
if(!cs) {
PKG_MEM_ERROR;
return -1;
}
r = snprintf(cs, cslen, "(%s)%s", signature, retval_sig);
if(r<0 || r>cslen) {
if(r < 0 || r > cslen) {
LM_ERR("building cs value failed\n");
pkg_free(cs);
return -1;
Expand Down Expand Up @@ -185,10 +185,9 @@ int java_exec(struct sip_msg *msgp, int is_static, int is_synchronized,
_aj_msg = msgp;

// find a method by signature
invk_method = is_static
? (*_aj_env)->GetStaticMethodID(
_aj_env, KamailioClassRef, method_name, cs)
: (*_aj_env)->GetMethodID(
invk_method = is_static ? (*_aj_env)->GetStaticMethodID(
_aj_env, KamailioClassRef, method_name, cs)
: (*_aj_env)->GetMethodID(
_aj_env, KamailioClassRef, method_name, cs);
if(!invk_method || (*_aj_env)->ExceptionCheck(_aj_env)) {
handle_exception();
Expand Down Expand Up @@ -220,10 +219,9 @@ int java_exec(struct sip_msg *msgp, int is_static, int is_synchronized,
}

if(param == NULL) {
retval = is_static
? (int)(*_aj_env)->CallStaticIntMethod(
_aj_env, KamailioClassRef, invk_method_ref)
: (int)(*_aj_env)->CallIntMethod(_aj_env,
retval = is_static ? (int)(*_aj_env)->CallStaticIntMethod(
_aj_env, KamailioClassRef, invk_method_ref)
: (int)(*_aj_env)->CallIntMethod(_aj_env,
KamailioClassInstanceRef, invk_method_ref);
} else {
jparam = get_value_by_sig_type(signature, param);
Expand All @@ -234,10 +232,9 @@ int java_exec(struct sip_msg *msgp, int is_static, int is_synchronized,
return -1;
}

retval = is_static
? (int)(*_aj_env)->CallStaticIntMethod(_aj_env,
KamailioClassRef, invk_method_ref, *jparam)
: (int)(*_aj_env)->CallIntMethod(_aj_env,
retval = is_static ? (int)(*_aj_env)->CallStaticIntMethod(
_aj_env, KamailioClassRef, invk_method_ref, *jparam)
: (int)(*_aj_env)->CallIntMethod(_aj_env,
KamailioClassInstanceRef, invk_method_ref,
*jparam);
}
Expand Down
10 changes: 5 additions & 5 deletions src/modules/app_java/java_msgobj.c
Expand Up @@ -278,11 +278,11 @@ jobject *fill_sipmsg_object(JNIEnv *env, struct sip_msg *msg)
APP_NAME);
return NULL;
}
jStrParam = (*env)->NewStringUTF(env,
(msg->set_global_address.len <= 0
|| msg->set_global_address.s == NULL)
? ""
: msg->set_global_address.s);
jStrParam = (*env)->NewStringUTF(
env, (msg->set_global_address.len <= 0
|| msg->set_global_address.s == NULL)
? ""
: msg->set_global_address.s);
(*env)->SetObjectField(env, SipMsgInstance, fid, jStrParam);
if((*env)->ExceptionCheck(env)) {
handle_exception();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/app_java/java_native_methods.c
Expand Up @@ -414,7 +414,7 @@ int KamExec(JNIEnv *jenv, char *fname, int argc, char **argv)
STRING_ST, argv[3], /* param. 4 */
STRING_ST, argv[4], /* param. 5 */
STRING_ST, argv[5] /* param. 6 */
);
);

if(!act) {
LM_ERR("%s: KamExec(): action structure couldn't be created\n",
Expand Down

0 comments on commit 70ac94f

Please sign in to comment.