blob: 1a80ca2807c5994fd09e3293005489f5c850ddc0 [file] [log] [blame]
alaffinf5589902000-09-21 21:35:06 +00001/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
31 *
32 */
33/* $Id: symbol.h,v 1.1 2000/09/21 21:35:06 alaffin Exp $ */
34#ifndef _SYMBOL_H_
35#define _SYMBOL_H_
36
37/*
38 * "Generic" Symbol Table
39 *
40 * These data structures are the internal part of a library providing
41 * an in-memory dbm-like (key, content) database with hierarchical
42 * key names.
43 */
44struct sym {
45 struct sym *next;
46 char *key;
47 void *data;
48};
49
50/*
51 * Symbol Table Header
52 */
53struct symh {
54 int magic;
55 struct sym *sym;
56 struct sym *cursor;
57};
58
59/*
60 * The "SYM" typedef is the only external data type.
61 */
62typedef struct symh *SYM;
63
64/*
65 * Data for keys and contents (lifted from dbopen(3))
66 * dbopen(3) uses this for all functions, but I'm hard-wired into chars
67 * for keys and the like; I just need this for sym_get
68 */
69typedef struct {
70 void *data;
71 int size;
72} DBT;
73
74/*
75 * Prototypes
76 */
77
78SYM sym_open(int flags, int mode, int openinfo );
79int sym_put (SYM sym, char *key, void *data, int flags );
80void *sym_get (SYM sym, char *key );
81int sym_seq (SYM sym, DBT *key, DBT *data, int flags );
82int sym_rm (SYM sym, int flags );
83
84/*
85 * Flags for sym_put
86 */
87#define PUT_REPLACE 1 /* replace data on a put */
88
89/*
90 * Flags for sym_rm
91 */
92#define RM_KEY 001 /* free() on key pointer */
93#define RM_DATA 002 /* free() on data pointer */
94
95/*
96 * Flags for sym_seq (clones of 44BSD dbopen(3))
97 */
98#define R_CURSOR 1 /* set "cursor" to where "data" key is */
99#define R_FIRST 2 /* set "cursor" to first item */
100#define R_NEXT 4 /* set "cursor" to next item */
101#define R_LAST 3 /* set "cursor" to last item (UNIMP) */
102#define R_PREV 5 /* set "cursor" to previous item (UNIMP) */
103
104#endif