]>
diplodocus.org Git - nmh/blob - uip/fmttest.c
50804c9d99d9d7e5efb90f7dccba55185fb244a9
1 /* fmttest.c -- A program to help test and debug format instructions
3 * This code is Copyright (c) 2012, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
9 #include "sbr/fmt_new.h"
11 #include "sbr/m_name.h"
12 #include "sbr/m_getfld.h"
13 #include "sbr/getarguments.h"
14 #include "sbr/seq_setprev.h"
15 #include "sbr/seq_save.h"
16 #include "sbr/smatch.h"
17 #include "sbr/snprintb.h"
18 #include "sbr/getcpy.h"
19 #include "sbr/m_convert.h"
20 #include "sbr/getfolder.h"
21 #include "sbr/folder_read.h"
22 #include "sbr/folder_free.h"
23 #include "sbr/context_save.h"
24 #include "sbr/context_replace.h"
25 #include "sbr/context_find.h"
26 #include "sbr/brkstring.h"
27 #include "sbr/ambigsw.h"
29 #include "sbr/print_version.h"
30 #include "sbr/print_help.h"
31 #include "sbr/seq_getnum.h"
32 #include "sbr/error.h"
33 #include "h/fmt_scan.h"
34 #include "h/fmt_compile.h"
36 #include "h/addrsbr.h"
38 #include "sbr/m_maildir.h"
39 #include "sbr/terminal.h"
41 #define FMTTEST_SWITCHES \
42 X("form formatfile", 0, FORMSW) \
43 X("format string", 5, FMTSW) \
44 X("address", 0, ADDRSW) \
46 X("date", 0, DATESW) \
47 X("message", 0, MESSAGESW) \
48 X("file", 0, FILESW) \
49 X("nofile", 0, NFILESW) \
50 X("-component-name component-text", 0, OTHERSW) \
51 X("dupaddrs", 0, DUPADDRSW) \
52 X("nodupaddrs", 0, NDUPADDRSW) \
53 X("ccme", 0, CCMESW) \
54 X("noccme", 0, NCCMESW) \
55 X("outsize size-in-characters", 0, OUTSIZESW) \
56 X("width column-width", 0, WIDTHSW) \
57 X("msgnum number", 0, MSGNUMSW) \
58 X("msgcur flag", 0, MSGCURSW) \
59 X("msgsize size", 0, MSGSIZESW) \
60 X("unseen flag", 0, UNSEENSW) \
61 X("dump", 0, DUMPSW) \
62 X("nodump", 0, NDUMPSW) \
63 X("trace", 0, TRACESW) \
64 X("notrace", 0, NTRACESW) \
65 X("version", 0, VERSIONSW) \
66 X("help", 0, HELPSW) \
68 #define X(sw, minchars, id) id,
69 DEFINE_SWITCH_ENUM(FMTTEST
);
72 #define X(sw, minchars, id) { sw, minchars, id },
73 DEFINE_SWITCH_ARRAY(FMTTEST
, switches
);
77 * An array containing labels used for branch instructions
80 static struct format
**lvec
= NULL
;
82 static int lallocated
= 0;
84 enum mode_t
{ MESSAGE
, ADDRESS
, DATE
, RAW
};
85 #define DEFADDRFORMAT "%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>"
86 #define DEFDATEFORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
89 * Context structure used by the tracing routines
92 struct trace_context
{
101 static void fmt_dump (char *, struct format
*);
102 static void dumpone(struct format
*);
103 static void initlabels(struct format
*);
104 static int findlabel(struct format
*);
105 static void assignlabel(struct format
*);
106 static const char *f_typestr(int);
107 static const char *c_typestr(int);
108 static const char *c_flagsstr(int);
109 static const char *c_textlabel(int);
110 static void litputs(const char *);
111 static void litputc(char);
112 static void process_addresses(struct format
*, struct msgs_array
*,
113 charstring_t
, int, int *,
114 struct fmt_callbacks
*);
115 static void process_raw(struct format
*, struct msgs_array
*, charstring_t
,
116 int, int *, struct fmt_callbacks
*);
117 static void process_messages(struct format
*, struct msgs_array
*,
118 struct msgs_array
*, charstring_t
, char *, int,
119 int, int *, struct fmt_callbacks
*);
120 static void process_single_file(FILE *, struct msgs_array
*, int *, int,
121 struct format
*, charstring_t
, int,
122 struct fmt_callbacks
*);
123 static void test_trace(void *, struct format
*, int, char *, const char *);
124 static char *test_formataddr(char *, char *);
125 static char *test_concataddr(char *, char *);
126 static int insert(struct mailname
*);
127 static void mlistfree(void);
129 static bool nodupcheck
; /* If set, no check for duplicates */
130 static bool ccme
; /* Should I cc myself? */
131 static struct mailname mq
; /* Mail addresses to check for duplicates */
132 static char *dummy
= "dummy";
135 main (int argc
, char **argv
)
137 char *cp
, *form
= NULL
, *format
= NULL
, *defformat
= FORMAT
, *folder
= NULL
;
138 char buf
[BUFSIZ
], *nfs
, **argp
, **arguments
;
142 struct msgs_array msgs
= { 0, 0, NULL
}, compargs
= { 0, 0, NULL
};
145 bool dupaddrs
= true;
148 int colwidth
= -1, msgnum
= -1, msgcur
= -1, msgsize
= -1, msgunseen
= -1;
149 enum mode_t mode
= MESSAGE
;
151 struct fmt_callbacks cb
, *cbp
= NULL
;
153 if (nmh_init(argv
[0], true, true)) { return 1; }
155 arguments
= getarguments (invo_name
, argc
, argv
, 1);
158 bool outputsize_given
= false;
160 while ((cp
= *argp
++)) {
163 * A -- means that we have a component name (like pick);
164 * save the component name and the next argument for the text.
168 die("missing component name after --");
169 app_msgarg(&compargs
, cp
);
170 /* Grab next argument for component text */
172 die("missing argument to %s", argp
[-2]);
173 app_msgarg(&compargs
, cp
);
176 switch (smatch (cp
, switches
)) {
178 ambigsw (cp
, switches
);
181 die("-%s unknown", cp
);
184 snprintf (buf
, sizeof(buf
), "%s [switches]", invo_name
);
185 print_help (buf
, switches
, 1);
188 print_version(invo_name
);
191 die("internal argument error!");
195 outputsize_given
= true;
196 if (!(cp
= *argp
++) || *cp
== '-')
197 die("missing argument to %s", argp
[-2]);
198 if (strcmp(cp
, "max") == 0)
199 outputsize
= INT_MAX
;
200 else if (strcmp(cp
, "width") == 0)
201 outputsize
= sc_width();
203 outputsize
= atoi(cp
);
207 if (!(form
= *argp
++) || *form
== '-')
208 die("missing argument to %s", argp
[-2]);
212 if (!(format
= *argp
++) || *format
== '-')
213 die("missing argument to %s", argp
[-2]);
226 defformat
= DEFADDRFORMAT
;
238 defformat
= DEFDATEFORMAT
;
263 if (!(cp
= *argp
++) || *cp
== '-')
264 die("missing argument to %s", argp
[-2]);
268 if (!(cp
= *argp
++) || *cp
== '-')
269 die("missing argument to %s", argp
[-2]);
273 if (!(cp
= *argp
++) || *cp
== '-')
274 die("missing argument to %s", argp
[-2]);
278 if (!(cp
= *argp
++) || *cp
== '-')
279 die("missing argument to %s", argp
[-2]);
283 if (!(cp
= *argp
++) || *cp
== '-')
284 die("missing argument to %s", argp
[-2]);
285 msgunseen
= atoi(cp
);
299 * Only interpret as a folder if we're in message mode
302 if (mode
== MESSAGE
&& !files
&& (*cp
== '+' || *cp
== '@')) {
304 die("only one folder at a time!");
305 folder
= pluspath (cp
);
307 app_msgarg(&msgs
, cp
);
311 * Here's our weird heuristic:
313 * - We allow -dump without any other arguments.
314 * - If you've given any component arguments, we don't require any
316 * - The arguments are interpreted as folders/messages _if_ we're in
317 * message mode, otherwise pass as strings in the text component.
320 if (!dump
&& compargs
.size
== 0 && msgs
.size
== 0) {
321 die("usage: [switches] [+folder] msgs | strings...");
325 * If you're picking "raw" as a mode, then you have to select
329 if (mode
== RAW
&& form
== NULL
&& format
== NULL
) {
330 die("You must specify a format with -form or -format when "
335 * Get new format string. Must be before chdir().
337 nfs
= new_fs (form
, format
, defformat
);
338 (void) fmt_compile(nfs
, &fmt
, 1);
344 if (compargs
.size
== 0 && msgs
.size
== 0)
349 buffer
= charstring_create(BUFSIZ
);
351 if (!outputsize_given
) {
352 outputsize
= mode
== MESSAGE
? sc_width() : INT_MAX
;
358 dat
[3] = colwidth
== -1 ? outputsize
: colwidth
;
362 * If we want to provide our own formataddr, concactaddr, or tracing
363 * callback, do that now. Also, prime ismymbox if we use it.
366 if (!dupaddrs
|| trace
) {
371 cb
.formataddr
= test_formataddr
;
372 cb
.concataddr
= test_concataddr
;
378 struct trace_context
*ctx
;
383 ctx
->outbuf
= mh_xstrdup("");
385 cb
.trace_func
= test_trace
;
386 cb
.trace_context
= ctx
;
390 if (mode
== MESSAGE
) {
391 process_messages(fmt
, &compargs
, &msgs
, buffer
, folder
, outputsize
,
395 for (i
= 0; i
< compargs
.size
; i
+= 2) {
396 cptr
= fmt_findcomp(compargs
.msgs
[i
]);
398 cptr
->c_text
= getcpy(compargs
.msgs
[i
+ 1]);
402 if (mode
== ADDRESS
) {
403 process_addresses(fmt
, &msgs
, buffer
, outputsize
, dat
, cbp
);
404 } else /* Fall-through for RAW or DATE */
405 process_raw(fmt
, &msgs
, buffer
, outputsize
, dat
, cbp
);
408 charstring_free(buffer
);
416 * Process each address with fmt_scan().
422 struct pqpair
*pq_next
;
426 process_addresses(struct format
*fmt
, struct msgs_array
*addrs
,
427 charstring_t buffer
, int outwidth
, int *dat
,
428 struct fmt_callbacks
*cb
)
431 char *cp
, error
[BUFSIZ
];
433 struct pqpair
*p
, *q
;
446 for (i
= 0; i
< addrs
->size
; i
++) {
447 (q
= &pq
)->pq_next
= NULL
;
448 while ((cp
= getname(addrs
->msgs
[i
]))) {
450 if ((mp
= getm(cp
, NULL
, 0, error
, sizeof(error
))) == NULL
) {
451 p
->pq_text
= mh_xstrdup(cp
);
452 p
->pq_error
= mh_xstrdup(error
);
454 p
->pq_text
= getcpy(mp
->m_text
);
457 q
= (q
->pq_next
= p
);
460 for (p
= pq
.pq_next
; p
; p
= q
) {
461 c
= fmt_findcomp("text");
464 c
->c_text
= p
->pq_text
;
467 c
= fmt_findcomp("error");
470 c
->c_text
= p
->pq_error
;
474 fmt_scan(fmt
, buffer
, outwidth
, dat
, cb
);
475 fputs(charstring_buffer(buffer
), stdout
);
476 charstring_clear(buffer
);
488 * Process messages and run them through the format engine. A lot taken
493 process_messages(struct format
*fmt
, struct msgs_array
*comps
,
494 struct msgs_array
*msgs
, charstring_t buffer
, char *folder
,
495 int outwidth
, int files
, int *dat
,
496 struct fmt_callbacks
*cb
)
498 int i
, msgnum
, msgsize
= dat
[2], num
= dat
[0], cur
= dat
[1];
499 int num_unseen_seq
= 0;
500 ivector_t seqnum
= ivector_create (0);
506 * If 'files' is set, short-circuit everything else and just process
511 for (i
= 0; i
< msgs
->size
; i
++) {
512 if ((in
= fopen(cp
= msgs
->msgs
[i
], "r")) == NULL
) {
513 admonish(cp
, "unable to open file");
516 process_single_file(in
, comps
, dat
, msgsize
, fmt
, buffer
,
524 folder
= getfolder(1);
526 maildir
= m_maildir(folder
);
528 if (chdir(maildir
) < 0)
529 adios(maildir
, "unable to change directory to");
531 if (!(mp
= folder_read(folder
, 1)))
532 die("unable to read folder %s", folder
);
535 die("no messages in %s", folder
);
537 for (i
= 0; i
< msgs
->size
; i
++)
538 if (!m_convert(mp
, msgs
->msgs
[i
]))
540 seq_setprev(mp
); /* set the Previous-Sequence */
542 context_replace(pfolder
, folder
); /* update current folder */
543 seq_save(mp
); /* synchronize message sequences */
544 context_save(); /* save the context file */
547 * We want to set the unseen flag if requested, so we have to check
548 * the unseen sequence as well.
552 if ((cp
= context_find(usequence
)) && *cp
) {
556 ap
= brkstring(dp
, " ", "\n");
557 for (i
= 0; ap
&& *ap
; i
++, ap
++)
558 ivector_push_back (seqnum
, seq_getnum(mp
, *ap
));
565 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++) {
566 if (is_selected(mp
, msgnum
)) {
567 if ((in
= fopen(cp
= m_name(msgnum
), "r")) == NULL
) {
568 admonish(cp
, "unable to open message");
578 dat
[1] = msgnum
== mp
->curmsg
;
581 * Check to see if this is in the unseen sequence
585 for (i
= 0; i
< num_unseen_seq
; i
++) {
586 if (in_sequence(mp
, ivector_at (seqnum
, i
), msgnum
)) {
593 * Read in the message and process the components
596 process_single_file(in
, comps
, dat
, msgsize
, fmt
, buffer
,
601 ivector_free (seqnum
);
606 * Process a single file in message mode
610 process_single_file(FILE *in
, struct msgs_array
*comps
, int *dat
, int msgsize
,
611 struct format
*fmt
, charstring_t buffer
, int outwidth
,
612 struct fmt_callbacks
*cb
)
615 char name
[NAMESZ
], rbuf
[NMH_BUFSIZ
];
616 m_getfld_state_t gstate
;
621 * Get our size if we didn't include one
627 if (fstat(fileno(in
), &st
) < 0)
634 * Initialize everything else
645 * Read in the message and process the components
648 gstate
= m_getfld_state_init(in
);
650 bufsz
= sizeof(rbuf
);
651 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
655 i
= fmt_addcomptext(name
, rbuf
);
657 while (state
== FLDPLUS
) {
658 bufsz
= sizeof(rbuf
);
659 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
660 fmt_appendcomp(i
, name
, rbuf
);
664 while (state
== FLDPLUS
) {
665 bufsz
= sizeof(rbuf
);
666 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
671 if (fmt_findcomp("body")) {
672 if ((i
= strlen(rbuf
)) < outwidth
) {
673 bufsz
= min (outwidth
, (int) sizeof rbuf
- i
);
674 m_getfld2(&gstate
, name
, rbuf
+ i
, &bufsz
);
677 fmt_addcomptext("body", rbuf
);
687 m_getfld_state_destroy(&gstate
);
690 * Do this now to override any components in the original message
693 for (i
= 0; i
< comps
->size
; i
+= 2) {
694 c
= fmt_findcomp(comps
->msgs
[i
]);
697 c
->c_text
= getcpy(comps
->msgs
[i
+ 1]);
701 fmt_scan(fmt
, buffer
, outwidth
, dat
, cb
);
702 fputs(charstring_buffer (buffer
), stdout
);
703 charstring_clear(buffer
);
708 * Run text through the format engine with no special processing
712 process_raw(struct format
*fmt
, struct msgs_array
*text
, charstring_t buffer
,
713 int outwidth
, int *dat
, struct fmt_callbacks
*cb
)
727 c
= fmt_findcomp("text");
729 for (i
= 0; i
< text
->size
; i
++) {
732 c
->c_text
= getcpy(text
->msgs
[i
]);
735 fmt_scan(fmt
, buffer
, outwidth
, dat
, cb
);
736 fputs(charstring_buffer (buffer
), stdout
);
737 charstring_clear(buffer
);
743 * Our basic tracing support callback.
745 * Print out each instruction as it's executed, including the values of
746 * the num and str registers if they've changed.
750 test_trace(void *context
, struct format
*fmt
, int num
, char *str
,
753 struct trace_context
*ctx
= (struct trace_context
*) context
;
754 bool changed
= false;
758 if (num
!= ctx
->num
) {
759 printf("num=%d", num
);
764 if (str
!= ctx
->str
) {
768 fputs("str=", stdout
);
776 if (strcmp(outbuf
, ctx
->outbuf
) != 0) {
777 fputs("outbuf=", stdout
);
781 ctx
->outbuf
= mh_xstrdup(outbuf
);
786 fmt_dump (char *nfs
, struct format
*fmth
)
790 printf("Instruction dump of format string: \n%s\n", nfs
);
793 for (fmt
= fmth
; fmt
; ++fmt
) {
795 if (fmt
->f_type
== FT_DONE
&& fmt
->f_value
== 0)
801 dumpone(struct format
*fmt
)
805 if ((i
= findlabel(fmt
)) >= 0)
809 fputs(f_typestr((int)fmt
->f_type
), stdout
);
811 switch (fmt
->f_type
) {
817 fputs(", comp ", stdout
);
818 litputs(fmt
->f_comp
->c_name
);
819 if (fmt
->f_comp
->c_type
)
820 printf(", c_type %s", c_typestr(fmt
->f_comp
->c_type
));
821 if (fmt
->f_comp
->c_flags
)
822 printf(", c_flags %s", c_flagsstr(fmt
->f_comp
->c_flags
));
849 fputs(", c_name ", stdout
);
850 litputs(fmt
->f_comp
->c_name
);
851 if (fmt
->f_comp
->c_type
)
852 printf(", c_type %s", c_typestr(fmt
->f_comp
->c_type
));
853 if (fmt
->f_comp
->c_flags
)
854 printf(", c_flags %s", c_flagsstr(fmt
->f_comp
->c_flags
));
873 fputs(", c_name ", stdout
);
874 litputs(fmt
->f_comp
->c_name
);
875 if (fmt
->f_comp
->c_type
)
876 printf(", c_type %s", c_typestr(fmt
->f_comp
->c_type
));
877 if (fmt
->f_comp
->c_flags
)
878 printf(", c_flags %s", c_flagsstr(fmt
->f_comp
->c_flags
));
882 printf(", width %d, fill '", fmt
->f_width
);
883 litputc(fmt
->f_fill
);
884 fputs("' name ", stdout
);
885 litputs(fmt
->f_comp
->c_name
);
886 if (fmt
->f_comp
->c_type
)
887 printf(", c_type %s", c_typestr(fmt
->f_comp
->c_type
));
888 if (fmt
->f_comp
->c_flags
)
889 printf(", c_flags %s", c_flagsstr(fmt
->f_comp
->c_flags
));
894 printf(", width %d, fill '", fmt
->f_width
);
895 litputc(fmt
->f_fill
);
901 litputs(fmt
->f_text
);
905 printf(", width %d, fill '", fmt
->f_width
);
906 litputc(fmt
->f_fill
);
908 litputs(fmt
->f_text
);
914 litputc(fmt
->f_char
);
922 fputs(c_textlabel(fmt
->f_type
), stdout
);
924 litputs(fmt
->f_text
);
929 fputs(" continue else goto", stdout
);
932 i
= findlabel(fmt
+ fmt
->f_skip
);
939 i
= findlabel(fmt
+ fmt
->f_skip
);
940 printf(" %d continue else goto L%d", fmt
->f_value
, i
);
949 case FT_LV_MULTIPLY_L
:
952 printf(" value %d", fmt
->f_value
);
962 fputs(c_textlabel(fmt
->f_type
), stdout
);
964 litputs(fmt
->f_text
);
967 case FT_LS_DECODECOMP
:
968 fputs(", comp ", stdout
);
969 litputs(fmt
->f_comp
->c_name
);
973 printf(", width %d", fmt
->f_width
);
977 printf(", value dat[%d]", fmt
->f_value
);
985 * Iterate over all instructions and assign labels to the targets of
990 initlabels(struct format
*fmth
)
992 struct format
*fmt
, *addr
;
996 for (fmt
= fmth
; fmt
; ++fmt
) {
1004 i
== FT_IF_AMATCH
||
1006 addr
= fmt
+ fmt
->f_skip
;
1007 if (findlabel(addr
) < 0)
1010 if (fmt
->f_type
== FT_DONE
&& fmt
->f_value
== 0)
1017 findlabel(struct format
*addr
)
1021 for (i
= 0; i
< lused
; ++i
)
1022 if (addr
== lvec
[i
])
1028 assignlabel(struct format
*addr
)
1030 if (lused
>= lallocated
) {
1032 lvec
= (struct format
**)
1033 mh_xrealloc(lvec
, sizeof(struct format
*) * lallocated
);
1036 lvec
[lused
++] = addr
;
1039 #define X(name) case FT_ ## name : return #name
1043 static char buf
[32];
1143 snprintf(buf
, sizeof(buf
), "/* ??? #%d */", t
);
1152 static char buf
[64];
1154 snprintb(buf
, sizeof(buf
), t
, CT_BITS
);
1161 static char buf
[64];
1163 snprintb(buf
, sizeof(buf
), t
, CF_BITS
);
1175 return "match string";
1183 return "profile entry";
1190 litputs(const char *s
)
1198 fputs("<nil>", stdout
);
1205 printf("\\x%02x", (unsigned char) c
);
1206 } else if (c
< 0x20 || c
== 0177) {
1210 } else if (c
== '\f') {
1213 } else if (c
== '\n') {
1216 } else if (c
== '\r') {
1219 } else if (c
== '\t') {
1224 putchar(c
^ 0x40); /* DEL to ?, others to alpha */
1231 * Routines/code to support the duplicate address suppression code, adapted
1235 static char *buf
; /* our current working buffer */
1236 static char *bufend
; /* end of working buffer */
1237 static char *last_dst
; /* buf ptr at end of last call */
1238 static unsigned int bufsiz
=0; /* current size of buf */
1240 #define BUFINCR 512 /* how much to expand buf when if fills */
1242 #define CPY(s) { cp = (s); while ((*dst++ = *cp++)) ; --dst; }
1245 * check if there's enough room in buf for str.
1246 * add more mem if needed
1248 #define CHECKMEM(str) \
1249 if ((len = strlen (str)) >= bufend - dst) {\
1251 int n = last_dst - buf;\
1252 bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
1253 buf = mh_xrealloc (buf, bufsiz);\
1255 last_dst = buf + n;\
1256 bufend = buf + bufsiz;\
1261 * These are versions of similar routines from replsbr.c; the purpose is
1262 * to suppress duplicate addresses from being added to a list when building
1263 * up addresses for the %(formataddr) format function. This is used by
1264 * repl to prevent duplicate addresses from being added to the "to" line.
1265 * See replsbr.c for more information.
1267 * We can't use the functions in replsbr.c directly because they are slightly
1268 * different and depend on the rest of replsbr.c
1271 test_formataddr (char *orig
, char *str
)
1279 struct mailname
*mp
= NULL
;
1281 /* if we don't have a buffer yet, get one */
1283 buf
= mh_xmalloc (BUFINCR
);
1284 last_dst
= buf
; /* XXX */
1285 bufsiz
= BUFINCR
- 6; /* leave some slop */
1286 bufend
= buf
+ bufsiz
;
1289 * If "orig" points to our buffer we can just pick up where we
1290 * left off. Otherwise we have to copy orig into our buffer.
1294 else if (!orig
|| !*orig
) {
1298 dst
= last_dst
; /* XXX */
1303 /* concatenate all the new addresses onto 'buf' */
1304 for (isgroup
= false; (cp
= getname (str
)); ) {
1305 if ((mp
= getm (cp
, NULL
, 0, error
, sizeof(error
))) == NULL
) {
1306 fprintf(stderr
, "bad address \"%s\" -- %s\n", cp
, error
);
1309 if (isgroup
&& (mp
->m_gname
|| !mp
->m_ingrp
)) {
1314 /* if we get here we're going to add an address */
1320 CHECKMEM (mp
->m_gname
);
1324 sp
= adrformat (mp
);
1340 * The companion to test_formataddr(); it behaves the same way, except doesn't
1341 * do duplicate address detection.
1344 test_concataddr(char *orig
, char *str
)
1349 cp
= test_formataddr(orig
, str
);
1355 insert (struct mailname
*np
)
1357 struct mailname
*mp
;
1362 if (np
->m_mbox
== NULL
)
1365 for (mp
= &mq
; mp
->m_next
; mp
= mp
->m_next
) {
1366 if (!strcasecmp (FENDNULL(np
->m_host
),
1367 FENDNULL(mp
->m_next
->m_host
)) &&
1368 !strcasecmp (FENDNULL(np
->m_mbox
),
1369 FENDNULL(mp
->m_next
->m_mbox
)))
1372 if (!ccme
&& ismymbox (np
))
1381 * Reset our duplicate address list
1387 struct mailname
*mp
, *mp2
;
1389 for (mp
= mq
.m_next
; mp
; mp
= mp2
) {