Browse Source

ktree - add an optional message to put in the dump file

master
kanoi 10 years ago
parent
commit
90d06a696c
  1. 8
      src/ktree.c
  2. 4
      src/ktree.h

8
src/ktree.c

@ -124,7 +124,7 @@ void _dump_ktree(K_TREE *root, char *(*dsp_funct)(K_ITEM *), KTREE_FFL_ARGS)
printf(" Empty ktree\n"); printf(" Empty ktree\n");
} }
void _dsp_ktree(K_LIST *list, K_TREE *root, char *filename, KTREE_FFL_ARGS) void _dsp_ktree(K_LIST *list, K_TREE *root, char *filename, char *msg, KTREE_FFL_ARGS)
{ {
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
K_ITEM *item; K_ITEM *item;
@ -146,9 +146,15 @@ void _dsp_ktree(K_LIST *list, K_TREE *root, char *filename, KTREE_FFL_ARGS)
stream = fopen(filename, "a"); stream = fopen(filename, "a");
if (!stream) if (!stream)
{
fprintf(stderr, "%s %s() failed to open '%s' (%d) %s", fprintf(stderr, "%s %s() failed to open '%s' (%d) %s",
stamp, __func__, filename, errno, strerror(errno)); stamp, __func__, filename, errno, strerror(errno));
return;
}
if (msg)
fprintf(stream, "%s %s\n", stamp, msg);
else
fprintf(stream, "%s Dump of ktree '%s':\n", stamp, list->name); fprintf(stream, "%s Dump of ktree '%s':\n", stamp, list->name);
if (root->isNil == No) if (root->isNil == No)

4
src/ktree.h

@ -40,8 +40,8 @@ extern K_TREE *_new_ktree(KTREE_FFL_ARGS);
#define new_ktree() _new_ktree(KLIST_FFL_HERE) #define new_ktree() _new_ktree(KLIST_FFL_HERE)
extern void _dump_ktree(K_TREE *root, char *(*dsp_funct)(K_ITEM *), KTREE_FFL_ARGS); extern void _dump_ktree(K_TREE *root, char *(*dsp_funct)(K_ITEM *), KTREE_FFL_ARGS);
#define dump_ktree(_root, _dsp_funct) _dump_ktree(_root, _dsp_funct, KLIST_FFL_HERE) #define dump_ktree(_root, _dsp_funct) _dump_ktree(_root, _dsp_funct, KLIST_FFL_HERE)
extern void _dsp_ktree(K_LIST *list, K_TREE *root, char *filename, KTREE_FFL_ARGS); extern void _dsp_ktree(K_LIST *list, K_TREE *root, char *filename, char *msg, KTREE_FFL_ARGS);
#define dsp_ktree(_list, _root, _filename) _dsp_ktree(_list, _root, _filename, KLIST_FFL_HERE) #define dsp_ktree(_list, _root, _filename, _msg) _dsp_ktree(_list, _root, _filename, _msg, KLIST_FFL_HERE)
extern K_ITEM *_first_in_ktree(K_TREE *root, K_TREE_CTX *ctx, KTREE_FFL_ARGS); extern K_ITEM *_first_in_ktree(K_TREE *root, K_TREE_CTX *ctx, KTREE_FFL_ARGS);
#define first_in_ktree(_root, _ctx) _first_in_ktree(_root, _ctx, KLIST_FFL_HERE) #define first_in_ktree(_root, _ctx) _first_in_ktree(_root, _ctx, KLIST_FFL_HERE)
extern K_ITEM *_last_in_ktree(K_TREE *root, K_TREE_CTX *ctx, KTREE_FFL_ARGS); extern K_ITEM *_last_in_ktree(K_TREE *root, K_TREE_CTX *ctx, KTREE_FFL_ARGS);

Loading…
Cancel
Save