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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
--- linksys-tftp-1.2.1/tftpsubs.c 2024-04-16 08:27:50.310449884 -0700
+++ linksys-tftp-1.2.1/tftpsubs.c 2024-04-16 08:53:26.084521570 -0700
@@ -38,6 +38,7 @@ static char sccsid[] = "@(#)tftpsubs.c 5
// modified tftp header to include pass
#include <tftp.h>
#include <stdio.h>
+#include <unistd.h>
#define PKTSIZE (1432+4) /* SEGSIZE+4 */ /* should be moved to tftp.h */
@@ -60,14 +61,22 @@ static int current; /* index of buff
int newline = 0; /* fillbuf: in middle of newline expansion */
int prevchar = -1; /* putbuf: previous char (cr check) */
-struct tftphdr *rw_init();
+/* functions declared in this program */
+struct tftphdr *w_init();
+struct tftphdr *r_init();
+struct tftphdr *rw_init(int x);
+int readit(FILE *file, struct tftphdr **dpp, int convert);
+int read_ahead(FILE *file, int convert);
+int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert);
+int write_behind( FILE *file, int convert);
+int synchnet(int f);
struct tftphdr *w_init() { return rw_init(0); } /* write-behind */
struct tftphdr *r_init() { return rw_init(1); } /* read-ahead */
-struct tftphdr *
-rw_init(x) /* init for either read-ahead or write-behind */
-int x; /* zero for write-behind, one for read-head */
+/* init for either read-ahead or write-behind */
+struct tftphdr *rw_init(int x)
+ /* zero for write-behind, one for read-head */
{
newline = 0; /* init crlf flag */
prevchar = -1;
@@ -82,10 +91,8 @@ int x; /* zero for writ
/* Have emptied current buffer by sending to net and getting ack.
Free it and return next buffer filled with data.
*/
-readit(file, dpp, convert)
- FILE *file; /* file opened for read */
- struct tftphdr **dpp;
- int convert; /* if true, convert to ascii */
+int readit(FILE *file, struct tftphdr **dpp, int convert)
+ /* file opened for read if true, convert to ascii */
{
struct bf *b;
@@ -104,9 +111,9 @@ readit(file, dpp, convert)
* fill the input buffer, doing ascii conversions if requested
* conversions are lf -> cr,lf and cr -> cr, nul
*/
-read_ahead(file, convert)
- FILE *file; /* file opened for read */
- int convert; /* if true, convert to ascii */
+int read_ahead(FILE *file, int convert)
+ /* file opened for read */
+ /* if true, convert to ascii */
{
register int i;
register char *p;
@@ -154,16 +161,14 @@ read_ahead(file, convert)
*p++ = c;
}
b->counter = (int)(p - dp->th_data);
+ return 0;
}
/* Update count associated with the buffer, get new buffer
from the queue. Calls write_behind only if next buffer not
available.
*/
-writeit(file, dpp, ct, convert)
- FILE *file;
- struct tftphdr **dpp;
- int convert;
+int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert)
{
bfs[current].counter = ct; /* set size of data to write */
current = !current; /* switch to other buffer */
@@ -180,9 +185,7 @@ writeit(file, dpp, ct, convert)
* Note spec is undefined if we get CR as last byte of file or a
* CR followed by anything else. In this case we leave it alone.
*/
-write_behind(file, convert)
- FILE *file;
- int convert;
+int write_behind( FILE *file, int convert)
{
char *buf;
int count;
@@ -238,9 +241,8 @@ skipit:
* when trace is active).
*/
-int
-synchnet(f)
-int f; /* socket to flush */
+int synchnet(int f)
+ /* socket to flush */
{
int i, j = 0;
char rbuf[PKTSIZE];
@@ -258,4 +260,5 @@ int f; /* socket to flush */
return(j);
}
}
+ return 0; /* should never get here */
}
|