summaryrefslogtreecommitdiff
path: root/networking/tftp.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-21 11:09:40 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-21 11:09:40 +0000
commit5e34ff29bcc870936ab18172f438a34d042d4e03 (patch)
treea5e7a528f2f916eb883f1161eadceacdf2dca4be /networking/tftp.c
parent8b814b4a349e2262c0ad25793b05206a14651ebb (diff)
downloadbusybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.tar.gz
busybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.tar.bz2
busybox-w32-5e34ff29bcc870936ab18172f438a34d042d4e03.zip
*: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially badly named. It was not skipping anything!
Diffstat (limited to 'networking/tftp.c')
-rw-r--r--networking/tftp.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index 9c78b6e14..352037f1b 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -64,15 +64,15 @@ enum {
64}; 64};
65 65
66#if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT 66#if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT
67#define USE_GETPUT(...) 67#define IF_GETPUT(...)
68#define CMD_GET(cmd) 1 68#define CMD_GET(cmd) 1
69#define CMD_PUT(cmd) 0 69#define CMD_PUT(cmd) 0
70#elif !ENABLE_FEATURE_TFTP_GET && ENABLE_FEATURE_TFTP_PUT 70#elif !ENABLE_FEATURE_TFTP_GET && ENABLE_FEATURE_TFTP_PUT
71#define USE_GETPUT(...) 71#define IF_GETPUT(...)
72#define CMD_GET(cmd) 0 72#define CMD_GET(cmd) 0
73#define CMD_PUT(cmd) 1 73#define CMD_PUT(cmd) 1
74#else 74#else
75#define USE_GETPUT(...) __VA_ARGS__ 75#define IF_GETPUT(...) __VA_ARGS__
76#define CMD_GET(cmd) ((cmd) & TFTP_OPT_GET) 76#define CMD_GET(cmd) ((cmd) & TFTP_OPT_GET)
77#define CMD_PUT(cmd) ((cmd) & TFTP_OPT_PUT) 77#define CMD_PUT(cmd) ((cmd) & TFTP_OPT_PUT)
78#endif 78#endif
@@ -160,9 +160,9 @@ static int tftp_protocol(
160 len_and_sockaddr *our_lsa, 160 len_and_sockaddr *our_lsa,
161 len_and_sockaddr *peer_lsa, 161 len_and_sockaddr *peer_lsa,
162 const char *local_file 162 const char *local_file
163 USE_TFTP(, const char *remote_file) 163 IF_TFTP(, const char *remote_file)
164 USE_FEATURE_TFTP_BLOCKSIZE(USE_TFTPD(, void *tsize)) 164 IF_FEATURE_TFTP_BLOCKSIZE(IF_TFTPD(, void *tsize))
165 USE_FEATURE_TFTP_BLOCKSIZE(, int blksize)) 165 IF_FEATURE_TFTP_BLOCKSIZE(, int blksize))
166{ 166{
167#if !ENABLE_TFTP 167#if !ENABLE_TFTP
168#define remote_file NULL 168#define remote_file NULL
@@ -178,7 +178,7 @@ static int tftp_protocol(
178#define socket_fd (pfd[0].fd) 178#define socket_fd (pfd[0].fd)
179 int len; 179 int len;
180 int send_len; 180 int send_len;
181 USE_FEATURE_TFTP_BLOCKSIZE(smallint want_option_ack = 0;) 181 IF_FEATURE_TFTP_BLOCKSIZE(smallint want_option_ack = 0;)
182 smallint finished = 0; 182 smallint finished = 0;
183 uint16_t opcode; 183 uint16_t opcode;
184 uint16_t block_nr; 184 uint16_t block_nr;
@@ -564,19 +564,19 @@ int tftp_main(int argc UNUSED_PARAM, char **argv)
564#endif 564#endif
565 int result; 565 int result;
566 int port; 566 int port;
567 USE_GETPUT(int opt;) 567 IF_GETPUT(int opt;)
568 568
569 INIT_G(); 569 INIT_G();
570 570
571 /* -p or -g is mandatory, and they are mutually exclusive */ 571 /* -p or -g is mandatory, and they are mutually exclusive */
572 opt_complementary = "" USE_FEATURE_TFTP_GET("g:") USE_FEATURE_TFTP_PUT("p:") 572 opt_complementary = "" IF_FEATURE_TFTP_GET("g:") IF_FEATURE_TFTP_PUT("p:")
573 USE_GETPUT("g--p:p--g:"); 573 IF_GETPUT("g--p:p--g:");
574 574
575 USE_GETPUT(opt =) getopt32(argv, 575 IF_GETPUT(opt =) getopt32(argv,
576 USE_FEATURE_TFTP_GET("g") USE_FEATURE_TFTP_PUT("p") 576 IF_FEATURE_TFTP_GET("g") IF_FEATURE_TFTP_PUT("p")
577 "l:r:" USE_FEATURE_TFTP_BLOCKSIZE("b:"), 577 "l:r:" IF_FEATURE_TFTP_BLOCKSIZE("b:"),
578 &local_file, &remote_file 578 &local_file, &remote_file
579 USE_FEATURE_TFTP_BLOCKSIZE(, &blksize_str)); 579 IF_FEATURE_TFTP_BLOCKSIZE(, &blksize_str));
580 argv += optind; 580 argv += optind;
581 581
582#if ENABLE_FEATURE_TFTP_BLOCKSIZE 582#if ENABLE_FEATURE_TFTP_BLOCKSIZE
@@ -614,8 +614,8 @@ int tftp_main(int argc UNUSED_PARAM, char **argv)
614 result = tftp_protocol( 614 result = tftp_protocol(
615 NULL /*our_lsa*/, peer_lsa, 615 NULL /*our_lsa*/, peer_lsa,
616 local_file, remote_file 616 local_file, remote_file
617 USE_FEATURE_TFTP_BLOCKSIZE(USE_TFTPD(, NULL /*tsize*/)) 617 IF_FEATURE_TFTP_BLOCKSIZE(IF_TFTPD(, NULL /*tsize*/))
618 USE_FEATURE_TFTP_BLOCKSIZE(, blksize) 618 IF_FEATURE_TFTP_BLOCKSIZE(, blksize)
619 ); 619 );
620 620
621 if (result != EXIT_SUCCESS && NOT_LONE_DASH(local_file) && CMD_GET(opt)) { 621 if (result != EXIT_SUCCESS && NOT_LONE_DASH(local_file) && CMD_GET(opt)) {
@@ -635,8 +635,8 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
635 char *local_file, *mode; 635 char *local_file, *mode;
636 const char *error_msg; 636 const char *error_msg;
637 int opt, result, opcode; 637 int opt, result, opcode;
638 USE_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) 638 IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;)
639 USE_FEATURE_TFTP_BLOCKSIZE(char *tsize = NULL;) 639 IF_FEATURE_TFTP_BLOCKSIZE(char *tsize = NULL;)
640 640
641 INIT_G(); 641 INIT_G();
642 642
@@ -667,9 +667,9 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
667 opcode = ntohs(*(uint16_t*)block_buf); 667 opcode = ntohs(*(uint16_t*)block_buf);
668 if (result < 4 || result >= sizeof(block_buf) 668 if (result < 4 || result >= sizeof(block_buf)
669 || block_buf[result-1] != '\0' 669 || block_buf[result-1] != '\0'
670 || (USE_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */ 670 || (IF_FEATURE_TFTP_PUT(opcode != TFTP_RRQ) /* not download */
671 USE_GETPUT(&&) 671 IF_GETPUT(&&)
672 USE_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */ 672 IF_FEATURE_TFTP_GET(opcode != TFTP_WRQ) /* not upload */
673 ) 673 )
674 ) { 674 ) {
675 goto err; 675 goto err;
@@ -711,9 +711,9 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
711 error_msg = bb_msg_write_error; 711 error_msg = bb_msg_write_error;
712 goto err; 712 goto err;
713 } 713 }
714 USE_GETPUT(option_mask32 |= TFTP_OPT_GET;) /* will receive file's data */ 714 IF_GETPUT(option_mask32 |= TFTP_OPT_GET;) /* will receive file's data */
715 } else { 715 } else {
716 USE_GETPUT(option_mask32 |= TFTP_OPT_PUT;) /* will send file's data */ 716 IF_GETPUT(option_mask32 |= TFTP_OPT_PUT;) /* will send file's data */
717 } 717 }
718 718
719 /* NB: if error_pkt_str or error_pkt_reason is set up, 719 /* NB: if error_pkt_str or error_pkt_reason is set up,
@@ -724,9 +724,9 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
724 /* tftp_protocol() will create new one, bound to particular local IP */ 724 /* tftp_protocol() will create new one, bound to particular local IP */
725 result = tftp_protocol( 725 result = tftp_protocol(
726 our_lsa, peer_lsa, 726 our_lsa, peer_lsa,
727 local_file USE_TFTP(, NULL /*remote_file*/) 727 local_file IF_TFTP(, NULL /*remote_file*/)
728 USE_FEATURE_TFTP_BLOCKSIZE(, tsize) 728 IF_FEATURE_TFTP_BLOCKSIZE(, tsize)
729 USE_FEATURE_TFTP_BLOCKSIZE(, blksize) 729 IF_FEATURE_TFTP_BLOCKSIZE(, blksize)
730 ); 730 );
731 731
732 return result; 732 return result;