4 * This module handles states which are global to the entire server.
24 #include "sysdep_decls.h"
29 struct CitControl CitControl;
33 * get_control - read the control record into memory.
35 void get_control(void) {
38 /* Zero it out. If the control record on disk is missing or short,
39 * the system functions with all control record fields initialized
42 memset(&CitControl, 0, sizeof(struct CitControl));
43 fp = fopen("citadel.control", "rb");
44 if (fp == NULL) return;
46 fread(&CitControl, sizeof(struct CitControl), 1, fp);
51 * put_control - write the control record to disk.
53 void put_control(void) {
56 fp = fopen("citadel.control", "wb");
58 fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
65 * get_new_message_number() - Obtain a new, unique ID to be used for a message.
67 long get_new_message_number(void) {
68 begin_critical_section(S_CONTROL);
70 ++CitControl.MMhighest;
72 end_critical_section(S_CONTROL);
73 return(CitControl.MMhighest);
78 * get_new_user_number() - Obtain a new, unique ID to be used for a user.
80 long get_new_user_number(void) {
81 begin_critical_section(S_CONTROL);
83 ++CitControl.MMnextuser;
85 end_critical_section(S_CONTROL);
86 return(CitControl.MMnextuser);
92 * get_new_room_number() - Obtain a new, unique ID to be used for a room.
94 long get_new_room_number(void) {
95 begin_critical_section(S_CONTROL);
97 ++CitControl.MMnextroom;
99 end_critical_section(S_CONTROL);
100 return(CitControl.MMnextroom);
106 * Get or set global configuration options
108 void cmd_conf(char *argbuf) {
113 if (!(CC->logged_in)) {
114 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
118 if (CC->usersupp.axlevel < 6) {
119 cprintf("%d Higher access required.\n",
120 ERROR+HIGHER_ACCESS_REQUIRED);
124 extract(cmd, argbuf, 0);
125 if (!strcasecmp(cmd, "GET")) {
126 cprintf("%d Configuration...\n", LISTING_FOLLOWS);
127 cprintf("%s\n", config.c_nodename);
128 cprintf("%s\n", config.c_fqdn);
129 cprintf("%s\n", config.c_humannode);
130 cprintf("%s\n", config.c_phonenum);
131 cprintf("%d\n", config.c_creataide);
132 cprintf("%d\n", config.c_sleeping);
133 cprintf("%d\n", config.c_initax);
134 cprintf("%d\n", config.c_regiscall);
135 cprintf("%d\n", config.c_twitdetect);
136 cprintf("%s\n", config.c_twitroom);
137 cprintf("%s\n", config.c_moreprompt);
138 cprintf("%d\n", config.c_restrict);
139 cprintf("%s\n", config.c_bbs_city);
140 cprintf("%s\n", config.c_sysadm);
141 cprintf("%d\n", config.c_maxsessions);
142 cprintf("%s\n", config.c_net_password);
143 cprintf("%d\n", config.c_userpurge);
147 else if (!strcasecmp(cmd, "SET")) {
148 cprintf("%d Send configuration...\n", SEND_LISTING);
150 while (client_gets(buf), strcmp(buf, "000")) {
152 case 0: strncpy(config.c_nodename, buf, 16);
154 case 1: strncpy(config.c_fqdn, buf, 64);
156 case 2: strncpy(config.c_humannode, buf, 21);
158 case 3: strncpy(config.c_phonenum, buf, 16);
160 case 4: config.c_creataide = atoi(buf);
162 case 5: config.c_sleeping = atoi(buf);
164 case 6: config.c_initax = atoi(buf);
165 if (config.c_initax < 1) config.c_initax = 1;
166 if (config.c_initax > 6) config.c_initax = 6;
168 case 7: config.c_regiscall = atoi(buf);
169 if (config.c_regiscall != 0)
170 config.c_regiscall = 1;
172 case 8: config.c_twitdetect = atoi(buf);
173 if (config.c_twitdetect != 0)
174 config.c_twitdetect = 1;
176 case 9: strncpy(config.c_twitroom,
179 case 10: strncpy(config.c_moreprompt, buf, 80);
181 case 11: config.c_restrict = atoi(buf);
182 if (config.c_restrict != 0)
183 config.c_restrict = 1;
185 case 12: strncpy(config.c_bbs_city, buf, 32);
187 case 13: strncpy(config.c_sysadm, buf, 26);
189 case 14: config.c_maxsessions = atoi(buf);
190 if (config.c_maxsessions < 1)
191 config.c_maxsessions = 1;
193 case 15: strncpy(config.c_net_password, buf, 20);
195 case 16: config.c_userpurge = atoi(buf);
201 snprintf(buf,sizeof buf,
202 "Global system configuration edited by %s",
208 cprintf("%d The only valid options are GET and SET.\n",
209 ERROR+ILLEGAL_VALUE);