home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / fido / pup_v2b.zip / QUOTE.C < prev    next >
C/C++ Source or Header  |  1987-10-29  |  882b  |  34 lines

  1. #include <puppy.h>
  2. #include <pupmem.h>
  3.  
  4. /* Pull the next quote from the file, output to the screen. */
  5.  
  6. quote() {
  7. int i,f;
  8. char mark[5];
  9. char c;
  10.  
  11.     f= open("quotes.pup",0);        /* open it, */
  12.     if (f == -1) return(0);            /* doesnt exist, */
  13.     lseek(f,pup.quote_pos,0);        /* seek to correct place, */
  14.     strcpy(mark,"abcd");            /* anything but CR LF CR LF */
  15.  
  16.     mputs("\r\n");
  17.     while (1) {
  18.         if (! read(f,&c,1)) {        /* read a character, */
  19.             lseek(f,0L,0);        /* rewind if we hit EOF */
  20.             pup.quote_pos= 0L;    /* (current position) */
  21.             if (! read(f,&c,1)) break; /* try again */
  22.         }
  23.         ++pup.quote_pos;        /* current actual position */
  24.         for (i= 0; i < 4; i++)        /* ASCII shift register */
  25.             mark[i]= mark[i + 1];    /* slide 'em through */
  26.         mark[3]= c;            /* add to the end */
  27.         if (strcmp(mark,"\r\n\r\n") == 0) break;
  28.  
  29.         fmconout(c);
  30.     }
  31.     mputs("\r\n");
  32.     close(f);
  33. }
  34.