8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man3gen / copylist.3gen
blob3545bcda0e0d272ce3fd565fdf5bbaa67ec173cb
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH COPYLIST 3GEN "Dec 29, 1996"
7 .SH NAME
8 copylist \- copy a file into memory
9 .SH SYNOPSIS
10 .LP
11 .nf
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ]
13 #include <libgen.h>
15 \fBchar *\fR\fBcopylist\fR(\fBconst char *\fR\fIfilenm\fR, \fBoff_t *\fR\fIszptr\fR);
16 .fi
18 .SH DESCRIPTION
19 .sp
20 .LP
21 The \fBcopylist()\fR function copies a list of items from a file into freshly
22 allocated memory,  replacing new-lines with null characters.  It expects two
23 arguments: a pointer \fIfilenm\fR to the name of the file to be copied, and a
24 pointer \fIszptr\fR to a variable where the size of the file will be stored.
25 .sp
26 .LP
27 Upon success, \fBcopylist()\fR returns a pointer to the memory allocated.
28 Otherwise it returns NULL if it has trouble finding the file, calling
29 \fBmalloc()\fR, or reading the file.
30 .SH USAGE
31 .sp
32 .LP
33 The \fBcopylist()\fR function has a transitional interface for 64-bit file
34 offsets. See \fBlf64\fR(5).
35 .SH EXAMPLES
36 .LP
37 \fBExample 1 \fRExample of \fBcopylist()\fR function.
38 .sp
39 .in +2
40 .nf
41 /* read "file" into buf */
42 off_t size;
43 char *buf;
44 buf = copylist("file", &size);
45 if (buf) {
46         for (i=0; i<size; i++)
47                 if (buf[i])
48                         putchar(buf[i]);
49                 else
50                         putchar('\en');
51         }
52 } else {
53         fprintf(stderr, "%s: Copy failed for "file".\en", argv[0]);
54         exit (1);
56 .fi
57 .in -2
59 .SH ATTRIBUTES
60 .sp
61 .LP
62 See \fBattributes\fR(5) for descriptions of the following attributes:
63 .sp
65 .sp
66 .TS
67 box;
68 c | c
69 l | l .
70 ATTRIBUTE TYPE  ATTRIBUTE VALUE
72 MT-Level        MT-Safe
73 .TE
75 .SH SEE ALSO
76 .sp
77 .LP
78 \fBmalloc\fR(3C), \fBattributes\fR(5), \fBlf64\fR(5)
79 .SH NOTES
80 .sp
81 .LP
82 When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be
83 defined on the compile line.  This flag should only be used in multithreaded
84 applications.