- int a;
-
- /* extract full name - first, it's From minus <userid> */
- strcpy(name,rfc822);
- for (a=0; a<strlen(name); ++a) if (name[a]=='<') {
- do {
- strcpy(&name[a],&name[a+1]);
- } while ( (strlen(name) > 0) && (name[a]!='>') );
- strcpy(&name[a],&name[a+1]);
- }
-
- /* strip anything to the left of a bang */
- while ( (strlen(name)>0) && (haschar(name,'!')>0) )
- strcpy(name,&name[1]);
-
- /* and anything to the right of a @ or % */
- for (a=0; a<strlen(name); ++a) {
- if (name[a]=='@') name[a]=0;
- if (name[a]=='%') name[a]=0;
- }
-
- /* but if there are parentheses, that changes the rules... */
- if ( (haschar(rfc822,'(') == 1) && (haschar(rfc822,')') == 1) ) {
- strcpy(name,rfc822);
- while ( (strlen(name) > 0) && (name[0]!='(') ) {
- strcpy(&name[0],&name[1]);
- }
- strcpy(&name[0],&name[1]);
- for (a=0; a<strlen(name); ++a)
- if (name[a]==')') name[a]=0;
- }
-
- /* but if there are a set of quotes, that supersedes everything */
- if (haschar(rfc822,34)==2) {
- strcpy(name,rfc822);
- while ( (strlen(name) > 0) && (name[0]!=34) ) {
- strcpy(&name[0],&name[1]);
- }
- strcpy(&name[0],&name[1]);
- for (a=0; a<strlen(name); ++a)
- if (name[a]==34) name[a]=0;
- }
-
- /* extract user id */
- strcpy(user,rfc822);
-
- /* first get rid of anything in parens */
- for (a=0; a<strlen(user); ++a) if (user[a]=='(') {
- do {
- strcpy(&user[a],&user[a+1]);
- } while ( (strlen(user) > 0) && (user[a]!=')') );
- strcpy(&user[a],&user[a+1]);
- }
-
- /* if there's a set of angle brackets, strip it down to that */
- if ( (haschar(user,'<') == 1) && (haschar(user,'>') == 1) ) {
- while ( (strlen(user) > 0) && (user[0]!='<') ) {
- strcpy(&user[0],&user[1]);
- }
- strcpy(&user[0],&user[1]);
- for (a=0; a<strlen(user); ++a)
- if (user[a]=='>') user[a]=0;
- }
-
- /* strip anything to the left of a bang */
- while ( (strlen(user)>0) && (haschar(user,'!')>0) )
- strcpy(user,&user[1]);
-
- /* and anything to the right of a @ or % */
- for (a=0; a<strlen(user); ++a) {
- if (user[a]=='@') user[a]=0;
- if (user[a]=='%') user[a]=0;
- }
-
-
-
- /* extract node name */
- strcpy(node, rfc822);
-
- /* first get rid of anything in parens */
- for (a=0; a<strlen(node); ++a) if (node[a]=='(') {
- do {
- strcpy(&node[a],&node[a+1]);
- } while ( (strlen(node) > 0) && (node[a]!=')') );
- strcpy(&node[a],&node[a+1]);
- }
-
- /* if there's a set of angle brackets, strip it down to that */
- if ( (haschar(node,'<') == 1) && (haschar(node,'>') == 1) ) {
- while ( (strlen(node) > 0) && (node[0]!='<') ) {
- strcpy(&node[0],&node[1]);
- }
- strcpy(&node[0],&node[1]);
- for (a=0; a<strlen(node); ++a)
- if (node[a]=='>') node[a]=0;