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

SRC/misc.c File Reference


Detailed Description

Module for various things:

Definition in file misc.c.

Go to the source code of this file.

Data Structures

struct  on_exit
 Register an on-exit function. More...
struct  cmd_block
 Run a COMMAND.COM/4DOS external/internal command. More...

Functions

void setup_dos_xfer_buf (void)
void is_in_stack_init (void)
STATIC int setup_stk_check (void)
void cdecl _fatal_runtime_error (UINT stk)
void cdecl _fatal_runtime_error_ (UINT stk)
 void (__cdecl *_aaltstkovr)(void)
void stk_overflow (void _far *where)
STATIC void test_stk_check (void)
unsigned long cdecl _w32_intel (unsigned long val)
 Convert 32-bit big-endian (network order) to intel (host order) format.
unsigned short cdecl _w32_intel16 (unsigned short val)
 Convert 16-bit big-endian (network order) to intel (host order) format.
void patch_with_bswap (void)
DWORD get_day_num (void)
 Simplified method of getting days since 1970-01-01.
BOOL RDTSC_enabled (void)
BOOL check_reg_struct (void)
void init_misc (void)
 Initialise various stuff.
void exit_misc (void)
 Called from sock_exit() to clear up things done here.
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.
int list_compare (const struct on_exit *a, const struct on_exit *b)
int rundown_add (void(*func)(void), const char *name, int order, const char *file, unsigned line)
 Register a function to be called from sock_exit().
void rundown_run (void)
 Run the registered and sorted exit_list[] functions.
void rundown_dump (void)
 Dump 'exit_list[]' list.
_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook2 (int, _CRT_REPORT_HOOK)
void __cdecl crtdbg_exit (void)
const char * report_name (int type)
void __cdecl crtdbg_dump (const void *buf, size_t len)
int __cdecl crtdbg_report (int type, char *message, int *ret_val)
void memdbg_init (void)
void fortify_report (void)
 Report routine for Fortify.
void assert_fail (const char *file, unsigned line, const char *what)
 Print an assert fail and store the text for later.
unsigned Random (unsigned a, unsigned b)
 Returns a random integer in range [a..b].
void 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)
int 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.
void unfinished (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")
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)
void free_selector (void)
int _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)
void stk_overflow (UINT ret_addr)
int stk_check_setup (void)
void stk_overflow (WORD cs, UINT eip)
void FATAL_HANDLER (UINT stk)
BOOL get_mem_strat (BYTE *strat)
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 num_exit_func_inserts = 0
int _w32_errno = 0
int __bss_count = 0
FARPTR _watt_dosFp
_CPUID lcc_cpuid
char cdecl x86_type = 5
char cdecl x86_vendor_id [13]
DWORD cdecl x86_capability
char cdecl __begtext
UINT cdecl _x386_stacklow
char * dummy_fatal_rte = (char*)&FATAL_HANDLER
const BYTE bswap32 []
const BYTE bswap16 []
on_exit exit_list [40]
_CrtMemState last_state
THREADLOCAL const char * stack_bottom = 0
unsigned _stklen
unsigned __djgpp_stack_limit
REALPTR _watt_dosTbr = 0
DWORD _watt_dosTbSize = 0
WORD rm_seg = 0
WORD _watt_dosTbSeg = 0
WORD _watt_dosTbSel = 0
WORD _watt_dos_ds
int __brklvl


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 145 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 157 of file misc.c.

int __cdecl crtdbg_report int  type,
char *  message,
int *  ret_val
[static]
 

<

Todo:
make a stack dumper
Definition at line 617 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. DOS/Watcom: simply call fopen(). Definition at line 441 of file misc.c.

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 688 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 198 of file misc.c.

References DWORD.

void init_misc void   ) 
 

Initialise various stuff.

Todo:
Definition at line 322 of file misc.c.

References _watt_assert_buf, _watt_dosFp, _watt_os_ver, DWORD, has_rdtsc, init_timers(), and win32_dos_box.

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 935 of file misc.c.

References _pktdevclass.


Variable Documentation

char _watt_assert_buf[256]
 

Print this in dbug_exit() Definition at line 55 of file misc.c.

FARPTR _watt_dosFp
 

Todo:
detect program restarts
Definition at line 69 of file misc.c.

BOOL _watt_fatal_error = FALSE
 

We're exiting via an exception handler Definition at line 53 of file misc.c.

WORD _watt_os_ver = 0x622
 

True DOS/WinNT version MSB.LSB Definition at line 54 of file misc.c.

const BYTE bswap16[] [static]
 

Initial value:

{ 0x8B,0x44,0x24,0x04, 0x0F,0xC8, 0xC1,0xE8,0x10, 0xC3 }
Definition at line 169 of file misc.c.

const BYTE bswap32[] [static]
 

Initial value:

{ 0x8B,0x44,0x24,0x04, 0x0F,0xC8, 0xC3 }
Definition at line 163 of file misc.c.

BOOL win32_dos_box = FALSE
 

Running under Windows DOS-box Definition at line 52 of file misc.c.


Generated on Wed Aug 4 08:55:56 2010 for Watt-32 tcp/ip by doxygen 1.3.8