AmendHub

Download

jcs

/

subtext

/

db.h

 

(View History)

jcs   logger: Add RFC3164 (BSD) syslog support Latest amendment: 585 on 2024-02-13

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 DB_CUR_VERS 22
23
24 #define SUBTEXT_CREATOR 'SUBT'
25 #define DB_TYPE 'STDB'
26
27 #define DB_TRUE 0x100
28 #define DB_FALSE 0x000
29
30 #define DB_CONFIG_RTYPE 'CONF'
31 #define DB_USER_RTYPE 'USER'
32 #define DB_BOARD_RTYPE 'BORD'
33 #define DB_FOLDER_RTYPE 'FOLD'
34 #define DB_VERS_RTYPE 'VERS'
35 #define DB_MOTD_RTYPE 'MOTD'
36
37 #define DB_USERNAME_LENGTH 16
38
39 #define SL_TYPE 'STSL'
40 #define SL_LOG_RTYPE 'SLOG'
41 #define SL_TALLY_RTYPE 'STLY'
42
43 #define BOARD_FILENAME_EXT "brd"
44 #define BOARD_THREAD_RTYPE 'BDTH'
45 #define BOARD_POST_RTYPE 'BDPS'
46 #define BOARD_FTN_POST_RTYPE 'BDFP'
47 #define BOARD_FTN_MSGID_CACHE_RTYPE 'BDMC'
48 #define BOARD_SORTED_ID_MAP_RTYPE 'BDDX'
49
50 #define FOLDER_FILENAME_EXT "fld"
51 #define FOLDER_FILE_RTYPE 'FILE'
52
53 #define MAIL_SPOOL_TYPE 'STMS'
54 #define MAIL_SPOOL_MESSAGE_RTYPE 'PMSG'
55
56 #define FTN_SPOOL_PACKET_TYPE 'FNSP'
57
58 #include "subtext.h"
59 #include "bile.h"
60 #include "board.h"
61 #include "folder.h"
62 #include "ipdb.h"
63 #include "settings.h"
64
65 struct config {
66 char name[32];
67 char phone_number[32];
68 char location[64];
69 char hostname[32];
70 short telnet_port;
71 short modem_port;
72 char modem_init[96];
73 short max_idle_minutes;
74 char timezone[8];
75 short open_signup;
76 short max_login_seconds;
77 short blanker_idle_seconds;
78 short blanker_runtime_seconds;
79 unsigned long trusted_proxy_ip;
80 unsigned long modem_speed;
81 unsigned short trusted_proxy_udp_port;
82 short session_log_prune_days;
83 char modem_parity[4];
84 char ftn_node_addr[32];
85 char ftn_hub_addr[32];
86 char ftn_hub_pkt_password[9];
87 char binkp_hostname[64];
88 unsigned short binkp_port;
89 char binkp_password[32];
90 unsigned long binkp_interval_seconds;
91 short binkp_delete_done;
92 short timezone_utcoff;
93 char ftn_network[16];
94 short mail_prune_days;
95 unsigned long ftn_max_tossed_message_size;
96 short max_sysop_idle_minutes;
97 char ipdb_path[255];
98 short modem_rings;
99 unsigned long syslog_ip;
100 };
101
102 extern struct struct_field config_fields[];
103 extern size_t nconfig_fields;
104
105 enum {
106 DB_VIEW_MENU = 0,
107 DB_VIEW_SHORTMENU,
108 DB_VIEW_ISSUE,
109 DB_VIEW_SIGNUP,
110 DB_VIEW_PAGE_SYSOP,
111 DB_VIEW_NO_FREE_NODES,
112 DB_VIEW_SIGNOFF,
113 DB_VIEW_MENU_OPTIONS,
114
115 DB_VIEW_COUNT
116 };
117
118 struct db {
119 struct bile *bile;
120 short fh;
121 struct config config;
122 struct username_cache *username_cache;
123 short nusers;
124 struct bile *sessions_bile;
125 struct board *boards;
126 short nboards;
127 struct folder *folders;
128 short nfolders;
129 struct bile *mail_bile;
130 struct ipdb_file *ipdb;
131 char *views[DB_VIEW_COUNT];
132 };
133
134 struct db * db_open(Str255 file, short vrefnum, bool ignore_last);
135 struct db * db_create(void);
136 void db_close(struct db *tdb);
137 void db_config_save(struct db *tdb);
138
139 void db_cache_boards(struct db *tdb);
140 struct bile * db_board_create(struct db *tdb, struct board *board,
141 bool delete_first);
142 void db_board_delete(struct db *tdb, struct board *board);
143
144 void db_cache_folders(struct db *tdb);
145 struct bile * db_folder_create(struct db *tdb, struct folder *folder,
146 bool delete_first);
147 void db_folder_delete(struct db *tdb, struct folder *folder);
148
149 void db_cache_views(struct db *tdb);
150 void db_view_write(struct db *tdb, short id, char *str, size_t size);
151
152 #endif