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 or set global configuration options
94 void cmd_conf(char *argbuf) {
99 if (!(CC->logged_in)) {
100 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
104 if (CC->usersupp.axlevel < 6) {
105 cprintf("%d Higher access required.\n",
106 ERROR+HIGHER_ACCESS_REQUIRED);
110 extract(cmd, argbuf, 0);
111 if (!strcasecmp(cmd, "GET")) {
112 cprintf("%d Configuration...\n", LISTING_FOLLOWS);
113 cprintf("%s\n", config.c_nodename);
114 cprintf("%s\n", config.c_fqdn);
115 cprintf("%s\n", config.c_humannode);
116 cprintf("%s\n", config.c_phonenum);
117 cprintf("%d\n", config.c_creataide);
118 cprintf("%d\n", config.c_sleeping);
119 cprintf("%d\n", config.c_initax);
120 cprintf("%d\n", config.c_regiscall);
121 cprintf("%d\n", config.c_twitdetect);
122 cprintf("%s\n", config.c_twitroom);
123 cprintf("%s\n", config.c_moreprompt);
124 cprintf("%d\n", config.c_restrict);
125 cprintf("%s\n", config.c_bbs_city);
126 cprintf("%s\n", config.c_sysadm);
127 cprintf("%d\n", config.c_maxsessions);
128 cprintf("%s\n", config.c_net_password);
129 cprintf("%d\n", config.c_userpurge);
133 else if (!strcasecmp(cmd, "SET")) {
134 cprintf("%d Send configuration...\n", SEND_LISTING);
136 while (client_gets(buf), strcmp(buf, "000")) {
138 case 0: strncpy(config.c_nodename, buf, 16);
140 case 1: strncpy(config.c_fqdn, buf, 64);
142 case 2: strncpy(config.c_humannode, buf, 21);
144 case 3: strncpy(config.c_phonenum, buf, 16);
146 case 4: config.c_creataide = atoi(buf);
148 case 5: config.c_sleeping = atoi(buf);
150 case 6: config.c_initax = atoi(buf);
151 if (config.c_initax < 1) config.c_initax = 1;
152 if (config.c_initax > 6) config.c_initax = 6;
154 case 7: config.c_regiscall = atoi(buf);
155 if (config.c_regiscall != 0)
156 config.c_regiscall = 1;
158 case 8: config.c_twitdetect = atoi(buf);
159 if (config.c_twitdetect != 0)
160 config.c_twitdetect = 1;
162 case 9: strncpy(config.c_twitroom,
165 case 10: strncpy(config.c_moreprompt, buf, 80);
167 case 11: config.c_restrict = atoi(buf);
168 if (config.c_restrict != 0)
169 config.c_restrict = 1;
171 case 12: strncpy(config.c_bbs_city, buf, 32);
173 case 13: strncpy(config.c_sysadm, buf, 26);
175 case 14: config.c_maxsessions = atoi(buf);
176 if (config.c_maxsessions < 1)
177 config.c_maxsessions = 1;
179 case 15: strncpy(config.c_net_password, buf, 20);
181 case 16: config.c_userpurge = atoi(buf);
187 sprintf(buf,"Global system configuration edited by %s",
193 cprintf("%d The only valid options are GET and SET.\n",
194 ERROR+ILLEGAL_VALUE);