home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- branch 1.3.1;
- access;
- symbols;
- locks
- simons:1.3.1.9
- andy:1.3; strict;
- comment @ * @;
-
-
- 1.3
- date 92.02.24.12.54.25; author andy; state Exp;
- branches
- 1.3.1.1;
- next ;
-
- 1.3.1.1
- date 93.12.26.00.41.57; author simons; state Exp;
- branches;
- next 1.3.1.2;
-
- 1.3.1.2
- date 93.12.26.18.42.11; author simons; state Exp;
- branches;
- next 1.3.1.3;
-
- 1.3.1.3
- date 93.12.26.19.35.55; author simons; state Exp;
- branches;
- next 1.3.1.4;
-
- 1.3.1.4
- date 93.12.26.21.22.27; author simons; state Exp;
- branches;
- next 1.3.1.5;
-
- 1.3.1.5
- date 93.12.27.17.37.04; author simons; state Exp;
- branches;
- next 1.3.1.6;
-
- 1.3.1.6
- date 93.12.28.17.35.16; author simons; state Exp;
- branches;
- next 1.3.1.7;
-
- 1.3.1.7
- date 93.12.28.22.16.34; author simons; state Exp;
- branches;
- next 1.3.1.8;
-
- 1.3.1.8
- date 93.12.29.06.24.47; author simons; state Exp;
- branches;
- next 1.3.1.9;
-
- 1.3.1.9
- date 93.12.29.06.56.57; author simons; state Exp;
- branches;
- next ;
-
-
- desc
- @Original Unix-Listserv distribution.
- @
-
-
- 1.3
- log
- @checked in with -k by simons at 1993/12/26 00:08:53
- @
- text
- @#include "listserv.h"
-
- static char rcsid[] = "$Header: /usr/local/src/mail/listserv/RCS/listsearch.c,v 1.3 92/02/24 12:54:25 andy Exp Locker: andy $";
-
- extern FILE *msg;
- extern FILE *mailer;
-
- listsearch(from,command)
- char *from,*command;
- {
- FILE *list;
- FILE *listtmp;
- FILE *subslist;
- DIR *listdir;
- struct dirent *entry;
- struct stat statbuf;
- char *s, *p;
- char *template = "/tmp/listservXXXXXX";
- char adr[256];
- char tmp[512];
- char request[256];
- char buf[BUFSIZ];
- int i;
-
- printf("listsearch %s %s \n", from, command);
- i = sscanf(command,"%s%s", request, adr);
- if ((i < 1) || (i > 2))
- sendhelp(from, command);
- if (i == 1)
- strcpy(adr, from);
- cleanup(adr,&i);
- listdir = opendir(SERVDIR);
- if (listdir == NULL)
- {
- perror(SERVDIR);
- exit(1);
- }
- i = mkstemp(template);
- if ( i == -1)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[5] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- else
- {
- subslist = fdopen(i, "w+");
- if (subslist == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[5] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- }
-
- while (entry = readdir(listdir))
- {
- if ((index(entry->d_name, '.'))
- || (isupper(entry->d_name[0])))
- continue;
- sprintf(tmp, "%s/%s", SERVDIR, entry->d_name);
- if (stat(tmp,&statbuf))
- {
- perror(tmp);
- exit(1);
- }
- /*If it's a directory, go to next entry*/
- else if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
- continue;
- /*Skip the restricted access ones*/
- if (access(tmp,R_OK) != 0)
- {
- callmailer(LISTSERVMANAGER, from, "");
- p = rindex(tmp, '/');
- fprintf(mailer,"Unable to access %s\n", p+1);
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- continue;
- }
-
- list = fopen(tmp, "r");
- if (list == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[6] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- flock(fileno(list), LOCK_EX);
- while(fgets(buf, sizeof(buf), list))
- {
- buf[strlen(buf)-1] = '\0';
- if (!strcasecmp(buf, adr))
- {
- fputs(entry->d_name, subslist);
- fputs("\n", subslist);
- }
- }
- fflush(list);
- flock(fileno(list), LOCK_UN);
- fclose(list);
- }
- closedir(listdir);
- if (!strcasecmp(request, "delete-all")
- || !strcasecmp(request, "unsubscribe-all")
- || !strcasecmp(request, "unsub-all")
- || !strcasecmp(request, "del-all"))
- {
- rewind(subslist);
- while(fgets(tmp, sizeof(tmp), subslist))
- {
- strcpy(buf, SERVDIR);
- strcat(buf, "/");
- strcat(buf, tmp);
- buf[strlen(buf) -1] = '\0';
- list = fopen(buf, "r");
- if (list == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer, "Error[7] processing request. Please try later.\n");
- fprintf(mailer, ">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- flock(fileno(list), LOCK_EX);
-
- strcat(buf, ".tmp");
- listtmp = fopen(buf, "w");
- if (listtmp == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[8] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- /* copy the list, omitting the one address */
- while (fgets(tmp, sizeof(tmp), list))
- {
- tmp[strlen(tmp)-1] = '\0';
- if (strcasecmp(tmp, adr))
- {
- fputs(tmp, listtmp);
- fputs("\n", listtmp);
- }
- }
- fflush(listtmp);
- fclose(listtmp);
-
- /* replace the old list with the shortened one */
- strcpy(tmp, buf);
- s = rindex(buf, '.');
- *s = '\0';
- unlink(buf);
- rename(tmp, buf); /* put updated one in place */
- flock(fileno(list), LOCK_UN); /* release lock */
- }
- }
- #ifndef DEBUG
- if (strcmp(from, adr))
- {
- callmailer(adr, from, command);
- fprintf(mailer,"Per request by %s\n", from);
- }
- else
- {
- callmailer("", from, command);
- fprintf(mailer,"Per your request\n");
- }
- #else
- callmailer("", from, command);
- fprintf(mailer,"Per your request\n");
-
- #endif
- fprintf(mailer,"\t\"%s\"\n", command);
- rewind(subslist);
- if ((i = getc(subslist)) == EOF)
- fprintf(mailer, "'%s' is not subscribed to any mailing lists.\n", adr);
- else
- {
- if (strcasecmp(request, "delete-all")
- && strcasecmp(request, "unsubscribe-all")
- && strcasecmp(request, "unsub-all")
- && strcasecmp(request, "del-all"))
- fprintf(mailer,"'%s' is subscribed to the following mailing lists:\n", adr);
- else
- fprintf(mailer,"'%s' was DELETED from the following mailing lists:\n", adr);
- mailcat(template, "\t");
- }
- fflush(mailer);
- pclose(mailer);
- unlink(template);
- fflush(subslist);
- fclose(subslist);
- }
-
-
- @
-
-
- 1.3.1.1
- log
- @Changed source code to compiler under SAS/C 6.50.
- @
- text
- @d1 1
- a1 1
- #include <functions.h>
- d3 1
- a3 2
- #include "listserv.h"
- #include "protos.h"
- d5 2
- a6 1
- static char rcsid[] = "$Id$";
- d8 1
- a8 1
- int listsearch(from,command)
- @
-
-
- 1.3.1.2
- log
- @Changed listsearch() to use a more amiga-specific diretory structure.
- Mailing lists are administrated in a subdirectory of LISTDIR
- (default: "ListSERV:groups/"), with the directoryname reflecting the
- name of the mailing list. The actual addresses are written down in a
- file names 'list'.
- Additionally, optiomized the code a lot. Removed UNIX stuff, etc...
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.1 1993/12/26 00:41:57 simons Exp simons $";
- d16 3
- a18 2
- char *s;
- char *template = tmpnam(NULL);
- d23 1
- a23 1
- int i, found = 0;
- d32 1
- a32 1
- listdir = opendir(LISTDIR);
- d35 1
- a35 1
- perror(LISTDIR);
- d38 2
- a39 1
- if (!(subslist = fopen(template, "w")))
- d48 14
- d64 24
- a87 2
- sprintf(tmp, "%s%s/list", LISTDIR, entry->d_name);
- /* LockFile(tmp); --FIXME */
- d98 1
- a105 1
- found++;
- d109 1
- a109 1
- /* UnLockFile(tmp); --FIXME */
- d122 1
- a169 1
-
- a185 1
-
- d187 2
- a188 4
- fclose(subslist); /* We have to close the file, so mailcat()
- * can access it.
- */
- if (!found)
- d203 1
- a203 1
- remove(template);
- @
-
-
- 1.3.1.3
- log
- @Removed the complete local/non-local user determination, including
- all >outsider< parameters and the cleanup() routine.
- Changed UNIX-paths to conform with AmigaDOS.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.2 1993/12/26 18:42:11 simons Exp simons $";
- d30 1
- a30 1
-
- @
-
-
- 1.3.1.4
- log
- @Added 'DELETE-ALL'-command.
- Added filelocking mechanism.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.3 1993/12/26 19:35:55 simons Exp simons $";
- d16 1
- a16 1
- char adr[256], tmp[512], tmp2[512], request[256], buf[BUFSIZ];
- d18 4
- d37 1
- a37 1
- if (!(subslist = fopen(template, "w+")))
- d49 1
- a49 1
- LockFile(tmp);
- a52 1
- UnLockFile(tmp);
- d71 1
- a71 1
- UnLockFile(tmp);
- d81 1
- a81 1
- while(fgets(buf, sizeof(tmp), subslist))
- d83 2
- d86 1
- a86 3
- sprintf(tmp, "%s%s/LIST", LISTDIR, buf);
- LockFile(tmp);
- list = fopen(tmp, "r");
- a88 1
- UnLockFile(tmp);
- d96 4
- a99 3
- sprintf(tmp2, "%s.tmp", tmp);
- LockFile(tmp2);
- listtmp = fopen(tmp2, "w");
- a101 1
- UnLockFile(tmp2);
- d110 1
- a110 1
- while (fgets(buf, sizeof(buf), list))
- d112 2
- a113 2
- buf[strlen(buf)-1] = '\0';
- if (strcasecmp(buf, adr))
- d115 1
- a115 1
- fputs(buf, listtmp);
- d119 1
- d123 6
- a128 5
- fclose(list);
- remove(tmp);
- rename(tmp2, tmp); /* put updated one in place */
- UnLockFile(tmp);
- UnLockFile(tmp2);
- @
-
-
- 1.3.1.5
- log
- @Changes filenames for the address-list.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.4 1993/12/26 21:22:27 simons Exp simons $";
- d44 1
- a44 1
- sprintf(tmp, "%s%s/List", LISTDIR, entry->d_name);
- d81 1
- a81 1
- sprintf(tmp, "%s%s/List", LISTDIR, buf);
- @
-
-
- 1.3.1.6
- log
- @Now, LISTSERVMANAGER receives a carbon copy of any successful ADD-ALL or
- DELETE-ALL command.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.5 1993/12/27 17:37:04 simons Exp simons $";
- d128 1
- d131 1
- a131 1
- callmailer(LISTSERVMANAGER, adr, command);
- d136 1
- a136 1
- callmailer(LISTSERVMANAGER, from, command);
- d139 3
- d143 2
- d168 1
- @
-
-
- 1.3.1.7
- log
- @Changed function declarations to ANSI-compliant style.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.6 1993/12/28 17:35:16 simons Exp simons $";
- d8 3
- a10 3
- int listsearch(char *from,
- char *command)
- {
- @
-
-
- 1.3.1.8
- log
- @Removed the strange internal string compare routines.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.7 1993/12/28 22:16:34 simons Exp simons $";
- d60 1
- a60 1
- if (!stricmp(buf, adr))
- d72 4
- a75 4
- if (!stricmp(request, "delete-all")
- || !stricmp(request, "unsubscribe-all")
- || !stricmp(request, "unsub-all")
- || !stricmp(request, "del-all"))
- d111 1
- a111 1
- if (stricmp(buf, adr))
- d147 4
- a150 4
- if (stricmp(request, "delete-all")
- && stricmp(request, "unsubscribe-all")
- && stricmp(request, "unsub-all")
- && stricmp(request, "del-all"))
- @
-
-
- 1.3.1.9
- log
- @Changed a string comparison to be case-independent.
- @
- text
- @d6 1
- a6 1
- static char rcsid[] = "$Id: listsearch.c,v 1.3.1.8 1993/12/29 06:24:47 simons Exp simons $";
- d128 1
- a128 1
- if (stricmp(from, adr))
- @
-