]> diplodocus.org Git - nmh/blob - sbr/seq_bits.c
Alter mh-chart(7)'s NAME to be lowercase.
[nmh] / sbr / seq_bits.c
1
2 /*
3 * seq_bits.c -- return the snprintb() string for a sequence
4 *
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
8 */
9
10 #include <h/mh.h>
11
12
13 char *
14 seq_bits (struct msgs *mp)
15 {
16 size_t i;
17 size_t len;
18 static char buffer[BUFSIZ];
19
20 strncpy (buffer, MBITS, sizeof(buffer));
21
22 for (i = 0; i < svector_size (mp->msgattrs); i++) {
23 len = strlen (buffer);
24 snprintf (buffer + len, sizeof(buffer) - len,
25 "%c%s", FFATTRSLOT + 1 + (int) i,
26 svector_at (mp->msgattrs, i));
27 /*
28 * seq_bits() is used by seq_printdebug(), which passes an
29 * unsigned int bit vector to snprintb(). So limit the
30 * size of the return value accordingly. Even worse,
31 * snprintb() only uses characters up through ASCII space
32 * as the delimiter (the %c character above). So limit
33 * based on that.
34 */
35 if ((int) i == ' ' - FFATTRSLOT - 1) break;
36 }
37
38 return buffer;
39 }