# # Patch name: MOTD-SAVE # Patch version: 1 # Author's name: Mike Kelly # Author's email: kellym@nbnet.nb.ca # Version of PennMUSH: PennMUSH 1.7.0 p11 # Date patch made: 12/19/97 # Author is willing to support (yes/no): yes # Patch format: Context Diff # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # This patch is just something I wrote up quickly after getting entirely sick of having to save my online MOTD's by hand when I want to @shutdown/reboot. Essentially all it does it dump the wizmotd and normal motd out into files, and re-read them when the game starts back up. Also, it can be easily tweaked to do the same for full MOTD and down MOTD. *** src/wiz.c Fri Dec 19 07:18:24 1997 --- /home/kellym/elrood/src/wiz.c Fri Dec 19 01:00:23 1997 *************** *** 57,62 **** --- 57,63 ---- extern dbref find_player_by_desc _((int port)); extern int paranoid_dump; extern int paranoid_checkpt; + extern void dump_motd _((void)); /* Added 12/18/97 */ extern int invok_counter; /* invocation limit */ *************** *** 2324,2330 **** fork_and_dump(0); alarm(0); dump_reboot_db(); ! #ifdef INFO_SLAVE kill_info_slave(); #endif --- 2325,2331 ---- fork_and_dump(0); alarm(0); dump_reboot_db(); ! dump_motd(); #ifdef INFO_SLAVE kill_info_slave(); #endif *** src/bsd.c Fri Dec 19 07:18:24 1997 --- /home/kellym/elrood/src/bsd.c Fri Dec 19 07:12:47 1997 *************** *** 329,334 **** --- 329,336 ---- void reopen_logs _((void)); void dump_reboot_db _((void)); void load_reboot_db _((void)); + void dump_motd _((void)); + void load_motd _((void)); #ifdef HAS_GETRLIMIT static void *************** *** 472,477 **** --- 474,480 ---- #endif #endif load_reboot_db(); + load_motd(); shovechars((Port_t) TINYPORT); #ifdef CSRI #ifdef CSRI_DEBUG *************** *** 4114,4117 **** --- 4142,4218 ---- fclose(f); remove(REBOOTFILE); flag_broadcast(0, 0, "GAME: Reboot finished."); + } + + /* MOTD dumping added 12/18/97 */ + #define MOTDF "motd.save" + #define WIZMOTDF "wizmotd.save" + + void + dump_motd(void) + { + int x = 0; /* result variable */ + int f_desc = 0; /* descriptor variable */ + int m_len = strlen(cf_motd_msg); /* length of MOTD to dump */ + + /* basic MOTD */ + if (m_len > 0) { + f_desc = open(MOTDF, O_WRONLY | O_CREAT); /* open new file to write to */ + if (f_desc > 0) { /* make sure the file is good */ + x = write(f_desc, cf_motd_msg, m_len); /* write out MOTD */ + if (x < m_len) { /* verify our writing */ + close(f_desc); + remove(MOTDF); + return; + } + close(f_desc); /* done this one */ + } + } + + /* wizard MOTD */ + m_len = strlen(cf_wizmotd_msg); + if (m_len > 0) { + f_desc = open(WIZMOTDF, O_WRONLY | O_CREAT); /* open new file to write to */ + if (f_desc > 0) { /* make sure the file is good */ + x = write(f_desc, cf_wizmotd_msg, m_len); /* write out MOTD */ + if (x < m_len) { /* verify our writing */ + close(f_desc); + remove(WIZMOTDF); + return; + } + close(f_desc); /* done this one */ + } + } + + /* as a side note, we don't really care about downmotd and fullmotd, + because, at least in our case, they are rarely, if ever used, so we + don't care if they're blanked out. + */ + } + + void + load_motd() + { + int x = 0; /* result variable */ + int f_desc = 0; /* descriptor variable */ + + /* basic MOTD */ + f_desc = open(MOTDF, O_RDONLY); /* open motd file */ + if (f_desc > 0) { /* make sure the file is good */ + x = read(f_desc, cf_motd_msg, BUFFER_LEN); /* read MOTD */ + cf_motd_msg[x] = '\0'; + close(f_desc); + remove(MOTDF); + } + + /* wizard MOTD */ + f_desc = open(WIZMOTDF, O_RDONLY); /* open wizmotd file */ + if (f_desc > 0) { /* make sure the file is good */ + x = read(f_desc, cf_wizmotd_msg, BUFFER_LEN); /* read WIZMOTD */ + cf_wizmotd_msg[x] = '\0'; + close(f_desc); + remove(WIZMOTDF); + } + + /* Once again, we don't really care about downmotd and fullmotd */ }