X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FFortuneServer.c;h=69e3b3413962faf3059c58fe0d1dd91d4f5dde88;hp=5f10062960b8dfddfa5daee88c06add0f5fa7d7d;hb=25f4892b651c913f842f7d3640ae556e960559f0;hpb=6c8d59152cff88b5835eeb749445148bb3546a5b diff --git a/sources/FortuneServer.c b/sources/FortuneServer.c index 5f10062..69e3b34 100644 --- a/sources/FortuneServer.c +++ b/sources/FortuneServer.c @@ -26,7 +26,7 @@ * * Usage: fortuned -h give all info * - * $Id: FortuneServer.c,v 1.3 2002/08/18 23:24:44 piccardi Exp $ + * $Id: FortuneServer.c,v 1.4 2002/08/19 17:34:23 piccardi Exp $ * ****************************************************************/ /* @@ -39,12 +39,15 @@ #include /* standard library */ #include /* ANSI C standard string */ #include /* errorstring */ +#include /* signals */ #include /* */ #include "macros.h" +#include "wrappers.h" /* Subroutines declaration */ void usage(void); +void HandSIGTERM(int signo); int FortuneParse(char *file, char **fortune, int n); /* name of well known fifo */ @@ -53,7 +56,7 @@ int main(int argc, char *argv[]) { /* Variables definition */ int i, n = 0; - char *fortunefilename = "/usr/share/games/fortunes/kids"; + char *fortunefilename = "/usr/share/games/fortunes/italia"; char **fortune; char line[80]; int fifo_server, fifo_client; @@ -94,39 +97,53 @@ int main(int argc, char *argv[]) * Main code beginning * * ***********************************************************/ - Signal(SIGTERM, HandSIGTERM); + if (n==0) usage(); /* if no pool depth exit printing usage info */ + Signal(SIGTERM, HandSIGTERM); /* set handlers for termination */ Signal(SIGINT, HandSIGTERM); Signal(SIGQUIT, HandSIGTERM); - if (n==0) usage(); /* if no pool depth exit printing usage info */ i = FortuneParse(fortunefilename, fortune, n); /* parse phrases */ - for (n=0; n