head 1.3; access; symbols PETIDOMO_4_0b6:1.3 PETIDOMO_4_0b5:1.3 PETIDOMO_4_0b4:1.3 PETIDOMO_4_0b3:1.3 BEFORETHL:1.3; locks; strict; comment @ * @; 1.3 date 2001.01.19.14.56.33; author rse; state Exp; branches; next 1.2; 1.2 date 2001.01.18.20.30.50; author rse; state Exp; branches; next 1.1; 1.1 date 2001.01.16.11.33.36; author simons; state Exp; branches; next ; desc @@ 1.3 log @Get rid of all complaints from GCC 2.97 (except for two things which I do not want to change on my own) @ text @/* $Source: /e/ossp/cvs/ossp-pkg/petidomo/address-db.c,v $ $Revision: 1.2 $ Copyright (C) 2000 by Peter Simons This file is part of Petidomo. Petidomo 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, or (at your option) any later version. Petidomo 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. */ #include #include #include #include "libtext/text.h" #include "petidomo.h" /* * rc == 0: Address is not on list. * rc == -1: Error occured while reading the file. * rc == 1: Address is on list. */ int is_address_on_list(const char* file, const char* address) { char * list; char * p; unsigned int len; int rc; list = loadfile(file); if (list == NULL) { if (errno == ENOENT) return 0; else return -1; } for (len = strlen(address), p = list; *p != '\0'; p = text_find_next_line(p)) { if (strncasecmp(p, address, len) == 0 && (p == list || p[-1] == '\n') && (isspace((int)p[len]) || p[len] == '\0')) { break; } } rc = ((*p != '\0') ? 1 : 0); free(list); return rc; } int add_address(const char* file, const char* address) { FILE* fh; int rc = is_address_on_list(file, address); if (rc != 0) return rc; fh = fopen(file, "a"); if (fh == NULL) { syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %s", file, strerror(errno)); return -1; } fprintf(fh, "%s\n", address); fclose(fh); return 0; } @ 1.2 log @As we agreed today, Petidomo is now open because licensed under GPL and always will be licensed under GPL, so use "Petidomo" as the program name everywhere and consistently. @ text @d3 1 a3 1 $Revision: 1.1 $ d72 1 a72 1 syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %m", file); @ 1.1 log @Implemented the acked-once feature. @ text @d2 2 a3 2 $Source: /d1/e/petidomo/cvs/petidomo/source/subscribe.c,v $ $Revision: 1.12 $ d7 1 a7 1 This file is part of OpenPetidomo. d9 1 a9 1 OpenPetidomo is free software; you can redistribute it and/or modify d14 1 a14 1 OpenPetidomo is distributed in the hope that it will be useful, but @