src/unparse.c File Reference

#include "copyright.h"
#include "config.h"
#include "db.h"
#include "mudconf.h"
#include "externs.h"
#include "interface.h"
#include "flags.h"
#include "powers.h"
#include "alloc.h"

Include dependency graph for unparse.c:

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 27 of file unparse.c.

Referenced by unparse_boolexp1(), and unparse_boolexp_decompile().

#define F_EXAMINE   1

Definition at line 21 of file unparse.c.

Referenced by unparse_boolexp(), and unparse_boolexp1().

#define F_FUNCTION   4

Definition at line 30 of file unparse.c.

Referenced by unparse_boolexp1(), and unparse_boolexp_function().

#define F_QUIET   2

Definition at line 24 of file unparse.c.

Referenced by unparse_boolexp1(), and unparse_boolexp_quiet().


Function Documentation

char* unparse_boolexp ( dbref  player,
BOOLEXP b 
)

Definition at line 222 of file unparse.c.

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

Referenced by debug_examine(), do_examine(), fun_colorpairs(), fun_eval(), fun_get(), fun_get_eval(), fun_pairs(), fun_xget(), and view_atr().

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

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

Definition at line 58 of file unparse.c.

References alloc_sbuf, 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, buftop, CARRY_TOKEN, F_DECOMPILE, F_EXAMINE, F_FUNCTION, F_QUIET, free_lbuf, free_sbuf, INDIR_TOKEN, IS_TOKEN, attr::name, Name(), attr::number, OR_TOKEN, OWNER_TOKEN, safe_chr, safe_str, boolexp::sub1, boolexp::sub2, boolexp::thing, TRUE_BOOLEXP, boolexp::type, TYPE_PLAYER, TYPE_THING, Typeof, unparse_object(), and unparse_object_quiet().

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

00060 {
00061         ATTR *ap;
00062         char *tbuf, sep_ch;
00063         char *buff;
00064 
00065         if((b == TRUE_BOOLEXP)) {
00066                 if(format == F_EXAMINE) {
00067                         safe_str((char *) "*UNLOCKED*", boolexp_buf, &buftop);
00068                 }
00069                 return;
00070         }
00071         switch (b->type) {
00072         case BOOLEXP_AND:
00073                 if(outer_type == BOOLEXP_NOT) {
00074                         safe_chr('(', boolexp_buf, &buftop);
00075                 }
00076                 unparse_boolexp1(player, b->sub1, b->type, format);
00077                 safe_chr(AND_TOKEN, boolexp_buf, &buftop);
00078                 unparse_boolexp1(player, b->sub2, b->type, format);
00079                 if(outer_type == BOOLEXP_NOT) {
00080                         safe_chr(')', boolexp_buf, &buftop);
00081                 }
00082                 break;
00083         case BOOLEXP_OR:
00084                 if(outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND) {
00085                         safe_chr('(', boolexp_buf, &buftop);
00086                 }
00087                 unparse_boolexp1(player, b->sub1, b->type, format);
00088                 safe_chr(OR_TOKEN, boolexp_buf, &buftop);
00089                 unparse_boolexp1(player, b->sub2, b->type, format);
00090                 if(outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND) {
00091                         safe_chr(')', boolexp_buf, &buftop);
00092                 }
00093                 break;
00094         case BOOLEXP_NOT:
00095                 safe_chr('!', boolexp_buf, &buftop);
00096                 unparse_boolexp1(player, b->sub1, b->type, format);
00097                 break;
00098         case BOOLEXP_INDIR:
00099                 safe_chr(INDIR_TOKEN, boolexp_buf, &buftop);
00100                 unparse_boolexp1(player, b->sub1, b->type, format);
00101                 break;
00102         case BOOLEXP_IS:
00103                 safe_chr(IS_TOKEN, boolexp_buf, &buftop);
00104                 unparse_boolexp1(player, b->sub1, b->type, format);
00105                 break;
00106         case BOOLEXP_CARRY:
00107                 safe_chr(CARRY_TOKEN, boolexp_buf, &buftop);
00108                 unparse_boolexp1(player, b->sub1, b->type, format);
00109                 break;
00110         case BOOLEXP_OWNER:
00111                 safe_chr(OWNER_TOKEN, boolexp_buf, &buftop);
00112                 unparse_boolexp1(player, b->sub1, b->type, format);
00113                 break;
00114         case BOOLEXP_CONST:
00115                 switch (format) {
00116                 case F_QUIET:
00117 
00118                         /*
00119                          * Quiet output - for dumps and internal use. * * * * 
00120                          * Always #Num 
00121                          */
00122 
00123                         safe_str((char *) unparse_object_quiet(player, b->thing),
00124                                          boolexp_buf, &buftop);
00125                         break;
00126                 case F_EXAMINE:
00127 
00128                         /*
00129                          * Examine output - informative. * Name(#Num) or Name 
00130                          * 
00131                          * *  
00132                          */
00133 
00134                         buff = unparse_object(player, b->thing, 0);
00135                         safe_str(buff, boolexp_buf, &buftop);
00136                         free_lbuf(buff);
00137                         break;
00138                 case F_DECOMPILE:
00139 
00140                         /*
00141                          * Decompile output - should be usable on other * * * 
00142                          * MUXes. * *Name if player, Name if thing, else #Num 
00143                          * 
00144                          * *  
00145                          */
00146 
00147                         switch (Typeof(b->thing)) {
00148                         case TYPE_PLAYER:
00149                                 safe_chr('*', boolexp_buf, &buftop);
00150                         case TYPE_THING:
00151                                 safe_str(Name(b->thing), boolexp_buf, &buftop);
00152                                 break;
00153                         default:
00154                                 buff = alloc_sbuf("unparse_boolexp1");
00155                                 sprintf(buff, "#%d", b->thing);
00156                                 safe_str(buff, boolexp_buf, &buftop);
00157                                 free_sbuf(buff);
00158                         }
00159                         break;
00160                 case F_FUNCTION:
00161 
00162                         /*
00163                          * Function output - must be usable by @lock cmd. * * 
00164                          * 
00165                          * *  * * *Name if player, else #Num 
00166                          */
00167 
00168                         switch (Typeof(b->thing)) {
00169                         case TYPE_PLAYER:
00170                                 safe_chr('*', boolexp_buf, &buftop);
00171                                 safe_str(Name(b->thing), boolexp_buf, &buftop);
00172                                 break;
00173                         default:
00174                                 buff = alloc_sbuf("unparse_boolexp1");
00175                                 sprintf(buff, "#%d", b->thing);
00176                                 safe_str(buff, boolexp_buf, &buftop);
00177                                 free_sbuf(buff);
00178                         }
00179                 }
00180                 break;
00181         case BOOLEXP_ATR:
00182         case BOOLEXP_EVAL:
00183                 if(b->type == BOOLEXP_EVAL)
00184                         sep_ch = '/';
00185                 else
00186                         sep_ch = ':';
00187                 ap = atr_num(b->thing);
00188                 if(ap && ap->number) {
00189                         safe_str((char *) ap->name, boolexp_buf, &buftop);
00190                         safe_chr(sep_ch, boolexp_buf, &buftop);
00191                         safe_str((char *) b->sub1, boolexp_buf, &buftop);
00192                 } else if(b->thing > 0) {
00193                         tbuf = alloc_sbuf("unparse_boolexp1.atr_num");
00194                         sprintf(tbuf, "%d", b->thing);
00195                         safe_str(tbuf, boolexp_buf, &buftop);
00196                         safe_chr(sep_ch, boolexp_buf, &buftop);
00197                         safe_str((char *) b->sub1, boolexp_buf, &buftop);
00198                         free_sbuf(tbuf);
00199                 } else {
00200                         safe_str((char *) b->sub2, boolexp_buf, &buftop);
00201                         safe_chr(sep_ch, boolexp_buf, &buftop);
00202                         safe_str((char *) b->sub1, boolexp_buf, &buftop);
00203                 }
00204                 break;
00205         default:
00206                 fprintf(stderr, "Fell off the end of switch in unparse_boolexp1()\n");
00207                 abort();                                /*
00208                                                                  * bad type 
00209                                                                  */
00210                 break;
00211         }
00212 }

char* unparse_boolexp_decompile ( dbref  player,
BOOLEXP b 
)

Definition at line 230 of file unparse.c.

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

Referenced by do_decomp().

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

char* unparse_boolexp_function ( dbref  player,
BOOLEXP b 
)

Definition at line 238 of file unparse.c.

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

Referenced by fun_lock().

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

char* unparse_boolexp_quiet ( dbref  player,
BOOLEXP b 
)

Definition at line 214 of file unparse.c.

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

Referenced by db_read(), do_lock(), and fun_setlock().

00215 {
00216         buftop = boolexp_buf;
00217         unparse_boolexp1(player, b, BOOLEXP_CONST, F_QUIET);
00218         *buftop++ = '\0';
00219         return boolexp_buf;
00220 }

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

Definition at line 40 of file unparse.c.

References HOME, NOTHING, and SBUF_SIZE.

Referenced by unparse_boolexp1().

00041 {
00042         static char buf[SBUF_SIZE];
00043 
00044         switch (loc) {
00045         case NOTHING:
00046                 return (char *) "-1";
00047         case HOME:
00048                 return (char *) "-3";
00049         default:
00050                 sprintf(buf, "(#%d)", loc);
00051                 return buf;
00052         }
00053 }


Variable Documentation

char boolexp_buf[LBUF_SIZE] [static]

Definition at line 55 of file unparse.c.

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

char* buftop [static]

Definition at line 56 of file unparse.c.

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


Generated on Mon May 28 04:25:48 2007 for BattletechMUX by  doxygen 1.4.7