src/lib/w32/w32misc.h File Reference

#include <io.h>

Include dependency graph for w32misc.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define vsnprintf   _vsnprintf
#define snprintf   _snprintf
#define initstate(seed, state, size)   __initstate((seed), (state), (size))
#define setstate(state)   __setstate((state))
#define srandom(seed)   __srandom((seed))
#define random()   __random()

Typedefs

typedef unsigned short mode_t
typedef long off_t
typedef int pid_t

Functions

char * __initstate (unsigned seed, char *state, size_t size)
long __random (void)
char * __setstate (char *state)
void __srandom (unsigned seed)
char * strptime (const char *buf, const char *fmt, struct tm *tm)


Define Documentation

#define initstate ( seed,
state,
size   )     __initstate((seed), (state), (size))

Definition at line 53 of file w32misc.h.

 
#define random (  )     __random()

Definition at line 57 of file w32misc.h.

Referenced by anti(), att_fight(), chance(), damage(), do_feed(), guerrilla(), landgun(), landunitgun(), launch_sat(), multifire(), new(), plague_people(), populace(), preport(), revolt(), roll(), sabo(), seagun(), takeover(), takeover_plane(), and update_sched().

#define setstate ( state   )     __setstate((state))

Definition at line 55 of file w32misc.h.

#define snprintf   _snprintf

Definition at line 48 of file w32misc.h.

#define srandom ( seed   )     __srandom((seed))

Definition at line 56 of file w32misc.h.

Referenced by init_server(), and main().

#define vsnprintf   _vsnprintf

Definition at line 47 of file w32misc.h.

Referenced by journal_entry(), and logerror().


Typedef Documentation

typedef unsigned short mode_t

Definition at line 65 of file w32misc.h.

typedef long off_t

Definition at line 66 of file w32misc.h.

typedef int pid_t

Definition at line 67 of file w32misc.h.


Function Documentation

char* __initstate ( unsigned  seed,
char *  state,
size_t  size 
)

long __random ( void   ) 

Definition at line 301 of file random.c.

References __libc_lock_lock, __libc_lock_unlock, __random_r(), and unsafe_state.

00302 {
00303   int32_t retval;
00304 
00305   __libc_lock_lock (lock);
00306 
00307   (void) __random_r (&unsafe_state, &retval);
00308 
00309   __libc_lock_unlock (lock);
00310 
00311   return retval;
00312 }

Here is the call graph for this function:

char* __setstate ( char *  state  ) 

Definition at line 270 of file random.c.

References __libc_lock_lock, __libc_lock_unlock, __setstate_r(), NULL, random_data::state, and unsafe_state.

00272 {
00273   int32_t *ostate;
00274 
00275   __libc_lock_lock (lock);
00276 
00277   ostate = &unsafe_state.state[-1];
00278 
00279   if (__setstate_r (arg_state, &unsafe_state) < 0)
00280     ostate = NULL;
00281 
00282   __libc_lock_unlock (lock);
00283 
00284   return (char *) ostate;
00285 }

Here is the call graph for this function:

void __srandom ( unsigned  seed  ) 

char* strptime ( const char *  buf,
const char *  fmt,
struct tm *  tm 
)

Definition at line 118 of file strptime.c.

References _ctloc, ALT_E, ALT_O, conv_num(), find_string(), LEGAL_ALT, NULL, and strptime().

Referenced by parse_time(), and strptime().

00119 {
00120         unsigned char c;
00121         const unsigned char *bp;
00122         int alt_format, i, split_year = 0;
00123         const char *new_fmt;
00124 
00125         bp = (const u_char *)buf;
00126 
00127         while (bp != NULL && (c = *fmt++) != '\0') {
00128                 /* Clear `alternate' modifier prior to new conversion. */
00129                 alt_format = 0;
00130                 i = 0;
00131 
00132                 /* Eat up white-space. */
00133                 if (isspace(c)) {
00134                         while (isspace(*bp))
00135                                 bp++;
00136                         continue;
00137                 }
00138 
00139                 if (c != '%')
00140                         goto literal;
00141 
00142 
00143 again:          switch (c = *fmt++) {
00144                 case '%':       /* "%%" is converted to "%". */
00145 literal:
00146                         if (c != *bp++)
00147                                 return NULL;
00148                         LEGAL_ALT(0);
00149                         continue;
00150 
00151                 /*
00152                  * "Alternative" modifiers. Just set the appropriate flag
00153                  * and start over again.
00154                  */
00155                 case 'E':       /* "%E?" alternative conversion modifier. */
00156                         LEGAL_ALT(0);
00157                         alt_format |= ALT_E;
00158                         goto again;
00159 
00160                 case 'O':       /* "%O?" alternative conversion modifier. */
00161                         LEGAL_ALT(0);
00162                         alt_format |= ALT_O;
00163                         goto again;
00164 
00165                 /*
00166                  * "Complex" conversion rules, implemented through recursion.
00167                  */
00168                 case 'c':       /* Date and time, using the locale's format. */
00169                         new_fmt = _ctloc(d_t_fmt);
00170                         goto recurse;
00171 
00172                 case 'D':       /* The date as "%m/%d/%y". */
00173                         new_fmt = "%m/%d/%y";
00174                         LEGAL_ALT(0);
00175                         goto recurse;
00176 
00177                 case 'R':       /* The time as "%H:%M". */
00178                         new_fmt = "%H:%M";
00179                         LEGAL_ALT(0);
00180                         goto recurse;
00181 
00182                 case 'r':       /* The time in 12-hour clock representation. */
00183                         new_fmt =_ctloc(t_fmt_ampm);
00184                         LEGAL_ALT(0);
00185                         goto recurse;
00186 
00187                 case 'T':       /* The time as "%H:%M:%S". */
00188                         new_fmt = "%H:%M:%S";
00189                         LEGAL_ALT(0);
00190                         goto recurse;
00191 
00192                 case 'X':       /* The time, using the locale's format. */
00193                         new_fmt =_ctloc(t_fmt);
00194                         goto recurse;
00195 
00196                 case 'x':       /* The date, using the locale's format. */
00197                         new_fmt =_ctloc(d_fmt);
00198                     recurse:
00199                         bp = (const u_char *)strptime((const char *)bp,
00200                                                             new_fmt, tm);
00201                         LEGAL_ALT(ALT_E);
00202                         continue;
00203 
00204                 /*
00205                  * "Elementary" conversion rules.
00206                  */
00207                 case 'A':       /* The day of week, using the locale's form. */
00208                 case 'a':
00209                         bp = find_string(bp, &tm->tm_wday, _ctloc(day),
00210                                         _ctloc(abday), 7);
00211                         LEGAL_ALT(0);
00212                         continue;
00213 
00214                 case 'B':       /* The month, using the locale's form. */
00215                 case 'b':
00216                 case 'h':
00217                         bp = find_string(bp, &tm->tm_mon, _ctloc(mon),
00218                                         _ctloc(abmon), 12);
00219                         LEGAL_ALT(0);
00220                         continue;
00221 
00222                 case 'C':       /* The century number. */
00223                         i = 20;
00224                         bp = conv_num(bp, &i, 0, 99);
00225 
00226                         i = i * 100 - TM_YEAR_BASE;
00227                         if (split_year)
00228                                 i += tm->tm_year % 100;
00229                         split_year = 1;
00230                         tm->tm_year = i;
00231                         LEGAL_ALT(ALT_E);
00232                         continue;
00233 
00234                 case 'd':       /* The day of month. */
00235                 case 'e':
00236                         bp = conv_num(bp, &tm->tm_mday, 1, 31);
00237                         LEGAL_ALT(ALT_O);
00238                         continue;
00239 
00240                 case 'k':       /* The hour (24-hour clock representation). */
00241                         LEGAL_ALT(0);
00242                         /* FALLTHROUGH */
00243                 case 'H':
00244                         bp = conv_num(bp, &tm->tm_hour, 0, 23);
00245                         LEGAL_ALT(ALT_O);
00246                         continue;
00247 
00248                 case 'l':       /* The hour (12-hour clock representation). */
00249                         LEGAL_ALT(0);
00250                         /* FALLTHROUGH */
00251                 case 'I':
00252                         bp = conv_num(bp, &tm->tm_hour, 1, 12);
00253                         if (tm->tm_hour == 12)
00254                                 tm->tm_hour = 0;
00255                         LEGAL_ALT(ALT_O);
00256                         continue;
00257 
00258                 case 'j':       /* The day of year. */
00259                         i = 1;
00260                         bp = conv_num(bp, &i, 1, 366);
00261                         tm->tm_yday = i - 1;
00262                         LEGAL_ALT(0);
00263                         continue;
00264 
00265                 case 'M':       /* The minute. */
00266                         bp = conv_num(bp, &tm->tm_min, 0, 59);
00267                         LEGAL_ALT(ALT_O);
00268                         continue;
00269 
00270                 case 'm':       /* The month. */
00271                         i = 1;
00272                         bp = conv_num(bp, &i, 1, 12);
00273                         tm->tm_mon = i - 1;
00274                         LEGAL_ALT(ALT_O);
00275                         continue;
00276 
00277                 case 'p':       /* The locale's equivalent of AM/PM. */
00278                         bp = find_string(bp, &i, _ctloc(am_pm), NULL, 2);
00279                         if (tm->tm_hour > 11)
00280                                 return NULL;
00281                         tm->tm_hour += i * 12;
00282                         LEGAL_ALT(0);
00283                         continue;
00284 
00285                 case 'S':       /* The seconds. */
00286                         bp = conv_num(bp, &tm->tm_sec, 0, 61);
00287                         LEGAL_ALT(ALT_O);
00288                         continue;
00289 
00290                 case 'U':       /* The week of year, beginning on sunday. */
00291                 case 'W':       /* The week of year, beginning on monday. */
00292                         /*
00293                          * XXX This is bogus, as we can not assume any valid
00294                          * information present in the tm structure at this
00295                          * point to calculate a real value, so just check the
00296                          * range for now.
00297                          */
00298                          bp = conv_num(bp, &i, 0, 53);
00299                          LEGAL_ALT(ALT_O);
00300                          continue;
00301 
00302                 case 'w':       /* The day of week, beginning on sunday. */
00303                         bp = conv_num(bp, &tm->tm_wday, 0, 6);
00304                         LEGAL_ALT(ALT_O);
00305                         continue;
00306 
00307                 case 'Y':       /* The year. */
00308                         i = TM_YEAR_BASE;       /* just for data sanity... */
00309                         bp = conv_num(bp, &i, 0, 9999);
00310                         tm->tm_year = i - TM_YEAR_BASE;
00311                         LEGAL_ALT(ALT_E);
00312                         continue;
00313 
00314                 case 'y':       /* The year within 100 years of the epoch. */
00315                         /* LEGAL_ALT(ALT_E | ALT_O); */
00316                         bp = conv_num(bp, &i, 0, 99);
00317 
00318                         if (split_year)
00319                                 /* preserve century */
00320                                 i += (tm->tm_year / 100) * 100;
00321                         else {
00322                                 split_year = 1;
00323                                 if (i <= 68)
00324                                         i = i + 2000 - TM_YEAR_BASE;
00325                                 else
00326                                         i = i + 1900 - TM_YEAR_BASE;
00327                         }
00328                         tm->tm_year = i;
00329                         continue;
00330 
00331                 /*
00332                  * Miscellaneous conversions.
00333                  */
00334                 case 'n':       /* Any kind of white-space. */
00335                 case 't':
00336                         while (isspace(*bp))
00337                                 bp++;
00338                         LEGAL_ALT(0);
00339                         continue;
00340 
00341 
00342                 default:        /* Unknown/unsupported conversion. */
00343                         return NULL;
00344                 }
00345         }
00346 
00347         return __UNCONST(bp);
00348 }

Here is the call graph for this function:


Generated on Fri Mar 28 11:01:57 2008 for empserver by  doxygen 1.5.2