forked from ROMEO/fsw-ws
70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
#include <errno.h>
|
|
#include <getopt.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <hardware/interfaces.h>
|
|
|
|
const char *sim_ip = "localhost";
|
|
int ai_family = AF_UNSPEC;
|
|
|
|
void mission(void);
|
|
|
|
void done() { exit(0); }
|
|
|
|
void done_error() { exit(1); }
|
|
|
|
int test_socket();
|
|
|
|
// TODO link to GCC's personality or make the linux build not use it?
|
|
// -> linux build is std at the moment, only used for tests
|
|
#ifdef LOW_LEVEL_TESTS
|
|
void rust_eh_personality() { puts("eh_personality"); }
|
|
#endif
|
|
|
|
void print_usage(const char *name) {
|
|
fprintf(stderr, "Usage: %s [-s sim_ip] [-4|6]\n", name);
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
hw_device_open(
|
|
"invalidpath",
|
|
11); // TODO for some weird linker behaviour, if this function is not used
|
|
// here, it will not be found by the linker when linking the rust lib
|
|
static struct option long_options[] = {
|
|
/* NAME ARGUMENT FLAG SHORTNAME */
|
|
{"sim_ip", required_argument, NULL, 's'},
|
|
{"help", no_argument, NULL, 'h'},
|
|
{NULL, 0, NULL, 0}};
|
|
int c;
|
|
int option_index = 0;
|
|
while ((c = getopt_long(argc, argv, "46hs:", long_options, &option_index)) !=
|
|
-1) {
|
|
switch (c) {
|
|
case 's':
|
|
if (optarg != NULL) {
|
|
sim_ip = optarg;
|
|
break;
|
|
case '4':
|
|
ai_family = AF_INET;
|
|
break;
|
|
case '6':
|
|
ai_family = AF_INET6;
|
|
break;
|
|
default:
|
|
print_usage(argv[0]);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
}
|
|
|
|
mission();
|
|
return 0;
|
|
}
|