1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/* $Id: $ */
/* Copyright (C) 1997 Sverre Hvammen Johansen,
* Department of Informatics, University of Oslo.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "file.h"
#include "simfile.h"
/******************************************************************************
BOOLEAN PROCEDURE INRECORD */
char
__riinrecord (p)
__bs2FILE *p;
{
long i,
j;
FILE *f;
char *s;
long c;
if (!((__bs1FILE *) p)->open)
__rerror ("Inrecord: File not open");
if (((__bs4FILE *) p)->endfile)
__rerror ("Inrecord: End of file");
if (p->IMAGE.obj == __NULL)
__rerror ("Inrecord: IMAGE equals notext");
f = ((__bs1FILE *) p)->file;
s = p->IMAGE.obj->string;
i = p->IMAGE.start - 1;
j = i + p->IMAGE.length;
while ((c = getc (f)) != __EOF)
{
if (c == '\n')
goto utinrecord;
if (i == j)
{
(void) ungetc ((int) c, f);
goto inrecordfull;
}
s[i++] = c;
}
if (i == p->IMAGE.start - 1)
{
((__bs4FILE *) p)->endfile = __TRUE;
s[i] = 25;
p->IMAGE.pos = 2;
return (__FALSE);
}
else
(void) ungetc ((int) c, f);
utinrecord:
p->IMAGE.pos = i - p->IMAGE.start + 2;
return (__FALSE);
inrecordfull:
p->IMAGE.pos = p->IMAGE.length + 1;
return (__TRUE);
}
|