Debian Codegraph @

upstream/debian-unstable/man3/rwarray.3am

raw
1 .TH RWARRAY 3am "Mar 11 2022" "Free Software Foundation" "GNU Awk Extension Modules"
2 .SH NAME
3 writea, reada, writeall, readall \- write and read gawk arrays to/from files
4 .SH SYNOPSIS
5 .ft CW
6 @load "rwarray"
7 .sp
8 ret = writea(file, array)
9 .br
10 ret = reada(file, array)
11 .br
12 ret = writeall(file)
13 .br
14 ret = readall(file)
15 .ft R
16 .SH DESCRIPTION
17 The
18 .I rwarray
19 extension adds functions named
20 .BR writea() ,
21 .BR reada() ,
22 .BR writeall() ,
23 and
24 .BR readall() ,
25 as follows.
26 .TP
27 .B writea()
28 This function takes a string argument, which is the name of the
29 file to which dump the array, and the array itself as the second
30 argument.
31 .B writea()
32 understands multidimensional arrays.
33 It returns one on success, or zero upon failure.
34 .TP
35 .B reada()
36 is the inverse of
37 .BR writea() ;
38 it reads the file named as its first argument, filling in
39 the array named as the second argument. It clears the array
40 first.
41 Here too, the return value is one on success and zero upon failure.
42 .TP
43 .B writeall()
44 This function takes a string argument, which is the name of the
45 file to which dump the state of all variables. Calling this function
46 is completely equivalent to calling
47 .B writea()
48 with the second argument equal to
49 .BR SYMTAB .
50 It returns one on success, or zero upon failure.
51 .TP
52 .B readall()
53 This function takes a string argument, which is the name of the
54 file from which to read the contents of various global variables.
55 For each variable in the file, the data is loaded unless the variable
56 already exists. If the variable already exists, the data for that variable
57 in the file is ignored.
58 It returns one on success, or zero upon failure.
59 .SH NOTES
60 The array created by
61 .B reada()
62 is identical to that written by
63 .B writea()
64 in the sense that the contents are the same. However, due
65 to implementation issues, the array traversal order of the recreated
66 array will likely be different from that of the original array.
67 As array traversal order in AWK is by default undefined, this is
68 not (technically) a problem. If you need to guarantee a particular
69 traversal order, use the array sorting features in
70 .I gawk
71 to do so.
72 .PP
73 The file contains binary data. All integral values are written
74 in network byte order.
75 However, double precision floating-point values are written as
76 native binary data. Thus, arrays containing only string data
77 can theoretically be dumped on systems with one byte order and
78 restored on systems with a different one, but this has not been tried.
79 .\" .SH BUGS
80 .SH EXAMPLE
81 .ft CW
82 .nf
83 @load "rwarray"
84 \&...
85 ret = writea("arraydump.bin", array)
86 \&...
87 ret = reada("arraydump.bin", array)
88 \&...
89 ret = writeall("globalstate.bin")
90 \&...
91 ret = readall("globalstate.bin")
92 .fi
93 .ft R
94 .SH "SEE ALSO"
95 .IR "GAWK: Effective AWK Programming" ,
96 .IR filefuncs (3am),
97 .IR fnmatch (3am),
98 .IR fork (3am),
99 .IR inplace (3am),
100 .IR ordchr (3am),
101 .IR readdir (3am),
102 .IR readfile (3am),
103 .IR revoutput (3am),
104 .IR time (3am).
105 .SH AUTHOR
106 Arnold Robbins,
107 .BR [email protected] .
108 .SH COPYING PERMISSIONS
109 Copyright \(co 2012, 2013, 2018, 2022
110 Free Software Foundation, Inc.
111 .PP
112 Permission is granted to make and distribute verbatim copies of
113 this manual page provided the copyright notice and this permission
114 notice are preserved on all copies.
115 .ig
116 Permission is granted to process this file through troff and print the
117 results, provided the printed document carries copying permission
118 notice identical to this one except for the removal of this paragraph
119 (this paragraph not being relevant to the printed manual page).
120 ..
121 .PP
122 Permission is granted to copy and distribute modified versions of this
123 manual page under the conditions for verbatim copying, provided that
124 the entire resulting derived work is distributed under the terms of a
125 permission notice identical to this one.
126 .PP
127 Permission is granted to copy and distribute translations of this
128 manual page into another language, under the above conditions for
129 modified versions, except that this permission notice may be stated in
130 a translation approved by the Foundation.
131 .\" vim: set filetype=nroff :