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