Hi! Here's the final patch of this serie, updating the entropy plugin to use the new frontend API and using the global symbol loading instead of manual calls to dlsym(). The dependency on libdebconfclient0-dev has been bumped accordingly. --- packages/cdebconf-entropy/debian/changelog | 4 ++ packages/cdebconf-entropy/debian/control | 2 +- .../cdebconf-entropy/newt-plugin-entropy-text.c | 50 +++----------------- 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/packages/cdebconf-entropy/debian/changelog b/packages/cdebconf-entropy/debian/changelog index aed0eca..c8a55e2 100644 --- a/packages/cdebconf-entropy/debian/changelog +++ b/packages/cdebconf-entropy/debian/changelog @@ -1,8 +1,12 @@ cdebconf-entropy (0.5) UNRELEASED; urgency=low * Switch the handler symbol to the "cdebconf_" namespace. + * Use the proper namespace to access newt frontend API. + * Remove the usage of dlsym() and dlopen() now that frontend symbols are + loaded globally. + * Bump Depends on cdebconf accordingly. -- Jérémy Bobbio <lunar@debian.org> Fri, 03 Aug 2007 02:12:31 +0200 cdebconf-entropy (0.4) unstable; urgency=low diff --git a/packages/cdebconf-entropy/debian/control b/packages/cdebconf-entropy/debian/control index b407868..e7864d4 100644 --- a/packages/cdebconf-entropy/debian/control +++ b/packages/cdebconf-entropy/debian/control @@ -3,7 +3,7 @@ Priority: extra Section: debian-installer Maintainer: Debian Install System Team <debian-boot@lists.debian.org> Uploaders: Max Vozeler <xam@debian.org> -Build-Depends: debhelper (>= 4.2), libnewt-dev, libtextwrap-dev, libdebconfclient0-dev (>= 0.101) +Build-Depends: debhelper (>= 4.2), libnewt-dev, libtextwrap-dev, libdebconfclient0-dev (>> 0.119) Standards-Version: 3.7.2 XS-Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/cdebconf-entropy diff --git a/packages/cdebconf-entropy/newt-plugin-entropy-text.c b/packages/cdebconf-entropy/newt-plugin-entropy-text.c index 9fedfb2..722cae9 100644 --- a/packages/cdebconf-entropy/newt-plugin-entropy-text.c +++ b/packages/cdebconf-entropy/newt-plugin-entropy-text.c @@ -25,7 +25,7 @@ #include <cdebconf/frontend.h> #include <cdebconf/question.h> #include <cdebconf/template.h> -#include <cdebconf/config-newt.h> +#include <cdebconf/cdebconf_newt.h> #define HAVE_LIBTEXTWRAP #ifdef HAVE_LIBTEXTWRAP @@ -42,11 +42,6 @@ extern int strtruncate (char *what, size_t maxsize); extern size_t strwidth (const char *what); -/* There are dlopen()ed from frontend/newt.so */ -int (*get_text_height)(const char *text, int win_width); -int (*get_text_width)(const char *text); -void(*create_window)(const int width, const int height, const char *title, const char *priority); - static void prepare_window(newtComponent *, struct frontend *, struct question *, int); @@ -83,31 +78,6 @@ success_text(struct frontend *obj) "Key data has been created successfully."); } -static void * -setup_handler_dlsyms(void) -{ - char *err; - void *newt; - newt = dlopen("/usr/lib/cdebconf/frontend/newt.so", RTLD_LAZY); - if (!newt) { - error("dlopen on newt.so failed: %s", dlerror()); - return NULL; - } - - dlerror(); - create_window = dlsym(newt, "newt_create_window"); - get_text_height = dlsym(newt, "newt_get_text_height"); - get_text_width = dlsym(newt, "newt_get_text_width"); - - if ((err = dlerror()) != NULL) { - error("dlsym failed: %s", err); - dlclose(newt); - return NULL; - } - - return newt; -} - static int copy_byte(int in, int out) { @@ -136,7 +106,6 @@ copy_byte(int in, int out) int cdebconf_newt_handler_entropy_text(struct frontend *obj, struct question *q) { - void *newt; newtComponent form; struct newtExitStruct nstat; const char *p; @@ -147,10 +116,6 @@ cdebconf_newt_handler_entropy_text(struct frontend *obj, struct question *q) int randfd = 0; int fifofd = 0; - newt = setup_handler_dlsyms(); - if (!newt) - return DC_NOTOK; - if (mlock(&rnd_byte, sizeof(rnd_byte)) < 0) { error("mlock failed: %s", strerror(errno)); goto errout; @@ -232,7 +197,6 @@ errout: close(fifofd); unlink(FIFO); - dlclose(newt); munlock(&rnd_byte, sizeof(rnd_byte)); return ret; @@ -275,7 +239,7 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in ext_description = wrappedtext; #endif - t_height = get_text_height(ext_description, win_width); + t_height = cdebconf_newt_get_text_height(ext_description, win_width); if (t_height + 6 + 4 <= height-5) win_height = t_height + 6 + 4; else { @@ -285,10 +249,10 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in } t_height = win_height - (6 + 4); - t_width = get_text_width(ext_description); + t_width = cdebconf_newt_get_text_width(ext_description); t_width_buttons = 2*BUTTON_PADDING; - t_width_buttons += get_text_width(goback_text(obj)) + 3; - t_width_buttons += get_text_width(continue_text(obj)) + 3; + t_width_buttons += cdebconf_newt_get_text_width(goback_text(obj)) + 3; + t_width_buttons += cdebconf_newt_get_text_width(continue_text(obj)) + 3; if (t_width_buttons > t_width) t_width = t_width_buttons; @@ -296,11 +260,11 @@ prepare_window(newtComponent *form, struct frontend *obj, struct question *q, in if (win_width > t_width + 2*TEXT_PADDING + t_width_scroll) win_width = t_width + 2*TEXT_PADDING + t_width_scroll; - t_width_title = get_text_width(obj->title); + t_width_title = cdebconf_newt_get_text_width(obj->title); if (t_width_title > win_width) win_width = t_width_title; - create_window(win_width, win_height, obj->title, q->priority); + cdebconf_newt_create_window(win_width, win_height, obj->title, q->priority); *form = newtForm(NULL, NULL, 0); textbox = newtTextbox(TEXT_PADDING, 1, t_width, t_height, tflags); -- Jérémy Bobbio .''`. lunar@debian.org : :Ⓐ : # apt-get install anarchism `. `'` `-
Attachment:
signature.asc
Description: Digital signature