inherit COMMAND_BASE; #include <creator.h> #include <mail.h> //#define DEBUG 1 #define CMD_NUM 5 class rcsforce_args { object player; string *cmd; string locker; string filen; } mapping globals = ([]), ret = ([]); mapping lockers = ([]); #define tp globals[fd] #define RET ret[fd] #define LCK lockers[fd] private void do_ci(string text, class rcsforce_args args); mixed cmd(string arg) { int nfiles = 0; string bit, *bits, file, locker, filen; string *cmd = allocate(3); if (!master()->query_senior(this_player()->query_name())) return 0; if (!arg) { return notify_fail("rcsforce: No arguments.\n"); } bits = explode(arg, " "); arg = ""; bits -= ({ "", 0 }); foreach(bit in bits) { string *files; if (bit[0] == '-') { arg += (" " + bit); continue; } files = (string *)this_player()->get_files(bit); if(sizeof(files)) { filen = file = files[0]; arg += (" " + file[1..]); nfiles++; } } if(!nfiles) { return notify_fail("rcsforce: no such file "+arg+".\n"); } // Now check if the file is locked and who it is locked by! bits = explode(file, "/"); file = "/" + (string)implode(bits[0..<2], "/") + "/RCS/" + bits[<1] + ",v"; if(file_size(file) < 0) return notify_fail("That file is not in RCS.\n"); if(strsrch(read_file(file, 4, 1), "locks; strict:") != -1) { return notify_fail("That file is not locked.\n"); } else { bits = explode(read_file(file, 5, 1), ":"); locker = bits[0][1..]; } cmd[0] = "-w" + locker; cmd[1] = "-u"; cmd[2] = "-m Forcibly unlocked by " + this_player()->query_name(); cmd += explode(arg, " "); #ifdef DEBUG printf("CMD: %O\n", cmd); #endif printf("Edit mail? (y/[n]): "); input_to("edit_mail", 0, new(class rcsforce_args, player : this_player(), cmd : cmd, locker : locker, filen : filen)); return 1; } protected void edit_mail(string choice, class rcsforce_args args) { if (!strlen(choice) || lower_case(choice) == "n") { printf("No.\n"); do_ci(0, args); return; } if (lower_case(choice) != "y") { printf("Invalid choice. Please answer y or n. (y/[n]): "); input_to("edit_mail", 0, args); } else { printf("Yes. Entering editor.\n"); args->player->do_edit(0, "do_ci", this_object(), 0, args); } } /* This canNOT be made private. /global/line_ed needs to call it */ void do_ci(string text, class rcsforce_args args) { int fd; AUTO_MAILER->auto_mail(args->locker, args->player->query_name(), "Automatic RCSForce Mail", "", sprintf("Your file: %s, has been forcibly " "unlocked by: %s.\nEnjoy.\n\n" "Automatic RCSForce Mailer.\n", args->filen, args->player->query_name()) + (strlen(text) ? "\n" + text : "")); fd = external_start(CMD_NUM, args->cmd, "read_call_back", "write_call_back", "close_call_back"); tp = args->player; RET = ""; LCK = args->locker; } // I _think_ this is the function to write the comment string to the ci command void read_call_back(int fd, mixed mess) { mess = replace(mess, "/home/dividsky/mudlib", ""); RET += mess; } void write_call_back(int fd) { tell_object(tp, "rcsforce: write_call_back() called.\n"); } void close_call_back(int fd) { string file, *file_stuff; int i; if (RET != "") { tp->more_string(RET); file_stuff = explode(RET, "\n"); i = 0; while (i + 2 < sizeof(file_stuff)) { if (file_stuff[i + 2] == "done") { /* success! */ sscanf(file_stuff[i], "%*s <-- %s", file); RCS_HANDLER->remove_lock(LCK, file); i += 3; } else { if (file_stuff[i + 1][0..2] == "ci:") { i += 2; } else { i += 3; } } } } else { tell_object(tp, "rcsforce completed.\n"); } map_delete(ret, fd); map_delete(globals, fd); map_delete(lockers, fd); }