-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBBSMAIN.C
executable file
·124 lines (99 loc) · 2.51 KB
/
MBBSMAIN.C
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
#include "gcomm.h"
#include "majorbbs.h"
#include "stdio.h"
#include "mbbsemu.h"
#include "globals.h"
#include "submod.h"
#include "topmenu.h"
#include "echo.h"
#include "float.h"
#include "timer.h"
#include "fsedit.h"
#include "fsdata.h"
#include "btrieve.h"
// Globals
int moduleState;
FILE *mcv = NULL;
BTVFILE* bdb = NULL;
static int initializeUserData() {
memset(getUserData(), 0, sizeof(UserData));
return pushSubModule(SUBMODULE_TOPMENU);
}
static void cleanupUserData() {
}
static int sttrou() {
int doDefaultInputProcessing = 1;
int ret = 1;
SubModule* subModule;
setmbk(mcv);
setbtv(bdb);
if (usrptr->substt == 0) {
usrptr->substt = 1;
ret = initializeUserData();
} else {
// user has entered marc, margv
subModule = getSubModule();
doDefaultInputProcessing =
subModule == NULL ||
((subModule->flags & NO_DEFAULT_INPUT_PROCESSING) == 0);
if (doDefaultInputProcessing && margc == 1 && strcmp(margv[0], "x") == 0) {
ret = popSubModule();
} else {
if (subModule->onInput != NULL) {
ret = subModule->onInput();
}
}
}
rstmbk();
rstbtv();
outprf(usrnum);
if (ret == 0) {
cleanupUserData();
}
return ret; // return 0 to exit module
};
static void exit_routine();
struct module example = {
"", // should be empty and gotten from .MDF
NULL, // user logon routine
sttrou, // input routine
NULL, // status-input routine
NULL, // injoth"
NULL, // user logoff
NULL, // hangup
NULL, // midnight cleanup
NULL, // delete account routine
exit_routine}; // finish up routine
static void initSubModules() {
initTopMenuSubModule();
initEchoSubModule();
initTimerSubModule();
initFullScreenEditorSubModule();
initFullScreenDataSubModule();
initFloatSubModule();
initBtrieveSubModule();
}
void EXPORT init__mbbsemu() {
initSubModules();
// get name from .MDF file
stzcpy(example.descrp, gmdnam("MBBSEMU.MDF"), MNMSIZ);
moduleState = register_module(&example);
mcv = opnmsg("MBBSEMU.MCV");
bdb = opnbtv("MBBSEMU.DAT", sizeof(DBRECORD));
// allocate memory per user
dclvda(sizeof(UserData));
setmbk(mcv); // pushes
LOG(getmsg(STARTUP));
rstmbk(); // pops
};
static void exit_routine() {
if (mcv != NULL) {
clsmsg(mcv);
mcv = NULL;
}
if (bdb != NULL) {
clsbtv(bdb);
bdb = NULL;
}
shocst(ACCOUNT_LOG, "Shutting down");
}