From 17a61e200f40ff3390d78645f3bdda62a09042ce Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Tue, 25 Apr 2023 13:40:09 +0200 Subject: seitan: use functions from util.h --- Makefile | 2 +- seitan.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2798a14..b7e2205 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ export OUTDIR COMMON_DIR := $(DIR)/common BIN := $(OUTDIR)seitan -SRCS := seitan.c $(COMMON_DIR)/common.c operations.c +SRCS := seitan.c $(COMMON_DIR)/common.c $(COMMON_DIR)/util.c operations.c HEADERS := $(COMMON_DIR)/common.h $(COMMON_DIR)/gluten.h \ $(COMMON_DIR)/numbers.h $(COMMON_DIR)/util.h operations.h diff --git a/seitan.c b/seitan.c index 100f72d..e2e5347 100644 --- a/seitan.c +++ b/seitan.c @@ -71,7 +71,7 @@ static void parse(int argc, char **argv, struct arguments *arguments) int option_index = 0; int oc; if (arguments == NULL) - fprintf(stderr, "Empty args\n"); + usage(); while ((oc = getopt_long(argc, argv, ":i:o:p:s:", options, &option_index)) != -1) { switch (oc) { @@ -89,12 +89,15 @@ static void parse(int argc, char **argv, struct arguments *arguments) } } if (arguments->input_file == NULL) { - fprintf(stderr, "missing input file\n"); + err("missing input file"); usage(); } if (arguments->socket != NULL && arguments->pid > 0) { - fprintf(stderr, - "the socket and pid options cannot be used together\n"); + err("the socket and pid options cannot be used together"); + usage(); + } + if (arguments->socket == NULL && arguments->pid < 0) { + err("select one of the options between socket and pid"); usage(); } } @@ -211,8 +214,6 @@ int main(int argc, char **argv) die(" creating the socket"); if ((notifier = recvfd(fd)) < 0) die(" failed recieving the notifier fd"); - } else { - die(" select between pid and socket option"); } sleep(1); -- cgit v1.2.3