conv.c (c38cc7439c21c0932dbbdfcb87274dde7b8663ca) conv.c (95e5dc04763beebca41acc991ee5c2cd26e1b267)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD$
34 */
35
36#ifndef lint
37static const char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
38#endif /* not lint */
32 */
33
34#ifndef lint
35static const char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
36#endif /* not lint */
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD$");
39
40#include <sys/types.h>
41
42#include <stdio.h>
43#include <ctype.h>
44#include "hexdump.h"
45
46void
47conv_c(pr, p)
48 PR *pr;
49 u_char *p;
50{
51 extern int deprecated;
39
40#include <sys/types.h>
41
42#include <stdio.h>
43#include <ctype.h>
44#include "hexdump.h"
45
46void
47conv_c(pr, p)
48 PR *pr;
49 u_char *p;
50{
51 extern int deprecated;
52 char buf[10], *str;
53 static char nul[] = "\\0";
54 static char alarm[] = "\\a";
55 static char backspace[] = "\\b";
56 static char formfeed[] = "\\f";
57 static char newline[] = "\\n";
58 static char carriageret[] = "\\r";
59 static char verticaltab[] = "\\v";
60 static char tab[] = "\\t";
52 char buf[10];
53 char const *str;
61
62 switch(*p) {
63 case '\0':
54
55 switch(*p) {
56 case '\0':
64 str = nul;
57 str = "\\0";
65 goto strpr;
66 /* case '\a': */
67 case '\007':
68 if (deprecated) /* od didn't know about \a */
69 break;
58 goto strpr;
59 /* case '\a': */
60 case '\007':
61 if (deprecated) /* od didn't know about \a */
62 break;
70 str = alarm;
63 str = "\\a";
71 goto strpr;
72 case '\b':
64 goto strpr;
65 case '\b':
73 str = backspace;
66 str = "\\b";
74 goto strpr;
75 case '\f':
67 goto strpr;
68 case '\f':
76 str = formfeed;
69 str = "\\f";
77 goto strpr;
78 case '\n':
70 goto strpr;
71 case '\n':
79 str = newline;
72 str = "\\n";
80 goto strpr;
81 case '\r':
73 goto strpr;
74 case '\r':
82 str = carriageret;
75 str = "\\r";
83 goto strpr;
84 case '\t':
76 goto strpr;
77 case '\t':
85 str = tab;
78 str = "\\t";
86 goto strpr;
87 case '\v':
88 if (deprecated)
89 break;
79 goto strpr;
80 case '\v':
81 if (deprecated)
82 break;
90 str = verticaltab;
83 str = "\\v";
91 goto strpr;
92 default:
93 break;
94 }
95 if (isprint(*p)) {
96 *pr->cchar = 'c';
97 (void)printf(pr->fmt, *p);
98 } else {
84 goto strpr;
85 default:
86 break;
87 }
88 if (isprint(*p)) {
89 *pr->cchar = 'c';
90 (void)printf(pr->fmt, *p);
91 } else {
99 (void)sprintf(str = buf, "%03o", (int)*p);
92 (void)sprintf(buf, "%03o", (int)*p);
93 str = buf;
100strpr: *pr->cchar = 's';
101 (void)printf(pr->fmt, str);
102 }
103}
104
105void
106conv_u(pr, p)
107 PR *pr;
108 u_char *p;
109{
110 extern int deprecated;
94strpr: *pr->cchar = 's';
95 (void)printf(pr->fmt, str);
96 }
97}
98
99void
100conv_u(pr, p)
101 PR *pr;
102 u_char *p;
103{
104 extern int deprecated;
111 static const char *list[] = {
105 static char const * list[] = {
112 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
113 "bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
114 "dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
115 "can", "em", "sub", "esc", "fs", "gs", "rs", "us",
116 };
117
118 /* od used nl, not lf */
119 if (*p <= 0x1f) {

--- 19 unchanged lines hidden ---
106 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
107 "bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
108 "dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
109 "can", "em", "sub", "esc", "fs", "gs", "rs", "us",
110 };
111
112 /* od used nl, not lf */
113 if (*p <= 0x1f) {

--- 19 unchanged lines hidden ---