*
* Usage: fortuned -h give all info
*
- * $Id: MQFortuneServer.c,v 1.3 2002/12/03 11:06:05 piccardi Exp $
- *
****************************************************************/
/*
* Include needed headers
*/
-#include <sys/types.h> /* predefined types */
-#include <sys/stat.h> /* */
-#include <unistd.h> /* include unix standard library */
-#include <stdio.h> /* include standard I/O library */
-#include <stdlib.h> /* standard library */
-#include <string.h> /* ANSI C standard string */
-#include <errno.h> /* errorstring */
-#include <signal.h> /* signals */
-#include <sys/ipc.h>
-#include <sys/msg.h>
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <unistd.h> /* unix standard library */
+#include <stdio.h> /* standard I/O library */
+#include <stdlib.h> /* C standard library */
+#include <string.h> /* C strings library */
+#include <errno.h> /* error definitions and routines */
+#include <signal.h> /* signal constants, types and functions */
+#include <sys/ipc.h> /* SysV IPC functions */
+#include <sys/msg.h> /* SysV message queues */
#include "macros.h"
#include "Gapil.h"
/* Variables definition */
int i, n = 0;
char **fortune; /* array of fortune message string */
- char *fortunefilename; /* fortune file name */
+ char *fortunefilename = "/usr/share/games/fortunes/linux"; /* file name */
struct msgbuf_read { /* message struct to read request from clients */
long mtype; /* message type, must be 1 */
long pid; /* message data, must be the pid of the client */
}
/* Main body: loop over requests */
+ daemon(0, 0);
while (1) {
msgrcv(msgid, &msg_read, sizeof(int), 1, MSG_NOERROR);
debug("received request from %d\n", msg_read.pid);