From: <jc...@fe...> - 2003-02-05 16:56:30
|
On Wednesday 05 February 2003 13:55, Rafael Laboissiere wrote: | * Rafael Laboissiere <lab...@ps...> [2003-02-04 22:37]: | > c) At build time (not configuration time), a small C program | > dlopen the <driver>.c files, get the symbols described above and | > write the associated device entries in <driver>.rc (or whichever | > name). | | Just to make things a bit more concrete, here is the design that I | have in mind. I will take the ps.c driver as an example. The | following global variables will be defined in the driver source: | | char* DEVICES_ps =3D "ps:psc"; | | char* DESCRIPTION_ps =3D "PostScript File (monochrome)"; | int TYPE_ps =3D plDevType_FileOriented; | int SEQNUM_ps =3D 29; | char* SYMTAG_ps =3D "psm"; | | char* DESCRIPTION_psc =3D "PostScript File (color)"; | int TYPE_psc =3D plDevType_FileOriented; | int SEQNUM_psc =3D 30; | char* SYMTAG_psc =3D "psc"; | | Of course, these variables should be used in the plD_dispatch_init_* | functions. In the case of ps.c: | | ps_dispatch_init_helper( pdt, | DESCRIPTION_ps, "ps", | TYPE_ps, SEQNUM_ps, | (plD_init_fp) plD_init_psm ); | | ps_dispatch_init_helper( pdt, | DESCRIPTION_psc, "psc", | TYPE_psc, SEQNUM_psc, | (plD_init_fp) plD_init_psc ); | | This will insure that things are not defined twice in different | places (like with the current DEVICE_INFO_* variable). | | The small C program that will generate the <driver>.rc file from the | <driver>.la file, would do: (1) dlopen the module; (2) get the | DEVICES_* symbol and parse its device components (in the ps.c | exemple, that would be "ps" and "psc"); (3) for each one of the | devices found, get the symbols DESCRIPTION_<dev>, TYPE_<dev>, | SEQNUM_<dev>, and SYMTAG_<dev>; (4) create the temp file that is | parsed by Geoff's code. (This could be improved along Joao's | suggestion of creating a structure instead of writing the information | in a temp file.) | | We have to decide first whether it is not worth abandoning the | current approach and adopting this "cached info" approach above.=20 I decided to give it a try but got a seg fault: [jcard@feup] gdb x01c (gdb) run -dev xwin Starting program: /usr/local/test/lib/plplot5.2.0/examples/c/x01c -dev=20 xwin Program received signal SIGSEGV, Segmentation fault. 0x0806a46e in lt_dlsym (handle=3D0x807b0e0,=20 symbol=3D0xbfffef50 "DEVICE_INFO_pstex") at ltdl.c:3330 3330 lensym =3D LT_STRLEN (symbol) + LT_STRLEN=20 (handle->loader->sym_prefix) (gdb) where #0 0x0806a46e in lt_dlsym (handle=3D0x807b0e0,=20 symbol=3D0xbfffef50 "DEVICE_INFO_pstex") at ltdl.c:3330 #1 0x08053d38 in plInitDispatchTable () at plcore.c:1638 #2 0x08049b9d in plMergeOpts (options=3D0x8073500,=20 name=3D0x11 <Address 0x11 out of bounds>, notes=3D0x11) at plargs.c:6= 99 #3 0x08049362 in main () #4 0x400674a2 in __libc_start_main () from /lib/libc.so.6 | There is also Joao's suggestion for dynamically building the | drivers.db, but I am too lazy to implement that (and I am not sure it | is a superior approach). | | What do you think? I accept suggestions for better variable names. |