home *** CD-ROM | disk | FTP | other *** search
- /* :set tabstops=4 */
- static char *RCSid = "$Header: read_stream.c,v 1.1 86/04/20 16:16:49 sysad Exp $";
-
- /*
- * $Log: read_stream.c,v $
- * Revision 1.1 86/04/20 16:16:49 sysad
- * Initial distribution version
- *
- *
- */
-
-
- /* It is the intent of the author that this software may be distributed
- * and used freely, without restriction. If you make improvements or
- * enhancements, I would appreciate a copy.
- *
- * Duane H. Hesser Teltone Corporation
- * ....uw-beaver!tikal!sysad
- * ....uw-beaver!tikal!dhh
- */
-
- #include "defs.h"
- #include "extern.h"
-
- read_stream(source)
- struct inbuf *source;
- {
- char c;
- char string[256],ebuf[64];
- int len,got;
- short x0,y0,x1,y1,r;
- char getbyte();
- short getshort();
-
- got = 0;
- #ifdef QUICKPLOT
- linemask = plotchar;
- #endif
- while((c = getbyte(source)) && !eof(source))
- {
- ++got;
- switch(c)
- {
- case 'm':
- curx = getshort(source);
- cury = getshort(source);
- move(curx,cury);
- break;
-
- case 'n':
- curx = getshort(source);
- cury = getshort(source);
- cont(curx,cury);
- break;
-
- case 'p':
- curx = getshort(source);
- cury = getshort(source);
- move(curx,cury);
- point(curxdot,curydot);
- break;
-
- case 'l':
- x1 = getshort(source);
- y1 = getshort(source);
- curx = getshort(source);
- cury = getshort(source);
- line(x1,y1,curx,cury);
- break;
-
- case 't':
- len = getstr(source,string);
- label(string,len);
- break;
-
- case 'a':
- curx = getshort(source);
- cury = getshort(source);
- x0 = getshort(source);
- y0 = getshort(source);
- x1 = getshort(source);
- y1 = getshort(source);
- arc(curx,cury,x0,y0,x1,y1);
- /* The manual doesn't specify this, but it seems
- * the most reasonable thing to do.
- */
- move(curx,cury);
- break;
-
- case 'c':
- x1 = getshort(source);
- y1 = getshort(source);
- r = getshort(source);
- circle(x1,y1,r);
- /* (x1,y1) becomes current point */
- break;
-
- case 'e':
- return(-got); /* negative got triggers erase */
- break;
- break;
-
- case 'f':
- --got;
- len = getstr(source,string);
- if(!len) break;
-
- #ifdef DEBUG
- if(debug & 1) printf("linemask=%s",string);
- #endif
- #ifdef QUICKPLOT
- if(strcmp(string,"solid") == 0)
- linemask = plotchar;
- else if(strcmp(string,"dotted") == 0)
- linemask = '2';
- else if(strcmp(string,"shortdashed") == 0)
- linemask = '3';
- else if(strcmp(string,"longdashed") == 0)
- linemask = '4';
- else if(strcmp(string,"dotdashed") == 0)
- linemask = '5';
- break;
- #else
- if(strcmp(string,"solid") == 0)
- linemask = SOLID;
- else if(strcmp(string,"dotted") == 0)
- linemask = DOTTED;
- else if(strcmp(string,"shortdashed") == 0)
- linemask = SHORTDASHED;
- else if(strcmp(string,"longdashed") == 0)
- linemask = LONGDASHED;
- else if(strcmp(string,"dotdashed") == 0)
- linemask = DOTDASHED;
- break;
- #endif QUICKPLOT
-
- case 's':
- --got;
- x0 = getshort(source);
- y0 = getshort(source);
- x1 = getshort(source);
- y1 = getshort(source);
- space(x0,y0,x1,y1);
- break;
- default:
- --got;
- sprintf(ebuf,"bad input data: cmd (0%o)\n",c);
- write(2,ebuf,strlen(ebuf));
- break;
- }
- }
- /* return the number of commands decoded */
- return(--got > 0 ? got : 0);
- }
-
-