lehors@lemur.inria.fr (Arnaud Le Hors) (11/12/90)
Here follows a little patch to the XPM2 distrib. The XReadPixmapFile and XWritePixmapFile now respectively reads from stdin and writes to stdout if NULL is given as filename. Documentation is updated, and demo handles new options such as -stdin, -sdtout and -nod (no display) which make demo a useful filter. -- Arnaud LE HORS BULL Research FRANCE -- Koala Project | Email : lehors@mirsa.inria.fr Inria - Sophia Antipolis | Phone : (33) 93 65 77 71 2004, Route des Lucioles | Telex : 97 00 50 F 06565 Valbonne CEDEX France | Fax : (33) 93 65 77 66 8<--------- cut here - xpm-2.6-to-2.7.patch ----------------- Go into the XPM v2.6 source directory, and pipe this file into "patch -p" You may want to clean the directory afterwards by a: find . \( -name \*.orig -o -size 0 \) -exec rm {} \; diff -c0 -r -N ./Makefile /tmp/xpm-new/Makefile *** ./Makefile Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/Makefile Mon Nov 12 15:20:16 1990 *************** *** 4,4 **** ! # $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 4,4 ---- ! # $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./README /tmp/xpm-new/README *** ./README Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/README Mon Nov 12 15:20:16 1990 *************** *** 1,1 **** ! $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 1,1 ---- ! $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./XCrPFData.c /tmp/xpm-new/XCrPFData.c *** ./XCrPFData.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/XCrPFData.c Mon Nov 12 15:20:16 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./XRdPixF.c /tmp/xpm-new/XRdPixF.c *** ./XRdPixF.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/XRdPixF.c Mon Nov 12 15:20:16 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./XWrPixF.c /tmp/xpm-new/XWrPixF.c *** ./XWrPixF.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/XWrPixF.c Mon Nov 12 15:20:17 1990 *************** *** 6,6 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 6,6 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ *************** *** 58,61 **** ! if (!(name = rindex(filename, '/'))) ! name = filename; ! else ! name++; --- 58,64 ---- ! if (filename) { ! if (!(name = rindex(filename, '/'))) ! name = filename; ! else ! name++; ! } else ! name = "pixmap_name"; diff -c0 -r -N ./create.c /tmp/xpm-new/create.c *** ./create.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/create.c Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./demo.c /tmp/xpm-new/demo.c *** ./demo.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/demo.c Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ *************** *** 67 **** --- 68,68 ---- + unsigned int stdinf = 0, stdoutf = 0, nod = 0; *************** *** 78,78 **** ! ColorSymbol symbols[4]; --- 79,79 ---- ! ColorSymbol symbols[10]; *************** *** 79 **** --- 81,81 ---- + int i; *************** *** 82,104 **** ! while (*++argv) { ! if (index(*argv,':')) display = *argv ; else ! if (!strcmp(*argv,"-d")) ! if (*++argv) display = *argv ; else Usage(); else ! if (!strcmp(*argv,"-display")) ! if (*++argv) display = *argv ; else Usage(); else ! if (index(*argv,'=')) geom = *argv ; else ! if (!strcmp(*argv,"-g")) ! if (*++argv) geom = *argv ; else Usage(); else ! if (!strcmp(*argv,"-geometry")) ! if (*++argv) geom = *argv ; else Usage(); else ! if (!strcmp(*argv,"-geom")) ! if (*++argv) geom = *argv ; else Usage(); else ! if (!strcmp(*argv,"-t")) ! if (*++argv) type = *argv ; else Usage(); else ! if (!strcmp(*argv,"-i")) ! if (*++argv) input = *argv ; else Usage(); else ! if (!strcmp(*argv,"-o")) ! if (*++argv) output = *argv ; else Usage(); else ! if (!strcmp(*argv,"-s")) { ! if (numsymbols < 4) { ! if (*++argv) symbols[numsymbols].name = *argv ; else Usage(); ! if (*++argv) symbols[numsymbols++].value = *argv ; else Usage(); --- 84,120 ---- ! for (i = 1; i < argc; i++) { ! if (strncmp(argv[i], "-d", 2) == 0) { ! display = argv[++i]; ! continue; ! } ! if (strncmp(argv[i], "-g", 2) == 0) { ! geom = argv[++i]; ! continue; ! } ! if (strncmp(argv[i], "-t", 2) == 0) { ! type = argv[++i]; ! continue; ! } ! if (strncmp(argv[i], "-i", 2) == 0) { ! input = argv[++i]; ! continue; ! } ! if (strncmp(argv[i], "-o", 2) == 0) { ! output = argv[++i]; ! continue; ! } ! if (strncmp(argv[i], "-stdin", 5) == 0) { ! stdinf = 1; ! continue; ! } ! if (strncmp(argv[i], "-stdout", 5) == 0) { ! stdoutf = 1; ! continue; ! } ! if (strncmp(argv[i], "-nod", 2) == 0) { ! nod = 1; ! continue; ! } ! if (strncmp(argv[i], "-s", 2) == 0) { ! if (i < argc + 1) { ! symbols[numsymbols].name = argv[++i]; ! symbols[numsymbols++].value = argv[++i]; *************** *** 106,107 **** ! } else ! Usage() ; --- 122,124 ---- ! continue; ! } ! Usage(); *************** *** 119,119 **** ! if (geom) { --- 136,136 ---- ! if (geom && !nod) { *************** *** 139,163 **** ! hints.flags = (((flag && XValue) || (flag && YValue))? ! USPosition : PPosition)| ! (((flag && WidthValue) || (flag && HeightValue))? ! USSize : PSize) ; ! hints.x = winx ; ! hints.y = winy ; ! hints.width = winw ; ! hints.height = winh ; ! ! XSetStandardProperties(dpy, win, ! command[0], ! command[0], ! None, ! command,argc, ! &hints); ! XSetNormalHints(dpy, win, &hints); ! ! classhint.res_name = command[0] ; ! classhint.res_class = "demo" ; ! XSetClassHint(dpy, win, &classhint); ! ! wmhints.input = True; ! wmhints.initial_state = NormalState; ! wmhints.flags = InputHint | StateHint; ! XSetWMHints(dpy, win, &wmhints); --- 156,182 ---- ! if (!nod) { ! hints.flags = (((flag && XValue) || (flag && YValue))? ! USPosition : PPosition)| ! (((flag && WidthValue) || (flag && HeightValue))? ! USSize : PSize) ; ! hints.x = winx ; ! hints.y = winy ; ! hints.width = winw ; ! hints.height = winh ; ! ! XSetStandardProperties(dpy, win, ! command[0], ! command[0], ! None, ! command,argc, ! &hints); ! XSetNormalHints(dpy, win, &hints); ! ! classhint.res_name = command[0] ; ! classhint.res_class = "demo" ; ! XSetClassHint(dpy, win, &classhint); ! ! wmhints.input = True; ! wmhints.initial_state = NormalState; ! wmhints.flags = InputHint | StateHint; ! XSetWMHints(dpy, win, &wmhints); ! } *************** *** 165,165 **** ! if (input) { --- 184,184 ---- ! if (input || stdinf) { *************** *** 182,183 **** - XSetWindowBackgroundPixmap(dpy, win, pix); - XMapWindow(dpy, win); --- 200 ---- *************** *** 185,185 **** ! if (output) --- 202,202 ---- ! if (output || stdoutf) *************** *** 193,197 **** ! do { ! XNextEvent(dpy, &e) ; ! if (e.type == ButtonPress) ! notend = 0; ! } while (notend) ; --- 210,219 ---- ! if (!nod) { ! XSetWindowBackgroundPixmap(dpy, win, pix); ! XMapWindow(dpy, win); ! do { ! XNextEvent(dpy, &e) ; ! if (e.type == ButtonPress) ! notend = 0; ! } while (notend) ; ! } ! *************** *** 207,211 **** ! fprintf(stderr,"%s %s %s%s", command[0], ! "[-g wxh+x+y] [-d host:display.screen]", ! "[-s symbol_name symbol_value]\n", ! "\t[-t type] [-i inputfile] [-o outputfile]\n"); ! exit(0); --- 229,240 ---- ! fprintf(stderr,"Usage: %s [-options...]\n", command[0]); ! fprintf(stderr,"%s\n", "Where options are:"); ! fprintf(stderr,"%s\n", "[-display host:display] Display to connect to."); ! fprintf(stderr,"%s\n", "[-geometry geom] Geometry of window."); ! fprintf(stderr,"%s\n", "[-s symbol_name symbol_value] Overwrite color defaults."); ! fprintf(stderr,"%s\n", "[-t type] Write output in `type` format: C, Lisp, ..."); ! fprintf(stderr,"%s\n", "[-i filename] Read input from file `filename`."); ! fprintf(stderr,"%s\n", "[-stdin] Read input from stdin."); ! fprintf(stderr,"%s\n", "[-o filename] Write output to file `filename`."); ! fprintf(stderr,"%s\n", "[-stdout] Write output to stdout."); ! fprintf(stderr,"%s\n", "[-nod] Don't display in window."); ! exit(0); diff -c0 -r -N ./free.c /tmp/xpm-new/free.c *** ./free.c Mon Nov 12 15:20:19 1990 --- /tmp/xpm-new/free.c Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./mio.c /tmp/xpm-new/mio.c *** ./mio.c Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/mio.c Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ *************** *** 185,193 **** ! if ((strlen(filename) > 2) && ! !strcmp(".Z", filename + (strlen(filename) - 2))) { ! mdata->type= MPIPE; ! sprintf(buf, "uncompress -c %s", filename); ! if (! (mdata->stream.file = popen(buf, "r"))) { ! free(mdata); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } --- 185,187 ---- ! if (!filename) { ! mdata->stream.file = (stdin); ! mdata->type = MFILE; *************** *** 195,203 **** ! if (! (compressfile = (char*)malloc(strlen(filename) + 3))) { ! free(mdata); ! XpmErrorStatus = PixmapNoMemory; ! return(NULL); ! } ! strcpy(compressfile, filename); ! strcat(compressfile, ".Z"); ! if (!stat(compressfile, &status)) { ! sprintf(buf, "uncompress -c %s", compressfile); --- 189,192 ---- ! if ((strlen(filename) > 2) && ! !strcmp(".Z", filename + (strlen(filename) - 2))) { ! mdata->type= MPIPE; ! sprintf(buf, "uncompress -c %s", filename); *************** *** 206,206 **** - free(compressfile); --- 194 ---- *************** *** 210,210 **** - mdata->type= MPIPE; --- 197 ---- *************** *** 212,212 **** ! if (! (mdata->stream.file = fopen(filename, "r"))) { --- 199,199 ---- ! if (! (compressfile = (char*)malloc(strlen(filename) + 3))) { *************** *** 214,215 **** ! free(compressfile); ! XpmErrorStatus = PixmapOpenFailed; --- 201,201 ---- ! XpmErrorStatus = PixmapNoMemory; *************** *** 218,218 **** ! mdata->type = MFILE; --- 204,224 ---- ! strcpy(compressfile, filename); ! strcat(compressfile, ".Z"); ! if (!stat(compressfile, &status)) { ! sprintf(buf, "uncompress -c %s", compressfile); ! if (! (mdata->stream.file = popen(buf, "r"))) { ! free(mdata); ! free(compressfile); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } ! mdata->type= MPIPE; ! } else { ! if (! (mdata->stream.file = fopen(filename, "r"))) { ! free(mdata); ! free(compressfile); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } ! mdata->type = MFILE; ! } ! free(compressfile); *************** *** 220,220 **** - free(compressfile); --- 225 ---- *************** *** 234,242 **** ! if ((strlen(filename) > 2) && ! !strcmp(".Z", filename + (strlen(filename) - 2))) { ! sprintf(buf, "compress > %s", filename); ! if (! (mdata->stream.file = popen(buf, "w"))) { ! free(mdata); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } ! mdata->type = MPIPE; --- 239,241 ---- ! if (!filename) { ! mdata->stream.file = (stdout); ! mdata->type = MFILE; *************** *** 244,247 **** ! if (! (mdata->stream.file = fopen(filename, "w"))) { ! free(mdata); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); --- 243,258 ---- ! if ((strlen(filename) > 2) && ! !strcmp(".Z", filename + (strlen(filename) - 2))) { ! sprintf(buf, "compress > %s", filename); ! if (! (mdata->stream.file = popen(buf, "w"))) { ! free(mdata); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } ! mdata->type = MPIPE; ! } else { ! if (! (mdata->stream.file = fopen(filename, "w"))) { ! free(mdata); ! XpmErrorStatus = PixmapOpenFailed; ! return(NULL); ! } ! mdata->type = MFILE; *************** *** 249,249 **** - mdata->type = MFILE; --- 259 ---- *************** *** 276,276 **** ! fclose(mdata->stream.file); --- 286,287 ---- ! if (mdata->stream.file != (stdout) && mdata->stream.file != (stdin)) ! fclose(mdata->stream.file); diff -c0 -r -N ./value.c /tmp/xpm-new/value.c *** ./value.c Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/value.c Mon Nov 12 15:20:17 1990 *************** *** 27,27 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 27,27 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./visual.c /tmp/xpm-new/visual.c *** ./visual.c Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/visual.c Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./xpm.h /tmp/xpm-new/xpm.h *** ./xpm.h Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/xpm.h Mon Nov 12 15:20:17 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ diff -c0 -r -N ./xpm.tex /tmp/xpm-new/xpm.tex *** ./xpm.tex Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/xpm.tex Mon Nov 12 15:20:18 1990 *************** *** 5,5 **** ! % $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 5,5 ---- ! % $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $ *************** *** 363 **** --- 364,366 ---- + If instead of a file name {\bf NULL} is passed to {\bf XReadPixmapFile}, it + reads from the standard input. + *************** *** 411 **** --- 415,417 ---- + + If instead of a file name {\bf NULL} is passed to {\bf XWritePixmapFile}, it + writes to the standard output. diff -c0 -r -N ./xpmP.h /tmp/xpm-new/xpmP.h *** ./xpmP.h Mon Nov 12 15:20:20 1990 --- /tmp/xpm-new/xpmP.h Mon Nov 12 15:20:18 1990 *************** *** 7,7 **** ! * $Id: xpm.shar,v 2.6 90/10/29 10:26:17 lehors Exp $ --- 7,7 ---- ! * $Id: xpm.shar,v 2.7 90/11/12 15:18:37 lehors Exp $