From ce3357fc9151e7b4f0d233b4accf6c7a780327d6 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 27 Jun 2018 20:51:32 +1200 Subject: Begin server refactor, remove hard-coded sockets --- alarm-tools/alarms-show.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'alarm-tools/alarms-show.c') diff --git a/alarm-tools/alarms-show.c b/alarm-tools/alarms-show.c index 7613489..3af493d 100644 --- a/alarm-tools/alarms-show.c +++ b/alarm-tools/alarms-show.c @@ -67,19 +67,23 @@ int dump_alarms(int sock) return 0; } -int main(void) +int main(int argc, char **argv) { int sock = 0; - char buffer[128]; struct sockaddr_un server; + if (argc != 2) { + fprintf(stderr, "Syntax: %s socket_name\n", argv[0]); + return 1; + } + if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { perror("socket"); return 1; } server.sun_family = AF_UNIX; - strcpy(server.sun_path, "/home/david/alarmd_sock"); + strcpy(server.sun_path, argv[1]); printf("Connecting...\n"); if (connect(sock, (struct sockaddr *)&server, strlen(server.sun_path) + sizeof(server.sun_family)) < 0) { close(sock); -- cgit v1.1