version 1.6, 2003/06/03 02:56:18 |
version 1.7, 2003/06/25 15:45:10 |
|
|
|
|
static struct tftphdr *rw_init(); |
static struct tftphdr *rw_init(); |
|
|
struct tftphdr *w_init() { return rw_init(0); } /* write-behind */ |
struct tftphdr * |
struct tftphdr *r_init() { return rw_init(1); } /* read-ahead */ |
w_init(void) |
|
{ |
|
return rw_init(0); /* write-behind */ |
|
} |
|
|
|
struct tftphdr * |
|
r_init(void) |
|
{ |
|
return rw_init(1); /* read-ahead */ |
|
} |
|
|
|
/* init for either read-ahead or write-behind */ |
|
/* zero for write-behind, one for read-head */ |
static struct tftphdr * |
static struct tftphdr * |
rw_init(x) /* init for either read-ahead or write-behind */ |
rw_init(int x) |
int x; /* zero for write-behind, one for read-head */ |
|
{ |
{ |
newline = 0; /* init crlf flag */ |
newline = 0; /* init crlf flag */ |
prevchar = -1; |
prevchar = -1; |
|
|
Free it and return next buffer filled with data. |
Free it and return next buffer filled with data. |
*/ |
*/ |
int |
int |
readit(file, dpp, convert) |
readit(FILE *file, struct tftphdr **dpp, int convert) |
FILE *file; /* file opened for read */ |
|
struct tftphdr **dpp; |
|
int convert; /* if true, convert to ascii */ |
|
{ |
{ |
struct bf *b; |
struct bf *b; |
|
|
|
|
* conversions are lf -> cr,lf and cr -> cr, nul |
* conversions are lf -> cr,lf and cr -> cr, nul |
*/ |
*/ |
void |
void |
read_ahead(file, convert) |
read_ahead(FILE *file, int convert) |
FILE *file; /* file opened for read */ |
|
int convert; /* if true, convert to ascii */ |
|
{ |
{ |
int i; |
int i; |
char *p; |
char *p; |
|
|
available. |
available. |
*/ |
*/ |
int |
int |
writeit(file, dpp, ct, convert) |
writeit(FILE *file, struct tftphdr **dpp, int ct, int convert) |
FILE *file; |
|
struct tftphdr **dpp; |
|
int ct, convert; |
|
{ |
{ |
bfs[current].counter = ct; /* set size of data to write */ |
bfs[current].counter = ct; /* set size of data to write */ |
current = !current; /* switch to other buffer */ |
current = !current; /* switch to other buffer */ |
|
|
* CR followed by anything else. In this case we leave it alone. |
* CR followed by anything else. In this case we leave it alone. |
*/ |
*/ |
int |
int |
write_behind(file, convert) |
write_behind(FILE *file, int convert) |
FILE *file; |
|
int convert; |
|
{ |
{ |
char *buf; |
char *buf; |
int count; |
int count; |
|
|
*/ |
*/ |
|
|
int |
int |
synchnet(f) |
synchnet(int f) |
int f; /* socket to flush */ |
|
{ |
{ |
int i, j = 0; |
int i, j = 0; |
char rbuf[PKTSIZE]; |
char rbuf[PKTSIZE]; |