Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 928051 | Differences between
and this patch

Collapse All | Expand All

(-)linksys-tftp-1.2.1/tftpsubs.c (-21 / +24 lines)
Lines 38-43 static char sccsid[] = "@(#)tftpsubs.c 5 Link Here
38
// modified tftp header to include pass
38
// modified tftp header to include pass
39
#include <tftp.h>
39
#include <tftp.h>
40
#include <stdio.h>
40
#include <stdio.h>
41
#include <unistd.h>
41
42
42
#define PKTSIZE (1432+4) /* SEGSIZE+4 */      /* should be moved to tftp.h */
43
#define PKTSIZE (1432+4) /* SEGSIZE+4 */      /* should be moved to tftp.h */
43
44
Lines 60-73 static int current; /* index of buff Link Here
60
int newline = 0;        /* fillbuf: in middle of newline expansion */
61
int newline = 0;        /* fillbuf: in middle of newline expansion */
61
int prevchar = -1;      /* putbuf: previous char (cr check) */
62
int prevchar = -1;      /* putbuf: previous char (cr check) */
62
63
63
struct tftphdr *rw_init();
64
/* functions declared in this program */
65
struct tftphdr *w_init();
66
struct tftphdr *r_init();
67
struct tftphdr *rw_init(int x);
68
int readit(FILE *file,  struct tftphdr **dpp, int convert);
69
int read_ahead(FILE *file, int convert);
70
int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert);
71
int write_behind( FILE *file, int convert);
72
int synchnet(int        f);
64
73
65
struct tftphdr *w_init() { return rw_init(0); }         /* write-behind */
74
struct tftphdr *w_init() { return rw_init(0); }         /* write-behind */
66
struct tftphdr *r_init() { return rw_init(1); }         /* read-ahead */
75
struct tftphdr *r_init() { return rw_init(1); }         /* read-ahead */
67
76
68
struct tftphdr *
77
/* init for either read-ahead or write-behind */
69
rw_init(x)              /* init for either read-ahead or write-behind */
78
struct tftphdr *rw_init(int x)
70
int x;                  /* zero for write-behind, one for read-head */
79
                     /* zero for write-behind, one for read-head */
71
{
80
{
72
	newline = 0;            /* init crlf flag */
81
	newline = 0;            /* init crlf flag */
73
	prevchar = -1;
82
	prevchar = -1;
Lines 82-91 int x; /* zero for writ Link Here
82
/* Have emptied current buffer by sending to net and getting ack.
91
/* Have emptied current buffer by sending to net and getting ack.
83
   Free it and return next buffer filled with data.
92
   Free it and return next buffer filled with data.
84
 */
93
 */
85
readit(file, dpp, convert)
94
int readit(FILE *file,  struct tftphdr **dpp, int convert)
86
	FILE *file;                     /* file opened for read */
95
    /* file opened for read               if true, convert to ascii */
87
	struct tftphdr **dpp;
88
	int convert;                    /* if true, convert to ascii */
89
{
96
{
90
	struct bf *b;
97
	struct bf *b;
91
98
Lines 104-112 readit(file, dpp, convert) Link Here
104
 * fill the input buffer, doing ascii conversions if requested
111
 * fill the input buffer, doing ascii conversions if requested
105
 * conversions are  lf -> cr,lf  and cr -> cr, nul
112
 * conversions are  lf -> cr,lf  and cr -> cr, nul
106
 */
113
 */
107
read_ahead(file, convert)
114
int read_ahead(FILE *file, int convert)  
108
	FILE *file;                     /* file opened for read */
115
	/* file opened for read */
109
	int convert;                    /* if true, convert to ascii */
116
			/* if true, convert to ascii */
110
{
117
{
111
	register int i;
118
	register int i;
112
	register char *p;
119
	register char *p;
Lines 154-169 read_ahead(file, convert) Link Here
154
	       *p++ = c;
161
	       *p++ = c;
155
	}
162
	}
156
	b->counter = (int)(p - dp->th_data);
163
	b->counter = (int)(p - dp->th_data);
164
        return 0;
157
}
165
}
158
166
159
/* Update count associated with the buffer, get new buffer
167
/* Update count associated with the buffer, get new buffer
160
   from the queue.  Calls write_behind only if next buffer not
168
   from the queue.  Calls write_behind only if next buffer not
161
   available.
169
   available.
162
 */
170
 */
163
writeit(file, dpp, ct, convert)
171
int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert)
164
	FILE *file;
165
	struct tftphdr **dpp;
166
	int convert;
167
{
172
{
168
	bfs[current].counter = ct;      /* set size of data to write */
173
	bfs[current].counter = ct;      /* set size of data to write */
169
	current = !current;             /* switch to other buffer */
174
	current = !current;             /* switch to other buffer */
Lines 180-188 writeit(file, dpp, ct, convert) Link Here
180
 * Note spec is undefined if we get CR as last byte of file or a
185
 * Note spec is undefined if we get CR as last byte of file or a
181
 * CR followed by anything else.  In this case we leave it alone.
186
 * CR followed by anything else.  In this case we leave it alone.
182
 */
187
 */
183
write_behind(file, convert)
188
int write_behind( FILE *file, int convert)
184
	FILE *file;
185
	int convert;
186
{
189
{
187
	char *buf;
190
	char *buf;
188
	int count;
191
	int count;
Lines 238-246 skipit: Link Here
238
 * when trace is active).
241
 * when trace is active).
239
 */
242
 */
240
243
241
int
244
int synchnet(int        f)
242
synchnet(f)
245
        /* socket to flush */
243
int	f;		/* socket to flush */
244
{
246
{
245
	int i, j = 0;
247
	int i, j = 0;
246
	char rbuf[PKTSIZE];
248
	char rbuf[PKTSIZE];
Lines 258-261 int f; /* socket to flush */ Link Here
258
			return(j);
260
			return(j);
259
		}
261
		}
260
	}
262
	}
263
        return 0;   /* should never get here */
261
}
264
}

Return to bug 928051