Download | Plain Text | No Line Numbers


  1. /*
  2.  * Name: global
  3.  * Author: Manuel Mausz, 0728348
  4.  * Description: Shared definitions and functions
  5.  * Created: 24.04.2009
  6.  */
  7.  
  8. #ifndef _GLOBAL_H
  9. #define _GLOBAL_H 1
  10.  
  11. /*
  12.  * IPC/shared memory stuff
  13.  */
  14. #include <sys/types.h>
  15. #include <sys/ipc.h>
  16. #include <sys/shm.h>
  17. #include <sem182.h>
  18.  
  19. #define SHM_KEY ((key_t) 49583L) /* shared memory key */
  20. #define SHM_PERMS 0600 /* permissions */
  21.  
  22. /* shared memory structure */
  23. #define MAX_LEN 512 /* maximal log message length */
  24. typedef struct
  25. {
  26. char msg[MAX_LEN];
  27. } shm_t;
  28.  
  29. /*
  30.  * Semaphore stuff
  31.  */
  32. #define SEM_KEY1 ((key_t) 49584L) /* semaphore key 1 */
  33. #define SEM_KEY2 ((key_t) 49585L) /* semaphore key 2 */
  34. #define SEM_PERMS 0600
  35.  
  36. /*
  37.  * Signal stuff
  38.  */
  39. #include <signal.h>
  40.  
  41. /* install signal handler macro */
  42. #define INSTALL_SIGNAL(signum, act, oldact) \
  43.   sigaction(signum, NULL, &oldact); \
  44.   if (oldact.sa_handler != SIG_IGN) \
  45.   sigaction(signum, &act, NULL);
  46.  
  47. /*
  48.  * global.c stuff
  49.  */
  50. #include <stdarg.h>
  51.  
  52. /* function declarations */
  53. void vprintferr(const char *fmt, va_list ap);
  54. void printferr(const char *fmt, ...);
  55. void bailout(const char *fmt, ...);
  56.  
  57. /* global variable definitions */
  58. /* libc manual: Handlers that return normally must modify some global variable
  59.  * in order to have any effect. Typically, the variable is one that is examined
  60.  * periodically by the program during normal operation. Its data type should be
  61.  * sig_atomic_t for reasons described in Atomic Data Access.
  62.  */
  63. extern volatile sig_atomic_t error; /* error flag */
  64. extern char *me; /* name of myself (argv[0]) */
  65.  
  66. #endif /* global.h */
  67.