/* Progam by PJ Waskiewicz.
 *
 * IPC which has been added: FIFO's, and semaphores.
 *
 * The program should take in a date, and then sleep for
 * the correct amount of time, and then print a message.
 * The program should be allowed to be woken up however,
 * by another instance of it.
 *
 * A race condition had been found in version 0.90.
 * Semaphores were being added in that version to try to
 * prevent it.  Success.
 *
 * Ver 0.93 - Child processes can now be found by traversing /proc.
 *
 * Ver 0.94 - FIFO's are now being used to read and write data.
 *
 * Ver 0.95 - The program has now been modularized.
 *
 * Ver 0.96 - A signal handler has been added.
 *
 * Ver 0.97 - The program has been split into an X and no-X version.
 *
 * Ver 0.98 - Garbage has been entering the FIFO.  Garbage has been flushed.
 *
 * Version: 0.98
 * Date:    12/07/99
 *
 */

#ifndef __HEADERS_H__
#define __HEADERS_H__

#define MY_MAX 256
#define SEM_PERM 0600
#define MINE "Copyright 1999 PJ Waskiewicz"
#define VER "0.98"

#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */
union semun {
  int val;                    /* value for SETVAL */
  struct semid_ds *buf;       /* buffer for IPC_STAT, IPC_SET */
  unsigned short int *array;  /* array for GETALL, SETALL */
  struct seminfo *__buf;      /* buffer for IPC_INFO */
};
#endif

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
#include <signal.h>

/* Parser for our date */
void parser(char *, struct tm *);

/* Finds the daemon if it is running */
pid_t find_child();

/* Client code */
void client(int, int);

/* User-defined signal handler */
void new_handler(int);

#endif