if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
perror_msg("socket");
- return 1;
+ return EXIT_FAILURE;
}
len = sizeof(sa);
}
if ((*cp != '\0') || (&buf[BUFSIZE - 1] - cp) < 7) {
- error_msg("too long server-filename.\n");
+ error_msg("too long server-filename");
break;
}
if (sendto(socketfd, buf, len, 0,
(struct sockaddr *) &sa, sizeof(sa)) < 0) {
- perror_msg("send()");
+ perror_msg("send");
len = -1;
break;
}
/* discard the packet - treat as timeout */
case 0:
- error_msg("timeout.\n");
+ error_msg("timeout");
if (!timeout) {
timeout = BB_TFTP_NO_RETRIES;
if (!timeout) {
len = -1;
- error_msg("last timeout!\n");
+ error_msg("last timeout");
}
break;
}
if (msg) {
- error_msg("server says: %s.\n", msg);
+ error_msg("server says: %s", msg);
}
break;
close(socketfd);
- if (finished) {
- return 0;
- }
-
- return 1;
+ return finished ? EXIT_SUCCESS : EXIT_FAILURE;
}
int tftp_main(int argc, char **argv)
free(s);
}
if (bad) {
- perror_msg_and_die("bad \"server:file\" combination");
+ error_msg_and_die("bad \"server:file\" combination");
}
if (BB_TFTP_DEBUG) {
if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
perror_msg("socket");
- return 1;
+ return EXIT_FAILURE;
}
len = sizeof(sa);
}
if ((*cp != '\0') || (&buf[BUFSIZE - 1] - cp) < 7) {
- error_msg("too long server-filename.\n");
+ error_msg("too long server-filename");
break;
}
if (sendto(socketfd, buf, len, 0,
(struct sockaddr *) &sa, sizeof(sa)) < 0) {
- perror_msg("send()");
+ perror_msg("send");
len = -1;
break;
}
/* discard the packet - treat as timeout */
case 0:
- error_msg("timeout.\n");
+ error_msg("timeout");
if (!timeout) {
timeout = BB_TFTP_NO_RETRIES;
if (!timeout) {
len = -1;
- error_msg("last timeout!\n");
+ error_msg("last timeout");
}
break;
}
if (msg) {
- error_msg("server says: %s.\n", msg);
+ error_msg("server says: %s", msg);
}
break;
close(socketfd);
- if (finished) {
- return 0;
- }
-
- return 1;
+ return finished ? EXIT_SUCCESS : EXIT_FAILURE;
}
int tftp_main(int argc, char **argv)
free(s);
}
if (bad) {
- perror_msg_and_die("bad \"server:file\" combination");
+ error_msg_and_die("bad \"server:file\" combination");
}
if (BB_TFTP_DEBUG) {