# # Patch name: Sitelock/name # Patch version: 1 # Author's name: Shawn Wagner # Author's email: shawnw@wpi.edu # Version of PennMUSH: 1.7.2p15 # Date patch made: # 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 allows wizards to remove entries from names.cnf from the MUSH, # by using @sitelock/name ! # It also fixes a minor bug that sometimes results in the last line of # names.cnf being displayed twice when doing @sitelock/name. # Apply with patch -p1 < sitelock_name-1.7.2p15.diff *** ../vanilla/src/wiz.c Fri Aug 14 11:50:56 1998 --- src/wiz.c Sat Aug 29 15:20:15 1998 *************** *** 2031,2037 **** int type; /* 0 = registration, 1 = siteban, 2 = names */ { ! FILE *fp; char buffer[80]; char *p; --- 2031,2037 ---- int type; /* 0 = registration, 1 = siteban, 2 = names */ { ! FILE *fp, *fptmp; char buffer[80]; char *p; *************** *** 2086,2093 **** if ((fp = fopen(NAMES_FILE, "r")) == NULL) { notify(player, "Unable to open names file."); } else { ! while (!feof(fp)) { ! fgets(buffer, 79, fp); if ((p = strrchr(buffer, '\n'))) /* extra parens for gcc */ *p = '\0'; notify(player, buffer); --- 2086,2092 ---- if ((fp = fopen(NAMES_FILE, "r")) == NULL) { notify(player, "Unable to open names file."); } else { ! while (fgets(buffer, 79, bp)) { if ((p = strrchr(buffer, '\n'))) /* extra parens for gcc */ *p = '\0'; notify(player, buffer); *************** *** 2098,2104 **** --- 2097,2139 ---- reserved = open("/dev/null", O_RDWR); #endif return; + } + + if (site[0] == '!') { /* Delete a name */ + #ifndef WIN32 + close(reserved); + #endif + if ((fp = fopen(NAMES_FILE, "r")) != NULL) { + if ((fptmp = fopen("tmp.tmp", "w")) == NULL) { + notify(player, "Unable to open names file."); + fclose(fp); + } else { + while(fgets(buffer, 79, fp)) { + if ((p = strrchr(buffer, '\n'))) + *p = '\0'; + if (strcmp(buffer, site + 1) != 0) + fprintf(fptmp, "%s\n", buffer); + } + fclose(fp); + fclose(fptmp); + if (unlink(NAMES_FILE) == 0) + if (rename("tmp.tmp", NAMES_FILE) == 0) { + notify(player, "Name removed."); + do_log(LT_WIZ, player, NOTHING, "*** UNLOCKED NAME *** %s", + site + 1); + } else + notify(player, "Unable to delete name."); + else + notify(player, "Unable to delete name."); + } + } else + notify(player, "Unable to delete name."); + #ifndef WIN32 + reserved = open("/dev/null", O_RDWR); + #endif + return; } + /* Add a name */ #ifndef WIN32 close(reserved);