]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libh/fmt.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libh / fmt.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../h/iobuf.h"
9 #define NBUFFED 256 /* limit on fmt buffer */
10
11 extern struct iobuf fout;
12 int fmtlen;
13
14 fmt(fmtstrng, arg1, arg2, arg3)
15 char *fmtstrng;
16 {
17 int svfildes, svnleft, svnextp;
18
19 flush();
20 svfildes = fout.b_fildes;
21 svnleft = fout.b_nleft;
22 svnextp = fout.b_nextp;
23
24 /* a very illegal file handle */
25 fout.b_fildes = 99;
26 /* use last half of fout buffer */
27 fout.b_nleft = NBUFFED;
28 fout.b_nextp = &fout.b_buff[512-NBUFFED];
29 printf("%r", &fmtstrng); /* and pass the buck ... */
30 fmtlen = fout.b_nextp - &fout.b_buff[512-NBUFFED];
31 putchar(0);
32
33 fout.b_fildes = svfildes;
34 fout.b_nleft = svnleft;
35 fout.b_nextp = svnextp;
36
37 return(&fout.b_buff[512-NBUFFED]);
38 }