Skip to content

Commit

Permalink
debugger: 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 2b597d8 commit 656e147
Show file tree
Hide file tree
Showing 9 changed files with 802 additions and 1,007 deletions.
124 changes: 54 additions & 70 deletions src/modules/debugger/debugger_act.c
Expand Up @@ -31,88 +31,73 @@

#include "debugger_act.h"

typedef struct _dbg_action {
typedef struct _dbg_action
{
int type;
str name;
} dbg_action_t;

static str _dbg_action_special[] = {
str_init("unknown"), /* 0 */
str_init("exit"), /* 1 */
str_init("drop"), /* 2 */
str_init("return"), /* 3 */
{0, 0}
};
static str _dbg_action_special[] = {str_init("unknown"), /* 0 */
str_init("exit"), /* 1 */
str_init("drop"), /* 2 */
str_init("return"), /* 3 */
{0, 0}};

static dbg_action_t _dbg_action_list[] = {
{ FORWARD_T, str_init("forward") },
{ LOG_T, str_init("log") },
{ ERROR_T, str_init("error") },
{ ROUTE_T, str_init("route") },
{ EXEC_T, str_init("exec") },
{ SET_HOST_T, str_init("sethost") },
{ SET_HOSTPORT_T, str_init("sethostport") },
{ SET_USER_T, str_init("setuser") },
{ SET_USERPASS_T, str_init("setuserpass") },
{ SET_PORT_T, str_init("setport") },
{ SET_URI_T, str_init("seturi") },
{ SET_HOSTPORTTRANS_T, str_init("sethostporttrans") },
{ SET_HOSTALL_T, str_init("sethostall") },
{ SET_USERPHONE_T, str_init("setuserphone") },
{ IF_T, str_init("if") },
{ SWITCH_T, str_init("switch") },
{ BLOCK_T, str_init("block") },
{ EVAL_T, str_init("eval") },
{ SWITCH_JT_T, str_init("switch") },
{ SWITCH_COND_T, str_init("switch") },
{ MATCH_COND_T, str_init("case") },
{ WHILE_T, str_init("while") },
{ SETFLAG_T, str_init("setflag") },
{ RESETFLAG_T, str_init("resetflag") },
{ ISFLAGSET_T, str_init("isflagset") },
{ AVPFLAG_OPER_T, str_init("avpflag") },
{ LEN_GT_T, str_init("lengt") },
{ PREFIX_T, str_init("prefix") },
{ STRIP_T, str_init("strip") },
{ STRIP_TAIL_T, str_init("striptail") },
{ APPEND_BRANCH_T, str_init("append_branch") },
{ REVERT_URI_T, str_init("reverturi") },
{ FORWARD_TCP_T, str_init("forward_tcp") },
{ FORWARD_UDP_T, str_init("forward_udp") },
{ FORWARD_TLS_T, str_init("forward_tls") },
{ FORWARD_SCTP_T, str_init("forward_sctp") },
{ FORCE_RPORT_T, str_init("force_rport") },
{ ADD_LOCAL_RPORT_T, str_init("add_local_rport") },
{ SET_ADV_ADDR_T, str_init("set_adv_addr") },
{ SET_ADV_PORT_T, str_init("set_adv_port") },
{ FORCE_TCP_ALIAS_T, str_init("force_tcp_alias") },
{ LOAD_AVP_T, str_init("load_avp") },
{ AVP_TO_URI_T, str_init("avp_to_uri") },
{ FORCE_SEND_SOCKET_T, str_init("force_send_socket") },
{ ASSIGN_T, str_init("assign") },
{ ADD_T, str_init("add") },
{ UDP_MTU_TRY_PROTO_T, str_init("udp_mtu_try_proto") },
{ SET_FWD_NO_CONNECT_T, str_init("set_fwd_no_connect") },
{ SET_RPL_NO_CONNECT_T, str_init("set_rpl_no_connect") },
{ SET_FWD_CLOSE_T, str_init("set_fwd_close") },
{ SET_RPL_CLOSE_T, str_init("set_rpl_close") },
{ 0, {0, 0} }
};
static dbg_action_t _dbg_action_list[] = {{FORWARD_T, str_init("forward")},
{LOG_T, str_init("log")}, {ERROR_T, str_init("error")},
{ROUTE_T, str_init("route")}, {EXEC_T, str_init("exec")},
{SET_HOST_T, str_init("sethost")},
{SET_HOSTPORT_T, str_init("sethostport")},
{SET_USER_T, str_init("setuser")},
{SET_USERPASS_T, str_init("setuserpass")},
{SET_PORT_T, str_init("setport")}, {SET_URI_T, str_init("seturi")},
{SET_HOSTPORTTRANS_T, str_init("sethostporttrans")},
{SET_HOSTALL_T, str_init("sethostall")},
{SET_USERPHONE_T, str_init("setuserphone")}, {IF_T, str_init("if")},
{SWITCH_T, str_init("switch")}, {BLOCK_T, str_init("block")},
{EVAL_T, str_init("eval")}, {SWITCH_JT_T, str_init("switch")},
{SWITCH_COND_T, str_init("switch")}, {MATCH_COND_T, str_init("case")},
{WHILE_T, str_init("while")}, {SETFLAG_T, str_init("setflag")},
{RESETFLAG_T, str_init("resetflag")},
{ISFLAGSET_T, str_init("isflagset")},
{AVPFLAG_OPER_T, str_init("avpflag")}, {LEN_GT_T, str_init("lengt")},
{PREFIX_T, str_init("prefix")}, {STRIP_T, str_init("strip")},
{STRIP_TAIL_T, str_init("striptail")},
{APPEND_BRANCH_T, str_init("append_branch")},
{REVERT_URI_T, str_init("reverturi")},
{FORWARD_TCP_T, str_init("forward_tcp")},
{FORWARD_UDP_T, str_init("forward_udp")},
{FORWARD_TLS_T, str_init("forward_tls")},
{FORWARD_SCTP_T, str_init("forward_sctp")},
{FORCE_RPORT_T, str_init("force_rport")},
{ADD_LOCAL_RPORT_T, str_init("add_local_rport")},
{SET_ADV_ADDR_T, str_init("set_adv_addr")},
{SET_ADV_PORT_T, str_init("set_adv_port")},
{FORCE_TCP_ALIAS_T, str_init("force_tcp_alias")},
{LOAD_AVP_T, str_init("load_avp")},
{AVP_TO_URI_T, str_init("avp_to_uri")},
{FORCE_SEND_SOCKET_T, str_init("force_send_socket")},
{ASSIGN_T, str_init("assign")}, {ADD_T, str_init("add")},
{UDP_MTU_TRY_PROTO_T, str_init("udp_mtu_try_proto")},
{SET_FWD_NO_CONNECT_T, str_init("set_fwd_no_connect")},
{SET_RPL_NO_CONNECT_T, str_init("set_rpl_no_connect")},
{SET_FWD_CLOSE_T, str_init("set_fwd_close")},
{SET_RPL_CLOSE_T, str_init("set_rpl_close")}, {0, {0, 0}}};

str* dbg_get_action_name(struct action *a)
str *dbg_get_action_name(struct action *a)
{
int i;
static str aname;
cmd_export_t *cmd;

if(a==NULL)
if(a == NULL)
return &_dbg_action_special[0];

switch(a->type) {
case DROP_T:
if(a->val[1].u.number&DROP_R_F)
if(a->val[1].u.number & DROP_R_F)
return &_dbg_action_special[2];
if(a->val[1].u.number&RETURN_R_F)
if(a->val[1].u.number & RETURN_R_F)
return &_dbg_action_special[3];
return &_dbg_action_special[1];
case MODULE0_T:
Expand All @@ -130,14 +115,13 @@ str* dbg_get_action_name(struct action *a)
case MODULE5_RVE_T:
case MODULE6_RVE_T:
case MODULEX_RVE_T:
cmd = (cmd_export_t*)(a->val[0].u.data);
cmd = (cmd_export_t *)(a->val[0].u.data);
aname.s = cmd->name;
aname.len = strlen(aname.s);
return &aname;
default:
for(i=0; _dbg_action_list[i].type!=0; i++)
{
if(_dbg_action_list[i].type==a->type)
for(i = 0; _dbg_action_list[i].type != 0; i++) {
if(_dbg_action_list[i].type == a->type)
return &_dbg_action_list[i].name;
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/modules/debugger/debugger_act.h
Expand Up @@ -21,14 +21,13 @@
*
*/


#ifndef _DEBUGGER_ACT_H_
#define _DEBUGGER_ACT_H_

#include "../../core/str.h"
#include "../../core/route_struct.h"
#include "../../core/route_struct.h"

str* dbg_get_action_name(struct action *a);
str *dbg_get_action_name(struct action *a);

#endif

0 comments on commit 656e147

Please sign in to comment.