From b11ae5cf86000bfce35b6ec511014d8f6b04416e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Oct 2020 22:55:18 +0000 Subject: add keypad --- net_keypad.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 net_keypad.c (limited to 'net_keypad.c') diff --git a/net_keypad.c b/net_keypad.c new file mode 100644 index 0000000..9169b80 --- /dev/null +++ b/net_keypad.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include +#include "util.h" +#include "keypad.h" + + + + +static int usage (const char *name) +{ + fprintf (stderr, "Usage:\n"); + fprintf (stderr, "%s -h host [-p port]\n", name); + fprintf (stderr, "\n"); + + return -1; +} + + +int main (int argc, char *argv[]) +{ + unsigned opt; + const char *host = NULL; + unsigned port = 10001; + int fd; + + while ((opt = getopt (argc, argv, "h:p:z:USPRBFTAD")) != -1) { + switch (opt) { + case 'h': + host = optarg; + break; + + case 'p': + port = atoi (optarg); + break; + + default: /* '?' */ + return usage (argv[0]); + } + } + + if (!host) return (usage (argv[0])); + + fd = open_tcp_client (host, port); + + if (fd < 0) { + perror ("open tcp port"); + return -1; + } + + return gd_keypad (fd); +} -- cgit v1.2.3