Download | Plain Text | No Line Numbers


  1. /*
  2.  * Name: global
  3.  * Author: Manuel Mausz, 0728348
  4.  * Description: Shared definitions and functions for gluefile + insertfile
  5.  * Created: 12.03.2009
  6.  */
  7.  
  8. #ifndef _GLOBAL_H
  9. #define _GLOBAL_H 1
  10.  
  11. /*
  12.  * IPC/msg queue stuff
  13.  */
  14. #include <sys/types.h>
  15. #include <sys/ipc.h>
  16. #include <sys/msg.h>
  17.  
  18. #define IPC_KEY ((key_t) 49583L) /* ipc key */
  19. #define IPC_PERMS 0600 /* permissions */
  20.  
  21. /* message structure for msg queue. struct size shouldn't exceed MSGMAX
  22.  * (default: 8192 byte on Linux. only ~2048 byte on FreeBSD)
  23.  */
  24. typedef struct
  25. {
  26. long mtype; /* message type, must be > 0 */
  27. unsigned int len; /* data length */
  28. char data[256]; /* message data */
  29. } msg_t;
  30.  
  31. #define MSGSIZE (sizeof(msg_t) - sizeof(long))
  32.  
  33. /*
  34.  * Signal stuff
  35.  */
  36. #include <signal.h>
  37.  
  38. /* install signal handler macro */
  39. #define INSTALL_SIGNAL(signum, act, oldact) \
  40.   sigaction(signum, NULL, &oldact); \
  41.   if (oldact.sa_handler != SIG_IGN) \
  42.   sigaction(signum, &act, NULL);
  43.  
  44. /*
  45.  * global.c stuff
  46.  */
  47. #include <stdarg.h>
  48.  
  49. /* function declarations */
  50. void vprintferr(const char *fmt, va_list ap);
  51. void printferr(const char *fmt, ...);
  52. void bailout(const char *fmt, ...);
  53.  
  54. /* global variable definitions */
  55. /* libc manual: Handlers that return normally must modify some global variable
  56.  * in order to have any effect. Typically, the variable is one that is examined
  57.  * periodically by the program during normal operation. Its data type should be
  58.  * sig_atomic_t for reasons described in Atomic Data Access.
  59.  */
  60. extern volatile sig_atomic_t error; /* error flag */
  61. extern char *me; /* name of myself (argv[0]) */
  62.  
  63. #endif /* global.h */
  64.