Commit c9d208e0dee7ed72921bf61db6653524dfe4a5c1
- Diff rendering mode:
- inline
- side by side
main.c
(19 / 5)
|   | |||
| 16 | 16 | ||
| 17 | 17 | #include "waitforsocket.h" | |
| 18 | 18 | ||
| 19 | static requested_socket *reqs; | ||
| 20 | |||
| 19 | 21 | static void | |
| 20 | 22 | usage(const char *name) | |
| 21 | 23 | { | |
| … | … | ||
| 34 | 34 | return buf; | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | static int | ||
| 38 | parse_commands(int argc, char **argv) | ||
| 39 | { | ||
| 40 | int rv = 0; | ||
| 41 | reqs = calloc(argc, sizeof(requested_socket)); | ||
| 42 | |||
| 43 | if(argc < 3) { | ||
| 44 | return -1; | ||
| 45 | } | ||
| 46 | |||
| 47 | reqs[0]=mk_req(argv[1], argv[2]); | ||
| 48 | |||
| 49 | return rv; | ||
| 50 | } | ||
| 51 | |||
| 37 | 52 | int | |
| 38 | 53 | main(int argc, char **argv) | |
| 39 | 54 | { | |
| 40 | 55 | time_t t=0, status; | |
| 41 | requested_socket req; | ||
| 42 | 56 | ||
| 43 | if (argc < 3) { | ||
| 57 | if (parse_commands(argc, argv) < 0) { | ||
| 44 | 58 | usage(argv[0]); | |
| 45 | 59 | exit(0); | |
| 46 | 60 | } | |
| 47 | 61 | ||
| 48 | req = mk_req(argv[1], argv[2]); | ||
| 49 | |||
| 50 | while((status=attemptConnection(&req)) != RV_SUCCESS) { | ||
| 62 | while((status=attemptConnection(&reqs[0])) != RV_SUCCESS) { | ||
| 51 | 63 | t=time(NULL); | |
| 52 | 64 | char *err="unknown"; | |
| 53 | 65 | switch(status) { |

