[lcdproc] LCDproc still alive? Yes :)

Mooneer Salem mooneer@earthlink.net
Sun, 6 Aug 2000 16:14:57 -0700


What a concidence! I'm working on adding URL translation in GPLTrans
and I was trying to get dynamic loading to work so I could write new
protocol
handlers without changing much code.

Example:

libtest.c

#include <stdio.h>

void printx () { printf ("blah blah\n"); }

lcdproc.c :)

#include <stdio.h>
#include <dlfcn.h>

void load_driver (char *drivername) {
       char tmp[150], *err;
        void *fhandle;
        char *(*processing_func)(char **urlobj);
        void (*printnow)();

        fhandle = dlopen("./libtest.so", RTLD_NOW);

        if (!fhandle) return NULL;

        printnow = dlsym(fhandle, drivername);
        if ((err = dlerror()) != NULL) {
                printf("dl err: %s\n", err);
                return NULL;
        }

        (*printnow)();
}

main.c:

#include <stdio.h>

int main () { load_driver("printx"); return 0; }

/* end of code */

To compile those files:

gcc -shared -o libtest.so libtest.c
gcc -c lcdproc.c
gcc -o lcdproc lcdproc.o main.c -ldl

Running ./lcdproc would result in:

root@apoc [/usr/local/src]# ./lcdproc
blah blah
root@apoc [/usr/local/src]#

End of lesson :)

----- Original Message -----
From: "Matt" <madmatt@bits.bris.ac.uk>
To: "LCDproc mailing list" <lcdproc@lists.omnipotent.net>
Sent: Sunday, August 06, 2000 3:42 PM
Subject: Re: [lcdproc] LCDproc still alive? Yes :)


> William W. Ferrell wrote:
> | > We *could* implement the drivers as .so libs, and only load the
drivers as
> | > required, just make sure the interface can work with this technique.
It'd
> | > keep the server code smaller, the same lib could provide access to a
> | > number of similar screens...
> |
> | This is probably a good idea. Now if someone could just refresh my
> | memory how .so libs actually work, and how to make it work in our little
> | project :)
>
> I sort of know how to use them, but I've forgotten most of the compiler
> flags to make 'em in the first place. If someone can tell me how to make
> libs, I can try and get some skeleton code working.
>
> Matt




-----------------------------------------------------------
To unsubscribe from this list send a blank message to
lcdproc-unsubscribe@lists.omnipotent.net