From 4933a7a9f75fc80afba004f0c55959d35d7ffe41 Mon Sep 17 00:00:00 2001 From: Roland Mainz Date: Sun, 16 May 2004 21:52:44 +0000 Subject: Fix for http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=623 - RFE: "xdpyinfo" should have support for XpExtension. --- xdpyinfo.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'xdpyinfo.c') diff --git a/xdpyinfo.c b/xdpyinfo.c index 607078f..35631e6 100644 --- a/xdpyinfo.c +++ b/xdpyinfo.c @@ -70,10 +70,14 @@ in this Software without prior written authorization from The Open Group. #ifdef PANORAMIX #include #endif +#include #include #include #include +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + char *ProgramName; Bool queryExtensions = False; @@ -1015,6 +1019,85 @@ print_xinerama_info(Display *dpy, char *extname) #endif /* PANORAMIX */ +static +void print_xprint_attrpool(const char *name, const char *attrpool) +{ + int c; + const char *s = attrpool; + + printf(" %s:\n ", name); + + while( (c = *s++) != '\0' ) + { + if (c == '\n') { + printf("\n "); + } + else + { + fputc(c, stdout); + } + } + fputc('\n', stdout); +} + +static int +print_xprint_info(Display *dpy, char *extname) +{ + short majorrev, + minorrev; + int xp_event_base, + xp_error_base; + XPPrinterList printerlist; + int plcount, + i; + + if (XpQueryVersion(dpy, &majorrev, &minorrev) == False) { + return 0; + } + + print_standard_extension_info(dpy, extname, majorrev, minorrev); + + if (XpQueryExtension(dpy, &xp_event_base, &xp_error_base) == False) { + printf(" XpQueryExtension() failed.\n"); + return 0; + } + + printf(" xp_event_base=%d, xp_error_base=%d\n", xp_event_base, xp_error_base); + + printerlist = XpGetPrinterList(dpy, NULL, &plcount); + /* Print number of printers, then each printer name and description */ + printf(" Found %d printers on this server.\n", plcount); + for( i = 0 ; i < plcount ; i++) { + printf(" printer %d: name='%s', descr='%s'\n", + i, NULLSTR(printerlist[i].name), NULLSTR(printerlist[i].desc)); + } + + for( i = 0 ; i < plcount ; i++) { + char *printername = printerlist[i].name; + XPContext pcontext; + char *s; + + printf(" Attributes of printer '%s':\n", NULLSTR(printername)); + + pcontext = XpCreateContext(dpy, printername); + if (pcontext == None) { + printf(" Error: Could not open printer.\n"); + continue; + } + + s=XpGetAttributes(dpy, pcontext, XPJobAttr); print_xprint_attrpool("XPJobAttr", s); XFree(s); + s=XpGetAttributes(dpy, pcontext, XPDocAttr); print_xprint_attrpool("XPDocAttr", s); XFree(s); + s=XpGetAttributes(dpy, pcontext, XPPageAttr); print_xprint_attrpool("XPPageAttr", s); XFree(s); + s=XpGetAttributes(dpy, pcontext, XPPrinterAttr); print_xprint_attrpool("XPPrinterAttr", s); XFree(s); + s=XpGetAttributes(dpy, pcontext, XPServerAttr); print_xprint_attrpool("XPServerAttr", s); XFree(s); + + XpDestroyContext(dpy, pcontext); + } + + XpFreePrinterList(printerlist); + + return 1; +} /* utilities to manage the list of recognized extensions */ @@ -1063,6 +1146,7 @@ ExtensionPrintInfo known_extensions[] = #ifdef PANORAMIX {"XINERAMA", print_xinerama_info, False}, #endif + {XP_PRINTNAME, print_xprint_info, False}, /* add new extensions here */ }; -- cgit v1.2.3