|
1 /* FPUTS.C |
|
2 * |
|
3 * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 */ |
|
6 |
|
7 /* |
|
8 * Copyright (c) 1990 The Regents of the University of California. |
|
9 * All rights reserved. |
|
10 * |
|
11 * Redistribution and use in source and binary forms are permitted |
|
12 * provided that the above copyright notice and this paragraph are |
|
13 * duplicated in all such forms and that any documentation, |
|
14 * advertising materials, and other materials related to such |
|
15 * distribution and use acknowledge that the software was developed |
|
16 * by the University of California, Berkeley. The name of the |
|
17 * University may not be used to endorse or promote products derived |
|
18 * from this software without specific prior written permission. |
|
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
|
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
22 */ |
|
23 |
|
24 /* |
|
25 FUNCTION |
|
26 <<fputs>>---write a character string in a file or stream |
|
27 |
|
28 INDEX |
|
29 fputs |
|
30 |
|
31 ANSI_SYNOPSIS |
|
32 #include <stdio.h> |
|
33 int fputs(const char *<[s]>, FILE *<[fp]>); |
|
34 |
|
35 TRAD_SYNOPSIS |
|
36 #include <stdio.h> |
|
37 int fputs(<[s]>, <[fp]>) |
|
38 char *<[s]>; |
|
39 FILE *<[fp]>; |
|
40 |
|
41 DESCRIPTION |
|
42 <<fputs>> writes the string at <[s]> (but without the trailing null) |
|
43 to the file or stream identified by <[fp]>. |
|
44 |
|
45 RETURNS |
|
46 If successful, the result is <<0>>; otherwise, the result is <<EOF>>. |
|
47 |
|
48 PORTABILITY |
|
49 ANSI C requires <<fputs>>, but does not specify that the result on |
|
50 success must be <<0>>; any non-negative value is permitted. |
|
51 |
|
52 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
|
53 <<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
|
54 */ |
|
55 |
|
56 #include <stdio.h> |
|
57 #include <string.h> |
|
58 #include "FVWRITE.H" |
|
59 |
|
60 |
|
61 /** |
|
62 Write string to a stream. |
|
63 Writes string to the current position of the given stream. |
|
64 On error the function returns EOF. |
|
65 @param s Null-terminated string to be written. |
|
66 @param fp pointer to an open file. |
|
67 */ |
|
68 EXPORT_C int |
|
69 fputs (char const *s, FILE * fp) |
|
70 { |
|
71 struct __suio uio; |
|
72 struct __siov iov; |
|
73 |
|
74 iov.iov_base = s; |
|
75 iov.iov_len = uio.uio_resid = strlen (s); |
|
76 uio.uio_iov = &iov; |
|
77 uio.uio_iovcnt = 1; |
|
78 return __sfvwrite (fp, &uio); |
|
79 } |