summaryrefslogtreecommitdiff
path: root/tbl_qcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tbl_qcmd.c')
-rw-r--r--tbl_qcmd.c237
1 files changed, 211 insertions, 26 deletions
diff --git a/tbl_qcmd.c b/tbl_qcmd.c
index 16ce944..261259d 100644
--- a/tbl_qcmd.c
+++ b/tbl_qcmd.c
@@ -76,38 +76,62 @@ tble_exec *tbl_exec_search_cmd(tbl_exec *tbl, char *cmd)
return ret;
}
-int tbl_exec_print(tbl_exec *tbl)
+
+int tbl_exec_print(tble_exec *tble, int flags)
+{
+ if (tble == NULL)
+ {
+ return -1;
+ }
+
+ if (flags&TBL_PF_EXEC_ID)
+ {
+ printf("ID:[%d] ", tble->id);
+ }
+
+ if (flags&TBL_PF_EXEC_NAME)
+ {
+ printf("NAME:[%s] ", tble->name);
+ }
+
+ if (flags&TBL_PF_EXEC_CMD)
+ {
+ printf("CMD:[%s] ", tble->cmd);
+ }
+
+ if (flags&TBL_PF_EXEC_TYPE)
+ {
+ printf("TYPE:[%d] ", tble->type);
+ }
+
+ printf("\n");
+
+ return 0;
+}
+
+int tbl_exec_print_tbl(tbl_exec *tbl, int flags)
{
int i;
- tble_exec *cmd=NULL;
+ tble_exec *el=NULL;
if (tbl == NULL)
{
return -1;
}
- for (i=0;i<tbl->size;i++)
+ for (i=0; i<tbl->size; i++)
{
- cmd = tbl->reg_cmd[i];
- if (cmd != NULL)
+ el = tbl->reg_cmd[i];
+ if (el != NULL)
{
- printf("->%d<-\n",i);
- printf("ID: %d\n", cmd->id);
- printf("TYPE: %d\n", cmd->type);
- if (cmd->name)
- {
- printf("%s\n", cmd->name);
- }
- if (cmd->cmd)
- {
- printf("%s\n", cmd->cmd);
- }
+ printf(">%02d< ",i);
+ tbl_exec_print(el, flags);
}
}
return 0;
}
-tble_qcmd *tbl_qcmd_c()
+tble_qcmd *tbl_qcmd_cmd_c()
{
MVAR_ALLOC_STRC(ret,tble_qcmd,{
return NULL;});
@@ -115,7 +139,7 @@ tble_qcmd *tbl_qcmd_c()
}
-tbl_qcmd* tbl_qcmd_list_c(int size)
+tbl_qcmd* tbl_qcmd_c(int size)
{
MVAR_ALLOC_STRC(ret,tbl_qcmd,{
return NULL;});
@@ -156,6 +180,7 @@ int tbl_qcmd_add(tbl_qcmd *tbl, tble_qcmd *cmd)
{
if (tbl == NULL || cmd == NULL)
return -1;
+ cmd->id = uniq_id();
tbl->cmd[tbl->size] = cmd;
if (tbl->size+1<tbl->max_size)
{
@@ -193,7 +218,7 @@ int tbl_qcmd_chk(tbl_qcmd *tbl)
return ret;
}
-
+//delete but dont free from list?
int tbl_qcmd_del(tbl_qcmd *tbl, int idx)
{
int ret=-1;
@@ -250,26 +275,186 @@ int tbl_qcmd_resp(tbl_qcmd *tbl, tble_cmd_resp *resp)
return ret;
}
-tble_cmd_param* tbl_cmd_param_c()
+tble_cmd_param* tbl_cmd_param(tble_qcmd *cmd)
{
MVAR_ALLOC_STRC(ret,tble_cmd_param,{
+ PERM();
return NULL;});
+ ret->id = uniq_id();
+ ret->qid = cmd->id;
+ ret->cmd = alloc_new_str(cmd->cmd);
+ ret->param = alloc_new_str(cmd->param);
+ ret->out_q = cmd->out_q;
+
return ret;
}
-int tbl_cmd_param_set(tble_cmd_param *cmd_param, tble_qcmd *cmd)
+int tbl_cmd_param_free(tble_cmd_param *param)
+{
+ if (param == NULL)
+ {
+ return -1;
+ }
+
+ free(param->cmd);
+ free(param->param);
+ free(param);
+
+ return 0;
+}
+
+int tbl_cmd_param_print(tble_cmd_param *param)
+{
+ if (param == NULL)
+ return -1;
+
+ printf("ID:[%d] ", param->id);
+ printf("QID:[%d] ", param->qid);
+ printf("OUT_Q:[%d] ", param->out_q);
+ printf("CMD:[%s] ", param->cmd);
+ printf("PARAM:[%s] ", param->param);
+ printf("\n");
+
+ return 0;
+}
+
+tble_cmd_resp* tbl_cmd_resp_c(tble_cmd_param *param)
+{
+ if (param == NULL)
+ {
+ PERM();
+ return NULL;
+ }
+
+ MVAR_ALLOC_STRC(ret, tble_cmd_resp,
+ {
+ PERM();
+ return NULL;
+ });
+
+ ret->id = uniq_id();
+ ret->qid = param->qid;
+
+ return ret;
+}
+
+int tbl_cmd_resp_free(tble_cmd_resp *resp)
+{
+ if (resp == NULL)
+ {
+ return -1;
+ }
+
+
+
+ return 0;
+}
+
+int tbl_cmd_resp_print(tble_cmd_resp *resp)
{
+ if (resp == NULL)
+ return -1;
+
+ printf("ID:[%d] ", resp->id);
+ printf("QID:[%d] ", resp->qid);
+ printf("TYPE:[%d] ", resp->type);
+ printf("RET_CODE:[%d] ", resp->ret_code);
+ printf("RESP:[%d] ", resp->resp);
+ printf("\n");
+
+ return 0;
+}
- if ((cmd_param == NULL) || (cmd == NULL))
+int tbl_qcmd_print_cmd(tble_qcmd *tbl, int flags)
+{
+ if (tbl == NULL)
{
return -1;
}
- cmd_param->id = cmd->id;
- cmd_param->cmd = alloc_new_str(cmd->cmd);
- cmd_param->param = alloc_new_str(cmd->param);
- cmd_param->out_q = cmd->out_q;
+
+ if (flags&TBL_PF_QCMD_ID)
+ {
+ printf("ID:[%d] ",tbl->id);
+ }
+ if (flags&TBL_PF_QCMD_CID)
+ {
+ printf("CID:[%d] ",tbl->cid);
+ }
+ if (flags&TBL_PF_QCMD_TIMESTAMP)
+ {
+ printf("TIMESTAMP:[%d] ", tbl->timestamp);
+ }
+ if (flags&TBL_PF_QCMD_STATE)
+ {
+ printf("STATE:[%d] ", tbl->state);
+ }
+ if (flags&TBL_PF_QCMD_TIMEOUT)
+ {
+ printf("TIMEOUT:[%d] ", tbl->timeout);
+ }
+ if (flags&TBL_PF_QCMD_CMD)
+ {
+ printf("CMD:[%s] ", tbl->cmd);
+ }
+ if (flags&TBL_PF_QCMD_PARAM)
+ {
+ printf("PARAM:[%s] ", tbl->param);
+ }
+ if (flags&TBL_PF_QCMD_OUT_Q)
+ {
+ printf("OUT_Q:[%d] ", tbl->out_q);
+ }
+ if (flags&TBL_PF_QCMD_IN_Q)
+ {
+ printf("IN_Q:[%d] ", tbl->in_q);
+ }
+ if (flags&TBL_PF_QCMD_IDX_EXEC)
+ {
+ printf("IDX_EXEC:[%d] ", tbl->idx_exec);
+ }
+ printf("\n");
return 0;
}
+
+int tbl_qcmd_print_tbl(tbl_qcmd *tbl, int flags)
+{
+ int i = -1;
+ tble_qcmd *el = NULL;
+
+ if (tbl == NULL)
+ {
+ PERM();
+ return -1;
+ }
+
+ if (tbl->cmd == NULL)
+ {
+ PERM();
+ return -1;
+ }
+
+ for (i=0; i<tbl->size; i++)
+ {
+ el = tbl->cmd[i];
+ printf(">%02d< ", i);
+ tbl_qcmd_print_cmd(el, flags);
+ }
+
+ return 0;
+}
+
+
+int tbl_qcmd_destroy_cmd(tble_qcmd *tbl)
+{
+ return 0;
+}
+
+
+int tbl_qcmd_destroy_table(tbl_qcmd *tbl)
+{
+ return 0;
+}
+