From 62c7fce61ed85a59c232233c086c39c0fe134d23 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 29 Sep 2016 21:02:13 +1000 Subject: [PATCH] ckdb - add msgline to cmd_dsp() code --- src/ckdb.c | 1 + src/ckdb.h | 3 ++- src/ckdb_cmd.c | 3 +++ src/ckdb_data.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/ckdb.c b/src/ckdb.c index 76591c6c..78934f9f 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -2023,6 +2023,7 @@ static void alloc_storage() msgline_free = k_new_list("MsgLine", sizeof(MSGLINE), ALLOC_MSGLINE, LIMIT_MSGLINE, true); msgline_store = k_new_store(msgline_free); + msgline_free->dsp_func = dsp_msgline; workqueue_free = k_new_list("WorkQueue", sizeof(WORKQUEUE), ALLOC_WORKQUEUE, LIMIT_WORKQUEUE, true); diff --git a/src/ckdb.h b/src/ckdb.h index f8bed5a7..eeb759f8 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.512" +#define CKDB_VERSION DB_VERSION"-2.513" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -3333,6 +3333,7 @@ extern INTRANSIENT *_get_intransient(const char *fldnam, char *value, #define intransient_str(_fld, _val) \ _intransient_str(_fld, _val, WHERE_FFL_HERE) extern char *_intransient_str(char *fldnam, char *value, WHERE_FFL_ARGS); +extern void dsp_msgline(K_ITEM *item, FILE *stream); extern char *_transfer_data(K_ITEM *item, WHERE_FFL_ARGS); extern void dsp_transfer(K_ITEM *item, FILE *stream); extern cmp_t cmp_transfer(K_ITEM *a, K_ITEM *b); diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 82b2c401..ae6c436f 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -5966,6 +5966,9 @@ static char *cmd_dsp(__maybe_unused PGconn *conn, __maybe_unused char *cmd, if (strcasecmp(name, "markersummary") == 0) dsp_kstore(markersummary_store, fil, NULL); + + if (strcasecmp(name, "msgline") == 0) + dsp_kstore(msgline_store, fil, NULL); } LOGDEBUG("%s.ok.dsp.file='%s'", id, fil); diff --git a/src/ckdb_data.c b/src/ckdb_data.c index c24f6a6e..4b2d3280 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -816,6 +816,37 @@ char *_intransient_str(char *fldnam, char *value, WHERE_FFL_ARGS) return in->str; } +void dsp_msgline(K_ITEM *item, FILE *stream) +{ + K_ITEM *t_item; + MSGLINE *m; + int c; + + if (!item) + fprintf(stream, "%s() called with (null) item\n", __func__); + else { + DATA_MSGLINE(m, item); + if (m->trf_store) + c = m->trf_store->count; + else + c = 0; + + fprintf(stream, " which=%d id='%s' cmd='%s' msg='%.42s' " + "trf_store=%c count=%d\n", + m->which_cmds, m->id, m->cmd, m->msg, + m->trf_store ? 'Y' : 'N', c); + + if (m->trf_store) { + t_item = m->trf_store->head; + while (t_item) { + fputc(' ', stream); + dsp_transfer(t_item, stream); + t_item = t_item->next; + } + } + } +} + // For mutiple variable function calls that need the data char *_transfer_data(K_ITEM *item, WHERE_FFL_ARGS) {