Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Functions | Variables
misc.c File Reference

Go to the source code of this file.

Data Structures

struct  cmd_block
 Run a COMMAND.COM/4DOS external/internal command. More...
 

Functions

static void setup_dos_xfer_buf (void)
 
static void is_in_stack_init (void)
 
unsigned long cdecl _w32_intel (unsigned long val)
 Convert 32-bit big-endian (network order) to intel (host order) format. More...
 
unsigned short cdecl _w32_intel16 (unsigned short val)
 Convert 16-bit big-endian (network order) to intel (host order) format. More...
 
static void patch_with_bswap (void)
 
DWORD get_day_num (void)
 Simplified method of getting days since 1970-01-01. More...
 
static BOOL RDTSC_enabled (void)
 
static BOOL check_reg_struct (void)
 
void W32_CALL init_misc (void)
 Initialise various stuff. More...
 
FILE * fopen_excl (const char *file, const char *mode)
 WIN32: Open an existing file (or create) in share-mode but deny other processes to write to the file. More...
 
_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook2 (int, _CRT_REPORT_HOOK)
 
static void __cdecl crtdbg_exit (void)
 
static const char * report_name (int type)
 
static void __cdecl crtdbg_dump (const void *buf, size_t len)
 
static int __cdecl crtdbg_report (int type, char *message, int *ret_val)
 
void memdbg_init (void)
 
void memdbg_post_init (void)
 
static void fortify_report (void)
 Report routine for Fortify. More...
 
void assert_fail (const char *file, unsigned line, const char *what)
 Store the "assert fail" text for later before printing it.
 
void W32_CALL assert_fail_test (void)
 
void W32_CALL abort_test (void)
 
void W32_CALL except_test (void)
 
void W32_CALL leak_test (void)
 
unsigned W32_CALL Random (unsigned a, unsigned b)
 Returns a random integer in range [a..b].
 
void W32_CALL RandomWait (unsigned a, unsigned b)
 Wait for a random period in range [a..b] millisec.
 
void Wait (unsigned msec)
 Not all vendors have delay().
 
const char * dos_extender_name (void)
 
void os_yield (void)
 
BOOL watt_check_break (void)
 
char * ctime_r (const time_t *t, char *res)
 A reentrant ctime().
 
struct tm * localtime_r (const time_t *t, struct tm *res)
 A reentrant localtime().
 
int W32_CALL watt_kbhit (void)
 A less CPU hogging kbhit().
 
const char * list_lookup (DWORD type, const struct search_list *list, int num)
 Search 'list' for 'type' and return it's name.
 
const char * list_lookupX (DWORD type, const struct search_list *list, int num)
 
const char * MAC_address (const void *addr)
 Return hexa-decimal string for an 6/7 byte MAC-address. More...
 
void unfinished (const char *func, const char *file, unsigned line)
 
void unimplemented (const char *func, const char *file, unsigned line)
 
const char * dword_str (DWORD val)
 Return nicely formatted string "xx,xxx,xxx" with thousand separators (left adjusted).
 
DWORD get_ds_limit (void)
 
DWORD get_cs_limit (void)
 
DWORD get_ss_limit (void)
 
unsigned dj_end asm ("end")
 
static unsigned get_frame_size (const char *x)
 
BOOL is_in_stack (const void *ptr)
 
unsigned used_stack (void)
 
BOOL valid_addr (const void *addr, unsigned len)
 
static void free_selector (void)
 
int W32_CALL _w32_ffs (int i)
 
void watt_large_check (const void *sock, int size, const char *file, unsigned line)
 
BOOL is_big_endian (void)
 
BOOL shell_exec (const char *cmd)
 
void _w32_intr (int int_no, IREGS *reg)
 Microsoft/Digital Mars doesn't have intr() so we make our own.
 
STATIC void stk_overflow (WORD ret_addr)
 
STATIC int setup_stk_check (void)
 
static void stk_overflow (UINT ret_addr)
 
static int stk_check_setup (void)
 
static void stk_overflow (WORD cs, UINT eip)
 
void FATAL_HANDLER (UINT stk)
 
static void stk_overflow (void _far *where)
 
static BOOL get_mem_strat (BYTE *strat)
 
static BOOL set_mem_strat (BYTE strat)
 
void foo_10 (void)
 
void foo_20 (void)
 
void foo_30 (void)
 
void foo_40 (void)
 
void foo_50 (void)
 
void foo_60 (void)
 
void foo_70 (void)
 
int main (void)
 

Variables

const char hex_chars_lower [] = "0123456789abcdef"
 
const char hex_chars_upper [] = "0123456789ABCDEF"
 
BOOL win32_dos_box = FALSE
 
BOOL _watt_fatal_error = FALSE
 
WORD _watt_os_ver = 0x622
 
char _watt_assert_buf [256]
 
int _w32_errno = 0
 
FARPTR _watt_dosFp
 
static _CPUID lcc_cpuid
 
char cdecl x86_type = 5
 
char cdecl x86_vendor_id [13]
 
DWORD cdecl x86_capability
 
static const BYTE bswap32 []
 
static const BYTE bswap16 []
 
static _CrtMemState last_state
 
static BOOL got_crt_assert
 
unsigned _stklen
 
unsigned __djgpp_stack_limit
 
static THREAD_LOCAL UINT_PTR stack_bottom = 0
 
static THREAD_LOCAL UINT_PTR stack_limit = 0
 
REALPTR _watt_dosTbr = 0
 
DWORD _watt_dosTbSize = 0
 
static WORD rm_seg = 0
 
WORD _watt_dosTbSeg = 0
 
WORD _watt_dosTbSel = 0
 
WORD _watt_dos_ds
 
int __brklvl
 

Detailed Description

Module for various things:

Definition in file misc.c.

Function Documentation

unsigned long cdecl _w32_intel ( unsigned long  val)

Convert 32-bit big-endian (network order) to intel (host order) format.

Or vice-versa. These are cdecl incase we patch them.

Definition at line 147 of file misc.c.

unsigned short cdecl _w32_intel16 ( unsigned short  val)

Convert 16-bit big-endian (network order) to intel (host order) format.

Or vice-versa

Definition at line 159 of file misc.c.

static void __cdecl crtdbg_exit ( void  )
static

-do: show a better MessageBox(). Show backtrace from where abort() was called; skip the 2 first CRT locations (raise, abort). Indent the printout 2 spaces.

Definition at line 528 of file misc.c.

FILE* fopen_excl ( const char *  file,
const char *  mode 
)

WIN32: Open an existing file (or create) in share-mode but deny other processes to write to the file.

On Watcom, fopen() already seems to open with SH_DENYWR internally. CygWin: if REENT_ONLY defined, call _fopen_r(). Otherwise call fopen(). MSDOS/Watcom: simply call fopen().

Definition at line 439 of file misc.c.

static void fortify_report ( void  )
static

Report routine for Fortify.

Report memory statistics and leaks done in this scope (the core API level). BSD socket API sets it's own scope with reporting done in sock_fortify_exit().

Definition at line 609 of file misc.c.

DWORD get_day_num ( void  )

Simplified method of getting days since 1970-01-01.

Don't use time() since it will probably link in sprintf(). We don't need accuracy. Only a reference for sock_stats().

Definition at line 200 of file misc.c.

void W32_CALL init_misc ( void  )

Initialise various stuff.

Todo:

Definition at line 324 of file misc.c.

References _watt_assert_buf, _watt_os_ver, has_rdtsc, init_timers(), is_in_stack_init(), and win32_dos_box.

static void is_in_stack_init ( void  )
static
Todo:
Make CS writeable
Todo:
Make CS read-only

Definition at line 83 of file misc.c.

const char* MAC_address ( const void addr)

Return hexa-decimal string for an 6/7 byte MAC-address.

Use 2 buffers in round-robin.

Definition at line 963 of file misc.c.

References _pktdevclass.

Variable Documentation

char _watt_assert_buf[256]

Print this in dbug_exit()

Definition at line 62 of file misc.c.

BOOL _watt_fatal_error = FALSE

We're exiting via an exception handler

Definition at line 60 of file misc.c.

WORD _watt_os_ver = 0x622

True DOS/WinNT version MSB.LSB

Definition at line 61 of file misc.c.

const BYTE bswap16[]
static
Initial value:
= {
0x8B,0x44,0x24,0x04,
0x0F,0xC8,
0xC1,0xE8,0x10,
0xC3
}

Definition at line 171 of file misc.c.

const BYTE bswap32[]
static
Initial value:
= {
0x8B,0x44,0x24,0x04,
0x0F,0xC8,
0xC3
}

Definition at line 165 of file misc.c.

BOOL win32_dos_box = FALSE

Running under Windows DOS-box

Definition at line 59 of file misc.c.