1copylist(3GEN)     String Pattern-Matching Library Functions    copylist(3GEN)
2
3
4

NAME

6       copylist - copy a file into memory
7

SYNOPSIS

9       cc [ flag ... ] file ... -lgen [ library ... ]
10       #include <libgen.h>
11
12       char *copylist(const char *filenm, off_t *szptr);
13
14

DESCRIPTION

16       The copylist() function copies a list of items from a file into freshly
17       allocated  memory,   replacing  new-lines  with  null  characters.   It
18       expects  two  arguments: a pointer filenm to the name of the file to be
19       copied, and a pointer szptr to a variable where the size  of  the  file
20       will be stored.
21
22
23       Upon  success,  copylist()  returns  a pointer to the memory allocated.
24       Otherwise it returns NULL if it has trouble finding the  file,  calling
25       malloc(), or reading the file.
26

USAGE

28       The  copylist()  function  has a transitional interface for 64-bit file
29       offsets. See lf64(5).
30

EXAMPLES

32       Example 1 Example of copylist() function.
33
34         /* read "file" into buf */
35         off_t size;
36         char *buf;
37         buf = copylist("file", &size);
38         if (buf) {
39              for (i=0; i<size; i++)
40                   if (buf[i])
41                        putchar(buf[i]);
42                   else
43                        putchar('\n');
44              }
45         } else {
46              fprintf(stderr, "%s: Copy failed for "file".\n", argv[0]);
47              exit (1);
48         }
49
50

ATTRIBUTES

52       See attributes(5) for descriptions of the following attributes:
53
54
55
56
57       ┌─────────────────────────────┬─────────────────────────────┐
58       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
59       ├─────────────────────────────┼─────────────────────────────┤
60       │MT-Level                     │MT-Safe                      │
61       └─────────────────────────────┴─────────────────────────────┘
62

SEE ALSO

64       malloc(3C), attributes(5), lf64(5)
65

NOTES

67       When compiling multithreaded applications, the _REENTRANT flag must  be
68       defined  on  the compile line.  This flag should only be used in multi‐
69       threaded applications.
70
71
72
73SunOS 5.11                        29 Dec 1996                   copylist(3GEN)
Impressum