Changeset 14494
- Timestamp:
- Aug 14, 2007, 2:38:13 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/Makefile.am
r14489 r14494 14 14 warptool \ 15 15 pzgetimfiles \ 16 ttree \ 16 17 pztool 17 18 … … 65 66 # for pxtools.h 66 67 AM_CPPFLAGS = -I$(top_srcdir)/src$ 68 69 70 ttree_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) 71 ttree_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la 72 ttree_SOURCES = \ 73 ttree.c 67 74 68 75 pztool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) -
trunk/ippTools/src/pxtree.c
r14489 r14494 57 57 return node; 58 58 } 59 60 61 void pxNodePrint(FILE *stream, pxNode *node) 62 { 63 fprintf(stream, "node name: %s\n", node->name); 64 fprintf(stream, "node parent's name: %s\n", node->parent 65 ? node->parent->name 66 : NULL); 67 psListIterator *iter = psListIteratorAlloc(node->children, 0, false); 68 pxNode *child = NULL; 69 while ((child = psListGetAndIncrement(iter))) { 70 fprintf(stream, "node child's name: %s\n", child->name); 71 } 72 psFree(iter); 73 } 74 75 76 bool pxTreeCrawl(pxNode *node, pxNodeFunc func) 77 { 78 // if func() returns false, stop 79 if (!func(node)) { 80 return false; 81 } 82 83 psListIterator *iter = psListIteratorAlloc(node->children, 0, false); 84 pxNode *child = NULL; 85 while ((child = psListGetAndIncrement(iter))) { 86 // if func() returns false, pxTreeCrawl() well return false, and we 87 // should stop 88 if (!pxTreeCrawl(child, func)) { 89 return false; 90 } 91 } 92 psFree(iter); 93 94 return true; 95 } -
trunk/ippTools/src/pxtree.h
r14489 r14494 21 21 #define PXTREE_H 1 22 22 23 #include <stdio.h> 24 #include <stdbool.h> 25 23 26 #include <pslib.h> 27 24 28 25 29 typedef struct pxNode { … … 29 33 } pxNode; 30 34 35 typedef bool (*pxNodeFunc)(pxNode *node); 36 31 37 pxNode *pxNodeAlloc( 32 38 const char *name, 33 39 pxNode *parent 34 40 ) PS_ATTR_MALLOC; 41 42 void pxNodePrint( 43 FILE *stream, 44 pxNode *node 45 ); 46 47 bool pxTreeCrawl( 48 pxNode *node, 49 pxNodeFunc func 50 ); 35 51 36 52 /*
Note:
See TracChangeset
for help on using the changeset viewer.
