home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xbv / patch3 next >
Text File  |  1990-07-11  |  8KB  |  293 lines

  1. Path: uunet!samsung!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!sun-barr!newstop!sun!number6.Solbourne.COM
  2. From: kucharsk@number6.Solbourne.COM (William Kucharski)
  3. Newsgroups: comp.sources.x
  4. Subject: v08i052: xbv - bitmap previewer, Patch3, Part01/01
  5. Message-ID: <138737@sun.Eng.Sun.COM>
  6. Date: 11 Jul 90 18:40:26 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 282
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: kucharsk@number6.Solbourne.COM (William Kucharski)
  12. Posting-number: Volume 8, Issue 52
  13. Archive-name: xbv/patch3
  14. Patch-To: xbv: Volume 6, Issue 37,40
  15.  
  16. The following patch to xbv cleans up a few bugs, and, thanks to Jim Wight of
  17. the University of Newcastle upon Tyne, changes things so that xbv can read a
  18. bitmap from stdin.
  19.  
  20.                         -- Bill
  21.  
  22.  
  23. *** patchlevel.h.orig    Tue Jun 19 11:08:47 1990
  24. --- patchlevel.h    Tue Jun 19 11:08:53 1990
  25. Prereq: 2
  26. ***************
  27. *** 1 ****
  28. ! #define PATCHLEVEL    2
  29. --- 1 ----
  30. ! #define PATCHLEVEL    3
  31.  
  32. *** xbv.c.orig    Wed Mar 21 10:31:27 1990
  33. --- xbv.c    Tue Jun 19 10:56:10 1990
  34. ***************
  35. *** 28,33 ****
  36. --- 28,34 ----
  37.   #include <X11/cursorfont.h>
  38.   #include <X11/Xlib.h>
  39.   #include <X11/Xutil.h>
  40. + #include <X11/Xmu/Xmu.h>
  41.   #include <stdio.h>
  42.   
  43.   static void
  44. ***************
  45. *** 35,41 ****
  46.   char    *progname;
  47.   {
  48.       (void) fprintf(stderr, 
  49. !         "usage: %s [-d display] [-b borderwidth] [-g geometry] [-rv] bitmapfile\n",
  50.           progname);
  51.   
  52.       exit(1);
  53. --- 36,42 ----
  54.   char    *progname;
  55.   {
  56.       (void) fprintf(stderr, 
  57. !         "usage: %s [-d display] [-b borderwidth] [-g geometry] [-rv] [bitmapfile]\n",
  58.           progname);
  59.   
  60.       exit(1);
  61. ***************
  62. *** 119,128 ****
  63.   
  64.       char    *wnname[1];
  65.   
  66. !     char    *file;    /* bitmap filename */
  67. !     int    argctr;    /* argument counter */
  68. !     int    status;    /* return status of XReadBitmapFile(3X11) */
  69.   
  70.       int    bwidth = 2;    /* default border width */
  71.       int    geomask = 0;    /* mask returned by XParseGeometry(3X11) */
  72.       int    reverse = 0;    /* reverse video */
  73. --- 120,134 ----
  74.   
  75.       char    *wnname[1];
  76.   
  77. !     int     stdio = FALSE;      /* input from stdin */
  78. !     char    *stdinput = "stdin";    /* 'filename' for stdin */
  79. !     char    *datap;         /* bitmap data pointer */
  80. !     int     x_hot;          /* bitmap hot spot x coord */
  81. !     int     y_hot;          /* bitmap hot spot y coord */
  82. !     char    *file;            /* bitmap filename */
  83. !     int    argctr;            /* argument counter */
  84.   
  85. +     int    status;        /* return status of XReadBitmapFile(3X11) */
  86.       int    bwidth = 2;    /* default border width */
  87.       int    geomask = 0;    /* mask returned by XParseGeometry(3X11) */
  88.       int    reverse = 0;    /* reverse video */
  89. ***************
  90. *** 136,145 ****
  91.       hints.min_width = 1;    hints.min_height = 1;
  92.       hints.flags = PMinSize;
  93.   
  94. !     if (argc == 1)
  95. !         usage(argv[0]);
  96. !     while (*(argv[argctr]) == '-') {
  97.           switch(*(argv[argctr] +1)) {
  98.               case 'b':
  99.                   if (argc <= ++argctr)
  100. --- 142,148 ----
  101.       hints.min_width = 1;    hints.min_height = 1;
  102.       hints.flags = PMinSize;
  103.   
  104. !     while ((argctr < argc) && (*(argv[argctr]) == '-')) {
  105.           switch(*(argv[argctr] +1)) {
  106.               case 'b':
  107.                   if (argc <= ++argctr)
  108. ***************
  109. *** 191,207 ****
  110.       }
  111.   
  112.       if (argc < (argctr + 1))
  113. !         usage(argv[0]);
  114.   
  115. !     file = argv[argctr];        /* bitmap filename */
  116. !     wnname[0] = file;
  117.   
  118. -     if (access(file, R_OK)) {
  119. -         (void) fprintf(stderr,
  120. -             "%s: %s: %s\n", argv[0], file, msg(errno));
  121.           exit(1);
  122.       }
  123.   
  124.       if ((dpy = XOpenDisplay(display)) == NULL) {
  125.           (void) fprintf(stderr, "%s: Can't Open Display \"%s\" (%s)\n",
  126. --- 194,214 ----
  127.       }
  128.   
  129.       if (argc < (argctr + 1))
  130. !         stdio = TRUE;
  131.   
  132. !     if (stdio)
  133. !         file = stdinput;
  134. !     else
  135. !     {
  136. !         file = argv[argctr];        /* bitmap filename */
  137. !         if (access(file, R_OK)) {
  138. !             (void) fprintf(stderr,
  139. !                     "%s: %s: %s\n", argv[0], file, msg(errno));
  140.   
  141.           exit(1);
  142. +         }
  143.       }
  144. +     wnname[0] = file;
  145.   
  146.       if ((dpy = XOpenDisplay(display)) == NULL) {
  147.           (void) fprintf(stderr, "%s: Can't Open Display \"%s\" (%s)\n",
  148. ***************
  149. *** 224,231 ****
  150.   
  151.       root = DefaultRootWindow(dpy);    /* use root window for a drawable */
  152.   
  153. !     status = XReadBitmapFile(dpy, root, file, &width, &height, 
  154. !             &bitmap, 0, 0);
  155.   
  156.       if (status != BitmapSuccess) {
  157.           (void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
  158. --- 231,242 ----
  159.   
  160.       root = DefaultRootWindow(dpy);    /* use root window for a drawable */
  161.   
  162. !     if (stdio)
  163. !         status = XmuReadBitmapData(stdin, &width, &height, &datap,
  164. !                        &x_hot, &y_hot);
  165. !     else
  166. !         status = XReadBitmapFile(dpy, root, file, &width, &height, 
  167. !                      &bitmap, 0, 0);
  168.   
  169.       if (status != BitmapSuccess) {
  170.           (void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
  171. ***************
  172. *** 234,239 ****
  173. --- 245,260 ----
  174.           exit(2);
  175.       }
  176.   
  177. +     if (stdio)
  178. +         bitmap = XCreateBitmapFromData(dpy, root, datap, width, height);
  179. +     if (bitmap == None)
  180. +     {
  181. +         (void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
  182. +                bitmap_err(BitmapNoMemory));
  183. +         exit(2);
  184. +     }
  185. +         
  186.       /* clean up window hints */
  187.   
  188.       if ((hints.height == 0) && (hints.width == 0)) {
  189.  
  190. *** xbv.man.orig    Tue Jun 19 11:07:30 1990
  191. --- xbv.man    Tue Jun 19 11:16:27 1990
  192. ***************
  193. *** 1,4 ****
  194. ! .TH XCPUSTATE 1
  195.   .SH NAME
  196.   xbv - display X11 bitmaps
  197.   .SH SYNTAX
  198. --- 1,4 ----
  199. ! .TH XBV 1
  200.   .SH NAME
  201.   xbv - display X11 bitmaps
  202.   .SH SYNTAX
  203. ***************
  204. *** 9,18 ****
  205.   .IR display "\|]"
  206.   .RB "[\|" \-g
  207.   .IR geometry "\|]"
  208. ! .RB "[\|" \-rv  "\|]"
  209. ! .RI bitmapfile 
  210.   .SH DESCRIPTION
  211. ! .I Xbv displays a window with the contents of the specified X11 bitmap file on
  212.   the specified display. Clicking a mouse button while the pointer is in the
  213.   window will dismiss the window.
  214.   .SH OPTIONS
  215. --- 9,19 ----
  216.   .IR display "\|]"
  217.   .RB "[\|" \-g
  218.   .IR geometry "\|]"
  219. ! .RB "[\|" \-rv "\|]"
  220. ! .RI "[\|" bitmapfile "\|]"
  221.   .SH DESCRIPTION
  222. ! .I Xbv
  223. ! displays a window with the contents of the specified X11 bitmap file on
  224.   the specified display. Clicking a mouse button while the pointer is in the
  225.   window will dismiss the window.
  226.   .SH OPTIONS
  227. ***************
  228. *** 25,38 ****
  229.   .TP 8
  230.   .IR \-g " geometry"
  231.   Specify the geometry of the bitmap window using standard X11 geometry syntax.
  232.   .SH NOTES
  233.   .I Xbv
  234.   is one of the few ways to easily display an X bitmap without resorting to
  235.   the use of the \fIxsetroot\fR(1) command. This program is written entirely
  236. ! in Xlib and is a good \*Qsample\*U program for introductory X tutorials.
  237.   .SH BUGS
  238. ! X11R4 window managers may not respect the size information within the geometry
  239. ! specification.
  240.   .SH SEE ALSO
  241.   \fIxsetroot\fR(1)
  242.   .SH AUTHOR
  243. --- 26,45 ----
  244.   .TP 8
  245.   .IR \-g " geometry"
  246.   Specify the geometry of the bitmap window using standard X11 geometry syntax.
  247. + .TP 8
  248. + .I bitmapfile
  249. + Specifies the name of a X11 bitmap file to read. If a filename is not specified,
  250. + input is taken from stdin. (Stdin modification by Jim Wight at the University of
  251. + Newcastle upon Tyne, UK.)
  252.   .SH NOTES
  253.   .I Xbv
  254.   is one of the few ways to easily display an X bitmap without resorting to
  255.   the use of the \fIxsetroot\fR(1) command. This program is written entirely
  256. ! in Xlib (with a call to Xmu tossed in for good measure) and is a good 
  257. ! \*Qsample\*U program for introductory X tutorials.
  258.   .SH BUGS
  259. ! Some X11R4 window managers may not respect the size information within the
  260. ! geometry specification.
  261.   .SH SEE ALSO
  262.   \fIxsetroot\fR(1)
  263.   .SH AUTHOR
  264.  
  265. *** Imakefile.orig    Tue Jun 19 10:54:08 1990
  266. --- Imakefile    Tue Jun 19 10:53:48 1990
  267. ***************
  268. *** 1,5 ****
  269.          INCLUDES = -I$(TOP) -I$(TOP)/X11
  270. ! LOCAL_LIBRARIES = $(XLIB)
  271.              SRCS = xbv.c
  272.              OBJS = xbv.o
  273.   
  274. --- 1,5 ----
  275.          INCLUDES = -I$(TOP) -I$(TOP)/X11
  276. ! LOCAL_LIBRARIES = $(XMULIB) $(XLIB)
  277.              SRCS = xbv.c
  278.              OBJS = xbv.o
  279.   
  280. --
  281. ===============================================================================
  282. | Internet:   kucharsk@Solbourne.COM          |    William Kucharski             |
  283. | uucp:    ...!{boulder,sun,uunet}!stan!kucharsk |    Solbourne Computer, Inc.      |
  284. = The opinions above are mine alone and NOT those of Solbourne Computer, Inc. =
  285.  
  286. dan
  287. ----------------------------------------------------
  288. O'Reilly && Associates   argv@sun.com / argv@ora.com
  289. Opinions expressed reflect those of the author only.
  290.