4 * This module handles states which are global to the entire server.
22 #include "sysdep_decls.h"
24 struct CitControl CitControl;
27 * get_control - read the control record into memory.
29 void get_control(void) {
32 /* Zero it out. If the control record on disk is missing or short,
33 * the system functions with all control record fields initialized
36 bzero(&CitControl, sizeof(struct CitControl));
37 fp = fopen("citadel.control", "rb");
38 if (fp == NULL) return;
40 fread(&CitControl, sizeof(struct CitControl), 1, fp);
45 * put_control - write the control record to disk.
47 void put_control(void) {
50 fp = fopen("citadel.control", "wb");
52 fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
59 * get_new_message_number() - Obtain a new, unique ID to be used for a message.
61 long get_new_message_number(void) {
62 begin_critical_section(S_CONTROL);
64 ++CitControl.MMhighest;
66 end_critical_section(S_CONTROL);
67 return(CitControl.MMhighest);
72 * get_new_user_number() - Obtain a new, unique ID to be used for a user.
74 long get_new_user_number(void) {
75 begin_critical_section(S_CONTROL);
77 ++CitControl.MMnextuser;
79 end_critical_section(S_CONTROL);
80 return(CitControl.MMnextuser);