X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FFortuneServer.c;h=c1c11462e81065e8d6c81fba04aef4ce35641310;hp=5f10062960b8dfddfa5daee88c06add0f5fa7d7d;hb=684f52a149bb07baec157b7f203af37444a708a1;hpb=6c8d59152cff88b5835eeb749445148bb3546a5b diff --git a/sources/FortuneServer.c b/sources/FortuneServer.c index 5f10062..c1c1146 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.8 2003/05/02 09:55:13 piccardi Exp $ * ****************************************************************/ /* @@ -39,12 +39,15 @@ #include /* standard library */ #include /* ANSI C standard string */ #include /* errorstring */ +#include /* signals */ #include /* */ #include "macros.h" +#include "Gapil.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/linux"; char **fortune; char line[80]; int fifo_server, fifo_client; @@ -94,39 +97,54 @@ 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