Had this lying in my acct.. and just thought somebody could use it. This is submitted in by Matt McLaughlin but originally attempted by who knows. Yes, folks, that infamous signal is annoying me to hell. Sometimes, for the oddest reason, when a person loses link, their architecture or program, whichever it is, sends a SIGPIPE(or whatever happens.) This is quite annoying, for the obvious reasons. Is there any easy way to fix it? (or uneasy way either.) Finally, I have a problem with a rewriting of do_reboot that I made when I was tired of doing the same things over and over. Basically, what it SHOULD do is allow you to reload any text file and, based on what you want to do with it, it can take as little as one line of addition or an infinite amount, if you wish to manipulate the data in the file. Here is the code: struct reboot_data { char reboot_option[MAX_STRING_LENGTH]; char reboot_file[MAX_STRING_LENGTH]; char *whichfile; }; #define TERM_ARRAY_CHAR '\n' #define NULL_FILE "\0" #define RB_OP(data) (data).reboot_option #define RB_FILE(data) (data).reboot_file #define RB_FILE_PTR(data) (data).which #define REREAD_FILE(file) file_to_string #define DO_ALL(str) ((is_abbrev((str), "all")) || *(str) == '*') #define DO_LIST(str) ((is_abbrev((str), "list")) || *(str) == '?') ACMD(do_reboot) { int i; STRING(debug); struct reboot_data reboot_info[] = { { "credits", CREDITS_FILE, credits}, { "news", NULL_FILE, '\0'}, { "motd", MOTD_FILE, motd}, { "kwdhelp", NULL_FILE, '\0'}, { "pagehelp", HELP_PAGE_FILE, help}, { "info", INFO_FILE, info}, { "wizlist", WIZLIST_FILE, wizlist}, { "poses", NULL_FILE, '\0'}, { "imotd", IMOTD_FILE, imotd}, { "policies", POLICIES_FILE, policies}, { "handbook", HANDBOOK_FILE, handbook}, { "background", BACKGROUND_FILE, background}, { "sacrifice", NULL_FILE, '\0'}, { "houses", HOUSE_FILE, houses}, { "marriages", MARRIAGES_FILE, marriages}, { "qmanual", QMANUAL_FILE, qmanual}, { "greetings", GREETINGS_FILE, GREETINGS}, { "socials", NULL_FILE, '\0'}, { "\n", NULL_FILE, '\0'} }; one_argument(argument, arg); if (!*arg) { send_to_char("Reboot what?\r\n",ch); return; } if (DO_LIST(arg)) { send_to_char("The following reload options are available:\n\r", ch); for (i = 0; *RB_OP(reboot_info[i]) != TERM_ARRAY_CHAR; i++) { sprintf(buf,"%s\n\r", RB_OP(reboot_info[i])); send_to_char(buf, ch); } return; } else if (!DO_ALL(arg)) { for (i = 0; *RB_OP(reboot_info[i]) != TERM_ARRAY_CHAR; i++) if (is_abbrev(arg, RB_OP(reboot_info[i]))) break; else { for (i = 0; *RB_OP(reboot_info[i]) != TERM_ARRAY_CHAR; i++) if (str_cmp(RB_FILE(reboot_info[i]), NULL_FILE)) { sprintf (debug, "Rebooting_file: %s\r\n", RB_FILE(reboot_info[i])); send_to_char(debug, ch); if (REREAD_FILE(reboot_info[i]) < 0) send_to_char("ERROR! That file could not be reloaded!\r\n", ch); } OK(ch); return; } /* if the two strings DON'T compare */ if (str_cmp(RB_FILE(reboot_info[i]), NULL_FILE)) { sprintf(debug, "Okay, rebooting file: %s\r\n", RB_FILE(reboot_info[i])); send_to_char(debug, ch); if (REREAD_FILE(reboot_info[i]) < 0) send_to_char("Could not reboot the file!\r\n", ch); OK(ch); return; } else { switch(i) { case 1: send_to_char("Reloading the news files\n\r", ch); file_to_string_alloc(NEWS_FILE, &news); file_to_string_alloc(NEWSVERSION, &nv); if (*news) newsversion = atoi(nv); OK(ch); break; case 3: /* this is for the keyword file */ send_to_char("Loading the help file again\n\r", ch); if (help_fl) fclose(help_fl); if (!(help_fl = fopen(HELP_KWRD_FILE, "r"))) return; else { for (i = 0; i < top_of_helpt; i++) free(help_index[i].keyword); free(help_index); help_index = build_help_index(help_fl, &top_of_helpt); } OK(ch); break; case 7: /* this is for the poses file */ send_to_char("Loading the poses file ;)\n\r", ch); boot_poses(); break; case 12: /* sacrifice messages */ send_to_char("Rebooting sacrifice messages", ch); boot_sacrifices(); break; case 17: send_to_char("Rebooting socials.\n\r", ch); boot_social_messages(); break; } return; } /* If all of this fails, then you KNOW it didn't work. */ send_to_char("Unknown reload option.\n\r", ch); send_to_char("Correct format: reload list | all | ? | * | <option>", ch); return; } +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | | Or send 'info circle' to majordomo@cspo.queensu.ca | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST