4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
37 * 'pickle' is the package for storing data structures into files.
38 * 'pickle_file' is the base class. Classes that inherit this base
39 * class need to instantiate the virtual function 'dump'.
43 PICKLE_READ
, PICKLE_WRITE
, PICKLE_APPEND
46 typedef enum pickle_mode pickle_mode
;
48 typedef void* pptr
; /* pickle pointer */
52 FILE *file
; /* file handle */
59 /* Constructor. Creates pickle_file with given name and mode. */
60 pickle_file(char *, pickle_mode
);
62 ~pickle_file() { delete filename
; DESTROYRW(pickle
); }
65 * Opens pickle_file with mode specified with constructor.
66 * Returns TRUE if open was successful; FALSE otherwise.
70 /* Closes pickle_file. Returns 0 if successful; -1 otherwise. */
74 * dump or load data structure to/from 'filename' using function 'f'.
75 * dump/load is determined by 'mode' with which pickle_file was created.
76 * Returns 0 if successful; 1 if file cannot be opened in mode
77 * specified; -1 if transfer failed do to encoding/decoding errors.
79 int transfer(pptr
, bool_t (*f
) (XDR
*, pptr
));
81 /* Exclusive access */
83 return (WLOCK(pickle
));
87 return (WULOCK(pickle
));