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 ***********************************************************************/
24 /* Write out a character n times
26 ** Written by Kiem-Phong Vo.
30 ssize_t
sfnputc(Sfio_t
* f
, int c
, size_t n
)
32 ssize_t
sfnputc(f
,c
,n
)
33 Sfio_t
* f
; /* file to write */
34 int c
; /* char to be written */
35 size_t n
; /* number of time to repeat */
47 if(SFMODE(f
,local
) != SF_WRITE
&& _sfmode(f
,SF_WRITE
,local
) < 0)
52 /* write into a suitable buffer */
53 if((size_t)(p
= (f
->endb
-(ps
= f
->next
))) < n
)
54 { ps
= buf
; p
= sizeof(buf
); }
62 { /* simple sfwrite */
70 { /* hard write of data */
71 if((p
= SFWRITE(f
,(Void_t
*)ps
,p
)) <= 0 || (n
-= p
) <= 0)