1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
--- Makefile.in.orig Wed Oct 26 16:13:45 2005
+++ Makefile.in Thu Oct 27 21:33:48 2005
@@ -30,7 +31,7 @@
src/%.lo: $(srcdir)/src/%.c
${LIBTOOL} --mode=compile ${CC} -c -o $@ $^ ${CFLAGS}
-src/libchm.la: src/chm_lib.lo src/lzx.lo
+src/libchm.la: src/chm_lib.lo src/lzx.lo src/az_chmlib_add.lo
${LIBTOOL} --mode=link ${CC} -o $@ $^ ${LDFLAGS} -rpath $(libdir)
install: src/libchm.la
patch-az_chmlib_add.c
--- /dev/null Fri Feb 25 18:33:00 2005
+++ src/az_chmlib_add.c Fri Feb 25 18:29:45 2005
@@ -0,0 +1,54 @@
+#include <string.h>
+#include "chm_lib.h"
+
+/*
+ * callback function for enumerate API
+ */
+int _get_name(struct chmFile *h,
+ chmUnitInfo *ui,
+ void *context)
+{
+ int i;
+
+
+ chm_dir *dirp = (chm_dir *)context;
+
+ dirp->info=realloc(dirp->info,(dirp->nentries+1)*sizeof (char*));
+
+ dirp->info[dirp->nentries] = malloc(sizeof(ui->path));
+ strcpy(dirp->info[dirp->nentries], ui->path);
+
+ dirp->nentries++;
+ return CHM_ENUMERATOR_CONTINUE;
+}
+
+chm_dir get_names(struct chmFile *h)
+//note: you should free() dir.info and all dir.info[i] in caller
+{
+ chm_dir dir;
+
+ dir.nentries=0;
+ dir.info = NULL;
+
+ if (! chm_enumerate(h,
+ CHM_ENUMERATE_ALL,
+ _get_name,
+ (void *)&dir))
+ printf(" *** ERROR ***\n");
+
+ return dir;
+}
+
+
+int main()
+{
+ int i;
+
+ struct chmFile *h = chm_open("/home/az/new/txt/chm/reg.chm");
+ chm_dir dir=get_names(h);
+ for(i=0;i<dir.nentries;i++)
+ printf("%d: %s\n",i,dir.info[i]);
+
+ return 0;
+}
+
|