diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:35 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:35 -0500 |
commit | 720f5023a8f68aaaa54cb6b7bf46efee23b5b4c3 (patch) | |
tree | 26a8d91183787418455f65c2bb44ed641800dad3 /arch/common/.svn/text-base/printers.h.svn-base | |
parent | 854292407779593a401a1d5ce71add51880fa84f (diff) |
Import Upstream version 0.4.1
Diffstat (limited to 'arch/common/.svn/text-base/printers.h.svn-base')
-rw-r--r-- | arch/common/.svn/text-base/printers.h.svn-base | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/arch/common/.svn/text-base/printers.h.svn-base b/arch/common/.svn/text-base/printers.h.svn-base new file mode 100644 index 00000000..01beb5dd --- /dev/null +++ b/arch/common/.svn/text-base/printers.h.svn-base @@ -0,0 +1,81 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +void +scan_printers(void) +{ + 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)) { + 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="); + return; + } + + if (!g_module_symbol(cups, "cupsGetPrinters", (gpointer) & cupsGetPrinters) + || !g_module_symbol(cups, "cupsGetDefault", + (gpointer) & cupsGetDefault)) { + printer_list = + g_strdup("[Printers]\n" + "No suitable CUPS library found="); + g_module_close(cups); + return; + } + } + + gchar **printers; + int noprinters, i; + const char *default_printer; + + noprinters = cupsGetPrinters(&printers); + default_printer = cupsGetDefault(); + + if (noprinters > 0) { + printer_list = g_strdup_printf("[Printers (CUPS)]\n"); + for (i = 0; i < noprinters; i++) { + printer_list = g_strconcat(printer_list, printers[i], + !strcmp(default_printer, + printers[i]) ? + "=<i>(Default)</i>\n" : "=\n", + NULL); + g_free(printers[i]); + } + } else { + printer_list = g_strdup("[Printers]\n" + "No printers found"); + } +} |