diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-06-10 12:46:54 +0000 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-06-10 12:46:54 +0000 | 
| commit | b4fbe4dab0f2f7ffdd39ca9caafbd9de8c5a342a (patch) | |
| tree | 0fa365a510ef20145be0ba12c8d30ea8787e0774 /hardinfo2 | |
| parent | 1452528564d2f160f13df75f3990419ccfbf4ed2 (diff) | |
Make printer detection work on some systems without having to install libcupsys-dev.
(Debian bug#370363).
Diffstat (limited to 'hardinfo2')
| -rw-r--r-- | hardinfo2/arch/common/printers.h | 26 | 
1 files changed, 20 insertions, 6 deletions
| diff --git a/hardinfo2/arch/common/printers.h b/hardinfo2/arch/common/printers.h index 8632ea18..01beb5dd 100644 --- a/hardinfo2/arch/common/printers.h +++ b/hardinfo2/arch/common/printers.h @@ -19,18 +19,30 @@  void  scan_printers(void)  { -    GModule *cups; +    static GModule *cups = NULL;      static int (*cupsGetPrinters) (char ***printers) = NULL;      static char *(*cupsGetDefault) (void) = NULL; +    static char *libcups[] = { "libcups", +                               "libcups.so", +                               "libcups.so.1", +                               "libcups.so.2", +                               NULL };      if (printer_list)  	g_free(printer_list);      if (!(cupsGetPrinters && cupsGetDefault)) { -	cups = g_module_open("libcups", G_MODULE_BIND_LAZY); -	if (!cups) { +        int i; +         +        for (i = 0; libcups[i] != NULL; i++) { +            cups = g_module_open(libcups[i], G_MODULE_BIND_LAZY); +            if (cups) +                break; +        } +         +        if (!cups) {  	    printer_list = g_strdup("[Printers]\n" -				    "CUPS libraries cannot be found="); +	                            "CUPS libraries cannot be found=");  	    return;  	} @@ -38,7 +50,8 @@ scan_printers(void)  	    || !g_module_symbol(cups, "cupsGetDefault",  				(gpointer) & cupsGetDefault)) {  	    printer_list = -		g_strdup("[Printers]\n" "No suitable CUPS library found="); +		g_strdup("[Printers]\n" +                         "No suitable CUPS library found=");              g_module_close(cups);  	    return;  	} @@ -62,6 +75,7 @@ scan_printers(void)  	    g_free(printers[i]);  	}      } else { -	printer_list = g_strdup("[Printers]\n" "No printers found"); +	printer_list = g_strdup("[Printers]\n" +	                        "No printers found");      }  } | 
