mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-31 06:50:06 +03:00
libxml 1/2 fixups, spec cleanup, 1.8.8 prerelease, Daniel.
This commit is contained in:
parent
43f300d933
commit
6117c6fb02
@ -1,3 +1,12 @@
|
||||
Thu Jun 29 01:27:19 MEST 2000
|
||||
|
||||
* configure.in: 1.8.8 prerelease
|
||||
* example/Makefile.am example/gjobread.c tree.h: work on
|
||||
libxml1 libxml2 convergence.
|
||||
* Makefile.in tree.[ch] : added xmlCheckVersion()
|
||||
and the LIBXML_TEST_VERSION macro
|
||||
* libxml.spec.in: fixed a spec problem, xml-config goes in devel
|
||||
|
||||
Mon Mar 6 09:34:52 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* doc/xml.html, doc/update.html: updated docs, 1.8.7
|
||||
|
@ -269,3 +269,9 @@ xmlConf.sh: xmlConf.sh.in Makefile
|
||||
-e 's?\@VERSION\@?$(VERSION)?g' \
|
||||
< $(srcdir)/xmlConf.sh.in > xmlConf.tmp \
|
||||
&& mv xmlConf.tmp xmlConf.sh
|
||||
|
||||
$(srcdir)/libxml:
|
||||
-$(RM) $(srcdir)/libxml
|
||||
ln -s $(srcdir)/. $(srcdir)/libxml
|
||||
|
||||
$(libxml_la_SOURCES): $(srcdir)/libxml
|
||||
|
@ -10,7 +10,18 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "parser.h"
|
||||
/*
|
||||
* This example should compile and run indifferently with libxml-1.8.8 +
|
||||
* and libxml2-2.1.0 +
|
||||
* Check the COMPAT comments below
|
||||
*/
|
||||
|
||||
/*
|
||||
* COMPAT using xml-config --cflags to get the include path this will
|
||||
* work with both
|
||||
*/
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#define DEBUG(x) printf(x)
|
||||
|
||||
@ -45,12 +56,13 @@ DEBUG("parsePerson\n");
|
||||
memset(ret, 0, sizeof(person));
|
||||
|
||||
/* We don't care what the top level element name is */
|
||||
cur = cur->childs;
|
||||
/* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
if ((!strcmp(cur->name, "Person")) && (cur->ns == ns))
|
||||
ret->name = xmlNodeListGetString(doc, cur->childs, 1);
|
||||
ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
if ((!strcmp(cur->name, "Email")) && (cur->ns == ns))
|
||||
ret->email = xmlNodeListGetString(doc, cur->childs, 1);
|
||||
ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
@ -103,7 +115,7 @@ DEBUG("parseJob\n");
|
||||
memset(ret, 0, sizeof(job));
|
||||
|
||||
/* We don't care what the top level element name is */
|
||||
cur = cur->childs;
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
|
||||
if ((!strcmp(cur->name, "Project")) && (cur->ns == ns)) {
|
||||
@ -113,9 +125,9 @@ DEBUG("parseJob\n");
|
||||
}
|
||||
}
|
||||
if ((!strcmp(cur->name, "Application")) && (cur->ns == ns))
|
||||
ret->application = xmlNodeListGetString(doc, cur->childs, 1);
|
||||
ret->application = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
if ((!strcmp(cur->name, "Category")) && (cur->ns == ns))
|
||||
ret->category = xmlNodeListGetString(doc, cur->childs, 1);
|
||||
ret->category = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
if ((!strcmp(cur->name, "Contact")) && (cur->ns == ns))
|
||||
ret->contact = parsePerson(doc, ns, cur);
|
||||
cur = cur->next;
|
||||
@ -167,7 +179,8 @@ gJobPtr parseGjobFile(char *filename) {
|
||||
/*
|
||||
* Check the document is of the right kind
|
||||
*/
|
||||
cur = doc->root;
|
||||
|
||||
cur = xmlDocGetRootElement(doc);
|
||||
if (cur == NULL) {
|
||||
fprintf(stderr,"empty document\n");
|
||||
xmlFreeDoc(doc);
|
||||
@ -201,16 +214,26 @@ gJobPtr parseGjobFile(char *filename) {
|
||||
* Now, walk the tree.
|
||||
*/
|
||||
/* First level we expect just Jobs */
|
||||
cur = cur->childs;
|
||||
cur = cur->xmlChildrenNode;
|
||||
while ( cur && xmlIsBlankNode ( cur ) )
|
||||
{
|
||||
cur = cur -> next;
|
||||
}
|
||||
if ( cur == 0 )
|
||||
return ( NULL );
|
||||
if ((strcmp(cur->name, "Jobs")) || (cur->ns != ns)) {
|
||||
fprintf(stderr,"document of the wrong type, Jobs expected");
|
||||
fprintf(stderr,"document of the wrong type, was '%s', Jobs expected",
|
||||
cur->name);
|
||||
fprintf(stderr,"xmlDocDump follows\n");
|
||||
xmlDocDump ( stderr, doc );
|
||||
fprintf(stderr,"xmlDocDump finished\n");
|
||||
xmlFreeDoc(doc);
|
||||
free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Second level is a list of Job, but be laxist */
|
||||
cur = cur->childs;
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != NULL) {
|
||||
if ((!strcmp(cur->name, "Job")) && (cur->ns == ns)) {
|
||||
job = parseJob(doc, ns, cur);
|
||||
@ -238,9 +261,16 @@ int main(int argc, char **argv) {
|
||||
int i;
|
||||
gJobPtr cur;
|
||||
|
||||
/* COMPAT: Do not genrate nodes for formatting spaces */
|
||||
xmlKeepBlanksDefault(0);
|
||||
|
||||
for (i = 1; i < argc ; i++) {
|
||||
cur = parseGjobFile(argv[i]);
|
||||
handleGjob(cur);
|
||||
if ( cur )
|
||||
handleGjob(cur);
|
||||
else
|
||||
fprintf( stderr, "Error parsing file '%s'\n", argv[i]);
|
||||
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -17,6 +17,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use those to be sure nothing nasty will happen if
|
||||
* your library and includes mismatch
|
||||
*/
|
||||
extern void xmlCheckVersion(int version);
|
||||
#define LIBXML_VERSION_NUMBER 10808
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(LIBXML_VERSION_NUMBER);
|
||||
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
|
@ -108,7 +108,6 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%doc AUTHORS ChangeLog NEWS README COPYING COPYING.LIB TODO
|
||||
%{prefix}/lib/lib*.so.*
|
||||
%{prefix}/bin/xml-config
|
||||
|
||||
%files devel
|
||||
%defattr(-, root, root)
|
||||
@ -117,3 +116,4 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{prefix}/lib/*a
|
||||
%{prefix}/lib/*.sh
|
||||
%{prefix}/include/*
|
||||
%{prefix}/bin/xml-config
|
||||
|
24
parser.c
24
parser.c
@ -57,6 +57,30 @@ const char *xmlW3CPIs[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* xmlCheckVersion:
|
||||
* @version: the include version number
|
||||
*
|
||||
* check the compiled lib version against the include one.
|
||||
* This can warn or immediately kill the application
|
||||
*/
|
||||
void
|
||||
xmlCheckVersion(int version) {
|
||||
int myversion = LIBXML_VERSION_NUMBER;
|
||||
|
||||
if ((myversion / 10000) != (version / 10000)) {
|
||||
fprintf(stderr,
|
||||
"Fatal: program compiled against libxml %d using libxml %d\n",
|
||||
(version / 10000), (myversion / 10000));
|
||||
exit(1);
|
||||
}
|
||||
if ((myversion / 100) < (version / 100)) {
|
||||
fprintf(stderr,
|
||||
"Warning: program compiled against libxml %d using older %d\n",
|
||||
(version / 100), (myversion / 100));
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Input handling functions for progressive parsing *
|
||||
|
1
tester.c
1
tester.c
@ -208,6 +208,7 @@ int main(int argc, char **argv) {
|
||||
int i, count;
|
||||
int files = 0;
|
||||
|
||||
LIBXML_TEST_VERSION
|
||||
for (i = 1; i < argc ; i++) {
|
||||
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
|
||||
debug++;
|
||||
|
9
tree.h
9
tree.h
@ -17,6 +17,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use those to be sure nothing nasty will happen if
|
||||
* your library and includes mismatch
|
||||
*/
|
||||
extern void xmlCheckVersion(int version);
|
||||
#define LIBXML_VERSION_NUMBER 10808
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(LIBXML_VERSION_NUMBER);
|
||||
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user