4 * This module handles states which are global to the entire server.
25 #include "sysdep_decls.h"
32 struct CitControl CitControl;
36 * get_control - read the control record into memory.
38 void get_control(void) {
41 /* Zero it out. If the control record on disk is missing or short,
42 * the system functions with all control record fields initialized
45 memset(&CitControl, 0, sizeof(struct CitControl));
46 fp = fopen("citadel.control", "rb");
47 if (fp == NULL) return;
49 fread(&CitControl, sizeof(struct CitControl), 1, fp);
54 * put_control - write the control record to disk.
56 void put_control(void) {
59 fp = fopen("citadel.control", "wb");
61 fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
68 * get_new_message_number() - Obtain a new, unique ID to be used for a message.
70 long get_new_message_number(void) {
71 begin_critical_section(S_CONTROL);
73 ++CitControl.MMhighest;
75 end_critical_section(S_CONTROL);
76 return(CitControl.MMhighest);
81 * get_new_user_number() - Obtain a new, unique ID to be used for a user.
83 long get_new_user_number(void) {
84 begin_critical_section(S_CONTROL);
86 ++CitControl.MMnextuser;
88 end_critical_section(S_CONTROL);
89 return(CitControl.MMnextuser);
95 * get_new_room_number() - Obtain a new, unique ID to be used for a room.
97 long get_new_room_number(void) {
98 begin_critical_section(S_CONTROL);
100 ++CitControl.MMnextroom;
102 end_critical_section(S_CONTROL);
103 return(CitControl.MMnextroom);
109 * Get or set global configuration options
111 void cmd_conf(char *argbuf) {
116 if (!(CC->logged_in)) {
117 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
121 if (CC->usersupp.axlevel < 6) {
122 cprintf("%d Higher access required.\n",
123 ERROR+HIGHER_ACCESS_REQUIRED);
127 extract(cmd, argbuf, 0);
128 if (!strcasecmp(cmd, "GET")) {
129 cprintf("%d Configuration...\n", LISTING_FOLLOWS);
130 cprintf("%s\n", config.c_nodename);
131 cprintf("%s\n", config.c_fqdn);
132 cprintf("%s\n", config.c_humannode);
133 cprintf("%s\n", config.c_phonenum);
134 cprintf("%d\n", config.c_creataide);
135 cprintf("%d\n", config.c_sleeping);
136 cprintf("%d\n", config.c_initax);
137 cprintf("%d\n", config.c_regiscall);
138 cprintf("%d\n", config.c_twitdetect);
139 cprintf("%s\n", config.c_twitroom);
140 cprintf("%s\n", config.c_moreprompt);
141 cprintf("%d\n", config.c_restrict);
142 cprintf("%s\n", config.c_bbs_city);
143 cprintf("%s\n", config.c_sysadm);
144 cprintf("%d\n", config.c_maxsessions);
145 cprintf("%s\n", config.c_net_password);
146 cprintf("%d\n", config.c_userpurge);
147 cprintf("%d\n", config.c_roompurge);
148 cprintf("%s\n", config.c_logpages);
152 else if (!strcasecmp(cmd, "SET")) {
153 cprintf("%d Send configuration...\n", SEND_LISTING);
155 while (client_gets(buf), strcmp(buf, "000")) {
157 case 0: strncpy(config.c_nodename, buf, 16);
159 case 1: strncpy(config.c_fqdn, buf, 64);
161 case 2: strncpy(config.c_humannode, buf, 21);
163 case 3: strncpy(config.c_phonenum, buf, 16);
165 case 4: config.c_creataide = atoi(buf);
167 case 5: config.c_sleeping = atoi(buf);
169 case 6: config.c_initax = atoi(buf);
170 if (config.c_initax < 1) config.c_initax = 1;
171 if (config.c_initax > 6) config.c_initax = 6;
173 case 7: config.c_regiscall = atoi(buf);
174 if (config.c_regiscall != 0)
175 config.c_regiscall = 1;
177 case 8: config.c_twitdetect = atoi(buf);
178 if (config.c_twitdetect != 0)
179 config.c_twitdetect = 1;
181 case 9: strncpy(config.c_twitroom,
184 case 10: strncpy(config.c_moreprompt, buf, 80);
186 case 11: config.c_restrict = atoi(buf);
187 if (config.c_restrict != 0)
188 config.c_restrict = 1;
190 case 12: strncpy(config.c_bbs_city, buf, 32);
192 case 13: strncpy(config.c_sysadm, buf, 26);
194 case 14: config.c_maxsessions = atoi(buf);
195 if (config.c_maxsessions < 1)
196 config.c_maxsessions = 1;
198 case 15: strncpy(config.c_net_password, buf, 20);
200 case 16: config.c_userpurge = atoi(buf);
202 case 17: config.c_roompurge = atoi(buf);
204 case 18: strncpy(config.c_logpages,
211 snprintf(buf,sizeof buf,
212 "Global system configuration edited by %s",
216 if (strlen(config.c_logpages) > 0)
217 create_room(config.c_logpages, 4, "", 0);
221 cprintf("%d The only valid options are GET and SET.\n",
222 ERROR+ILLEGAL_VALUE);