1 | /* |
---|
2 | * emfdb.h -- EMF database compatability functions for GoAhead WebServer. |
---|
3 | * |
---|
4 | * Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved. |
---|
5 | * |
---|
6 | * See the file "license.txt" for usage and redistribution license requirements |
---|
7 | * |
---|
8 | * $Id$ |
---|
9 | */ |
---|
10 | |
---|
11 | /******************************** Description *********************************/ |
---|
12 | /* |
---|
13 | * Emf-like textfile database support for WebServer 2.1. |
---|
14 | */ |
---|
15 | |
---|
16 | /********************************* Includes ***********************************/ |
---|
17 | |
---|
18 | #ifndef _h_EMFDB |
---|
19 | #define _h_EMFDB 1 |
---|
20 | |
---|
21 | #if ! UEMF |
---|
22 | #include "basic/basic.h" |
---|
23 | #include "emf/emf.h" |
---|
24 | #else |
---|
25 | #include "uemf.h" |
---|
26 | #endif |
---|
27 | |
---|
28 | |
---|
29 | /********************************* Defines ************************************/ |
---|
30 | |
---|
31 | #define T_INT 0 |
---|
32 | #define T_STRING 1 |
---|
33 | |
---|
34 | #define DB_OK 0 |
---|
35 | #define DB_ERR_GENERAL -1 |
---|
36 | #define DB_ERR_COL_NOT_FOUND -2 |
---|
37 | #define DB_ERR_COL_DELETED -3 |
---|
38 | #define DB_ERR_ROW_NOT_FOUND -4 |
---|
39 | #define DB_ERR_ROW_DELETED -5 |
---|
40 | #define DB_ERR_TABLE_NOT_FOUND -6 |
---|
41 | #define DB_ERR_TABLE_DELETED -7 |
---|
42 | #define DB_ERR_BAD_FORMAT -8 |
---|
43 | |
---|
44 | typedef struct dbTable_s { |
---|
45 | char_t *name; |
---|
46 | int nColumns; |
---|
47 | char_t **columnNames; |
---|
48 | int *columnTypes; |
---|
49 | int nRows; |
---|
50 | int **rows; |
---|
51 | } dbTable_t; |
---|
52 | |
---|
53 | /********************************** Prototypes ********************************/ |
---|
54 | |
---|
55 | /* |
---|
56 | * Add a schema to the module-internal schema database |
---|
57 | */ |
---|
58 | extern int dbRegisterDBSchema(dbTable_t *sTable); |
---|
59 | |
---|
60 | extern int dbOpen(char_t *databasename, char_t *filename, |
---|
61 | int (*gettime)(int did), int flags); |
---|
62 | extern void dbClose(int did); |
---|
63 | extern int dbGetTableId(int did, char_t *tname); |
---|
64 | extern char_t *dbGetTableName(int did, int tid); |
---|
65 | extern int dbReadInt(int did, char_t *table, char_t *column, int row, |
---|
66 | int *returnValue); |
---|
67 | extern int dbReadStr(int did, char_t *table, char_t *column, int row, |
---|
68 | char_t **returnValue); |
---|
69 | extern int dbWriteInt(int did, char_t *table, char_t *column, int row, |
---|
70 | int idata); |
---|
71 | extern int dbWriteStr(int did, char_t *table, char_t *column, int row, |
---|
72 | char_t *s); |
---|
73 | extern int dbAddRow(int did, char_t *table); |
---|
74 | extern int dbDeleteRow(int did, char_t *table, int rid); |
---|
75 | extern int dbSetTableNrow(int did, char_t *table, int nNewRows); |
---|
76 | extern int dbGetTableNrow(int did, char_t *table); |
---|
77 | |
---|
78 | /* |
---|
79 | * Dump the contents of a database to file |
---|
80 | */ |
---|
81 | extern int dbSave(int did, char_t *filename, int flags); |
---|
82 | |
---|
83 | /* |
---|
84 | * Load the contents of a database to file |
---|
85 | */ |
---|
86 | extern int dbLoad(int did, char_t *filename, int flags); |
---|
87 | |
---|
88 | /* |
---|
89 | * Search for a data in a given column |
---|
90 | */ |
---|
91 | extern int dbSearchStr(int did, char_t *table, char_t *column, |
---|
92 | char_t *value, int flags); |
---|
93 | |
---|
94 | extern void dbZero(int did); |
---|
95 | |
---|
96 | extern char_t *basicGetProductDir(); |
---|
97 | extern void basicSetProductDir(char_t *proddir); |
---|
98 | |
---|
99 | #endif /* _h_EMFDB */ |
---|
100 | |
---|
101 | /******************************************************************************/ |
---|
102 | |
---|