AmendHub

Download

jcs

/

subtext

/

db.h

 

(View History)

jcs   db: Properly close board and folder biles at shutdown Latest amendment: 297 on 2022-11-30

1 /*
2 * Copyright (c) 2021 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __DB_H__
18 #define __DB_H__
19
20 #include <time.h>
21
22 #define SUBTEXT_CREATOR 'SUBT'
23
24 #define DB_TYPE 'STDB'
25
26 #define DB_CUR_VERS 12
27
28 #define DB_TRUE 0x100
29 #define DB_FALSE 0x000
30
31 #define DB_CONFIG_RTYPE 'CONF'
32 #define DB_USER_RTYPE 'USER'
33 #define DB_BOARD_RTYPE 'BORD'
34 #define DB_FOLDER_RTYPE 'FOLD'
35 #define DB_VERS_RTYPE 'VERS'
36 #define DB_MESSAGE_RTYPE 'PMSG'
37 #define DB_MOTD_RTYPE 'MOTD'
38
39 #define DB_TEXT_TYPE 'TEXT'
40 #define DB_TEXT_MENU_ID 1
41 #define DB_TEXT_SHORTMENU_ID 2
42 #define DB_TEXT_ISSUE_ID 3
43 #define DB_TEXT_SIGNUP_ID 4
44 #define DB_TEXT_PAGE_SYSOP_ID 5
45 #define DB_TEXT_NO_FREE_NODES_ID 6
46 #define DB_TEXT_SIGNOFF_ID 7
47 #define DB_TEXT_MENU_OPTIONS_ID 8
48
49 #define DB_USERNAME_LENGTH 16
50
51 #define SL_TYPE 'STSL'
52 #define SL_LOG_RTYPE 'SLOG'
53 #define SL_TALLY_RTYPE 'STLY'
54
55 #define BOARD_FILENAME_EXT "brd"
56 #define BOARD_THREAD_RTYPE 'BDTH'
57 #define BOARD_POST_RTYPE 'BDPS'
58
59 #define FOLDER_FILENAME_EXT "fld"
60 #define FOLDER_FILE_RTYPE 'FILE'
61
62 #include "subtext.h"
63 #include "bile.h"
64 #include "board.h"
65 #include "folder.h"
66 #include "settings.h"
67
68 struct config {
69 char name[32];
70 char phone_number[32];
71 char location[64];
72 char hostname[32];
73 short telnet_port;
74 short modem_port;
75 char modem_init[96];
76 short max_idle_minutes;
77 char timezone[8];
78 short open_signup;
79 short max_login_seconds;
80 short blanker_idle_seconds;
81 short blanker_runtime_seconds;
82 unsigned long trusted_proxy_ip;
83 unsigned long modem_speed;
84 unsigned short trusted_proxy_udp_port;
85 short session_log_days;
86 char modem_parity[4];
87 };
88
89 extern struct struct_field config_fields[];
90 extern size_t nconfig_fields;
91
92 struct db {
93 struct bile *bile;
94 short fh;
95 struct config config;
96 struct username_cache *username_cache;
97 short nusers;
98 struct bile *sessions_bile;
99 struct board *boards;
100 short nboards;
101 struct folder *folders;
102 short nfolders;
103 };
104
105 struct db * db_open(Str255 file, short vrefnum);
106 struct db * db_create(void);
107 void db_close(struct db *tdb);
108 void db_config_save(struct db *tdb);
109 void db_cache_boards(struct db *tdb);
110 struct bile * db_board_create(struct db *tdb, struct board *board,
111 bool delete_first);
112 void db_cache_folders(struct db *tdb);
113 struct bile * db_folder_create(struct db *tdb, struct folder *folder,
114 bool delete_first);
115
116 #endif