output.c (8832864298b522bb2b4b3d2fdb1fa0443bedd681) output.c (c3f57269e604d9e4c9d5f1312a751fd796415202)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

117out2qstr(const char *p)
118{
119 outqstr(p, out2);
120}
121
122void
123outstr(const char *p, struct output *file)
124{
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

117out2qstr(const char *p)
118{
119 outqstr(p, out2);
120}
121
122void
123outstr(const char *p, struct output *file)
124{
125 while (*p)
126 outc(*p++, file);
125 outbin(p, strlen(p), file);
127}
128
129/* Like outstr(), but quote for re-input into the shell. */
130void
131outqstr(const char *p, struct output *file)
132{
133 char ch;
134 int inquotes;

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

160 inquotes = 1;
161 outc(ch, file);
162 }
163 }
164 if (inquotes)
165 outc('\'', file);
166}
167
126}
127
128/* Like outstr(), but quote for re-input into the shell. */
129void
130outqstr(const char *p, struct output *file)
131{
132 char ch;
133 int inquotes;

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

159 inquotes = 1;
160 outc(ch, file);
161 }
162 }
163 if (inquotes)
164 outc('\'', file);
165}
166
167void
168outbin(const void *data, size_t len, struct output *file)
169{
170 const char *p;
171
172 p = data;
173 while (len-- > 0)
174 outc(*p++, file);
175}
176
168static char out_junk[16];
169
170void
171emptyoutbuf(struct output *dest)
172{
173 int offset;
174
175 if (dest->fd == BLOCK_OUT) {

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

280 if (strout.flags & OUTPUT_ERR)
281 outbuf[length - 1] = '\0';
282}
283
284static int
285doformat_wr(void *cookie, const char *buf, int len)
286{
287 struct output *o;
177static char out_junk[16];
178
179void
180emptyoutbuf(struct output *dest)
181{
182 int offset;
183
184 if (dest->fd == BLOCK_OUT) {

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

289 if (strout.flags & OUTPUT_ERR)
290 outbuf[length - 1] = '\0';
291}
292
293static int
294doformat_wr(void *cookie, const char *buf, int len)
295{
296 struct output *o;
288 int origlen;
289 unsigned char c;
290
291 o = (struct output *)cookie;
297
298 o = (struct output *)cookie;
292 origlen = len;
293 while (len-- != 0) {
294 c = (unsigned char)*buf++;
295 outc(c, o);
296 }
299 outbin(buf, len, o);
297
300
298 return (origlen);
301 return (len);
299}
300
301void
302doformat(struct output *dest, const char *f, va_list ap)
303{
304 FILE *fp;
305
306 if ((fp = fwopen(dest, doformat_wr)) != NULL) {

--- 33 unchanged lines hidden ---
302}
303
304void
305doformat(struct output *dest, const char *f, va_list ap)
306{
307 FILE *fp;
308
309 if ((fp = fwopen(dest, doformat_wr)) != NULL) {

--- 33 unchanged lines hidden ---