Boilerplate
This commit is contained in:
parent
3c15d3c9a8
commit
803888fbd0
40
common.h
Normal file
40
common.h
Normal file
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <semaphore.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#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 */
|
||||||
46
generator.c
46
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;
|
||||||
|
}
|
||||||
44
supervisor.c
44
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;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user