4 * This module handles states which are global to the entire server.
24 #include "sysdep_decls.h"
26 struct CitControl CitControl;
29 * get_control - read the control record into memory.
31 void get_control(void) {
34 /* Zero it out. If the control record on disk is missing or short,
35 * the system functions with all control record fields initialized
38 memset(&CitControl, 0, sizeof(struct CitControl));
39 fp = fopen("citadel.control", "rb");
40 if (fp == NULL) return;
42 fread(&CitControl, sizeof(struct CitControl), 1, fp);
47 * put_control - write the control record to disk.
49 void put_control(void) {
52 fp = fopen("citadel.control", "wb");
54 fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
61 * get_new_message_number() - Obtain a new, unique ID to be used for a message.
63 long get_new_message_number(void) {
64 begin_critical_section(S_CONTROL);
66 ++CitControl.MMhighest;
68 end_critical_section(S_CONTROL);
69 return(CitControl.MMhighest);
74 * get_new_user_number() - Obtain a new, unique ID to be used for a user.
76 long get_new_user_number(void) {
77 begin_critical_section(S_CONTROL);
79 ++CitControl.MMnextuser;
81 end_critical_section(S_CONTROL);
82 return(CitControl.MMnextuser);