X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FFortuneParse.c;fp=sources%2FFortuneParse.c;h=0000000000000000000000000000000000000000;hp=c81c7e828a2e192f4a9fe12efb3db0076e784f3f;hb=d12bc3e1e4b3ee762036d1c226c3b2ba1a720fb9;hpb=e3e15ed6d698e5cc35f3b7f4c5db96adc38255c3 diff --git a/sources/FortuneParse.c b/sources/FortuneParse.c deleted file mode 100644 index c81c7e8..0000000 --- a/sources/FortuneParse.c +++ /dev/null @@ -1,88 +0,0 @@ -/* FortuneParse.c - * - * Copyright (C) 2002 Simone Piccardi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -/**************************************************************** - * - * Routine FortuneParse - * parse fortunes from a fortune file - * - * Author: Simone Piccardi - * Aug. 2002 - * - * Usage: int FortuneParse(char *file, char ** fortune, int n); - * Read n fortunes from fortune file file, and put it into the - * string array fortune - * - * $Id: FortuneParse.c,v 1.3 2003/01/12 16:10:07 piccardi Exp $ - * - ****************************************************************/ -/* - * Include needed headers - */ -#include /* predefined types */ -#include /* */ -#include /* include unix standard library */ -#include /* include standard I/O library */ -#include /* standard library */ -#include /* ANSI C standard string */ -#include /* error definitions */ -#include /* */ - -#include "macros.h" - -/* Subroutines declaration */ -extern void usage(void); - -int FortuneParse(char *file, char **fortune, int n) -{ -/* Variables definition */ - FILE *fortunefile; - char line[80]; - int i, len; - /* - * fortune file scanning, read string in memory - */ - fortunefile = fopen(file,"r"); - if (fortunefile == NULL) { /* on open error exit */ - printf("On file %s\n", file); - perror("Cannot open file"); - exit(-1); - } - i = 0; - do { - if (!fgets(line, 80, fortunefile)) { - if (feof(fortunefile)) break; - perror("Read error"); - exit(-1); - } - debug("i=%d, line=%s", i, line); - if (line[0]=='%') { - if (fortune[i]!=NULL) i++; - continue; - } - len = strlen(line) + 1; - if (fortune[i]==NULL) { - fortune[i] = malloc(len); - strncpy(fortune[i], line, len); - } else { - fortune[i] = realloc(fortune[i], strlen(fortune[i])+len+1); - strncat(fortune[i], line, len); - } - } while (i