4 * This module handles states which are global to the entire server.
24 #include "sysdep_decls.h"
30 struct CitControl CitControl;
34 * get_control - read the control record into memory.
36 void get_control(void) {
39 /* Zero it out. If the control record on disk is missing or short,
40 * the system functions with all control record fields initialized
43 memset(&CitControl, 0, sizeof(struct CitControl));
44 fp = fopen("citadel.control", "rb");
45 if (fp == NULL) return;
47 fread(&CitControl, sizeof(struct CitControl), 1, fp);
52 * put_control - write the control record to disk.
54 void put_control(void) {
57 fp = fopen("citadel.control", "wb");
59 fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
66 * get_new_message_number() - Obtain a new, unique ID to be used for a message.
68 long get_new_message_number(void) {
69 begin_critical_section(S_CONTROL);
71 ++CitControl.MMhighest;
73 end_critical_section(S_CONTROL);
74 return(CitControl.MMhighest);
79 * get_new_user_number() - Obtain a new, unique ID to be used for a user.
81 long get_new_user_number(void) {
82 begin_critical_section(S_CONTROL);
84 ++CitControl.MMnextuser;
86 end_critical_section(S_CONTROL);
87 return(CitControl.MMnextuser);
93 * get_new_room_number() - Obtain a new, unique ID to be used for a room.
95 long get_new_room_number(void) {
96 begin_critical_section(S_CONTROL);
98 ++CitControl.MMnextroom;
100 end_critical_section(S_CONTROL);
101 return(CitControl.MMnextroom);
107 * Get or set global configuration options
109 void cmd_conf(char *argbuf) {
114 if (!(CC->logged_in)) {
115 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
119 if (CC->usersupp.axlevel < 6) {
120 cprintf("%d Higher access required.\n",
121 ERROR+HIGHER_ACCESS_REQUIRED);
125 extract(cmd, argbuf, 0);
126 if (!strcasecmp(cmd, "GET")) {
127 cprintf("%d Configuration...\n", LISTING_FOLLOWS);
128 cprintf("%s\n", config.c_nodename);
129 cprintf("%s\n", config.c_fqdn);
130 cprintf("%s\n", config.c_humannode);
131 cprintf("%s\n", config.c_phonenum);
132 cprintf("%d\n", config.c_creataide);
133 cprintf("%d\n", config.c_sleeping);
134 cprintf("%d\n", config.c_initax);
135 cprintf("%d\n", config.c_regiscall);
136 cprintf("%d\n", config.c_twitdetect);
137 cprintf("%s\n", config.c_twitroom);
138 cprintf("%s\n", config.c_moreprompt);
139 cprintf("%d\n", config.c_restrict);
140 cprintf("%s\n", config.c_bbs_city);
141 cprintf("%s\n", config.c_sysadm);
142 cprintf("%d\n", config.c_maxsessions);
143 cprintf("%s\n", config.c_net_password);
144 cprintf("%d\n", config.c_userpurge);
145 cprintf("%d\n", config.c_roompurge);
149 else if (!strcasecmp(cmd, "SET")) {
150 cprintf("%d Send configuration...\n", SEND_LISTING);
152 while (client_gets(buf), strcmp(buf, "000")) {
154 case 0: strncpy(config.c_nodename, buf, 16);
156 case 1: strncpy(config.c_fqdn, buf, 64);
158 case 2: strncpy(config.c_humannode, buf, 21);
160 case 3: strncpy(config.c_phonenum, buf, 16);
162 case 4: config.c_creataide = atoi(buf);
164 case 5: config.c_sleeping = atoi(buf);
166 case 6: config.c_initax = atoi(buf);
167 if (config.c_initax < 1) config.c_initax = 1;
168 if (config.c_initax > 6) config.c_initax = 6;
170 case 7: config.c_regiscall = atoi(buf);
171 if (config.c_regiscall != 0)
172 config.c_regiscall = 1;
174 case 8: config.c_twitdetect = atoi(buf);
175 if (config.c_twitdetect != 0)
176 config.c_twitdetect = 1;
178 case 9: strncpy(config.c_twitroom,
181 case 10: strncpy(config.c_moreprompt, buf, 80);
183 case 11: config.c_restrict = atoi(buf);
184 if (config.c_restrict != 0)
185 config.c_restrict = 1;
187 case 12: strncpy(config.c_bbs_city, buf, 32);
189 case 13: strncpy(config.c_sysadm, buf, 26);
191 case 14: config.c_maxsessions = atoi(buf);
192 if (config.c_maxsessions < 1)
193 config.c_maxsessions = 1;
195 case 15: strncpy(config.c_net_password, buf, 20);
197 case 16: config.c_userpurge = atoi(buf);
199 case 17: config.c_roompurge = atoi(buf);
205 snprintf(buf,sizeof buf,
206 "Global system configuration edited by %s",
212 cprintf("%d The only valid options are GET and SET.\n",
213 ERROR+ILLEGAL_VALUE);