-/*
- * Back end for convert_internet_address()
- * (Compares an internet name [buffer1] and stores in [buffer2] if found)
- */
-void try_name(struct usersupp *us, void *data) {
- struct passwd *pw;
- struct trynamebuf *tnb;
- tnb = (struct trynamebuf *)data;
-
- if (!strncasecmp(tnb->buffer1, "cit", 3))
- if (atol(&tnb->buffer1[3]) == us->usernum)
- strcpy(tnb->buffer2, us->fullname);
-
- if (!collapsed_strcmp(tnb->buffer1, us->fullname))
- strcpy(tnb->buffer2, us->fullname);
-
- if (us->uid != BBSUID) {
- pw = getpwuid(us->uid);
- if (pw != NULL) {
- if (!strcasecmp(tnb->buffer1, pw->pw_name)) {
- strcpy(tnb->buffer2, us->fullname);
- }
- }
- }
-}
-
-
-/*
- * Convert an Internet email address to a Citadel user/host combination
- */
-int convert_internet_address(char *destuser, char *desthost, char *source)
-{
- char user[SIZ];
- char node[SIZ];
- char name[SIZ];
- struct quickroom qrbuf;
- int i;
- int hostalias;
- struct trynamebuf tnb;
- char buf[SIZ];
- int passes = 0;
- char sourcealias[1024];
-
- safestrncpy(sourcealias, source, sizeof(sourcealias) );
- alias(sourcealias);
-
-REALIAS:
- /* Split it up */
- process_rfc822_addr(sourcealias, user, node, name);
- lprintf(9, "process_rfc822_addr() converted to <%s@%s> (%s)\n",
- user, node, name);
-
- /* Map the FQDN to a Citadel node name
- */
- hostalias = CtdlHostAlias(node);
- switch(hostalias) {
- case hostalias_localhost:
- strcpy(node, config.c_nodename);
- break;
-
- case hostalias_gatewaydomain:
- extract_token(buf, node, 0, '.');
- safestrncpy(node, buf, sizeof buf);
- }
-
- /* Now try to resolve the name
- * FIXME ... do the multiple-addresses thing
- */
- if (!strcasecmp(node, config.c_nodename)) {
-
-
- /* First, see if we hit an alias. Don't do this more than
- * a few times, in case we accidentally hit an alias loop
- */
- strcpy(sourcealias, user);
- alias(user);
- if ( (strcasecmp(user, sourcealias)) && (++passes < 3) )
- goto REALIAS;
-
- /* Try all local rooms */
- if (!strncasecmp(user, "room_", 5)) {
- strcpy(name, &user[5]);
- for (i=0; i<strlen(name); ++i)
- if (name[i]=='_') name[i]=' ';
- if (getroom(&qrbuf, name) == 0) {
- strcpy(destuser, qrbuf.QRname);
- strcpy(desthost, config.c_nodename);
- return rfc822_room_delivery;
- }
- }
-
- /* Try all local users */
- strcpy(destuser, user);
- strcpy(desthost, config.c_nodename);
- strcpy(tnb.buffer1, user);
- strcpy(tnb.buffer2, "");
- ForEachUser(try_name, &tnb);
- if (strlen(tnb.buffer2) == 0) return(rfc822_no_such_user);
- strcpy(destuser, tnb.buffer2);
- return(rfc822_address_locally_validated);
- }
-
- strcpy(destuser, user);
- strcpy(desthost, node);
- if (hostalias == hostalias_gatewaydomain) {
- return(rfc822_address_on_citadel_network);
- }
- return(rfc822_address_nonlocal);
-}
-
-
-
-
/*
* convert_field() is a helper function for convert_internet_message().
* Given start/end positions for an rfc822 field, it converts it to a Citadel
struct recptypes *validate_recipients(char *recipients) {
struct recptypes *ret;
char this_recp[SIZ];
+ char this_recp_cooked[SIZ];
char append[SIZ];
int num_recps;
- int i;
+ int i, j;
int mailtype;
int invalid;
struct usersupp tempUS;
+ struct quickroom tempQR;
/* Initialize */
ret = (struct recptypes *) malloc(sizeof(struct recptypes));
ret->num_internet = 0;
ret->num_ignet = 0;
ret->num_error = 0;
+ ret->num_room = 0;
if (recipients == NULL) {
num_recps = 0;
mailtype = alias(this_recp);
mailtype = alias(this_recp);
mailtype = alias(this_recp);
+ for (j=0; j<=strlen(this_recp); ++j) {
+ if (this_recp[j]=='_') {
+ this_recp_cooked[j] = ' ';
+ }
+ else {
+ this_recp_cooked[j] = this_recp[j];
+ }
+ }
invalid = 0;
switch(mailtype) {
case MES_LOCAL:
}
strcat(ret->recp_local, this_recp);
}
+ else if (getuser(&tempUS, this_recp_cooked) == 0) {
+ ++ret->num_local;
+ strcpy(this_recp, tempUS.fullname);
+ if (strlen(ret->recp_local) > 0) {
+ strcat(ret->recp_local, "|");
+ }
+ strcat(ret->recp_local, this_recp);
+ }
+ else if ( (!strncasecmp(this_recp, "room_", 5))
+ && (!getroom(&tempQR, &this_recp_cooked[5])) ) {
+ ++ret->num_room;
+ if (strlen(ret->recp_room) > 0) {
+ strcat(ret->recp_room, "|");
+ }
+ strcat(ret->recp_room, &this_recp_cooked[5]);
+ }
else {
++ret->num_error;
invalid = 1;