Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

bit.c File Reference

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "tables.h"
#include "lookup.h"

Include dependency graph for bit.c:

Go to the source code of this file.

Functions

char * flag_string (const struct flag_type *flag_table, int bits)
int flag_value (const struct flag_type *flag_table, char *argument)
bool is_stat (const struct flag_type *flag_table)

Variables

const struct flag_stat_type flag_stat_table []


Function Documentation

char* flag_string const struct flag_type flag_table,
int  bits
 

Definition at line 151 of file bit.c.

References IS_SET, and is_stat().

Referenced by AEDIT(), display_resets(), MEDIT(), OEDIT(), REDIT(), save_resets(), and show_obj_values().

00152 {
00153     static char buf[2][512];
00154     static int cnt = 0;
00155     int flag;
00156 
00157     if (++cnt > 1)
00158         cnt = 0;
00159 
00160     buf[cnt][0] = '\0';
00161 
00162     for (flag = 0; flag_table[flag].name != NULL; flag++)
00163     {
00164         if (!is_stat (flag_table) && IS_SET (bits, flag_table[flag].bit))
00165         {
00166             strcat (buf[cnt], " ");
00167             strcat (buf[cnt], flag_table[flag].name);
00168         }
00169         else if (flag_table[flag].bit == bits)
00170         {
00171             strcat (buf[cnt], " ");
00172             strcat (buf[cnt], flag_table[flag].name);
00173             break;
00174         }
00175     }
00176     return (buf[cnt][0] != '\0') ? buf[cnt] + 1 : "none";
00177 }

Here is the call graph for this function:

int flag_value const struct flag_type flag_table,
char *  argument
 

Definition at line 111 of file bit.c.

References FALSE, flag_lookup(), is_stat(), MAX_INPUT_LENGTH, NO_FLAG, one_argument(), SET_BIT, and TRUE.

Referenced by aedit(), change_exit(), do_oflagall(), do_resets(), do_rflagall(), MEDIT(), OEDIT(), REDIT(), and set_obj_values().

00112 {
00113     char word[MAX_INPUT_LENGTH];
00114     int bit;
00115     int marked = 0;
00116     bool found = FALSE;
00117 
00118     if (is_stat (flag_table))
00119         return flag_lookup (argument, flag_table);
00120 
00121     /*
00122      * Accept multiple flags.
00123      */
00124     for (;;)
00125     {
00126         argument = one_argument (argument, word);
00127 
00128         if (word[0] == '\0')
00129             break;
00130 
00131         if ((bit = flag_lookup (word, flag_table)) != NO_FLAG)
00132         {
00133             SET_BIT (marked, bit);
00134             found = TRUE;
00135         }
00136     }
00137 
00138     if (found)
00139         return marked;
00140     else
00141         return NO_FLAG;
00142 }

Here is the call graph for this function:

bool is_stat const struct flag_type flag_table  ) 
 

Definition at line 93 of file bit.c.

References FALSE, flag_stat_table, and TRUE.

Referenced by flag_string(), and flag_value().

00094 {
00095     int flag;
00096 
00097     for (flag = 0; flag_stat_table[flag].structure; flag++)
00098     {
00099         if (flag_stat_table[flag].structure == flag_table
00100             && flag_stat_table[flag].stat)
00101             return TRUE;
00102     }
00103     return FALSE;
00104 }


Variable Documentation

const struct flag_stat_type flag_stat_table[]
 

Initial value:

Definition at line 50 of file bit.c.

Referenced by is_stat().


Generated on Thu Jan 13 21:54:49 2005 for Beyond the Shadows by  doxygen 1.4.0