#include "msgbase.h"
#include "support.h"
#include "sysdep_decls.h"
+#include "citserver.h"
#include "room_ops.h"
#include "user_ops.h"
#include "file_ops.h"
#define MSGS_LAST 4
#define MSGS_GT 5
+#define desired_section ((char *)CtdlGetUserData(SYM_DESIRED_SECTION))
+
extern struct config config;
lprintf(9, "alias() called for <%s>\n", name);
remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
-
+
fp=fopen("network/mail.aliases","r");
if (fp==NULL) fp=fopen("/dev/null","r");
- if (fp==NULL) return(M_ERROR);
-GNA: strcpy(aaa,""); strcpy(bbb,"");
- do {
- a=getc(fp);
- if (a==',') a=0;
- if (a>0) {
- b=strlen(aaa);
- aaa[b]=a;
- aaa[b+1]=0;
- }
- } while(a>0);
- do {
- a=getc(fp);
- if (a==10) a=0;
- if (a>0) {
- b=strlen(bbb);
- bbb[b]=a;
- bbb[b+1]=0;
+ if (fp==NULL) return(MES_ERROR);
+ strcpy(aaa,""); strcpy(bbb,"");
+ while (fgets(aaa, sizeof aaa, fp)!=NULL) {
+ while (isspace(name[0])) strcpy(name, &name[1]);
+ aaa[strlen(aaa)-1] = 0;
+ strcpy(bbb, "");
+ for (a=0; a<strlen(aaa); ++a) {
+ if (aaa[a] == ',') {
+ strcpy(bbb, &aaa[a+1]);
+ aaa[a] = 0;
+ }
}
- } while(a>0);
- if (a<0) {
- fclose(fp);
- goto DETYPE;
+ if (!strcasecmp(name, aaa)) strcpy(name, bbb);
}
- if (strcasecmp(name,aaa)) goto GNA;
fclose(fp);
- strcpy(name,bbb);
lprintf(7, "Mail is being forwarded to %s\n", name);
-DETYPE: /* determine local or remote type, see citadel.h */
- for (a=0; a<strlen(name); ++a) if (name[a]=='!') return(M_INTERNET);
+ /* determine local or remote type, see citadel.h */
+ for (a=0; a<strlen(name); ++a) if (name[a]=='!') return(MES_INTERNET);
for (a=0; a<strlen(name); ++a)
if (name[a]=='@')
for (b=a; b<strlen(name); ++b)
- if (name[b]=='.') return(M_INTERNET);
+ if (name[b]=='.') return(MES_INTERNET);
b=0; for (a=0; a<strlen(name); ++a) if (name[a]=='@') ++b;
if (b>1) {
lprintf(7, "Too many @'s in address\n");
- return(M_ERROR);
+ return(MES_ERROR);
}
if (b==1) {
for (a=0; a<strlen(name); ++a)
if (name[a]=='@') strcpy(bbb,&name[a+1]);
while (bbb[0]==32) strcpy(bbb,&bbb[1]);
fp = fopen("network/mail.sysinfo","r");
- if (fp==NULL) return(M_ERROR);
+ if (fp==NULL) return(MES_ERROR);
GETSN: do {
a=getstring(fp,aaa);
} while ((a>=0)&&(strcasecmp(aaa,bbb)));
}
while(bbb[strlen(bbb)-1]=='_') bbb[strlen(bbb)-1]=0;
sprintf(name,&aaa[4],bbb);
- return(M_INTERNET);
+ return(MES_INTERNET);
}
if (!strncmp(aaa,"bin",3)) {
strcpy(aaa,name); strcpy(bbb,name);
strcpy(bbb,&bbb[1]);
while (bbb[0]==' ') strcpy(bbb,&bbb[1]);
sprintf(name,"%s @%s",aaa,bbb);
- return(M_BINARY);
+ return(MES_BINARY);
}
- return(M_ERROR);
+ return(MES_ERROR);
}
- return(M_LOCAL);
+ return(MES_LOCAL);
}
}
goto FMTA;
-FMTEND: cprintf("\n");
+FMTEND: cprintf("%s\n", aaa);
}
if (CC->download_fp != NULL) return;
/* ...or if this is not the desired section */
- if (strcasecmp(CC->desired_section, partnum)) return;
+ if (strcasecmp(desired_section, partnum)) return;
snprintf(tmpname, sizeof tmpname,
"/tmp/CitServer.download.%4x.%4x", getpid(), ++seq);
if (CC->download_fp == NULL) {
cprintf("%d Section %s not found.\n",
ERROR+FILE_NOT_FOUND,
- CC->desired_section);
+ desired_section);
}
}
cdb_free(dmsgtext);
{
char msgid[256];
+ CtdlAllocUserData(SYM_DESIRED_SECTION, 64);
+
extract(msgid, cmdbuf, 0);
- extract(CC->desired_section, cmdbuf, 1);
+ extract(desired_section, cmdbuf, 1);
output_message(msgid, MT_DOWNLOAD, 0);
}
static int seqnum = 0;
lprintf(9, "save_message(%s,%s,%s,%d,%d)\n",
- mtmp, rec, force_room, mailtype, generate_id);
+ mtmp, rec, force, mailtype, generate_id);
strcpy(force_room, force);
/* ...or if this is a private message, go to the target mailbox. */
lprintf(9, "mailbox aliasing loop\n");
-lprintf(9, "1\n");
if (strlen(recipient) > 0) {
-lprintf(9, "2\n");
/* mailtype = alias(recipient); */
- if (mailtype == M_LOCAL) {
-lprintf(9, "3\n");
+ if (mailtype == MES_LOCAL) {
if (getuser(&userbuf, recipient)!=0) {
/* User not found, goto Aide */
-lprintf(9, "4\n");
strcpy(force_room, AIDEROOM);
}
else {
-lprintf(9, "5\n");
strcpy(hold_rm, actual_rm);
-lprintf(9, "6\n");
MailboxName(actual_rm, &userbuf, MAILROOM);
}
}
lputroom(&CC->quickroom, actual_rm);
/* Network mail - send a copy to the network program. */
- if ( (strlen(recipient)>0) && (mailtype != M_LOCAL) ) {
+ if ( (strlen(recipient)>0) && (mailtype != MES_LOCAL) ) {
sprintf(aaa,"./network/spoolin/netmail.%04lx.%04x.%04x",
(long)getpid(), CC->cs_pid, ++seqnum);
copy_file(mtmp,aaa);
fp=fopen(CC->temp,"wb");
fprintf(fp,"%c%c%c",255,MES_NORMAL,0);
fprintf(fp,"Psysop%c",0);
- fprintf(fp,"T%ld%c", time(NULL), 0);
+ fprintf(fp,"T%ld%c", (long)time(NULL), 0);
fprintf(fp,"ACitadel%c",0);
fprintf(fp,"OAide%c",0);
fprintf(fp,"N%s%c",NODENAME,0);
fprintf(fp,"M%s\n%c",text,0);
fclose(fp);
- save_message(CC->temp,"",AIDEROOM,M_LOCAL,1);
+ save_message(CC->temp,"",AIDEROOM,MES_LOCAL,1);
syslog(LOG_NOTICE,text);
}
strcpy(dest_node, "");
- /* If net_type is M_BINARY, split out the destination node. */
- if (net_type == M_BINARY) {
+ /* If net_type is MES_BINARY, split out the destination node. */
+ if (net_type == MES_BINARY) {
strcpy(dest_node,NODENAME);
for (a=0; a<strlen(recipient); ++a) {
if (recipient[a]=='@') {
}
}
- /* if net_type is M_INTERNET, set the dest node to 'internet' */
- if (net_type == M_INTERNET) {
+ /* if net_type is MES_INTERNET, set the dest node to 'internet' */
+ if (net_type == MES_INTERNET) {
strcpy(dest_node,"internet");
}
putc(type,fp); /* Normal or anonymous, see MES_ flags */
putc(format_type,fp); /* Formatted or unformatted */
fprintf(fp,"Pcit%ld%c",author->usernum,0); /* path */
- fprintf(fp,"T%ld%c",now,0); /* date/time */
+ fprintf(fp,"T%ld%c",(long)now,0); /* date/time */
if (fake_name[0])
fprintf(fp,"A%s%c",fake_name,0);
else
strcpy(buf,recipient);
}
else strcpy(buf,"sysop");
+ lprintf(9, "calling alias()\n");
e=alias(buf); /* alias and mail type */
- if ((buf[0]==0) || (e==M_ERROR)) {
+ lprintf(9, "alias() returned %d\n", e);
+ if ((buf[0]==0) || (e==MES_ERROR)) {
cprintf("%d Unknown address - cannot send message.\n",
ERROR+NO_SUCH_USER);
return;
}
- if ((e!=M_LOCAL)&&(CC->usersupp.axlevel<4)) {
+ if ((e!=MES_LOCAL)&&(CC->usersupp.axlevel<4)) {
cprintf("%d Net privileges required for network mail.\n",
ERROR+HIGHER_ACCESS_REQUIRED);
return;
}
- if ((RESTRICT_INTERNET==1)&&(e==M_INTERNET)
+ if ((RESTRICT_INTERNET==1)&&(e==MES_INTERNET)
&&((CC->usersupp.flags&US_INTERNET)==0)
&&(!CC->internal_pgm) ) {
cprintf("%d You don't have access to Internet mail.\n",
mtsflag=1;
goto SKFALL;
}
- if (e!=M_LOCAL) goto SKFALL; /* don't search local file */
+ if (e!=MES_LOCAL) goto SKFALL; /* don't search local file */
if (!strcasecmp(buf,CC->usersupp.fullname)) {
cprintf("%d Can't send mail to yourself!\n",
ERROR+NO_SUCH_USER);
/* Check to make sure the user exists; also get the correct
* upper/lower casing of the name.
*/
- a = getuser(&tempUS,buf);
+ a = getuser(&tempUS, buf);
if (a != 0) {
cprintf("%d No such user.\n",ERROR+NO_SUCH_USER);
return;
/* If we're in Mail, check the recipient */
if (strlen(recp) > 0) {
e=alias(recp); /* alias and mail type */
- if ((recp[0]==0) || (e==M_ERROR)) {
+ if ((recp[0]==0) || (e==MES_ERROR)) {
cprintf("%d Unknown address - cannot send message.\n",
ERROR+NO_SUCH_USER);
return;
}
- if (e == M_LOCAL) {
+ if (e == MES_LOCAL) {
a = getuser(&tempUS,recp);
if (a!=0) {
cprintf("%d No such user.\n",