dbref absolute_nref(char *str) { char *p, *q, *buf, *bp; dbref *np, nref; /* * Global or local reference? Global references are automatically * * prepended with an additional underscore. i.e., #__foo_ is a global * * reference, and #_foo_ is a local reference. * * Our beginning and end underscores have already been stripped, so * * we would see only _foo or foo. * * * * We are not allowed to nibble our buffer, because we've got a * * pointer into the match string. Therefore we must copy it. * * If we're matching locally we copy the dbref of the owner first, * * which means that we then need to worry about buffer size. */ buf = alloc_lbuf("absolute_nref"); if (*str == '_') { for (p = buf, q = str; *q; p++, q++) { *p = tolower(*q); } *p = '\0'; } else { bp = buf; safe_ltos(buf, &bp, Owner(md.player), LBUF_SIZE); safe_chr('.', buf, &bp); for (q = str; *q; q++) { safe_chr(tolower(*q), buf, &bp); } *bp = '\0'; } np = (int *) hashfind(buf, &mudstate.nref_htab); if (np && Good_obj(*np)) { nref = *np; } else { nref = NOTHING; } free_lbuf(buf); return nref; }
static void unparse_boolexp1( dbref player, BOOLEXP *b, char outer_type, int format ) { ATTR *ap; char sep_ch; char *buff; if( b == TRUE_BOOLEXP ) { if( format == F_EXAMINE ) { safe_str( ( char * ) "*UNLOCKED*", boolexp_buf, &buftop ); } return; } switch( b->type ) { case BOOLEXP_AND: if( outer_type == BOOLEXP_NOT ) { safe_chr( '(', boolexp_buf, &buftop ); } unparse_boolexp1( player, b->sub1, b->type, format ); safe_chr( AND_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub2, b->type, format ); if( outer_type == BOOLEXP_NOT ) { safe_chr( ')', boolexp_buf, &buftop ); } break; case BOOLEXP_OR: if( outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND ) { safe_chr( '(', boolexp_buf, &buftop ); } unparse_boolexp1( player, b->sub1, b->type, format ); safe_chr( OR_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub2, b->type, format ); if( outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND ) { safe_chr( ')', boolexp_buf, &buftop ); } break; case BOOLEXP_NOT: safe_chr( '!', boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub1, b->type, format ); break; case BOOLEXP_INDIR: safe_chr( INDIR_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub1, b->type, format ); break; case BOOLEXP_IS: safe_chr( IS_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub1, b->type, format ); break; case BOOLEXP_CARRY: safe_chr( CARRY_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub1, b->type, format ); break; case BOOLEXP_OWNER: safe_chr( OWNER_TOKEN, boolexp_buf, &buftop ); unparse_boolexp1( player, b->sub1, b->type, format ); break; case BOOLEXP_CONST: if( !mudstate.standalone ) { switch( format ) { case F_QUIET: /* * Quiet output - for dumps and internal use. * Always #Num */ safe_str( ( char * ) unparse_object_quiet( player, b->thing ), boolexp_buf, &buftop ); break; case F_EXAMINE: /* * Examine output - informative. * * Name(#Num) or Name */ buff = unparse_object( player, b->thing, 0 ); safe_str( buff, boolexp_buf, &buftop ); free_lbuf( buff ); break; case F_DECOMPILE: /* * Decompile output - should be usable on * other MUSHes. *Name if player, Name if * thing, else #Num */ switch( Typeof( b->thing ) ) { case TYPE_PLAYER: safe_chr( '*', boolexp_buf, &buftop ); case TYPE_THING: safe_name( b->thing, boolexp_buf, &buftop ); break; default: safe_dbref( boolexp_buf, &buftop, b->thing ); break; } break; case F_FUNCTION: /* * Function output - must be usable by @lock * cmd. *Name if player, else #Num */ switch( Typeof( b->thing ) ) { case TYPE_PLAYER: safe_chr( '*', boolexp_buf, &buftop ); safe_name( b->thing, boolexp_buf, &buftop ); break; default: safe_dbref( boolexp_buf, &buftop, b->thing ); break; } } } else { safe_str( ( char * ) unparse_object_quiet( player, b->thing ), boolexp_buf, &buftop ); } break; case BOOLEXP_ATR: case BOOLEXP_EVAL: if( b->type == BOOLEXP_EVAL ) { sep_ch = '/'; } else { sep_ch = ':'; } ap = atr_num( b->thing ); if( ap && ap->number ) { safe_str( ( char * ) ap->name, boolexp_buf, &buftop ); } else { safe_ltos( boolexp_buf, &buftop, b->thing ); } safe_chr( sep_ch, boolexp_buf, &buftop ); safe_str( ( char * ) b->sub1, boolexp_buf, &buftop ); break; default: log_write_raw( 1, "ABORT! unparse.c, bad boolexp type in unparse_boolexp1().\n" ); abort(); break; } }