* More internet addressing and global directory stuff. I think it's all working now
authorArt Cancro <ajc@citadel.org>
Sat, 26 Jan 2002 21:33:38 +0000 (21:33 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 26 Jan 2002 21:33:38 +0000 (21:33 +0000)
  except for the purging of old entries.

citadel/ChangeLog
citadel/internet_addressing.c
citadel/internet_addressing.h
citadel/msgbase.c

index 72a94ba9ca13a5d4098f64f299eefe3305e9ef11..5f1cf4d7e069d615cbfa31291d73f6a735359329 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 590.93  2002/01/26 21:33:38  ajc
+ * More internet addressing and global directory stuff.  I think it's all working now
+   except for the purging of old entries.
+
  Revision 590.92  2002/01/26 11:02:37  error
  * citadel.spec cleaned up
 
@@ -3259,4 +3263,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index a263bf42c0c80eff579a1c7703445ec8698cbe27..3063395025593de3801027dba132f5856a93a906 100644 (file)
@@ -270,119 +270,6 @@ void process_rfc822_addr(char *rfc822, char *user, char *node, char *name)
 
 
 
-/*
- * 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
index 6f283f16b136562f5cebb8f8cc57a3229833a9ae..bf78e5dba01bfd0c472788d80acfe00afcae4a8f 100644 (file)
@@ -22,19 +22,7 @@ void CtdlDirectoryInit(void);
 void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr);
 void CtdlDirectoryDelUser(char *internet_addr);
 int CtdlDirectoryLookup(char *target, char *internet_addr);
-
-int convert_internet_address(char *destuser, char *desthost, char *source);
-enum {
-       rfc822_address_locally_validated,
-       rfc822_no_such_user,
-       rfc822_address_on_citadel_network,
-       rfc822_address_nonlocal,
-       rfc822_room_delivery
-};
-
-
 struct CtdlMessage *convert_internet_message(char *rfc822);
-
 int CtdlHostAlias(char *fqdn);
 
 /* 
index 8eba07ce4cb0ce865fb998794b8dc158c54385f9..d8e7609560518340db9c87df93f66a9c8dc61378 100644 (file)
@@ -2171,12 +2171,14 @@ int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf) {
 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));
@@ -2187,6 +2189,7 @@ struct recptypes *validate_recipients(char *recipients) {
        ret->num_internet = 0;
        ret->num_ignet = 0;
        ret->num_error = 0;
+       ret->num_room = 0;
 
        if (recipients == NULL) {
                num_recps = 0;
@@ -2213,6 +2216,14 @@ struct recptypes *validate_recipients(char *recipients) {
                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:
@@ -2232,6 +2243,22 @@ struct recptypes *validate_recipients(char *recipients) {
                                        }
                                        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;