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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
diff -r -C2 domc-0.7.0/Makefile domc/Makefile
*** domc-0.7.0/Makefile 2003-03-22 17:08:50.000000000 -0700
--- domc/Makefile 2004-07-29 17:05:29.000000000 -0600
***************
*** 1,6 ****
! prefix = /usr/local
! includedir = $(prefix)/include
! libdir = $(prefix)/lib
! mandir = $(prefix)/man
CC = gcc
LIBNAME = domc
--- 1,7 ----
! _EXTRA = -I../libmba/src/ -L../libmba/
! prefix = ./
! includedir = $(prefix)
! libdir = $(prefix)
! mandir = $(prefix)
CC = gcc
LIBNAME = domc
***************
*** 12,16 ****
DISTRO = $(LIBNAME)-$(MINVERSION)
RPM_OPT_FLAGS = -O2
! CFLAGS = -Wall -W -DMSGNO $(RPM_OPT_FLAGS) -I$(includedir) -L$(libdir)
#CFLAGS = -Wall -W -DMSGNO -I$(includedir) -L$(libdir) $(RPM_OPT_FLAGS) -ansi -pedantic -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wtraditional -Wconversion -Waggregate-return -Wno-parentheses
OBJS = src/expatls.o src/events.o src/node.o src/nodelist.o src/namednodemap.o src/dom.o src/timestamp.o src/wcwidth.o
--- 13,17 ----
DISTRO = $(LIBNAME)-$(MINVERSION)
RPM_OPT_FLAGS = -O2
! CFLAGS = -Wall -W -DMSGNO $(RPM_OPT_FLAGS) $(_EXTRA) -I$(includedir) -L$(libdir)
#CFLAGS = -Wall -W -DMSGNO -I$(includedir) -L$(libdir) $(RPM_OPT_FLAGS) -ansi -pedantic -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wtraditional -Wconversion -Waggregate-return -Wno-parentheses
OBJS = src/expatls.o src/events.o src/node.o src/nodelist.o src/namednodemap.o src/dom.o src/timestamp.o src/wcwidth.o
***************
*** 20,24 ****
$(SONAME): $(OBJS)
! $(CC) -shared $(OBJS) -L$(libdir) -lmba -lexpat -Wl,-h,$(SOVERSION) -o $(SONAME)
.c.a:
--- 21,25 ----
$(SONAME): $(OBJS)
! $(CC) -shared $(OBJS) $(_EXTRA) -L$(libdir) -lmba -Wl,-h,$(SOVERSION) -o $(SONAME)
.c.a:
***************
*** 48,51 ****
clean:
rm -f $(OBJS) $(ARNAME) $(SONAME) $(includedir)/domc.h $(libdir)/$(ARNAME) $(libdir)/$(SONAME) $(libdir)/$(SOVERSION) $(libdir)/lib$(LIBNAME).so $(DISTRO).zip
! cd $(mandir)/man3 && rm -f $(MAN)
--- 49,52 ----
clean:
rm -f $(OBJS) $(ARNAME) $(SONAME) $(includedir)/domc.h $(libdir)/$(ARNAME) $(libdir)/$(SONAME) $(libdir)/$(SOVERSION) $(libdir)/lib$(LIBNAME).so $(DISTRO).zip
! # cd $(mandir)/man3 && rm -f $(MAN)
diff -r -C2 domc-0.7.0/Makefile.msvc domc/Makefile.msvc
*** domc-0.7.0/Makefile.msvc 2003-03-22 16:44:29.000000000 -0700
--- domc/Makefile.msvc 2004-07-29 19:55:06.000000000 -0600
***************
*** 1,15 ****
!include <win32.mak>
! LIBMBA=..\libmba-0.5.0
! EXPAT=..\Expat-1.95.5
# For i18n support in domc the encdec library is required.
# Specify were the encdec library is below, change HAVE_ENCDEC to 1
# in src\defines.h and add /LIBPATH:$(ENCDEC) encdec.lib to the
# .dll link command.
! ENCDEC=..\encdec-0.3.7
OBJS=src\expatls.obj src\events.obj src\timestamp.obj src\dom.obj src\node.obj src\namednodemap.obj src\nodelist.obj src\wcwidth.obj
! domc.dll: $(OBJS)
! $(link) /INCREMENTAL:NO /NOLOGO /LIBPATH:$(EXPAT)\Libs /LIBPATH:$(LIBMBA) /LIBPATH:$(ENCDEC) libexpat.lib libmba.lib encdec.lib /DEF:domc.def /OUT:domc.dll -entry:_DllMainCRTStartup@12 -dll $(OBJS)
domc.lib: $(OBJS)
--- 1,19 ----
!include <win32.mak>
! LIBMBA=..\libmba
! # EXPAT=..\Expat-1.95.5
# For i18n support in domc the encdec library is required.
# Specify were the encdec library is below, change HAVE_ENCDEC to 1
# in src\defines.h and add /LIBPATH:$(ENCDEC) encdec.lib to the
# .dll link command.
! # ENCDEC=..\encdec-0.3.7
OBJS=src\expatls.obj src\events.obj src\timestamp.obj src\dom.obj src\node.obj src\namednodemap.obj src\nodelist.obj src\wcwidth.obj
+ # Debug flags
+ cflags=$(cflags) /MLd /GZ /Gm /ZI /Od /D_DEBUG
! all: domc.lib
!
! # domc.dll: $(OBJS)
! # $(link) $(lflags) /INCREMENTAL:NO /NOLOGO /LIBPATH:$(LIBMBA) libmba.lib /DEF:domc.def /OUT:domc.dll -entry:_DllMainCRTStartup@12 -dll $(OBJS)
domc.lib: $(OBJS)
***************
*** 17,21 ****
.c.obj:
! $(cc) $(cflags) /I$(EXPAT)\Source\lib /I$(ENCDEC)\src /I$(LIBMBA)\src /Fo$@ $*.c
clean:
--- 21,25 ----
.c.obj:
! $(cc) $(cflags) /I$(LIBMBA)\src /Fo$@ $*.c
clean:
diff -r -C2 domc-0.7.0/src/defines.h domc/src/defines.h
*** domc-0.7.0/src/defines.h 2003-03-22 16:35:36.000000000 -0700
--- domc/src/defines.h 2004-07-29 17:05:29.000000000 -0600
***************
*** 22,26 ****
#define HAVE_STRDUP 1
#define HAVE_STRNLEN 0
! #define HAVE_EXPAT 195
#define HAVE_MBSTATE 0
#define HAVE_WCWIDTH 0
--- 22,26 ----
#define HAVE_STRDUP 1
#define HAVE_STRNLEN 0
! #define HAVE_EXPAT 0
#define HAVE_MBSTATE 0
#define HAVE_WCWIDTH 0
***************
*** 36,40 ****
#define HAVE_STRDUP 1
#define HAVE_STRNLEN 1
! #define HAVE_EXPAT 195
#define HAVE_MBSTATE 1
#define HAVE_WCWIDTH 1
--- 36,40 ----
#define HAVE_STRDUP 1
#define HAVE_STRNLEN 1
! #define HAVE_EXPAT 0
#define HAVE_MBSTATE 1
#define HAVE_WCWIDTH 1
diff -r -C2 domc-0.7.0/src/dom.c domc/src/dom.c
*** domc-0.7.0/src/dom.c 2003-03-21 01:50:28.000000000 -0700
--- domc/src/dom.c 2004-07-29 19:38:46.000000000 -0600
***************
*** 183,188 ****
{
DOM_Document *doc;
! namespaceURI = NULL; qualifiedName = NULL;
msgno_add_codes(dom_codes);
--- 183,189 ----
{
DOM_Document *doc;
+ DOM_Element *el;
! namespaceURI = NULL;
msgno_add_codes(dom_codes);
***************
*** 197,200 ****
--- 198,210 ----
}
+ if (qualifiedName && *qualifiedName) {
+ if ((el = DOM_Document_createElement(doc, qualifiedName)) == NULL) {
+ AMSG("");
+ DOM_Document_destroyNode(doc, doc);
+ return NULL;
+ }
+ DOM_Node_appendChild(doc, el);
+ }
+
return doc;
}
***************
*** 281,293 ****
attr = DOM_NamedNodeMap_removeNamedItem(element->attributes, name);
! DOM_MutationEvent_initMutationEvent(&evt, "DOMAttrModified", 1, 0,
! attr, attr->nodeValue, NULL, attr->nodeName, DOM_MUTATION_EVENT_REMOVAL);
! DOM_EventTarget_dispatchEvent(element, &evt);
! updateCommonParent(element->parentNode);
! if (attr) {
! DOM_Document_destroyNode(attr->ownerDocument, attr);
}
}
--- 291,307 ----
attr = DOM_NamedNodeMap_removeNamedItem(element->attributes, name);
+
+ /* removeAttribute doesn't throw exceptions on NOT_FOUND_ERR */
+ if (DOM_Exception == DOM_NOT_FOUND_ERR)
+ DOM_Exception = 0;
! if (attr) {
! DOM_MutationEvent_initMutationEvent(&evt, "DOMAttrModified", 1, 0,
! attr, attr->nodeValue, NULL, attr->nodeName, DOM_MUTATION_EVENT_REMOVAL);
! DOM_EventTarget_dispatchEvent(element, &evt);
! updateCommonParent(element->parentNode);
! DOM_Document_destroyNode(attr->ownerDocument, attr);
}
}
diff -r -C2 domc-0.7.0/src/domc.h domc/src/domc.h
*** domc-0.7.0/src/domc.h 2003-03-22 16:46:46.000000000 -0700
--- domc/src/domc.h 2004-07-29 17:05:29.000000000 -0600
***************
*** 186,189 ****
--- 186,191 ----
} ProcessingInstruction;
} u;
+ unsigned int rtfxRefCount; /* Reference counting added for RTFX */
+ void* userData; /* User data added for RTFX */
};
***************
*** 213,216 ****
--- 215,220 ----
unsigned short filter;
struct DOM_NodeList *list; /* Used for entities and notations */
+ /* Reference counting added for RTFX */
+ unsigned int rtfxRefCount;
};
***************
*** 287,293 ****
*/
int DOM_DocumentLS_load(DOM_DocumentLS *this, const char *uri);
- int DOM_DocumentLS_save(DOM_DocumentLS *this, const char *uri, const DOM_Node *node);
int DOM_DocumentLS_fread(DOM_DocumentLS *this, FILE *stream);
int DOM_DocumentLS_fwrite(const DOM_DocumentLS *this, FILE *stream);
--- 291,299 ----
*/
+ #if HAVE_EXPAT > 0
int DOM_DocumentLS_load(DOM_DocumentLS *this, const char *uri);
int DOM_DocumentLS_fread(DOM_DocumentLS *this, FILE *stream);
+ #endif /* HAVE_EXPAT */
+ int DOM_DocumentLS_save(DOM_DocumentLS *this, const char *uri, const DOM_Node *node);
int DOM_DocumentLS_fwrite(const DOM_DocumentLS *this, FILE *stream);
diff -r -C2 domc-0.7.0/src/expatls.c domc/src/expatls.c
*** domc-0.7.0/src/expatls.c 2003-03-21 02:20:24.000000000 -0700
--- domc/src/expatls.c 2004-08-02 16:58:41.000000000 -0600
***************
*** 128,131 ****
--- 128,133 ----
}
+ #if HAVE_EXPAT > 0
+
static void
xmldecl_fn(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone)
***************
*** 708,711 ****
--- 710,753 ----
}
+ #endif /* HAVE_EXPAT */
+
+ static void
+ fputds_encoded(const DOM_String *s, FILE *stream)
+ {
+ size_t l;
+
+ while (*s) {
+ l = strcspn(s, "<>&\"'");
+ if (l > 0) {
+ fwrite((void*)s, 1, sizeof(DOM_String) * l, stream);
+ s += l;
+ }
+ switch (*s) {
+ case '\0':
+ break;
+ case '<':
+ fputs("<", stream);
+ break;
+ case '>':
+ fputs(">", stream);
+ break;
+ case '&':
+ fputs("'", stream);
+ break;
+ case '"':
+ fputs(""", stream);
+ break;
+ case '\'':
+ fputs("&squot;", stream);
+ break;
+ default:
+ AMSG("");
+ break;
+ };
+ if(*s)
+ ++s;
+ }
+ }
+
int
DOM_DocumentLS_fwrite(const DOM_DocumentLS *node, FILE *stream)
***************
*** 732,736 ****
fputds(e->node->nodeName, stream);
fputs("=\"", stream);
! fputds(e->node->nodeValue, stream);
fputc('"', stream);
}
--- 774,778 ----
fputds(e->node->nodeName, stream);
fputs("=\"", stream);
! fputds_encoded(e->node->nodeValue, stream);
fputc('"', stream);
}
***************
*** 753,757 ****
break;
case DOM_TEXT_NODE:
! fputds(node->nodeValue, stream);
break;
case DOM_CDATA_SECTION_NODE:
--- 795,799 ----
break;
case DOM_TEXT_NODE:
! fputds_encoded(node->nodeValue, stream);
break;
case DOM_CDATA_SECTION_NODE:
***************
*** 761,803 ****
case DOM_NOTATION_NODE:
fputs(" <!NOTATION ", stream);
! fputs(node->nodeName, stream);
if (node->u.Entity.publicId) {
fputs(" PUBLIC \"", stream);
! fputs(node->u.Entity.publicId, stream);
fputs("\" \"", stream);
! fputs(node->u.Entity.systemId, stream);
fputc('"', stream);
} else if (node->u.Entity.systemId) {
fputs(" SYSTEM \"", stream);
! fputs(node->u.Entity.systemId, stream);
fputc('"', stream);
}
! fputs(">"NL, stream);
break;
case DOM_ENTITY_NODE:
fputs(" <!ENTITY ", stream);
! fputs(node->nodeName, stream);
if (node->nodeValue) {
fputc('"', stream);
! fputs(node->nodeValue, stream);
fputc('"', stream);
} else {
if (node->u.Entity.publicId) {
fputs(" PUBLIC \"", stream);
! fputs(node->u.Entity.publicId, stream);
fputs("\" \"", stream);
! fputs(node->u.Entity.systemId, stream);
fputc('"', stream);
} else if (node->u.Entity.systemId) {
fputs(" SYSTEM \"", stream);
! fputs(node->u.Entity.systemId, stream);
fputc('"', stream);
}
if (node->u.Entity.notationName) {
fputs(" NDATA ", stream);
! fputs(node->u.Entity.notationName, stream);
}
}
! fputs(">"NL, stream);
break;
case DOM_PROCESSING_INSTRUCTION_NODE:
--- 803,845 ----
case DOM_NOTATION_NODE:
fputs(" <!NOTATION ", stream);
! fputds(node->nodeName, stream);
if (node->u.Entity.publicId) {
fputs(" PUBLIC \"", stream);
! fputds(node->u.Entity.publicId, stream);
fputs("\" \"", stream);
! fputds(node->u.Entity.systemId, stream);
fputc('"', stream);
} else if (node->u.Entity.systemId) {
fputs(" SYSTEM \"", stream);
! fputds(node->u.Entity.systemId, stream);
fputc('"', stream);
}
! fputs(">", stream);
break;
case DOM_ENTITY_NODE:
fputs(" <!ENTITY ", stream);
! fputds(node->nodeName, stream);
if (node->nodeValue) {
fputc('"', stream);
! fputds(node->nodeValue, stream);
fputc('"', stream);
} else {
if (node->u.Entity.publicId) {
fputs(" PUBLIC \"", stream);
! fputds(node->u.Entity.publicId, stream);
fputs("\" \"", stream);
! fputds(node->u.Entity.systemId, stream);
fputc('"', stream);
} else if (node->u.Entity.systemId) {
fputs(" SYSTEM \"", stream);
! fputds(node->u.Entity.systemId, stream);
fputc('"', stream);
}
if (node->u.Entity.notationName) {
fputs(" NDATA ", stream);
! fputds(node->u.Entity.notationName, stream);
}
}
! fputs(">", stream);
break;
case DOM_PROCESSING_INSTRUCTION_NODE:
***************
*** 805,823 ****
fputds(node->u.ProcessingInstruction.target, stream);
fputc(' ', stream);
! fputds(node->u.ProcessingInstruction.data, stream);
fputs("?>", stream);
break;
case DOM_COMMENT_NODE:
fputs("<!--", stream);
! fputds(node->nodeValue, stream);
fputs("-->", stream);
break;
case DOM_DOCUMENT_NODE:
fputs("<?xml", stream);
! if (node->u.Document.version) {
! fputs(" version=\"", stream);
! fputs(node->u.Document.version, stream);
! fputc('\"', stream);
! }
#ifdef CODESET
fputs(" encoding=\"", stream);
--- 847,863 ----
fputds(node->u.ProcessingInstruction.target, stream);
fputc(' ', stream);
! fputds_encoded(node->u.ProcessingInstruction.data, stream);
fputs("?>", stream);
break;
case DOM_COMMENT_NODE:
fputs("<!--", stream);
! fputds_encoded(node->nodeValue, stream);
fputs("-->", stream);
break;
case DOM_DOCUMENT_NODE:
fputs("<?xml", stream);
! fputs(" version=\"", stream);
! fputds(node->u.Document.version ? node->u.Document.version : "1.0", stream);
! fputc('\"', stream);
#ifdef CODESET
fputs(" encoding=\"", stream);
***************
*** 825,834 ****
fputc('\"', stream);
#endif
! if (node->u.Document.standalone == 0) {
! printf(" standalone=\"no\"");
! } else if (node->u.Document.standalone == 1) {
! printf(" standalone=\"yes\"");
}
! fputs("?>"NL NL, stream);
for (c = node->firstChild; c != NULL; c = c->nextSibling) {
if (DOM_DocumentLS_fwrite(c, stream) == -1) {
--- 865,872 ----
fputc('\"', stream);
#endif
! if (node->u.Document.standalone != 0) {
! fputs(" standalone=\"yes\"", stream);
}
! fputs("?>"NL, stream);
for (c = node->firstChild; c != NULL; c = c->nextSibling) {
if (DOM_DocumentLS_fwrite(c, stream) == -1) {
|