Ethereal-dev: Re: [Ethereal-dev] Dynamically loading libxml2

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: David Frascone <dave@xxxxxxxxxxxx>
Date: Tue, 5 Jun 2001 21:43:47 -0500
On Tue, Jun 05, 2001 at 06:43:22PM -0700, Guy Harris wrote:
> > Code to dynamically load libxml2.  (xmlstub.h is all of the types defined
> > in the real libxml2 header files.
> 
> 	...
> 
> > 	if ((handle = dlopen("libxml2.so", RTLD_LAZY)) == NULL) {
> > 		fprintf(stderr, "Unable to dlopen \"libxml2\"\n");
> > 		return (-1);
> > 	}
> 
> Not all platforms on which Ethereal runs have "dlopen()".  (HP-UX and
> Windows don't.)
> 
> You might want to see whether you can use the GLib gmodule routines
> instead, as they hide that particular platform dependency.

I didn't know that those existed.  I'll look at them.  I'm trying to do a bit
of code shareing between my application that uses that dictionary and
ethereal.

> 
> Note that this won't work on platforms that don't support dynamic
> linking at all, so you'd have to check the HAVE_PLUGINS #define (which
> should probably get renamed to HAVE_DYNAMIC_LINKING).

Will do.

> 
> Note also that the names of files containing dynamically-loadable
> modules don't end with ".so" on all platforms; see "plugins_scan_dir()"
> in "epan/plugins.c" for a sleazy hack to determine the suffix.

Will do.

> 
> How quickly does libxml load the XML files?  Does that significantly
> slow down startup time?

You shouldn't notice a thing.  The dictionary is about 2000 lines of xml.  It
is parsed instantly. . . . I could profile it with times() if ya want.


My only worry is that libxml doesn't exist at all for Windows.  (I have no 
idea if there is a port or not)  In that case, the dynamic loading would fail,
and it would fall back to a minimal hard-coded dictionary.