home *** CD-ROM | disk | FTP | other *** search
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <X11/Xatom.h>
- #include <stdio.h>
- #include "copyright.h"
-
- static Widget toplevel;
-
- main (argc, argv)
- int argc;
- char *argv[];
- {
- void clipboard();
- Window window;
- Arg args[10];
- int i;
-
- toplevel = XtInitialize(NULL, "xlpr", NULL, 0, &argc, argv);
- XtSetMappedWhenManaged(toplevel, False);
-
- i = 0;
- XtSetArg(args[i], XtNwidth, 100); i++;
- XtSetArg(args[i], XtNheight, 100); i++;
- XtSetValues(toplevel, args, i);
-
- XtRealizeWidget(toplevel);
-
- XtGetSelectionValue(toplevel,
- XInternAtom(XtDisplay(toplevel), "CLIPBOARD", False),
- XA_STRING, clipboard, NULL, CurrentTime);
-
- XtMainLoop();
- }
-
- void clipboard(w, client_data, selection, type, buf, length, format)
- Widget w;
- XtPointer client_data;
- Atom *selection;
- Atom *type;
- XtPointer buf;
- unsigned long *length;
- int *format;
- {
- FILE *fp;
-
- if (*type == XT_CONVERT_FAIL || *length <= 0)
- return;
-
- fp = popen("/usr/ucb/lpr", "w");
- if (fp == NULL) {
- perror("xlpr: could not open pipe to /usr/ucb/lpr");
- } else {
- fputs (buf, fp);
- pclose(fp);
- }
-
- XtFree (buf);
- XtDestroyApplicationContext(XtWidgetToApplicationContext(toplevel));
- exit (0);
- }
-