summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Mainz <roland.mainz@nrubsig.org>2005-04-11 01:06:16 +0000
committerRoland Mainz <roland.mainz@nrubsig.org>2005-04-11 01:06:16 +0000
commit9c6438171706f3cec7473968a993e84092ce255b (patch)
tree2a67ea4677480c1405452eeb34831b9ddf2221bd
parent6652de2af572eba6fd91804878a72d1df9cd1286 (diff)
xc/programs/glxgears/glxgears.c xc/programs/xdbedizzy/xdbedizzy.c xc/programs/xedit/Imakefile xc/programs/xedit/Xedit-xprint.ad xc/programs/xedit/util.c xc/programs/xedit/xedit.h xc/programs/xlogo/print.c xc/programs/xlogo/xlogo.c xc/programs/xlogo/xlogo.h xc/programs/xman/Imakefile xc/programs/xman/print.h xc/programs/xmore/Imakefile xc/programs/xmore/print.c xc/programs/xmore/print.h xc/programs/xmore/printdialog.c xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c xc/programs/xphelloworld/xphelloworld/xphelloworld.c xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c //bugs.freedesktop.org/show_bug.cgi?id=790) attachment #2379 (https://bugs.freedesktop.org/attachment.cgi?id=2379) Implement support client+Xserver support for passing output (stdout+stderr) of the spooler command started by the Xprint server back to the application using the "xp-spooler-command-results" XPJobAttr attribute (applications can fetch the attribute value after the XPEndJobNotify event was received; more details can be found in http://xprint.mozdev.org/docs/dtprint_fspec.ps).
-rw-r--r--xpawhelloworld/xpawhelloworld.c39
-rw-r--r--xphelloworld/xphelloworld.c42
-rw-r--r--xpsimplehelloworld/xpsimplehelloworld.c32
-rw-r--r--xpxmhelloworld/xpxmhelloworld.c39
-rw-r--r--xpxthelloworld/xpxthelloworld.c40
5 files changed, 186 insertions, 6 deletions
diff --git a/xpawhelloworld/xpawhelloworld.c b/xpawhelloworld/xpawhelloworld.c
index a480255..96e5009 100644
--- a/xpawhelloworld/xpawhelloworld.c
+++ b/xpawhelloworld/xpawhelloworld.c
@@ -52,6 +52,7 @@ 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 */
static int do_hello_world( int argc, char *argv[], const char *printername,
@@ -60,6 +61,7 @@ static int do_hello_world( int argc, char *argv[], const char *printername,
/* 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 doPrint = False; /* Do we print on a printer ? */
Display *pdpy = NULL; /* (Paper) display */
Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */
@@ -75,10 +77,37 @@ 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);
}
+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);
+ }
+}
+
int main( int argc, char *argv[] )
{
const char *printername = NULL; /* printer to query */
@@ -122,6 +151,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
{
@@ -418,7 +453,9 @@ 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... */
if( pcontext != None )
diff --git a/xphelloworld/xphelloworld.c b/xphelloworld/xphelloworld.c
index c796d29..bfd5993 100644
--- a/xphelloworld/xphelloworld.c
+++ b/xphelloworld/xphelloworld.c
@@ -37,9 +37,11 @@ in this Software without prior written authorization from The Open Group.
#define NULLSTR(x) (((x)!=NULL)?(x):(""))
#define Log(x) { if(verbose) printf x; }
+#define Msg(x) { if(!quiet) printf x; }
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) */
static
void usage( void )
@@ -54,18 +56,44 @@ void usage( void )
fprintf (stderr, "\t\tplex=<plex>\n");
fprintf (stderr, "\t\ttitle=<string>\n");
fprintf (stderr, "-v\tverbose output\n");
+ fprintf (stderr, "-q\tbe quiet (no output except errors)\n");
fprintf (stderr, "-text <string>\ttext to print (in ISO-8859-1)\n");
fprintf (stderr, "\n");
exit(EXIT_FAILURE);
}
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
int do_hello_world( const char *printername, const char *printerargs, const char *hello_world_message )
{
char *printerfile = NULL;
Window pwin;
XGCValues gcvalues;
- XEvent ev;
GC pgc;
unsigned short dummy;
XRectangle winrect;
@@ -187,11 +215,15 @@ int do_hello_world( const char *printername, const char *printerargs, const char
}
XpauWaitForPrintNotify(context, XPEndJobNotify);
-
+
+ /* end of spooled job - get spooler command results and print them */
+ PrintSpoolerCommandResults(context->pdpy, context->pcontext);
+
XpauReleaseContext(context);
return(EXIT_SUCCESS);
}
+
int main (int argc, char *argv[])
{
const char *printername = NULL; /* printer to query */
@@ -237,6 +269,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
{
diff --git a/xpsimplehelloworld/xpsimplehelloworld.c b/xpsimplehelloworld/xpsimplehelloworld.c
index 79bdb48..3fd05e8 100644
--- a/xpsimplehelloworld/xpsimplehelloworld.c
+++ b/xpsimplehelloworld/xpsimplehelloworld.c
@@ -38,9 +38,11 @@ in this Software without prior written authorization from The Open Group.
#define NULLSTR(x) (((x)!=NULL)?(x):(""))
#define Log(x) { if(verbose) printf x; }
+#define Msg(x) { if(!quiet) printf x; }
static const char *ProgramName; /* program name (from argv[0]) */
static Bool verbose = False; /* verbose output what the program is doing */
+Bool quiet = False; /* be quiet (no output except errors) */
static
void usage(void)
@@ -51,6 +53,7 @@ void usage(void)
fprintf (stderr, "-embedpsl2data string\tPostScript level 2 fragment to embed\n"
"\t\t(use 'xppsembeddemo1' to embed demo data)\n");
fprintf (stderr, "-v\tverbose output\n");
+ fprintf (stderr, "-q\tbe quiet (no output except errors)\n");
fprintf (stderr, "\n");
exit(EXIT_FAILURE);
}
@@ -93,12 +96,12 @@ int do_hello_world(const char *printername, const char *printerfile, const char
int pscreennumber;
Window pwin;
XGCValues gcvalues;
- XEvent ev;
GC pgc;
unsigned short dummy;
XRectangle winrect;
char fontname[256]; /* BUG: is this really big enougth ? */
XFontStruct *font;
+ char *scr;
if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 )
{
@@ -305,6 +308,27 @@ int do_hello_world(const char *printername, const char *printerfile, const char
return(EXIT_FAILURE);
}
}
+
+ /* End of spooled job - get spooler command results and print them */
+ 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);
+ }
XpuClosePrinterDisplay(pdpy, pcontext);
return(EXIT_SUCCESS);
@@ -348,6 +372,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
{
diff --git a/xpxmhelloworld/xpxmhelloworld.c b/xpxmhelloworld/xpxmhelloworld.c
index e142fc1..4d1538e 100644
--- a/xpxmhelloworld/xpxmhelloworld.c
+++ b/xpxmhelloworld/xpxmhelloworld.c
@@ -49,6 +49,7 @@ 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 */
static int do_hello_world( int argc, char *argv[], const char *printername,
@@ -57,6 +58,7 @@ static int do_hello_world( int argc, char *argv[], const char *printername,
/* 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 doPrint = False; /* Do we print on a printer ? */
Display *pdpy = NULL; /* (Paper) display */
Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */
@@ -72,10 +74,37 @@ 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);
}
+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);
+ }
+}
+
int main( int argc, char *argv[] )
{
const char *printername = NULL; /* printer to query */
@@ -119,6 +148,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
{
@@ -257,7 +292,7 @@ void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data)
XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data;
Log(("--> PrintEndJobCB\n"));
-
+
/* We're done with printing, tell |XtAppMainLoop()| that it can exit */
XtAppSetExitFlag(mpcd->appcontext);
}
@@ -437,6 +472,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... */
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... */