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/main.c (-49 / +51 lines)
Lines 33-38 static char sccsid[] = "@(#)main.c 5.8 ( Link Here
33
#include <sys/file.h>
33
#include <sys/file.h>
34
34
35
#include <netinet/in.h>
35
#include <netinet/in.h>
36
#include <arpa/inet.h>
36
37
37
#include <signal.h>
38
#include <signal.h>
38
#include <stdio.h>
39
#include <stdio.h>
Lines 43-49 static char sccsid[] = "@(#)main.c 5.8 ( Link Here
43
#include <stdlib.h>
44
#include <stdlib.h>
44
#include <string.h>
45
#include <string.h>
45
#include <unistd.h>
46
#include <unistd.h>
46
#include <sys/sendfile.h>
47
/* #include <sys/sendfile.h> */
48
49
/* routines from tftp.c */
50
extern void sendfile(int fd, char *name, char *mode, char *linkpass);
51
extern void recvfile(int fd, char *name, char *mode, char *linkpass);
47
52
48
#define	TIMEOUT		5		/* secs between rexmt's */
53
#define	TIMEOUT		5		/* secs between rexmt's */
49
54
Lines 64-72 struct servent *sp; Link Here
64
69
65
int	segsize = 512;
70
int	segsize = 512;
66
71
67
int	quit(), help(), setverbose(), settrace(), status();
72
/* local routines */
68
int     get(), put(), setpeer(), modecmd(), setrexmt(), settimeout();
73
int     quit(), help(), setverbose(), settrace(), status(), command();
69
int     setbinary(), banner(), setascii(), setblocksize();
74
int     get(), getusage(), put(), putusage();
75
int     setpeer(), modecmd(), setrexmt(), settimeout(), status();
76
int     setbinary(),  setascii(); 
77
void    setmode(), makeargv();
78
int     setblocksize(), banner(); 
70
79
71
#define HELPINDENT (sizeof("connect"))
80
#define HELPINDENT (sizeof("connect"))
72
81
Lines 114-121 struct cmd *getcmd(); Link Here
114
char	*index();
123
char	*index();
115
char	*rindex();
124
char	*rindex();
116
125
117
int main(argc, argv)
126
int main(int argc, char *argv[])
118
	char *argv[];
119
{
127
{
120
	struct sockaddr_in sin;
128
	struct sockaddr_in sin;
121
	int top;
129
	int top;
Lines 147-159 int main(argc, argv) Link Here
147
	top = setjmp(toplevel) == 0;
155
	top = setjmp(toplevel) == 0;
148
	for (;;)
156
	for (;;)
149
		command(top);
157
		command(top);
158
        return 0;
150
}
159
}
151
160
152
char    hostname[100];
161
char    hostname[100];
153
162
154
setpeer(argc, argv)
163
int setpeer(int argc, char *argv[])
155
	int argc;
156
	char *argv[];
157
{
164
{
158
	struct hostent *host;
165
	struct hostent *host;
159
166
Lines 187-192 setpeer(argc, argv) Link Here
187
		port = htons(port);
194
		port = htons(port);
188
	}
195
	}
189
	connected = 1;
196
	connected = 1;
197
        return 0;
190
}
198
}
191
199
192
struct	modes {
200
struct	modes {
Lines 201-208 struct modes { Link Here
201
	{ 0,		0 }
209
	{ 0,		0 }
202
};
210
};
203
211
204
modecmd(argc, argv)
212
int modecmd(int argc, char *argv[])
205
	char *argv[];
206
{
213
{
207
	register struct modes *p;
214
	register struct modes *p;
208
	char *sep;
215
	char *sep;
Lines 234-251 modecmd(argc, argv) Link Here
234
	return 0;
241
	return 0;
235
}
242
}
236
243
237
setbinary(argc, argv)
244
int setbinary(int argc, char *argv[])
238
char *argv[];
245
{
239
{       setmode("octet");
246
        setmode("octet");
240
}
247
}
241
248
242
setascii(argc, argv)
249
int setascii(int argc, char *argv[])
243
char *argv[];
250
{
244
{       setmode("netascii");
251
        setmode("netascii");
245
}
252
 }
246
253
247
setmode(newmode)
254
void setmode(char *newmode)
248
char *newmode;
249
{
255
{
250
	strcpy(mode, newmode);
256
	strcpy(mode, newmode);
251
	if (verbose)
257
	if (verbose)
Lines 256-263 char *newmode; Link Here
256
 * Send file(s).
262
 * Send file(s).
257
 */
263
 */
258
264
259
put(argc, argv)
265
int put(int argc, char *argv[])
260
	char *argv[];
261
{
266
{
262
	int fd;
267
	int fd;
263
	register int n;
268
	register int n;
Lines 286-293 put(argc, argv) Link Here
286
		return 0;
291
		return 0;
287
}
292
}
288
293
289
putusage(s)
294
int putusage(char *s)
290
	char *s;
291
{
295
{
292
	printf("usage: %s file [linksys pass] (you must be connected)\n", s);
296
	printf("usage: %s file [linksys pass] (you must be connected)\n", s);
293
	return 0;
297
	return 0;
Lines 296-303 putusage(s) Link Here
296
/*
300
/*
297
 * Receive file(s).
301
 * Receive file(s).
298
 */
302
 */
299
get(argc, argv)
303
int get(int argc, char *argv[])
300
	char *argv[];
301
{
304
{
302
	int fd;
305
	int fd;
303
	register int n;
306
	register int n;
Lines 327-342 get(argc, argv) Link Here
327
		return 0;
330
		return 0;
328
}
331
}
329
332
330
getusage(s)
333
int getusage(char *s)
331
char * s;
332
{
334
{
333
	printf("usage: %s file [linksys pass] (you must be connected)\n", s);
335
	printf("usage: %s file [linksys pass] (you must be connected)\n", s);
336
        return 0;
334
}
337
}
335
338
336
int	rexmtval = TIMEOUT;
339
int	rexmtval = TIMEOUT;
337
340
338
setrexmt(argc, argv)
341
int setrexmt(int argc, char *argv[])
339
	char *argv[];
340
{
342
{
341
	int t;
343
	int t;
342
344
Lines 357-368 setrexmt(argc, argv) Link Here
357
		printf("%d: bad value\n", t);
359
		printf("%d: bad value\n", t);
358
	else
360
	else
359
		rexmtval = t;
361
		rexmtval = t;
362
        return 0;
360
}
363
}
361
364
362
int	maxtimeout = 5 * TIMEOUT;
365
int	maxtimeout = 5 * TIMEOUT;
363
366
364
settimeout(argc, argv)
367
int settimeout(int argc, char *argv[])
365
	char *argv[];
366
{
368
{
367
	int t;
369
	int t;
368
370
Lines 383-392 settimeout(argc, argv) Link Here
383
		printf("%d: bad value\n", t);
385
		printf("%d: bad value\n", t);
384
	else
386
	else
385
		maxtimeout = t;
387
		maxtimeout = t;
388
        return 0;
386
}
389
}
387
390
388
status(argc, argv)
391
int status(int argc, char *argv[])
389
	char *argv[];
390
{
392
{
391
	if (connected)
393
	if (connected)
392
		printf("Connected to %s.\n", hostname);
394
		printf("Connected to %s.\n", hostname);
Lines 396-401 status(argc, argv) Link Here
396
		verbose ? "on" : "off", trace ? "on" : "off");
398
		verbose ? "on" : "off", trace ? "on" : "off");
397
	printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n",
399
	printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n",
398
		rexmtval, maxtimeout);
400
		rexmtval, maxtimeout);
401
	return 0;
399
}
402
}
400
403
401
void intr(int sig)
404
void intr(int sig)
Lines 408-415 void intr(int sig) Link Here
408
/*
411
/*
409
 * Command parser.
412
 * Command parser.
410
 */
413
 */
411
command(top)
414
int command(int top)
412
	int top;
413
{
415
{
414
	register struct cmd *c;
416
	register struct cmd *c;
415
417
Lines 438-448 command(top) Link Here
438
		}
440
		}
439
		(*c->handler)(margc, margv);
441
		(*c->handler)(margc, margv);
440
	}
442
	}
443
        return 0;
441
}
444
}
442
445
443
struct cmd *
446
struct cmd *getcmd(register char *name)
444
getcmd(name)
445
	register char *name;
446
{
447
{
447
	register char *p, *q;
448
	register char *p, *q;
448
	register struct cmd *c, *found;
449
	register struct cmd *c, *found;
Lines 473-479 getcmd(name) Link Here
473
/*
474
/*
474
 * Slice a string up into argc/argv.
475
 * Slice a string up into argc/argv.
475
 */
476
 */
476
makeargv()
477
void makeargv()
477
{
478
{
478
	register char *cp;
479
	register char *cp;
479
	register char **argp = margv;
480
	register char **argp = margv;
Lines 496-502 makeargv() Link Here
496
}
497
}
497
498
498
/*VARARGS*/
499
/*VARARGS*/
499
quit()
500
int quit()
500
{
501
{
501
	exit(0);
502
	exit(0);
502
}
503
}
Lines 504-512 quit() Link Here
504
/*
505
/*
505
 * Help command.
506
 * Help command.
506
 */
507
 */
507
help(argc, argv)
508
int help(int argc, char *argv[])
508
	int argc;
509
	char *argv[];
510
{
509
{
511
	register struct cmd *c;
510
	register struct cmd *c;
512
511
Lines 527-550 help(argc, argv) Link Here
527
		else
526
		else
528
			printf("%s\n", c->help);
527
			printf("%s\n", c->help);
529
	}
528
	}
529
        return 0;
530
}
530
}
531
531
532
/*VARARGS*/
532
/*VARARGS*/
533
settrace()
533
int settrace()
534
{
534
{
535
	trace = !trace;
535
	trace = !trace;
536
	printf("Packet tracing %s.\n", trace ? "on" : "off");
536
	printf("Packet tracing %s.\n", trace ? "on" : "off");
537
        return 0;
537
}
538
}
538
539
539
/*VARARGS*/
540
/*VARARGS*/
540
setverbose()
541
int setverbose()
541
{
542
{
542
	verbose = !verbose;
543
	verbose = !verbose;
543
	printf("Verbose mode %s.\n", verbose ? "on" : "off");
544
	printf("Verbose mode %s.\n", verbose ? "on" : "off");
545
        return 0;
544
}
546
}
545
547
546
setblocksize(argc, argv)
548
int setblocksize(int argc, char *argv[])
547
	char *argv[];
548
{
549
{
549
	int t;
550
	int t;
550
551
Lines 565-572 setblocksize(argc, argv) Link Here
565
		printf("%d: bad value\n", t);
566
		printf("%d: bad value\n", t);
566
	else
567
	else
567
		segsize = t;
568
		segsize = t;
569
        return 0;
568
}
570
}
569
banner() {
571
int banner() {
570
	printf("TJ Shelton\tredsand [at] redsand.net\n");
572
	printf("TJ Shelton\tredsand [at] redsand.net\n");
571
	printf("Mike Lynn\tabaddon [at] 802.11ninja.net\n");
573
	printf("Mike Lynn\tabaddon [at] 802.11ninja.net\n");
572
	printf("Linksys TFTP Client for *BSD/Linux\tThe Firmware gets sexier\n");
574
	printf("Linksys TFTP Client for *BSD/Linux\tThe Firmware gets sexier\n");

Return to bug 928051