DSWaylandProtocolTrace::~DSWaylandProtocolTrace()
{
-
+ DSWaylandCompositor::releaseInstance();
}
DSWaylandProtocolTrace *DSWaylandProtocolTrace::getInstance()
// set rule file path
env_path = getenv("E_INFO_RULE_FILE");
- DSLOG_DBG("DSWaylandProtocolTrace", "========================== rule file path = %s", env_path);
+ DSLOG_DBG("DSWaylandProtocolTrace", "==================================================== rule file path = %s", env_path);
ret = priv->protocol_rule_init(env_path);
DSLOG_DBG("DSWaylandProtocolTrace", "result of protocol rule init = %d", ret);
if(env_path)
{
+ //TODO: free env_path
DSLOG_DBG("DSWaylandProtocolTrace", "delete rule file path = %s", env_path);
- //delete env_path;
//free(env_path);
env_path = nullptr;
DSLOG_DBG("DSWaylandProtocolTrace", "delete rule file path done.");
if(!ret) return ret;
// set trace file path
- DSLOG_DBG("DSWaylandProtocolTrace", "====================================================");
+ DSLOG_DBG("DSWaylandProtocolTrace", "========================================================================================================");
env_path = getenv("E_INFO_TRACE_FILE");
- DSLOG_DBG("DSWaylandProtocolTrace", "========================== trace file path = %s", env_path);
+ DSLOG_DBG("DSWaylandProtocolTrace", "==================================================== trace file path = %s", env_path);
ret = priv->protocol_trace_init(env_path);
DSLOG_DBG("DSWaylandProtocolTrace", "result of protocol trace init = %d", ret);
if(env_path)
{
+ //TODO: free env_path
DSLOG_DBG("DSWaylandProtocolTrace", "delete trace file path = %s", env_path);
- //delete env_path;
//free(env_path);
env_path = nullptr;
DSLOG_DBG("DSWaylandProtocolTrace", "delete trace file path done.");
DSLOG_DBG("DSWaylandProtocolTracePriv", "saved trace path = %s", trace_env_path);
//enable
- protocol_trace_set();
+ protocol_trace_unset();
DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_trace_init");
/*
log_fp_ptrace = fopen(trace_path, "a");
//REPLY("Error : Too few arguments.");
return false;
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: go on");
if(!strcasecmp(policy, "ALLOW"))
policy_type = PROTOCOLTRACE_TYPE_ALLOW;
//REPLY;
return false;
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: policy_type = %d", policy_type);
// protocol arguments merge
protocol_arguments_merge(merge, sizeof(merge), argc -2, &(argv[2]));
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: merge = %s", merge);
size_rule = sizeof(rule) -1;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: size_rule = %d", size_rule);
for(i=0; i<strlen(merge); i++)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: merge[%d] = %c", i, merge[i]);
if(merge[i] == '\"' || merge[i] == '\'')
{
rule[index++] = ' ';
continue;
}
rule[index++] = merge[i];
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: rule[%d] = %c", index-1, rule[index-1]);
if(index >size_rule)
return false;
}
DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: rule = %s", rule);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: rulechecker_rule_add (before) -> rc %d",rc->count);
result = rulechecker_rule_add(rc, policy_type, rule);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: rulechecker_rule_add (after) -> rc %d",rc->count);
if(result == PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES)
{
if(!strcasecmp(remove_idx, "all"))
{
DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: all");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: (before destroy) rc = %d", rc->count);
rulechecker_destroy(rc);
rc = rulechecker_init();
if(!rc)
DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: rules not removed");
return false;
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: (after destroy) rc = %d", rc->count);
DSLOG_INF("DSWaylandProtocolTracePriv", "Every rules were successfully removed");
}
else
int index = atoi(remove_idx);
DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: remove idx = %d", index);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: (before rulechecker_rule_remove) rc = %d", rc->count);
if(isdigit(*remove_idx) && rulechecker_rule_remove(rc, index) == 0)
DSLOG_INF("DSWaylandProtocolTracePriv", "The rule [%d] was successfully removed.", index);
else
DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : No such rule [%s]", remove_idx);
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE :: (after rulechecker_rule_remove) rc = %d", rc->count);
}
}
rulechecker_rule_print(rc);
bool DSWaylandProtocolTracePrivate::protocol_rule_validate(ProtocolTrace_Protocol_Log *log)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_rule_validate << ");
char *cmd = "";
if(!rc)
void DSWaylandProtocolTracePrivate::wl_protocol_cb_client_destroy(struct wl_listener *listener, void *data)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> wl_protocol_cb_client_destroy");
-
struct wl_client *wc = (struct wl_client *)data;
struct timespec tp;
unsigned int time;
//free(listener);
delete listener;
listener = nullptr;
-
- DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << wl_protocol_cb_client_destroy");
-
}
void DSWaylandProtocolTracePrivate::protocol_client_destroy_listener_reg(struct wl_client *client)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> protocol_client_destroy_listener_reg");
-
struct wl_listener *destroy_listener;
destroy_listener = wl_client_get_destroy_listener(client, wl_protocol_cb_client_destroy);
- if(destroy_listener) return;
+ if(destroy_listener) {
+ return;
+ }
destroy_listener = (struct wl_listener *)calloc(1, sizeof(wl_listener));
//EINA_SAFETY_ON_NULL_RETURN(destroy_listener);
destroy_listener->notify = wl_protocol_cb_client_destroy;
wl_client_add_destroy_listener(client, destroy_listener);
-
- DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol_client_destroy_listener_reg");
}
void DSWaylandProtocolTracePrivate::protocol_trace_func(void *user_data, enum wl_protocol_logger_type direction, const struct wl_protocol_logger_message *message)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> protocol_trace_func");
-
int i;
struct argument_details arg;
struct wl_client *wc = wl_resource_get_client(message->resource);
if(wc)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv","has wl_client");
protocol_client_destroy_listener_reg(wc);
wl_client_get_credentials(wc, &client_pid, nullptr, nullptr);
}
- DSLOG_DBG("DSWaylandProtocolTracePriv","go on");
-
clock_gettime(CLOCK_MONOTONIC, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
ProtocolTrace_Protocol_Log elog = {PROTOCOL_TYPE_REQUEST,};
- DSLOG_DBG("DSWaylandProtocolTracePriv", "before get info protocol log => type: %s, client_pit: %d, target_id: %d, name: %s, cmd: %s", elog.type, elog.client_pid, elog.target_id, elog.name, elog.cmd);
elog.type = (direction == WL_PROTOCOL_LOGGER_EVENT)? PROTOCOL_TYPE_EVENT:PROTOCOL_TYPE_REQUEST;
elog.client_pid = client_pid;
elog.target_id = wl_resource_get_id(message->resource);
snprintf(elog.name, PATH_MAX,"%s:%s", wl_resource_get_class(message->resource), message->message->name);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "after get info protocol log => type: %s, client_pit: %d, target_id: %d, name: %s, cmd: %s", elog.type, elog.client_pid, elog.target_id, elog.name, elog.cmd);
-
if(!protocol_rule_validate(&elog)) return;
BUF_SNPRINTF("[%10.3f] %s%d%s%s@%u.%s(",
fprintf(log_fp_ptrace, "%s\n", strbuf);
else
DSLOG_INF("DSWaylandProtocolTracePriv","%s", strbuf);
-
- DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol_trace_func");
-
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_create_node(ProtocolTrace_Tree *tree)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> bintree_create_node");
-
ProtocolTrace_Tree_Node *node = (ProtocolTrace_Tree_Node*) calloc(1, sizeof(ProtocolTrace_Tree_Node) + tree->size);
// enia safety
node->left = nullptr;
node->right = nullptr;
- DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << bintree_create_node");
return node;
}
ProtocolTrace_Tree *DSWaylandProtocolTracePrivate::bintree_create_tree(int size)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_create_tree");
-
ProtocolTrace_Tree *tree = (ProtocolTrace_Tree *)calloc(1, sizeof(ProtocolTrace_Tree) + size);
// eina safety
tree->size = size;
tree->head = nullptr;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "bintree create treee => size : %d", tree->size);
-
- DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << bintree_create_tree");
-
return tree;
}
void DSWaylandProtocolTracePrivate::bintree_destroy_tree(ProtocolTrace_Tree *tree)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_destroy_tree");
if(tree->head)
bintree_remove_node_recursive(tree->head);
//free(tree);
delete tree;
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_destroy_tree");
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_head(ProtocolTrace_Tree *tree)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_get_head >> OUT");
return tree->head;
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_left_child(ProtocolTrace_Tree_Node *node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_get_left_child >> OUT");
return node->left;
}
void *DSWaylandProtocolTracePrivate::bintree_get_node_data(ProtocolTrace_Tree_Node *node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_get_node_data >> OUT");
return (void*)(node+1);
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_right_child(ProtocolTrace_Tree_Node *node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_get_right_child >> OUT");
return node->right;
}
void DSWaylandProtocolTracePrivate::bintree_inorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_inorder_traverse");
if(tree->head)
bintree_inorder_traverse_recursive(tree, tree->head, tree->head, func, arg);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_inorder_traverse");
}
int DSWaylandProtocolTracePrivate::bintree_inorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_inorder_traverse_recursive >> ");
if(node->left)
if(bintree_inorder_traverse_recursive(tree, node->left, node, func, arg)!=0)
return 1;
void DSWaylandProtocolTracePrivate::bintree_postorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_postorder_traverse");
if(tree->head)
bintree_postorder_traverse_recursive(tree, tree->head, tree->head, func, arg);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_postorder_traverse");
}
int DSWaylandProtocolTracePrivate::bintree_postorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_postorder_traverse_recursive >> ");
if(node->left)
if(bintree_postorder_traverse_recursive(tree, node->left, node, func, arg)!=0)
return 1;
void DSWaylandProtocolTracePrivate::bintree_remove_node(ProtocolTrace_Tree_Node *node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_remove_node");
//free(node);
delete node;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_remove_node");
}
void DSWaylandProtocolTracePrivate::bintree_remove_node_recursive(ProtocolTrace_Tree_Node *node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_remove_node_recursive");
if(node->left)
bintree_remove_node_recursive(node->left);
if(node->right)
bintree_remove_node_recursive(node->right);
bintree_remove_node(node);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_remove_node_recursive");
}
void DSWaylandProtocolTracePrivate::bintree_set_head(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *head)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_set_head");
tree->head = head;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_set_head");
}
void DSWaylandProtocolTracePrivate::bintree_set_left_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_set_left_child");
node->left = child;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_set_left_child");
}
void DSWaylandProtocolTracePrivate::bintree_set_right_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> bintree_set_right_child");
node->right = child;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << bintree_set_right_child");
}
ProtocolTrace_Token DSWaylandProtocolTracePrivate::parser_next_token_get(const char **string)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> parser_next_token_get");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parameter string = %s",*string);
-
static int token_cnt = sizeof(token_table) / sizeof(token_table[0]);
int i, compare_res, found =0, first, last;
while(1)
{
compare_res = strncmp(*string, token_table[i].token_char, token_table[i].token_length);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parser_next_token_get:: i = %d// compare string -> string = %s ,vs, token_char = %s",i,*string, token_table[i].token_char);
while(compare_res == 0)
{
found = 1;
if(found)
{
i--;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parm string (before)=> %s",*string);
*string += token_table[i].token_length;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parm string (after = add token length) => %s",*string);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parser next token => %d, token_table name = %d",i,token_table[i].token_name);
return token_table[i].token_name;
}
if(isalpha(**string))
{
(*string)++;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "string is alpha >> next? = %c",**string);
while(isalpha(**string) || isdigit(**string) || **string == '_' || **string == '-')
{
(*string)++;
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "string is alpha >> end alpha = %c",**string);
return PROTOCOLTRACE_TOKEN_SYMBOL;
}
if(isdigit(**string))
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "string is digit = %c",**string);
(*string)++;
while(isdigit(**string))
(*string)++;
return PROTOCOLTRACE_TOKEN_NUMBER;
}
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_next_token_get");
return PROTOCOLTRACE_TOKEN_UNKNOWN;
}
ProtocolTrace_Tree *DSWaylandProtocolTracePrivate::protocol_parser_rule_string_parse(const char *string)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_parser_rule_string_parse");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "parameter string = %s", string);
-
ProtocolTrace_Tree *tree;
ProtocolTrace_Tree_Node *node;
ProtocolTrace_Token_Data token;
token.string = &string;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "token = %s", *token.string);
parser_token_process(&token);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "token(after parser) = %s, %d", *token.string, token.last_token);
tree = bintree_create_tree(sizeof(ProtocolTrace_Rule_Node));
if(!tree) return nullptr;
node = parser_token_parse(tree, &token);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "get node");
if(!node)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "node is null");
bintree_destroy_tree(tree);
DSLOG_DBG("DSWaylandProtocolTracePriv", "finish destroy tree & return null");
return nullptr;
}
bintree_set_head(tree, node);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_parser_rule_string_parse ");
return tree;
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_statement_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> parser_statement_parse");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) token->string = %s, token->last symbol =%s", *token->string, token->last_symbol);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) tree_size = %d", tree->size);
-
ProtocolTrace_Tree_Node *node = nullptr;
ProtocolTrace_Rule_Node *data;
if(token->last_token == PROTOCOLTRACE_TOKEN_L_BR)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "last token = %d", PROTOCOLTRACE_TOKEN_L_BR);
parser_token_process(token);
node = parser_token_parse(tree, token);
if(token->last_token != PROTOCOLTRACE_TOKEN_R_BR)
goto fail;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "not fail");
parser_token_process(token);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_statement_parse");
return node;
}
data->node_type = PROTOCOLTRACE_NODE_TYPE_ALL;
parser_token_process(token);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_statement_parse");
return node;
}
parser_token_process(token);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_statement_parse");
return node;
fail:
if(node)
bintree_remove_node_recursive(node);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_statement_parse");
return nullptr;
}
ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_token_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> parser_token_parse");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) string = %s, last token = %d, last symbol = %s", *token->string, token->last_token, token->last_symbol);
ProtocolTrace_Tree_Node *node, *left = nullptr, *right = nullptr;
ProtocolTrace_Rule_Node *data;
bintree_set_left_child(node, left);
bintree_set_right_child(node, right);
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_token_parse");
return node;
fail:
DSLOG_DBG("DSWaylandProtocolTracePriv", "[fail] recursive remove node");
if(left)
bintree_remove_node_recursive(left);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "return null");
return nullptr;
}
void DSWaylandProtocolTracePrivate::parser_token_process(ProtocolTrace_Token_Data *token)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> parser_token_process");
do
{
token->last_symbol = *(token->string);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "last symbol = %c", token->last_symbol);
token->last_token = parser_next_token_get(token->string);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "last token = %d", token->last_token);
token->symbol_len = *(token->string) - token->last_symbol;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "last_symbol : %s , last_token : %d, symbol_len : %d", token->last_symbol, token->last_token, token->symbol_len);
} while (token->last_token == PROTOCOLTRACE_TOKEN_SPACE);
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << parser_token_process");
}
void DSWaylandProtocolTracePrivate::protocol_arguments_merge(char *target, int target_size, int argc, const char **argv)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_arguments_merge");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) target = %s", target);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) target size= %d", target_size);
-
int i, len;
for(i=0; i<argc; i++)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "argv[i] = %s", argv[i]);
len = snprintf(target, target_size, "%s", argv[i]);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "len = %d", len);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "target = %s", target);
target += len;
target_size -= len;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "target + len = %s", target);
if(i!=argc-1)
{
*(target++) = ' ';
- DSLOG_DBG("DSWaylandProtocolTracePriv", "target = %s", target);
target_size--;
}
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "[last]target = %s", target);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_arguments_merge");
}
char * DSWaylandProtocolTracePrivate::protocol_cmd_get(char *path)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_cmd_get");
char *p;
if(!path) return nullptr;
p = strrchr(path, '/');
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_cmd_get");
return (p)?p+1:path;
}
void DSWaylandProtocolTracePrivate::rulechecker_destroy(ProtocolTrace_Rule_Checker *rc)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_destroy");
-
int i;
for(i=rc->count-1; i>=0; i--)
rulechecker_rule_remove(rc,i);
//free(rc);
delete rc;
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rulechecker_destroy");
}
ProtocolTrace_Rule_Checker *DSWaylandProtocolTracePrivate::rulechecker_init()
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_init");
-
ProtocolTrace_Rule_Checker *rc = (ProtocolTrace_Rule_Checker *) calloc(1, sizeof(ProtocolTrace_Rule_Checker));
if (!rc)
return nullptr;
rc->count = 0;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rulechecker_init");
-
return rc;
}
int DSWaylandProtocolTracePrivate::rulechecker_int_compare(ProtocolTrace_Comparer comparer, int int2, int int1)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_int_compare >> ");
-
switch (comparer)
{
case PROTOCOLTRACE_COMPARER_EQUAL:
ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_add(ProtocolTrace_Rule_Checker *rc, ProtocolTrace_Policy_Type policy, const char *rule_string)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_rule_add");
- DSLOG_DBG("DSWaylandProtocolTracePriv", "rc->count = %d", rc->count);
-
if(rc->count == MAX_RULE)
return PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES;
rc->rules[rc->count].policy = policy;
rc->count++;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "rc->rules[rc->count].policy = %d", rc->rules[rc->count -1].policy);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "rc->count = %d", rc->count -1);
-
return PROTOCOLTRACE_RULE_SET_OK;
}
ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_remove(ProtocolTrace_Rule_Checker *rc, int index)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_rule_remove");
-
if(index <0 || index >= rc->count)
return PROTOCOLTRACE_RULE_SET_ERR_NO_RULE;
if(index!=rc->count)
memmove(&rc->rules[index], &rc->rules[index+1], sizeof(ProtocolTrace_Rule)*(rc->count - index));
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rulechecker_rule_remove");
-
return PROTOCOLTRACE_RULE_SET_OK;
}
int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, char *cmd)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_rule_validate");
-
ProtocolTrace_Validate_Args args = {type, target_id, name, pid, cmd};
ProtocolTrace_Tree_Node *node;
ProtocolTrace_Rule_Node *data;
if(data->result == PROTOCOLTRACE_RESULT_TRUE)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rulechecker_rule_validate");
return rc->rules[i].policy == PROTOCOLTRACE_TYPE_ALLOW;
}
}
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rulechecker_rule_validate");
return default_policy == PROTOCOLTRACE_TYPE_ALLOW;
}
int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, char *str1)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rulechecker_string_compare >> ");
-
int result = strcasecmp(str2, str1);
switch (comparer)
int DSWaylandProtocolTracePrivate::rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rule_print_func");
ProtocolTrace_Reply_Buffer *buffer = (ProtocolTrace_Reply_Buffer *)arg;
char *reply = *buffer->reply;
int *len = buffer->len;
}
*buffer->reply = reply;
- DSLOG_DBG("DSWaylandProtocolTracePriv", "buffer->reply = %s", reply);
+ //DSLOG_DBG("DSWaylandProtocolTracePriv", "buffer->reply = %s", reply);
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rule_print_func");
return 0;
}
int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg)
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> rule_validate_func ");
-
ProtocolTrace_Validate_Args *args = (ProtocolTrace_Validate_Args *)arg;
ProtocolTrace_Tree_Node *left, *right;
ProtocolTrace_Rule_Node *data, *left_data =nullptr, *right_data = nullptr;
}
else
{
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rule_validate_func ");
return -1;
}
-
- DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << rule_validate_func ");
return 0;
}