1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
25 * return the record format string given a format descriptor
32 fmtrec(Recfmt_t f
, int fs
)
40 b
= s
= fmtbuf(n
= 32);
46 if ((del
[0] = REC_D_DELIMITER(f
)) != '\n')
50 sfsprintf(s
, e
- s
, "0x%02x", *(unsigned char*)del
);
52 sfsprintf(s
, e
- s
, "%s", fmtquote(del
, NiL
, NiL
, 1, 0));
60 sfsprintf(s
, e
- s
, "%lu", REC_F_SIZE(f
));
64 if (n
= REC_V_SIZE(f
))
65 s
+= sfsprintf(s
, e
- s
, "%lu", n
);
66 if (REC_V_HEADER(f
) != 4)
67 s
+= sfsprintf(s
, e
- s
, "h%u", REC_V_HEADER(f
));
68 if (REC_V_OFFSET(f
) != 0)
69 s
+= sfsprintf(s
, e
- s
, "o%u", REC_V_OFFSET(f
));
70 if (REC_V_LENGTH(f
) != 2)
71 s
+= sfsprintf(s
, e
- s
, "z%u", REC_V_LENGTH(f
));
72 if (REC_V_LITTLE(f
) != 0)
74 if (REC_V_INCLUSIVE(f
) == 0)
80 switch (n
= REC_M_INDEX(f
))
83 sfsprintf(s
, e
- s
, "data");
86 sfsprintf(s
, e
- s
, "path");
89 sfsprintf(s
, e
- s
, "%lu", n
);
98 sfsprintf(s
, e
- s
, "u%u.0x%07x", RECTYPE(f
), REC_U_ATTRIBUTES(f
));