mux/src/unparse.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"

Include dependency graph for unparse.cpp:

Go to the source code of this file.

Defines

#define F_EXAMINE   1
#define F_QUIET   2
#define F_DECOMPILE   3
#define F_FUNCTION   4

Functions

static char * unparse_object_quiet (dbref player, dbref loc)
static void unparse_boolexp1 (dbref player, BOOLEXP *b, char outer_type, int format)
char * unparse_boolexp_quiet (dbref player, BOOLEXP *b)
char * unparse_boolexp (dbref player, BOOLEXP *b)
char * unparse_boolexp_decompile (dbref player, BOOLEXP *b)
char * unparse_boolexp_function (dbref player, BOOLEXP *b)

Variables

static char boolexp_buf [LBUF_SIZE]
static char * buftop


Define Documentation

#define F_DECOMPILE   3

Definition at line 15 of file unparse.cpp.

Referenced by unparse_boolexp1(), and unparse_boolexp_decompile().

#define F_EXAMINE   1

Definition at line 13 of file unparse.cpp.

Referenced by unparse_boolexp(), and unparse_boolexp1().

#define F_FUNCTION   4

Definition at line 16 of file unparse.cpp.

Referenced by unparse_boolexp1(), and unparse_boolexp_function().

#define F_QUIET   2

Definition at line 14 of file unparse.cpp.

Referenced by unparse_boolexp1(), and unparse_boolexp_quiet().


Function Documentation

char* unparse_boolexp ( dbref  player,
BOOLEXP b 
)

Definition at line 229 of file unparse.cpp.

References boolexp_buf, BOOLEXP_CONST, buftop, F_EXAMINE, and unparse_boolexp1().

Referenced by debug_examine(), do_examine(), and view_atr().

00230 {
00231     buftop = boolexp_buf;
00232     unparse_boolexp1(player, b, BOOLEXP_CONST, F_EXAMINE);
00233     *buftop = '\0';
00234     return boolexp_buf;
00235 }

static void unparse_boolexp1 ( dbref  player,
BOOLEXP b,
char  outer_type,
int  format 
) [static]

Definition at line 45 of file unparse.cpp.

References AND_TOKEN, atr_num(), BOOLEXP_AND, BOOLEXP_ATR, boolexp_buf, BOOLEXP_CARRY, BOOLEXP_CONST, BOOLEXP_EVAL, BOOLEXP_INDIR, BOOLEXP_IS, BOOLEXP_NOT, BOOLEXP_OR, BOOLEXP_OWNER, statedata::bStandAlone, buftop, CARRY_TOKEN, ENDLINE, F_DECOMPILE, F_EXAMINE, F_FUNCTION, F_QUIET, CLogFile::Flush(), free_lbuf, INDIR_TOKEN, IS_TOKEN, Log, mudstate, attr::name, Name, attr::number, OR_TOKEN, OWNER_TOKEN, safe_chr, safe_ltoa(), safe_str, safe_tprintf_str(), boolexp::sub1, boolexp::sub2, boolexp::thing, TRUE_BOOLEXP, boolexp::type, TYPE_PLAYER, TYPE_THING, Typeof, unparse_object(), unparse_object_quiet(), and CLogFile::WriteString().

Referenced by unparse_boolexp(), unparse_boolexp_decompile(), unparse_boolexp_function(), and unparse_boolexp_quiet().

00046 {
00047     if ((b == TRUE_BOOLEXP))
00048     {
00049         if (format == F_EXAMINE)
00050         {
00051             safe_str("*UNLOCKED*", boolexp_buf, &buftop);
00052         }
00053         return;
00054     }
00055     switch (b->type)
00056     {
00057     case BOOLEXP_AND:
00058         if (outer_type == BOOLEXP_NOT)
00059         {
00060             safe_chr('(', boolexp_buf, &buftop);
00061         }
00062         unparse_boolexp1(player, b->sub1, b->type, format);
00063         safe_chr(AND_TOKEN, boolexp_buf, &buftop);
00064         unparse_boolexp1(player, b->sub2, b->type, format);
00065         if (outer_type == BOOLEXP_NOT)
00066         {
00067             safe_chr(')', boolexp_buf, &buftop);
00068         }
00069         break;
00070     case BOOLEXP_OR:
00071         if (outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND)
00072         {
00073             safe_chr('(', boolexp_buf, &buftop);
00074         }
00075         unparse_boolexp1(player, b->sub1, b->type, format);
00076         safe_chr(OR_TOKEN, boolexp_buf, &buftop);
00077         unparse_boolexp1(player, b->sub2, b->type, format);
00078         if (outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND)
00079         {
00080             safe_chr(')', boolexp_buf, &buftop);
00081         }
00082         break;
00083     case BOOLEXP_NOT:
00084         safe_chr('!', boolexp_buf, &buftop);
00085         unparse_boolexp1(player, b->sub1, b->type, format);
00086         break;
00087     case BOOLEXP_INDIR:
00088         safe_chr(INDIR_TOKEN, boolexp_buf, &buftop);
00089         unparse_boolexp1(player, b->sub1, b->type, format);
00090         break;
00091     case BOOLEXP_IS:
00092         safe_chr(IS_TOKEN, boolexp_buf, &buftop);
00093         unparse_boolexp1(player, b->sub1, b->type, format);
00094         break;
00095     case BOOLEXP_CARRY:
00096         safe_chr(CARRY_TOKEN, boolexp_buf, &buftop);
00097         unparse_boolexp1(player, b->sub1, b->type, format);
00098         break;
00099     case BOOLEXP_OWNER:
00100         safe_chr(OWNER_TOKEN, boolexp_buf, &buftop);
00101         unparse_boolexp1(player, b->sub1, b->type, format);
00102         break;
00103     case BOOLEXP_CONST:
00104 
00105         if (mudstate.bStandAlone)
00106         {
00107             safe_str(unparse_object_quiet(player, b->thing),
00108                 boolexp_buf, &buftop);
00109         }
00110         else
00111         {
00112             switch (format)
00113             {
00114             case F_QUIET:
00115 
00116                 // Quiet output - for dumps and internal use. Always #Num.
00117                 //
00118                 safe_str(unparse_object_quiet(player, b->thing),
00119                      boolexp_buf, &buftop);
00120                 break;
00121 
00122             case F_EXAMINE:
00123 
00124                 // Examine output - informative. Name(#Num) or Name.
00125                 //
00126                 char *buff;
00127 
00128                 buff = unparse_object(player, b->thing, false);
00129                 safe_str(buff, boolexp_buf, &buftop);
00130                 free_lbuf(buff);
00131                 break;
00132 
00133             case F_DECOMPILE:
00134 
00135                 // Decompile output - should be usable on other MUXes. Name if
00136                 // player, Name if thing, else #Num.
00137                 //
00138                 switch (Typeof(b->thing))
00139                 {
00140                 case TYPE_PLAYER:
00141 
00142                     safe_chr('*', boolexp_buf, &buftop);
00143 
00144                 case TYPE_THING:
00145 
00146                     safe_str(Name(b->thing), boolexp_buf, &buftop);
00147                     break;
00148 
00149                 default:
00150 
00151                     safe_tprintf_str(boolexp_buf, &buftop, "#%d", b->thing);
00152                     break;
00153                 }
00154                 break;
00155 
00156             case F_FUNCTION:
00157 
00158                 // Function output - must be usable by @lock cmd. Name if player,
00159                 // else #Num.
00160                 //
00161                 switch (Typeof(b->thing))
00162                 {
00163                 case TYPE_PLAYER:
00164 
00165                     safe_chr('*', boolexp_buf, &buftop);
00166                     safe_str(Name(b->thing), boolexp_buf, &buftop);
00167                     break;
00168 
00169                 default:
00170 
00171                     safe_tprintf_str(boolexp_buf, &buftop, "#%d", b->thing);
00172                     break;
00173                 }
00174             }
00175         }
00176         break;
00177 
00178     case BOOLEXP_ATR:
00179     case BOOLEXP_EVAL:
00180         ATTR *ap;
00181 
00182         ap = atr_num(b->thing);
00183         if (ap && ap->number)
00184         {
00185             // Use the attribute name if the attribute exists.
00186             //
00187             safe_str(ap->name, boolexp_buf, &buftop);
00188         }
00189         else
00190         {
00191             // Otherwise use the attribute number.
00192             //
00193             // Only god or the db loader can create a new boolexp
00194             // with an invalid attribute, but anyone may keep a lock
00195             // whose attribute has subsequently disappeared.
00196             //
00197             safe_ltoa(b->thing, boolexp_buf, &buftop);
00198         }
00199         if (b->type == BOOLEXP_EVAL)
00200         {
00201             safe_chr('/', boolexp_buf, &buftop);
00202         }
00203         else
00204         {
00205             safe_chr(':', boolexp_buf, &buftop);
00206         }
00207         safe_str((char *)b->sub1, boolexp_buf, &buftop);
00208         break;
00209 
00210     default:
00211 
00212         // Bad type.
00213         //
00214         Log.WriteString("ABORT! unparse.cpp, fell off the end of switch in unparse_boolexp1()" ENDLINE);
00215         Log.Flush();
00216         abort();
00217         break;
00218     }
00219 }

char* unparse_boolexp_decompile ( dbref  player,
BOOLEXP b 
)

Definition at line 237 of file unparse.cpp.

References boolexp_buf, BOOLEXP_CONST, buftop, F_DECOMPILE, and unparse_boolexp1().

Referenced by do_decomp().

00238 {
00239     buftop = boolexp_buf;
00240     unparse_boolexp1(player, b, BOOLEXP_CONST, F_DECOMPILE);
00241     *buftop = '\0';
00242     return boolexp_buf;
00243 }

char* unparse_boolexp_function ( dbref  player,
BOOLEXP b 
)

Definition at line 245 of file unparse.cpp.

References boolexp_buf, BOOLEXP_CONST, buftop, F_FUNCTION, and unparse_boolexp1().

Referenced by FUNCTION().

00246 {
00247     buftop = boolexp_buf;
00248     unparse_boolexp1(player, b, BOOLEXP_CONST, F_FUNCTION);
00249     *buftop = '\0';
00250     return boolexp_buf;
00251 }

char* unparse_boolexp_quiet ( dbref  player,
BOOLEXP b 
)

Definition at line 221 of file unparse.cpp.

References boolexp_buf, BOOLEXP_CONST, buftop, F_QUIET, and unparse_boolexp1().

Referenced by db_read(), and do_lock().

00222 {
00223     buftop = boolexp_buf;
00224     unparse_boolexp1(player, b, BOOLEXP_CONST, F_QUIET);
00225     *buftop = '\0';
00226     return boolexp_buf;
00227 }

static char* unparse_object_quiet ( dbref  player,
dbref  loc 
) [static]

Definition at line 24 of file unparse.cpp.

References HOME, NOTHING, SBUF_SIZE, and UNUSED_PARAMETER.

Referenced by unparse_boolexp1().

00025 {
00026     UNUSED_PARAMETER(player);
00027 
00028     static char buf[SBUF_SIZE];
00029 
00030     switch (loc)
00031     {
00032     case NOTHING:
00033         return (char *)"-1";
00034     case HOME:
00035         return (char *)"-3";
00036     default:
00037         sprintf(buf, "(#%d)", loc);
00038         return buf;
00039     }
00040 }


Variable Documentation

char boolexp_buf[LBUF_SIZE] [static]

Definition at line 42 of file unparse.cpp.

Referenced by unparse_boolexp(), unparse_boolexp1(), unparse_boolexp_decompile(), unparse_boolexp_function(), and unparse_boolexp_quiet().

char* buftop [static]

Definition at line 43 of file unparse.cpp.

Referenced by unparse_boolexp(), unparse_boolexp1(), unparse_boolexp_decompile(), unparse_boolexp_function(), and unparse_boolexp_quiet().


Generated on Mon May 28 04:40:23 2007 for MUX by  doxygen 1.4.7