Added check for number of arguments
This commit is contained in:
11
main.c
11
main.c
@@ -3,6 +3,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "easysock.h"
|
||||
#define PROG_NAME "basicproxy"
|
||||
|
||||
void forward_data(int from_fd, int to_fd) {
|
||||
int n = 0;
|
||||
@@ -24,6 +25,10 @@ int check_ip_ver(char* address) {
|
||||
}
|
||||
|
||||
|
||||
void print_prog_info() {
|
||||
printf("%s - [Local IP address] [local port] [remote IP address] [remote port]\n",PROG_NAME);
|
||||
}
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
|
||||
/* argv[1] = local address
|
||||
@@ -31,6 +36,12 @@ int main(int argc,char* argv[]) {
|
||||
argv[3] = remote address
|
||||
argv[4] = remote port */
|
||||
|
||||
if (argc != 5) {
|
||||
print_prog_info();
|
||||
exit(-30);
|
||||
}
|
||||
|
||||
|
||||
char* local_addr = argv[1];
|
||||
int local_port = strtol(argv[2],NULL,10);
|
||||
char* remote_addr = argv[3];
|
||||
|
Reference in New Issue
Block a user