'\"macro stdmacro
.if n .pH g3g.copylist @(#)copylist	40.7 of 10/10/89
.\" Copyright 1989 AT&T
'''	ident	"@(#)libgen:doc/copylist.3G	1.1"
.nr X
.if \nX=0 .ds x} copylist 3G "" "\&"
.if \nX=1 .ds x} copylist 3G ""
.if \nX=2 .ds x} copylist 3G "" "\&"
.if \nX=3 .ds x} copylist "" "" "\&"
.TH \*(x}
.SH NAME
\f4copylist\f1 \- copy a file into memory
.SH SYNOPSIS
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lgen\f1
[\f2library\fP \|.\|.\|.]
.PP
\f4#include <libgen.h>\f1
.PP
\f4char \(**copylist (const char \(**filenm, off_t \(**szptr);\f1
.SH DESCRIPTION
\f4copylist\fP
copies a list of items from a file into freshly allocated memory, 
replacing new-lines with null characters.  It expects two arguments: a pointer
.I filenm
to the name of the file to be copied, and a pointer
.I szptr
to a variable where the size of the file will be stored.
.PP
Upon success,
\f4copylist\fP
returns a pointer to the memory allocated.  Otherwise it returns \s-1NULL\s+1
if it has trouble finding the file, calling \f4malloc\fP, or opening the file.
.SH EXAMPLES
.PP
.ft 4
.nf
/\(** read "file" into buf \(**/
off_t size;
char \(**buf;
buf = copylist("file", &size);
for (i = 0; i < size; i++) 
	if(buf[i])
		putchar(buf[i]);
	else
		putchar('\en');
.fi
.ft 1
.SH "SEE ALSO"
\f4malloc\fP(3C).
