• Home
  • Raw
  • Download

Lines Matching +full:detect +full:- +full:newline

39 /* Simple minded read-ahead/write-behind subroutines for tftp user and
43 Todo: add some sort of final error check so when the write-buffer
44 is finally flushed, the caller can detect if the disk filled up
67 #define BF_ALLOC -3 /* alloc'd but not yet filled */
68 #define BF_FREE -2 /* free */
69 /* [-1 .. SEGSIZE] = size of data in the data buffer */
75 int newline = 0; /* fillbuf: in middle of newline expansion */ variable
76 int prevchar = -1; /* putbuf: previous char (cr check) */
80 struct tftphdr *w_init() { return rw_init(0); } /* write-behind */ in w_init()
81 struct tftphdr *r_init() { return rw_init(1); } /* read-ahead */ in r_init()
83 /* init for either read-ahead or write-behind */
84 /* x is zero for write-behind, one for read-head */
87 newline = 0; /* init crlf flag */ in rw_init()
88 prevchar = -1; in rw_init()
108 if (b->counter == BF_FREE) /* if it's empty */ in readit()
111 assert(b->counter != BF_FREE); /* check */ in readit()
113 *dpp = (struct tftphdr *)b->buf; /* set caller's ptr */ in readit()
114 return b->counter; in readit()
119 * conversions are lf -> cr,lf and cr -> cr, nul
130 if (b->counter != BF_FREE) /* nop if not free */ in read_ahead()
134 dp = (struct tftphdr *)b->buf; in read_ahead()
137 b->counter = read(fileno(file), dp->th_data, SEGSIZE); in read_ahead()
141 p = dp->th_data; in read_ahead()
143 if (newline) { in read_ahead()
147 newline = 0; in read_ahead()
155 newline = 1; in read_ahead()
160 b->counter = (int)(p - dp->th_data); in read_ahead()
180 * CR,NUL -> CR and CR,LF => LF.
195 if (b->counter < -1) /* anything to flush? */ in write_behind()
198 count = b->counter; /* remember byte count */ in write_behind()
199 b->counter = BF_FREE; /* reset flag */ in write_behind()
200 dp = (struct tftphdr *)b->buf; in write_behind()
202 buf = dp->th_data; in write_behind()
204 if (count <= 0) return -1; /* nak logic? */ in write_behind()
211 while (ct--) { /* loop over the buffer */ in write_behind()
215 fseek(file, -1, 1); /* smash lf on top of the cr */ in write_behind()
231 * response to packet N is really their response to packet N-1.