summaryrefslogtreecommitdiff
path: root/xpxthelloworld/xpxthelloworld.c
diff options
context:
space:
mode:
Diffstat (limited to 'xpxthelloworld/xpxthelloworld.c')
-rw-r--r--xpxthelloworld/xpxthelloworld.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/xpxthelloworld/xpxthelloworld.c b/xpxthelloworld/xpxthelloworld.c
index e631e8a..929f655 100644
--- a/xpxthelloworld/xpxthelloworld.c
+++ b/xpxthelloworld/xpxthelloworld.c
@@ -41,8 +41,10 @@ in this Software without prior written authorization from The Open Group.
#define Error(x) { printf x ; exit(EXIT_FAILURE); }
#define Log(x) { if(verbose) printf x; }
+#define Msg(x) { if(!quiet) printf x; }
-/* Prototypes */
+/* Local prototypes */
+static void PrintSpoolerCommandResults(Display *pdpy, XPContext pcontext);
static void redisplayWidget(Widget widget);
static void MyAppMainLoop(XtAppContext app, Widget printwidget);
static int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile );
@@ -50,6 +52,7 @@ static int do_hello_world( int argc, char *argv[], const char *printername, con
/* Global vars */
const char *ProgramName; /* program name (from argv[0]) */
Bool verbose = False; /* verbose output what the program is doing */
+Bool quiet = False; /* be quiet (no output except errors) */
Bool done = False; /* Done with printing ? */
Bool doPrint = False; /* Do we print on a printer ? */
int xp_eventbase, /* XpExtension event base */
@@ -63,6 +66,32 @@ int numpages = 0; /* pages being printed */
static
+void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext )
+{
+ char *scr;
+
+ scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results");
+ if( scr )
+ {
+ if( strlen(scr) > 0 )
+ {
+ const char *msg = XpuCompoundTextToXmb(pdpy, scr);
+ if( msg )
+ {
+ Msg(("Spooler command returned '%s'.\n", msg));
+ XpuFreeXmbString(msg);
+ }
+ else
+ {
+ Msg(("Spooler command returned '%s' (unconverted).\n", scr));
+ }
+ }
+
+ XFree((void *)scr);
+ }
+}
+
+static
void MyAppMainLoop(XtAppContext app, Widget printwidget)
{
XEvent xevent;
@@ -159,6 +188,7 @@ void usage( void )
fprintf (stderr, "-printer printernname\tprinter to use\n");
fprintf (stderr, "-printfile file\tprint to file instead of printer\n");
fprintf (stderr, "-v\tverbose output\n");
+ fprintf (stderr, "-q\tbe quiet (no output except errors)\n");
fprintf (stderr, "\n");
exit(EXIT_FAILURE);
}
@@ -200,6 +230,12 @@ int main( int argc, char *argv[] )
else if (!strncmp("-v", arg, len))
{
verbose = True;
+ quiet = False;
+ }
+ else if (!strncmp("-q", arg, len))
+ {
+ verbose = False;
+ quiet = True;
}
else
{
@@ -400,6 +436,8 @@ int do_hello_world( int argc, char *argv[], const char *printername, const char
fprintf(stderr, "%s: Error while printing to file.\n", ProgramName);
}
}
+
+ PrintSpoolerCommandResults(pdpy, pcontext);
/* We have to use XpDestroyContext() and XtCloseDisplay() instead
* of XpuClosePrinterDisplay() to make libXt happy... */