home *** CD-ROM | disk | FTP | other *** search
- head 1.4;
- branch 1.4.1;
- access;
- symbols;
- locks
- simons:1.4.1.10
- andy:1.4; strict;
- comment @ * @;
-
-
- 1.4
- date 92.09.14.11.04.20; author andy; state Exp;
- branches
- 1.4.1.1;
- next ;
-
- 1.4.1.1
- date 93.12.26.00.42.45; author simons; state Exp;
- branches;
- next 1.4.1.2;
-
- 1.4.1.2
- date 93.12.26.19.35.55; author simons; state Exp;
- branches;
- next 1.4.1.3;
-
- 1.4.1.3
- date 93.12.26.19.56.04; author simons; state Exp;
- branches;
- next 1.4.1.4;
-
- 1.4.1.4
- date 93.12.26.20.26.43; author simons; state Exp;
- branches;
- next 1.4.1.5;
-
- 1.4.1.5
- date 93.12.26.21.22.27; author simons; state Exp;
- branches;
- next 1.4.1.6;
-
- 1.4.1.6
- date 93.12.27.17.37.04; author simons; state Exp;
- branches;
- next 1.4.1.7;
-
- 1.4.1.7
- date 93.12.28.17.24.22; author simons; state Exp;
- branches;
- next 1.4.1.8;
-
- 1.4.1.8
- date 93.12.28.22.16.34; author simons; state Exp;
- branches;
- next 1.4.1.9;
-
- 1.4.1.9
- date 93.12.29.06.24.47; author simons; state Exp;
- branches;
- next 1.4.1.10;
-
- 1.4.1.10
- date 93.12.29.06.56.57; author simons; state Exp;
- branches;
- next ;
-
-
- desc
- @Original Unix-Listserv distribution.
- @
-
-
- 1.4
- 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/subscribe.c,v 1.4 92/09/14 11:04:20 andy Exp Locker: andy $";
-
- extern FILE *msg;
- extern FILE *mailer;
-
- subscription(from,command,add,outsider)
- char *from,*command;
- int add,outsider;
- {
- FILE *list;
- FILE *listtmp;
- char grp[256];
- char adr[256];
- char tmp[256];
- char buf[BUFSIZ];
- int del = 0;
- int i, l;
- int aliasok;
-
- printf("subscription %s %s %d\n", from, command, add);
-
- i = sscanf(command,"%s%s%s", tmp, adr, grp);
- if (i < 2 || i > 3)
- sendhelp(from, command);
- if (i == 2)
- {
- strcpy(grp, adr);
- strcpy(adr, from);
- }
-
- cleanup(grp,&i);
- cleanup(adr,&outsider);
-
- if (strcasecmp(grp, adr) == 0)
- {
- callmailer("", from, "");
- fprintf(mailer,"Subscription address loop: %s\n", adr);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
-
- if (outsider)
- sprintf(tmp,"%s/%s.pub", SERVDIR, grp);
- else
- sprintf(tmp,"%s/%s.info", SERVDIR, grp);
- if (access(tmp,R_OK) != 0)
- {
- callmailer("", from, "");
- fprintf(mailer,"The mailing list \"%s\" could not be found.\n",
- grp);
- fprintf(mailer,"You may use the INDEX command to get a listing\n");
- fprintf(mailer,"of available mailing lists.\n");
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
-
- strcpy(tmp, SERVDIR);
- strcat(tmp, "/");
- strcat(tmp, grp);
- if (add)
- {
- l = open(tmp, AFLAGS, AMODE);
- if (l == -1)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[1] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- else
- {
- list = fdopen(l, "a");
- if (list == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[1] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- }
- flock(l, LOCK_EX);
- fprintf(list, "%s\n", adr);
- fflush(list);
- flock(l, LOCK_UN);
- close(l);
- }
- else
- {
- del = 0;
- list = fopen(tmp, "r");
- if (list == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[2] processing request. Please try later.\n");
- fprintf(mailer,">%s\n", command);
- fflush(mailer);
- pclose(mailer);
- return(-1);
- }
- flock(fileno(list), LOCK_EX);
-
- strcpy(tmp, SERVDIR);
- strcat(tmp, "/");
- strcat(tmp, grp);
- strcat(tmp, ".tmp");
- listtmp = fopen(tmp, "w");
- if (listtmp == NULL)
- {
- callmailer(LISTSERVMANAGER, from, "");
- fprintf(mailer,"Error[3] 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(buf, sizeof(buf), list))
- {
- buf[strlen(buf)-1] = '\0';
- if (strcasecmp(buf, adr))
- {
- fputs(buf, listtmp);
- fputs("\n", listtmp);
- }
- else
- del++;
- }
- fflush(listtmp);
- fclose(listtmp);
-
- /* replace the old list with the shortened one */
- strcpy(buf, SERVDIR);
- strcat(buf, "/");
- strcat(buf, grp);
- unlink(buf); /* delete original file */
- 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);
- /* Mail subscription confirmation and info/intro files.*/
- if (add)
- {
- fprintf(mailer,"'%s' was ADDED to the '%s' mailing list.\n",
- adr, grp);
- fflush(mailer);
- pclose(mailer);
-
- sprintf(tmp, "%s/%s.intro", SERVDIR,grp);
- if (access(tmp,R_OK) == 0)
- {
- #ifndef DEBUG
- callmailer("", adr, command);
- #else
- callmailer("", from, command);
- #endif
- mailcat(tmp, "");
- sprintf(tmp, "%s/%s.faq", SERVDIR, grp);
- if(access(tmp,R_OK) == 0)
- mailcat(tmp,"\n\n");
- fflush(mailer);
- pclose(mailer);
- }
- }
-
- else
- if (del)
- {
- fprintf(mailer,
- "'%s' was DELETED from the '%s' mailing list.\n",
- adr, grp);
- fprintf(mailer,
- "\nAlthough you have been deleted from the list,");
- fprintf(mailer,
- " some mail sent previous to your deletion may be\n");
- fprintf(mailer,
- "queued in the system. Please don't panic if you");
- fprintf(mailer,
- " receive a few last pieces of mail.\n");
- fflush(mailer);
- pclose(mailer);
- }
- else
- {
- fprintf(mailer,
- "'%s' was NOT FOUND on the '%s' mailing list.\n",
- adr, grp);
- fflush(mailer);
- pclose(mailer);
- }
-
- }
- @
-
-
- 1.4.1.1
- log
- @Changed source code to compiler under SAS/C 6.50.
- @
- text
- @a1 1
- #include "protos.h"
- d3 1
- a3 1
- static char rcsid[] = "$Id$";
- d5 4
- a8 1
- int subscription(from,command,add,outsider)
- @
-
-
- 1.4.1.2
- 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
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.1 1993/12/26 00:42:45 simons Exp simons $";
- d6 1
- a6 1
- int subscription(from,command,add)
- d8 1
- a8 1
- int add;
- d31 3
- d43 4
- a46 1
- sprintf(tmp,"%s%s.pub", SERVDIR, grp);
- d60 1
- d109 1
- d139 1
- d170 1
- a170 1
- sprintf(tmp, "%s%s.intro", SERVDIR,grp);
- d179 1
- a179 1
- sprintf(tmp, "%s%s.faq", SERVDIR, grp);
- @
-
-
- 1.4.1.3
- log
- @Fixed the 'ADD'-command. Currently, it's not detected when somebody
- adds his address several times to the same list.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.2 1993/12/26 19:35:55 simons Exp simons $";
- d17 2
- a18 1
- int i;
- d31 1
- a31 1
- if (!strcasecmp(grp, adr))
- d40 2
- a41 2
- sprintf(tmp,"%s%s/LIST", LISTDIR, grp);
- if (access(tmp,R_OK))
- d53 2
- d57 2
- a58 1
- if (!(list = fopen(tmp, "a")))
- d67 14
- a80 1
- /* FileLock(tmp) ---FIXME */
- d82 3
- a84 2
- fclose(list);
- /* UnFileLock(tmp) ---FIXME */
- @
-
-
- 1.4.1.4
- log
- @Corrected the routine handling 'DELETE'-commands.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.3 1993/12/26 19:56:04 simons Exp simons $";
- d12 4
- a15 1
- char grp[256], adr[256], tmp[256], tmp2[256], buf[BUFSIZ];
- a53 1
- /* FileLock(tmp) ---FIXME */
- d63 1
- d71 2
- a72 2
- /* FileLock(tmp) ---FIXME */
- if (!(list = fopen(tmp, "r")))
- d81 1
- d83 5
- a87 2
- sprintf(tmp2, "%s.tmp", tmp);
- if (!(listtmp = fopen(tmp2, "w")))
- d108 1
- d110 1
- a110 1
- fclose(list);
- d112 5
- a116 4
-
- remove(tmp); /* delete original file */
- rename(tmp2, tmp); /* put updated one in place */
- /* UnFileLock(tmp); ---FIXME */
- @
-
-
- 1.4.1.5
- log
- @Added filelocking mechanism.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.4 1993/12/26 20:26:43 simons Exp simons $";
- d51 1
- a51 1
- LockFile(tmp);
- d63 1
- a63 1
- UnLockFile(tmp);
- d68 1
- a68 1
- LockFile(tmp);
- a79 1
- LockFile(tmp2);
- d107 1
- a107 2
- UnLockFile(tmp);
- UnLockFile(tmp2);
- @
-
-
- 1.4.1.6
- log
- @Changes filenames for the address-list.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.5 1993/12/26 21:22:27 simons Exp simons $";
- d36 1
- a36 1
- sprintf(tmp,"%s%s/List", LISTDIR, grp);
- @
-
-
- 1.4.1.7
- log
- @Improved file-locking.
- Notification about un-/subscription is now directed to the address that
- is changed, not the the from line.
- LISTSERVMANAGER receives a carbon copy of any list-change.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.6 1993/12/27 17:37:04 simons Exp simons $";
- d29 1
- a29 1
- callmailer(LISTSERVMANAGER, from, "");
- a36 1
- LockFile(tmp);
- a38 1
- UnLockFile(tmp);
- d51 1
- a53 1
- UnLockFile(tmp);
- d68 1
- a70 1
- UnLockFile(tmp);
- d111 1
- a111 4
-
-
- /* Mail subscription confirmation and introduction files.*/
-
- d114 2
- a115 2
- callmailer(LISTSERVMANAGER, adr, command);
- fprintf(mailer, "Per request by %s\n", from);
- d119 1
- a119 1
- callmailer(LISTSERVMANAGER, from, command);
- d122 4
- d128 1
- a128 1
-
- d136 15
- a150 3
- /* mail introduction file --TODO
- */
-
- @
-
-
- 1.4.1.8
- log
- @Changed function declarations to ANSI-compliant style.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.7 1993/12/28 17:24:22 simons Exp simons $";
- d6 4
- a9 4
- int subscription(char *from,
- char *command,
- int add)
- {
- @
-
-
- 1.4.1.9
- log
- @Removed the strange internal string compare routines.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.8 1993/12/28 22:16:34 simons Exp simons $";
- d27 1
- a27 1
- if (!stricmp(grp, adr))
- d96 1
- a96 1
- if (stricmp(buf, adr))
- @
-
-
- 1.4.1.10
- log
- @Changed a string comparison to be case-independent.
- @
- text
- @d4 1
- a4 1
- static char rcsid[] = "$Id: subscribe.c,v 1.4.1.9 1993/12/29 06:24:47 simons Exp simons $";
- d117 1
- a117 1
- if (stricmp(from, adr))
- @
-