diff --git a/common.h b/common.h new file mode 100644 index 0000000..1d2228a --- /dev/null +++ b/common.h @@ -0,0 +1,40 @@ +/** + * @file common.h + * @date 2018-05-21 + * + * @brief Header file for common includes and constants as well as data structures. + */ + +// guard block +#ifndef COMMON_H +#define COMMON_H + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define SHM_NAME "/01527193" + +#define PERMISSION (0600) + +#define SEM_FREE_SPACE "/sem_free_space_01527193" +#define SEM_USED_SPACE "/sem_used_space_01527193" +#define SEM_WRITE_END "/sem_write_end_01527193" + +struct circ_buf { + int id; +}; + +#endif /* ifndef COMMON_H */ diff --git a/generator.c b/generator.c index e69de29..00ccb92 100644 --- a/generator.c +++ b/generator.c @@ -0,0 +1,46 @@ +/** + * @file generator.c + * @date 2018-05-21 + * + * @brief Client program which generates solutions and submits them. + */ + +#include "common.h" + +static const char *pname; + +struct sigaction sa; + +static volatile sig_atomic_t quit = 0; + +static void sig_handler(int signum) +{ + quit = 1; +} + +void usage(void) +{ + fprintf(stderr, "SYNOPSIS\n" + "\tgenerator EDGE1...\n" + "EXAMPLE\n" + "\tgenerator 0-1 1-2 1-3 1-4 2-4 3-6 4-3 4-5 6-0\n"); + exit(EXIT_FAILURE); +} + +int main(int argc, char *argv[]) +{ + if (argc == 1) + usage(); + + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = &sig_handler; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + while (quit == 0) { + + } + + return 0; +} diff --git a/supervisor.c b/supervisor.c index e69de29..6edc971 100644 --- a/supervisor.c +++ b/supervisor.c @@ -0,0 +1,44 @@ +/** + * @file supervisor.c + * @date 2018-05-21 + * + * @brief Server program which reads solutions and orders them. + */ + +#include "common.h" + +static const char *pname; + +struct sigaction sa; + +static volatile sig_atomic_t quit = 0; + +static void sig_handler(int signum) +{ + quit = 1; +} + +void usage(void) +{ + fprintf(stderr, "SYNOPSIS\n" + "\tsupervisor\n"); + exit(EXIT_FAILURE); +} + +int main(int argc, char *argv[]) +{ + if (argc != 1) + usage(); + + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = &sig_handler; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + while (quit == 0) { + + } + + return 0; +}