]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/uip/ali.c
1 /* ali.c - the new ali */
3 static char ident
[] = "@(#)$Id: ali.c,v 1.9 1993/09/02 00:05:15 jromine Exp $";
7 #include "../h/addrsbr.h"
8 #include "../h/aliasbr.h"
15 #define NVEC 50 /* maximum number of names */
19 static struct swit switches
[] = {
50 extern struct aka
*akahead
;
75 setlocale(LC_ALL
, "");
77 invo_name
= r1bindex (argv
[0], '/');
79 if ((cp
= m_find (invo_name
)) != NULL
) {
80 ap
= brkstring (cp
= getcpy (cp
), " ", "\n");
81 ap
= copyip (ap
, arguments
);
85 (void) copyip (argv
+ 1, ap
);
90 while (cp
= *argp
++) {
92 switch (smatch (++cp
, switches
)) {
94 ambigsw (cp
, switches
);
97 adios (NULLCP
, "-%s unknown", cp
);
99 (void) sprintf (buf
, "%s [switches] aliases ...",
101 help (buf
, switches
);
105 if (!(cp
= *argp
++) || *cp
== '-')
106 adios (NULLCP
, "missing argument to %s", argp
[-2]);
107 if ((i
= alias (cp
)) != AK_OK
)
108 adios (NULLCP
, "aliasing error in %s - %s",
140 if (cp
= m_find ("Aliasfile")) { /* allow Aliasfile: profile entry */
143 for (ap
= brkstring(dp
= getcpy(cp
), " ", "\n"); ap
&& *ap
; ap
++)
144 if ((i
= alias (*ap
)) != AK_OK
)
146 "aliasing error in %s - %s", *ap
, akerror (i
));
150 (void) alias (AliasFile
);
157 for (i
= 0; i
< vecp
; i
++)
159 print_usr (vec
[i
], list
, normalize
);
161 print_aka (akvalue (vec
[i
]), list
, 0);
165 "usage: %s -user addresses ... (you forgot the addresses)",
168 for (ak
= akahead
; ak
; ak
= ak
-> ak_next
) {
169 printf ("%s: ", ak
-> ak_name
);
170 pos
+= strlen (ak
-> ak_name
) + 1;
171 print_aka (akresult (ak
), list
, pos
);
180 print_aka (p
, list
, margin
)
188 printf ("<empty>\n");
197 printf ("\n%*s", margin
, "");
216 (void) putchar ('\n');
222 print_usr (s
, list
, norm
)
230 register struct aka
*ak
;
231 register struct mailname
*mp
,
234 if ((pp
= getname (s
)) == NULL
)
235 adios (NULLCP
, "no address in \"%s\"", s
);
236 if ((mp
= getm (pp
, NULLCP
, 0, norm
, NULLCP
)) == NULL
)
237 adios (NULLCP
, "bad address \"%s\"", s
);
242 for (ak
= akahead
; ak
; ak
= ak
-> ak_next
) {
244 while (cp
= getname (pp
)) {
245 if ((np
= getm (cp
, NULLCP
, 0, norm
, NULLCP
)) == NULL
)
247 if (uleq (mp
-> m_host
, np
-> m_host
)
248 && uleq (mp
-> m_mbox
, np
-> m_mbox
)) {
249 vp
= vp
? add (ak
-> ak_name
, add (",", vp
))
250 : getcpy (ak
-> ak_name
);
263 print_aka (vp
? vp
: s
, list
, pos
+= strlen (s
) + 1);
265 print_aka (vp
? vp
: s
, list
, 0);