|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 3848 (0xf08) Types: TextFile Names: »picture.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/dsap/common/picture.c«
/* picture.c - */ #ifndef lint static char *rcsid = "$Header: /f/osi/dsap/common/RCS/picture.c,v 6.1 89/03/23 22:27:04 mrose Exp $"; #endif /* * $Header: /f/osi/dsap/common/RCS/picture.c,v 6.1 89/03/23 22:27:04 mrose Exp $ * * * $Log: picture.c,v $ * Revision 6.1 89/03/23 22:27:04 mrose * out-the-door * * Revision 6.0 89/03/18 23:27:44 mrose * Release 5.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ /* LINTLIBRARY */ #include "quipu/util.h" #include "quipu/photo.h" #include "quipu/attr.h" #include "psap.h" #include <errno.h> #include <signal.h> #include <sys/wait.h> int childpid,display; char *getenv (); picture_print (ps,pe,format) PS ps; PE pe; int format; { extern char * (*picture_display)(); char * ptr; PS sps; if (format != READOUT) return; (void) ps_flush (ps); if ((sps = ps_alloc (str_open)) == NULLPS) return; if (str_setup (sps,NULLCP,LINESIZE,0) == NOTOK) return; (void) pe2ps (sps,pe); /* default is picture_display is show_picture() */ ptr = (*picture_display)(sps->ps_base,"Photo Attribute"); ps_print (ps,ptr); ps_free (sps); } char * show_picture (picture,persons_name) char *picture; char *persons_name; { int len,ret; int pd[2]; int pd2[2]; char *decode_t4(); static char buffer [BUFLEN]; char * cp; extern char * picture_process; if ((len = photolen(picture)) == -1) return ("PHOTO: data does not look like a picture to me!!!"); hide_picture (); if (picture_process == NULLCP) return ("(No display process defined)"); /* get next two file descriptors used for data xfer */ ret = pipe(pd); if (ret == -1) return ("PHOTO: could not create pipe"); ret = pipe(pd2); if (ret == -1) { (void) close (pd[1]); (void) close (pd[0]); return ("PHOTO: could not create 2nd pipe"); } /* generate one parent and one child process */ if ((childpid = fork()) == -1) { (void) close (pd[1]); (void) close (pd[0]); (void) close (pd2[1]); (void) close (pd2[0]); return ("PHOTO: could not fork"); } if (childpid > 0) { /* in parent process */ (void) close (pd[0]); (void) close (pd2[1]); if (write (pd[1], picture, len) != len) { (void) close (pd[1]); (void) close (pd2[0]); return("PHOTO: length error"); } (void) close (pd[1]); for (cp = buffer, len = BUFLEN; len > 0;) { if ((ret = read (pd2[0], cp, len)) <= 0) break; cp += ret; len -= ret; } if ( ret != 0 ) { (void) close (pd2[0]); return ("PHOTO: read error"); } (void) close (pd2[0]); return (buffer); } else { /* you're in child process */ (void) close (0); if (dup(pd[0]) == -1) exit (-1); (void) close (pd[0]); (void) close (pd[1]); (void) close (2); if (dup(pd2[1]) == -1) exit (-1); (void) close (pd2[1]); (void) close (pd2[0]); if (*picture != '\0') { execl(picture_process,picture_process,persons_name,0); (void) fprintf (stderr,"PHOTO: can't execute %s",picture_process); exit (-1); } (void) fprintf (stderr,"PHOTO: Null photo"); /* safety catch */ exit (-1); } return ("PHOTO: system failure!!!"); } hide_picture () { union wait status; if (childpid > 0) { if (kill (childpid,SIGTERM) == 0) (void) wait(&status); } childpid = 0; } photolen (s1) char * s1; { int length=0,cnt,i; char * temp; if (*s1 == 0x03) { /* we have a coded picture */ temp = s1; temp++; cnt = *temp++ & 0x7f; /*assume len > 127 for now */ for (i=0; i<cnt; i++) length = (length << 8) | (*temp++ & 0xff) ; length += 2 + cnt; return (length); } else return (-1); }