Missing dependencies added.
[AROS-Contrib.git] / rexx / lstring / linein.c
blob24369f3f7a93adc1b9c7354d13686bff17e18236
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:37 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 1999/11/26 12:52:25 bnv
8 * Changed: To use the new macros.
10 * Revision 1.2 1999/03/15 15:25:53 bnv
11 * Corrected: initial value to prev
13 * Revision 1.1 1998/07/02 17:18:00 bnv
14 * Initial Version
18 #include <lstring.h>
20 /* ---------------- Llinein ------------------- */
21 void
22 Llinein( FILEP f, const PLstr line, long *curline, long start, long length )
24 int ch,prev='\n';
25 Lstr aux;
27 /* initialise line */
28 LZEROSTR(*line);
30 /* find current line */
31 if (start>=0) {
32 if (*curline>start) {
33 *curline = 1;
34 FSEEK(f,0,SEEK_SET);
36 while (start>*curline) {
37 ch = FGETC(f);
38 if (ch==EOF) {
39 if (prev!='\n') (*curline)++;
40 break;
42 if (ch=='\n') (*curline)++;
43 prev = ch;
45 if (start > *curline) return;
48 if (length<=0) return;
50 if (length==1) {
51 Lread(f,line,LREADLINE);
52 (*curline)++;
53 } else {
54 LINITSTR(aux);
55 while (length) {
56 Lread(f,&aux,LREADLINE);
57 Lstrcat(line,&aux);
58 if (length>1)
59 Lcat(line,"\n");
60 (*curline)++;
61 length--;
63 LFREESTR(aux);
65 } /* Llinein */