home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / atap.lha / ATAP / SourceCode / freadline.c < prev    next >
Text File  |  1992-06-13  |  570b  |  38 lines

  1. char *freadline(FILE *sourceFile)
  2. {
  3.  
  4. static    char    copyBuffer[128];
  5. static    char    char1,char2;
  6. static    int    index,endofstring,dummyChar;
  7.  
  8.     index=0;
  9.     endofstring=0;
  10.     dummyChar=0;
  11.     copyBuffer[0]=0;
  12.  
  13.     while(endofstring==0 && index<127)
  14.     {
  15.         char1=fgetc(sourceFile);
  16.         if (feof(sourceFile))
  17.             endofstring=-1;
  18.  
  19.         else if(char1==13)
  20.         {
  21.             char2=fgetc(sourceFile);
  22.             if (char2!=10)
  23.                 ungetc(char2,sourceFile);
  24.             endofstring=-1;
  25.         }
  26.         else if(char1==10)
  27.             endofstring=-1;
  28.         else
  29.         {
  30.             copyBuffer[index]=char1;
  31.             index++;
  32.         }
  33.     }
  34.  
  35.     copyBuffer[index]=0;
  36.     return(copyBuffer);
  37. };
  38.