Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / share / man / man3gen / copylist.3gen
blob2520aaba25dd136def59b8e4d606115a13da4bb7
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 EXAMPLES
31 .LP
32 \fBExample 1 \fRExample of \fBcopylist()\fR function.
33 .sp
34 .in +2
35 .nf
36 /* read "file" into buf */
37 off_t size;
38 char *buf;
39 buf = copylist("file", &size);
40 if (buf) {
41         for (i=0; i<size; i++)
42                 if (buf[i])
43                         putchar(buf[i]);
44                 else
45                         putchar('\en');
46         }
47 } else {
48         fprintf(stderr, "%s: Copy failed for "file".\en", argv[0]);
49         exit (1);
51 .fi
52 .in -2
54 .SH ATTRIBUTES
55 .sp
56 .LP
57 See \fBattributes\fR(5) for descriptions of the following attributes:
58 .sp
60 .sp
61 .TS
62 box;
63 c | c
64 l | l .
65 ATTRIBUTE TYPE  ATTRIBUTE VALUE
67 MT-Level        MT-Safe
68 .TE
70 .SH SEE ALSO
71 .sp
72 .LP
73 \fBmalloc\fR(3C), \fBattributes\fR(5)