int on_close() { object remote; if( this_object()->query_closed() ) { msg(capitalize((string) this_object()->query_specific()) + " is already closed. Attempting to close it further would likely arouse undesired criticism."); return 1; } if( query_locked() ) { msg( capitalize(this_object()->query_specific()) + " is locked. You can't close it."); return 1; } set_target( MOBJ ); this_player()->msg_local( "~CACT~Name ~verbclose ~targ.~CDEF" ); this_object()->set_closed( 1 ); return 1; }
int on_open() { object remote; if( !this_object()->query_closed() ) { msg(capitalize((string) this_object()->query_specific()) + " is already open. Attempting to open it again would just look strange."); return 1; } if( query_locked() ) { msg( capitalize(this_object()->query_specific()) + " is locked. You can't open it."); return 1; } set_target( MOBJ ); this_player()->msg_local( "~CACT~Name ~verbopen ~targ.~CDEF" ); this_object()->set_closed( 0 ); return 1; }
void do_delete( CHAR_DATA * ch, char * argument ) { DESCRIPTOR_DATA * d; if ( !ch->desc ) { return; } if ( str_cmp( ch->desc->incomm, "delete yes" ) ) { send_to_char( C_DEFAULT, "If you want to DELETE yourself, type 'delete yes'\n\r", ch ); return; } if ( ch->desc->original || IS_NPC( ch ) ) { send_to_char( C_DEFAULT, "You may not delete a switched character.\n\r", ch ); return; } stop_fighting( ch, TRUE ); send_to_char( C_DEFAULT, "You are no more.\n\r", ch ); act( AT_BLOOD, "$n is no more.", ch, NULL, NULL, TO_ROOM ); info( "%s is no more.", (int)( ch->name ), 0 ); sprintf( log_buf, "$N has DELETED in room vnum %d.", ch->in_room->vnum ); wiznet( log_buf, ch, NULL, WIZ_LOGINS, 0, 0 ); // delete player file sprintf( log_buf, "%s%c/%s", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) ); remove( log_buf ); // delete finger file sprintf( log_buf, "%s%c/%s.fng", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) ); remove( log_buf ); // delete corpses sprintf( log_buf, "%s%c/%s.cps", PLAYER_DIR, LOWER( ch->name[ 0 ] ), capitalize( ch->name ) ); remove( log_buf ); delete_playerlist( ch->name ); d = ch->desc; extract_char( ch, TRUE ); if ( d ) { close_socket( d ); } return; }
static int remove_user(string where, int verbose, int flag, int test) { string name, wiz_dir, tmp; sscanf(where, "%s" + __SAVE_EXTENSION__, name); wiz_dir = HOME_DIRS + extract(name, 0, 0) + "/" + name + "/"; total++; // Don't want to purge admins -- Rust if( adminp(name) ) return 0; tmp = capitalize(name); if(flag == 2 && directory_exists(wiz_dir)) { /* if(!test) CLEAN_D->clean_dir(wiz_dir); */ // Rather than delete the dirs, move them to /purged/name/blah // inspiral. if( !test ) "/adm/daemons/move_dir" -> clean_dir( wiz_dir ); tmp += " and " + wiz_dir + " " + (test ? "flagged" : "deleted") + ".\n"; } else tmp += " " + (test ? "flagged" : "deleted") + ".\n"; if(!test) { rm(DATA_DIR + "/std/user/" + name[0..0] + "/" + name + __SAVE_EXTENSION__); rm(PDATA_DIR + "/" + name[0..0] + "/" + name + __SAVE_EXTENSION__); } if(verbose) write(tmp); return 1; }
WrapperStr UmlOperation::compute_name() { WrapperStr get_set_spec = javaNameSpec(); if (! get_set_spec.isEmpty()) { UmlClassMember * it; if ((it = getOf()) == 0) it = setOf(); int index; WrapperStr s = (it->kind() == aRelation) ? ((UmlRelation *) it)->roleName() : it->name(); if ((index = get_set_spec.find("${name}")) != -1) get_set_spec.replace(index, 7, s); else if ((index = get_set_spec.find("${Name}")) != -1) get_set_spec.replace(index, 7, capitalize(s)); else if ((index = s.find("${NAME}")) != -1) get_set_spec.replace(index, 7, s.upper()); else if ((index = s.find("${nAME}")) != -1) get_set_spec.replace(index, 7, s.lower()); return get_set_spec; } else return name(); }
mixed direct_drink_from_obj() { object ob; if (this_object()->query_closed()) return capitalize(the_short()) + " is closed.\n"; if (needs_contents) ob = first_inventory(); else ob = this_object(); if (!ob) return capitalize(the_short()) + " is empty.\n"; return ob->direct_drink_obj(); }
void repl() { SqlParser parser; while (true) { std::string command = read_command(); std::string::size_type first_space = command.find_first_of(" "); std::string fst_token = first_space == string::npos ? command : command.substr(0, first_space); capitalize(&fst_token); #ifdef MAIN_DBG Utils::info("[REPL] execute \"" + command +"\""); #endif if (fst_token.compare("QUIT") == 0 || fst_token.compare("EXIT") == 0) { return; } else if (fst_token.compare("PURGE") == 0) { BufferManager &bm = BufferManager::get_instance(); bm.purge(); std::cout << "Purge has been done" << std::endl; } else if (fst_token.compare("BMST") == 0) { std::cout << "BufferManager state:" << std::endl; std::cout << " Pinned pages: " + std::to_string(BufferManager::get_instance().get_pinned_page_count()) << std::endl; BufferManager::get_instance().print_pinned_page(); } else if (fst_token.compare("ABOUT") == 0) { std::string table_name = command.substr(6); #ifdef MAIN_DBG Utils::info("[REPL] 'about' was called for " + table_name); #endif describe_table(table_name); } else { SqlStatement const * stmt = parser.parse(command); DBFacade::get_instance()->execute_statement(stmt); delete stmt; } } }
String ActionStack::redoName() const { if (canRedo()) { return _(" ") + capitalize(redo_actions.back()->getName(false)); } else { return wxEmptyString; } }
/* current line has first token removed (instruction) and comments * removed. Now go through the rest and assume they're instructions * separated with ',' */ struct instruction *get_operands(struct instruction *cur) { int cur_op_num; char *buf; /* check for operands */ cur_op_num = 0; while ((buf = (char *) strtok(NULL, comma))) { remove_whitespace(buf); //remove any tabs etc. if (strlen(buf) > 0) { if (!cur->operands) cur->operands = (char **) malloc(sizeof( char *)); else cur->operands = (char **) realloc(cur->operands, (sizeof(char *)*(cur_op_num+1))); capitalize(buf); cur->operands[cur_op_num] = (char *) malloc(strlen(buf) ); strcpy(cur->operands[cur_op_num], buf); cur->op_num = ++cur_op_num; } } cur->op_num = cur_op_num; return cur; }
void DictFilterConfig::doMenu(const QAction * i) { if (i == addA) { if ( input.count() == 0 ) { QMessageBox::information(0, tr("Adding Words"), tr("<qt>To add words, pick the letters, then " "open the Add dialog. In that dialog, tap " "the correct letters from the list " "(tap twice for capitals).</qt>")); } else { PickboardAdd add(parent,capitalize(input)); if ( add.exec() ) generateText(add.word()); input.clear(); matches.clear(); updateRows(0,0); } } else if (i == resetA) { if ( !input.isEmpty() ) { input.clear(); matches.clear(); StringConfig::doMenu(i); updateRows(0,1); } else { reset(); } } else { StringConfig::doMenu(i); } shift = 0; lit0 = -1; }
mixed raise(string str, int skill, int cast) { mixed ob; if (!str || str == "") return "You try to raise nothing and fail miserably.\n"; ob = find_match(str, environment(this_player())); if (sizeof(ob)) ob = ob[0]; else return "Who is " + capitalize(str) + "?\n"; if (!living(ob)) return (string)ob->query_cap_name() + " refuses to be brought to life.\n"; if (!ob->query_property("dead")) return (string)ob->query_cap_name() + " is not dead ... yet.\n"; if (ob->query_property("noregen")) return "Death tells you: HOLD ON, I'M NOT FINISHED WITH THEM YET.\n"; if (cast && (int)this_player()->adjust_gp(-SP_COST) < 0) return "Too low on power.\n"; write("You call upon the gods to restore " + (string)ob->query_cap_name() + " from " + (string)ob->query_possessive() + " immaterial state.\n"); tell_object(ob, (string)this_player()->query_cap_name() + " summons the gods for you.\n"); say((string)this_player()->query_cap_name() + " summons the gods to raise " + (string)ob->query_cap_name() + " from the dead.\n", ob); ob->remove_ghost(); return 1; }
void CAdministrationWindow::flush(CMySQLServer *m, int flush_type) { QString f = QString::null; switch (flush_type) { case FLUSH_HOSTS: f = "HOSTS"; break; case FLUSH_LOGS: f = "LOGS"; break; case FLUSH_PRIVILEGES: f = "PRIVILEGES"; break; case FLUSH_TABLES: f = "TABLES"; break; case FLUSH_STATUS: f = "STATUS"; break; case FLUSH_TABLES_RL: f = "TABLES WITH READ LOCK"; break; case FLUSH_DES_KEY_FILE: f = "DES_KEY_FILE"; break; case FLUSH_QUERY_CACHE: f = "QUERY CACHE"; break; case FLUSH_USER_RESOURCES: f = "USER_RESOURCES"; break; } CMySQLQuery *qry = new CMySQLQuery(m->mysql()); qry->setEmitMessages(false); if (qry->execStaticQuery("FLUSH " + f)) m->messagePanel()->information("Flush " + capitalize(f) + " " + tr("successful")); delete qry; }
int can_cast(object tp, object tgt) { if (!tp) return 0; if (environment(tp)->query_property("no magic")) FAIL("Some force prevents your magic."); if (tp->query_busy()) FAIL("You are busy."); if (tp->query_ghost()) FAIL("You cannot call upon such forces in your state."); if (!tgt) FAIL("Call it upon whom?"); if (!tgt->is_living()) FAIL("That is not alive."); if (tgt->query_effect("bisonsmight")) FAIL( (tgt == tp ? "You are" : capitalize(tgt->query_subjective())+" is")+ " already filled with that power." ); if (tp->query_mp() < 75) FAIL("Too low on magic."); return 1; }
string _query_long() { string str; str=player->name(); return capitalize(str)+" ist "+str+" ist "+str+".\n"; }
int can_cast(object tp, object tgt) { if (!tp) return 0; if (environment(tp)->query_property("no attack") || environment(tp)->query_property("no magic")) FAIL("Some force prevents your magic."); if (tp->query_busy()) FAIL("You are busy."); if (tp->query_ghost()) FAIL("It is too dangerous to manipulate such " "powerful magic in your current state."); if (!tgt) FAIL("Polymorph who?"); if (!(tgt->is_player() || tgt->is_monster())) FAIL("This magic only works against living things."); if (tgt->query_property("no polymorph") || tgt->query_property("no magic")) FAIL(tgt->query_cap_name()+" is immune to such magic."); if (tgt->query_effect("polymorph")) FAIL( (tgt == tp ? "You have" : capitalize(tgt->query_subjective())+" has")+ " already been polymorphed!"); if (tp->query_mp() < 100) FAIL("Your magic is too low."); return 1; }
QString DictFilterConfig::text(int r, int i) { QStringList l = r ? sets_a : input.isEmpty() ? othermodes : matches; return i < (int)l.count() ? (input.isEmpty() ? l[i] : capitalize(l[i])) : QString(); }
int can_cast(object tp, object tgt, object *wep) { if (!tp) return 0; if (environment(tp)->query_property("no attack")) FAIL("Some force prevents your mischief."); if (tp->query_busy()) FAIL("You are busy."); if (tp->query_ghost()) FAIL("You're barely visible as is, ghosty."); if (!sizeof(wep)) FAIL("You need to use a sword or knife for that."); if (!tgt) FAIL("Flash your blades at whom?"); if (!tgt->is_living()) FAIL("That isn't alive."); if (tgt == tp) FAIL("Blind yourself?"); if (!tgt->query_is_limb("head")) FAIL(capitalize(tgt->query_subjective())+" has no head!"); if (!tp->ok_to_kill(tgt)) FAIL("You can't blind "+tgt->query_cap_name()+"."); return 1; }
void sure_to_suicide(string pa) { // mixed er; string pass, str; object ob; if(((pass = (string)this_player()->query_password()) != oldcrypt(pa, pass)) && ((string)this_player()->query_password() != crypt(pa, pass))) { message("info", "Suicide failed.", this_player()); return 0; } ob = this_player(); str = (string)ob->query_name(); if (!str) return; message("info", "You terminate your existance on Primal Darkness.",ob); CHAT_D->do_raw_chat("system", "Suicide <system> "+this_player()->query_name()+" suicided."); seteuid(UID_LOG); log_file("suicide", "[ " + ctime(time()) + " ] " + capitalize(str) + " suicided from IP: " + ob->query_ip() + "\n"); seteuid(getuid()); seteuid(UID_USERSAVE); rename(DIR_USERS+"/"+str[0..0]+"/"+str+".o",DIR_USERS+"/rid/"+str+".o"); seteuid(geteuid()); IDENTITY_D->manage_identity(0, this_player(), "deleting"); MSQL_D->msql_delete_player("pd", "player_t", (string)ob->query_name()); BANK_D->remove_all_bank_accounts((string)ob->query_name()); if(file_exists("/adm/save/boats/"+(string)ob->query_name()+".o")) rm("/adm/save/boats/"+(string)ob->query_name()+".o"); ob->remove(); if (ob) destruct(ob); return; }
String ActionStack::undoName() const { if (canUndo()) { return _(" ") + capitalize(undo_actions.back()->getName(true)); } else { return wxEmptyString; } }
// Swallow new GNUPLOT window; search from window created on root. static void SwallowCB(Widget swallower, XtPointer client_data, XtPointer call_data) { PlotWindowInfo *plot = (PlotWindowInfo *)client_data; assert(plot->swallower == swallower); SwallowerInfo *info = (SwallowerInfo *)call_data; Window root = info->window; Window window = None; Display *display = XtDisplay(swallower); // Try the exact name as given if (window == None) window = findWindow(display, root, plot->window_name.chars()); // Try the capitalized name. Gnuplot does this. if (window == None) { const string s1 = capitalize(plot->window_name); window = findWindow(display, root, s1.chars()); } // Try any `Gnuplot' window just created if (window == None) window = findWindow(display, root, app_data.plot_window_class); if (window != None) swallow(plot, window); }
QString get_python_name(const BrowserClass * cl, ShowContextMode mode) { ClassData * d = (ClassData *) cl->get_data(); if (! d->python_is_external()) return cl->contextual_name(mode); QString name = cl->get_name(); QString s = d->get_pythondecl(); int index = s.indexOf('\n'); s = (index == -1) ? s.trimmed() : s.left(index).trimmed(); if ((index = s.indexOf("${name}")) != -1) s.replace(index, 7, name); else if ((index = s.indexOf("${Name}")) != -1) s.replace(index, 7, capitalize(name)); else if ((index = s.indexOf("${NAME}")) != -1) s.replace(index, 7, name.toUpper()); else if ((index = s.indexOf("${nAME}")) != -1) s.replace(index, 7, name.toLower()); return s; }
// Swallow new GNUPLOT window; search from root window (expensive). static void SwallowTimeOutCB(XtPointer client_data, XtIntervalId *id) { (void) id; PlotWindowInfo *plot = (PlotWindowInfo *)client_data; assert(*id == plot->swallow_timer); plot->swallow_timer = 0; Window root = RootWindowOfScreen(XtScreen(plot->swallower)); Window window = None; Display *display = XtDisplay(plot->swallower); // Try the exact name as given if (window == None) window = findWindow(display, root, plot->window_name.chars()); // Try the capitalized name. Gnuplot does this. if (window == None) { const string s1 = capitalize(plot->window_name); window = findWindow(display, root, s1.chars()); } if (window == None) { // Try again later plot->swallow_timer = XtAppAddTimeOut(XtWidgetToApplicationContext(plot->swallower), app_data.plot_window_delay, SwallowTimeOutCB, XtPointer(plot)); } if (window != None) swallow(plot, window); }
MessageHandler_& end(std::string const& msg = "", std::string const& info = "") { if (name.empty()) return *this; indent = --indentLevel * INDENT_SIZE; ResourceUsage rusage = ResourceUsage() - initialUsage; if (beginLine == lineno) { if (!info.empty()) { *this << " " << info; } else if (msg.empty()) { *this << " done"; } else { *this << " " << msg; } } else { if (msg.empty()) { *this << "\nDone " << name; } else { *this << "\n" << capitalize(msg); } if (!info.empty()) *this << " " << info; } *this << " in " << rusage << ".\n"; name = ""; return *this; }
static void PlotterNotFoundHP(Agent *plotter, void *client_data, void *) { #if !NDEBUG PlotWindowInfo *plot = (PlotWindowInfo *)client_data; assert(plot->plotter == 0 || plot->plotter == plotter); #endif plotter->removeHandler(Died, PlotterNotFoundHP, client_data); string base = app_data.plot_command; if (base.contains(' ')) base = base.before(' '); Arg args[10]; Cardinal arg = 0; MString msg = rm( capitalize(base) + " could not be started."); XtSetArg(args[arg], XmNmessageString, msg.xmstring()); arg++; Widget dialog = verify(XmCreateErrorDialog(find_shell(), XMST("no_plotter_dialog"), args, arg)); XtUnmanageChild(XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON)); XtAddCallback(dialog, XmNhelpCallback, ImmediateHelpCB, XtPointer(0)); Delay::register_shell(dialog); manage_and_raise(dialog); }
bool check_ban( char *site, int type ) { BAN_DATA * pban; char host[ MAX_STRING_LENGTH ]; strcpy( host, capitalize( site ) ); host[ 0 ] = LOWER( host[ 0 ] ); for ( pban = ban_list; pban != NULL; pban = pban->next ) { if ( !IS_SET( pban->ban_flags, type ) ) continue; if ( IS_SET( pban->ban_flags, BAN_PREFIX ) && IS_SET( pban->ban_flags, BAN_SUFFIX ) && strstr( pban->site, host ) != NULL ) return TRUE; if ( IS_SET( pban->ban_flags, BAN_PREFIX ) && !str_suffix( pban->site, host ) ) return TRUE; if ( IS_SET( pban->ban_flags, BAN_SUFFIX ) && !str_prefix( pban->site, host ) ) return TRUE; } return FALSE; }
void send_gtell(string mud, string wiz_to, object source, string msg) { mapping minfo; if(!ACCESS_CHECK(previous_object()) && base_name(previous_object()) != TELL_CMD) return; mud = htonn( mud ); if(mud == mud_nname() || !geteuid(source)) return; minfo = (mapping)DNS_MASTER->query_mud_info(mud); if (!minfo) return ; msg = replace_string(msg, "|", ""); msg = replace_string(msg, "@@@", ""); DNS_MASTER->send_udp(minfo["HOSTADDRESS"], minfo["PORTUDP"], "@@@" + DNS_GTELL + "||NAME:" + Mud_name() + "||PORTUDP:" + udp_port() + "||WIZTO:" + wiz_to + "||WIZFROM:" + capitalize(geteuid(source)) + "||CNAME:" + source->name(1) + "||MSG:"+msg+"@@@\n"); }
QString get_idl_name(const BrowserClass * cl, ShowContextMode mode) { ClassData * d = (ClassData *) cl->get_data(); if (! d->idl_is_external()) return cl->contextual_name(mode); QString name = cl->get_name(); QString s = d->get_idldecl(); int index = s.find('\n'); s = (index == -1) ? s.stripWhiteSpace() : s.left(index).stripWhiteSpace(); if ((index = s.find("${name}")) != -1) s.replace(index, 7, name); else if ((index = s.find("${Name}")) != -1) s.replace(index, 7, capitalize(name)); else if ((index = s.find("${NAME}")) != -1) s.replace(index, 7, name.upper()); else if ((index = s.find("${nAME}")) != -1) s.replace(index, 7, name.lower()); return s; }
int main(object me, string arg) { string name, reason; string status; int day; status = wizhood(me); if( me!=this_player(1) || wiz_level(me) < wiz_level(status) ) return notify_fail("你没有权力使用这个指令。\n"); if( !arg ) return notify_fail(SYNTAX); if( sscanf(arg, "%d", day) && day >= 0) return do_purge_players(day); if( sscanf(arg, "%s because %s", name, reason)!=2 ) return notify_fail(SYNTAX); seteuid(getuid()); if( file_size(DATA_DIR + "login/" + name[0..0] + "/" + name + SAVE_EXTENSION)<0 ) return notify_fail("没有这位使用者。\n"); rm(DATA_DIR + "login/" + name[0..0] + "/" + name + SAVE_EXTENSION); rm(DATA_DIR + "user/" + name[0..0] + "/" + name + SAVE_EXTENSION); write( "使用者 " + capitalize(name) + " 删除掉了。\n"); log_file("static/PURGE", sprintf("[%s] %s purged %s because %s.\n", ctime(time())[0..15], geteuid(this_player(1)), name, reason)); return 1; }
int send_gtell(string mud, string wiz_to, object source, string msg) { mapping minfo; if (! ACCESS_CHECK(previous_object()) && is_root(previous_object())) return 0; mud = htonn(mud); if (mud == mud_nname() || ! source) return 0; minfo = (mapping)DNS_MASTER->query_mud_info(mud); if (! minfo) { write(LOCAL_MUD_NAME() + "并没有和 " + mud + " 联系上。\n"); return 0; } msg = replace_string(msg, "|", ""); msg = replace_string(msg, "@@@", ""); DNS_MASTER->send_udp(minfo["HOSTADDRESS"], minfo["PORTUDP"], "@@@" + DNS_GTELL + "||NAME:" + Mud_name() + "||PORTUDP:" + udp_port() + "||WIZTO:" + wiz_to + "||WIZFROM:" + capitalize(source->query("id")) + "||CNAME:" + source->name(1) + "||WIZ_LEVEL:" + wiz_level(source) + "||MSG:" + msg + "@@@\n"); return 1; }
nomask mixed query(string what) { if (!what) return 0; switch (what) { case "name" : return (name ? name : "logon"); case "cap_name" : return (name ? capitalize(name) :"Logon"); case "password" : return password; case "wizard" : return wizard; case "body" : return body; case "dead" : return dead; case "tmp_body" : return tmp_body; case "hibernate" : return hibernate; case "real_name" : return real_name; case "passwd_fail" : return passwd_fail; case "email" : return email; case "body_ob" : return body_ob; case "last_on" : return last_on; case "ip" : return ip; case "termtype" : return termtype; case "userid" : { if(geteuid(previous_object()) != ROOT_UID) return 0; else return userid; } case "domains" : { if (geteuid(previous_object()) == ROOT_UID) { return domains; } else return copy(domains); } default : return 0; } }