forked from xythian/wp-lambdamoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_io.h
131 lines (111 loc) · 4.46 KB
/
db_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/******************************************************************************
Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved.
Portions of this code were written by Stephen White, aka ghond.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
Pavel Curtis
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
Pavel@Xerox.Com
*****************************************************************************/
/*****************************************************************************
* Routines for use by non-DB modules with persistent state stored in the DB
*****************************************************************************/
#include "program.h"
#include "structures.h"
#include "version.h"
/*********** Input ***********/
extern DB_Version dbio_input_version;
/* What DB-format version are we reading? */
extern void dbio_read_line(char *s, int n);
/* Reads at most N-1 characters through the
* next newline into S, terminating S with a
* null. (Like the `fgets()' function.)
*/
extern int dbio_scanf(const char *format,...);
extern int dbio_read_num(void);
extern Objid dbio_read_objid(void);
extern double dbio_read_float(void);
extern const char *dbio_read_string(void);
/* The returned string is in private storage of
* the DBIO module, so the caller should
* str_dup() it if it is to persist.
*/
extern const char *dbio_read_string_intern(void);
/* The returned string is duplicated
* and possibly interned in a db-load
* string intern table.
*/
extern Var dbio_read_var(void);
/* The DBIO module retains no references to
* the returned value, so freeing it is
* entirely the responsibility of the caller.
*/
extern Program *dbio_read_program(DB_Version version,
const char *(*fmtr) (void *),
void *data);
/* FMTR is called with DATA to produce a human-
* understandable identifier for the program
* being read, for use in any error/warning
* messages. If FMTR is null, then DATA should
* be the required string.
*/
/*********** Output ***********/
/* NOTE: All output routines can raise a (private) exception if they are unable
* to write all of the requested output (e.g., because there is no more space
* on disk). The DB module catches this exception and retries the DB dump
* after performing appropriate notifications, waiting, and/or fixes. Callers
* should thus be prepared for any call to these routines to fail to return
* normally, using TRY ... FINALLY ... if necessary to recover from such an
* event.
*/
extern void dbio_printf(const char *format,...);
extern void dbio_write_num(int);
extern void dbio_write_objid(Objid);
extern void dbio_write_float(double);
extern void dbio_write_string(const char *);
/* The given string should not contain any
* newline characters.
*/
extern void dbio_write_var(Var);
extern void dbio_write_program(Program *);
extern void dbio_write_forked_program(Program * prog, int f_index);
/*
* $Log$
* Revision 1.4 1998/12/14 13:17:35 nop
* Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
*
* Revision 1.3 1998/02/19 07:36:16 nop
* Initial string interning during db load.
*
* Revision 1.2 1997/03/03 04:18:28 nop
* GNU Indent normalization
*
* Revision 1.1.1.1 1997/03/03 03:45:02 nop
* LambdaMOO 1.8.0p5
*
* Revision 2.3 1996/02/08 06:28:21 pavel
* Added dbio_input_version, dbio_read/write_float(). Made dbio_read_program
* version-dependent. Updated copyright notice for 1996. Release 1.8.0beta1.
*
* Revision 2.2 1995/12/28 00:46:52 pavel
* Added support for printing location of MOO-compilation warnings and errors
* during loading. Release 1.8.0alpha3.
*
* Revision 2.1 1995/12/11 08:00:11 pavel
* Removed another silly use of `unsigned'.
*
* Release 1.8.0alpha2.
*
* Revision 2.0 1995/11/30 05:05:29 pavel
* New baseline version, corresponding to release 1.8.0alpha1.
*
* Revision 1.1 1995/11/30 05:05:21 pavel
* Initial revision
*/