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

Go to the source code of this file.

Data Structures

struct  search_list
 
struct  DPMI_regs
 
struct  IREGS
 

Typedefs

typedef struct DPMI_regs IREGS
 
typedef INTR_PROTOTYPE(* W32_IntrHandler )()
 

Functions

int __cdecl kbhit (void)
 
void Wait (unsigned msec)
 Not all vendors have delay().
 
BOOL is_in_stack (const void *ptr)
 
unsigned used_stack (void)
 
BOOL valid_addr (const void *addr, unsigned len)
 
void os_yield (void)
 
void assert_fail (const char *file, unsigned line, const char *what)
 Store the "assert fail" text for later before printing it.
 
DWORD get_day_num (void)
 Simplified method of getting days since 1970-01-01. More...
 
void memdbg_init (void)
 
void memdbg_post_init (void)
 
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...
 
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().
 
char * strtok_r (char *ptr, const char *sep, char **end)
 
const char * dos_extender_name (void)
 
const char * dword_str (DWORD val)
 Return nicely formatted string "xx,xxx,xxx" with thousand separators (left adjusted).
 
const char * list_lookup (DWORD, const struct search_list *, int)
 Search 'list' for 'type' and return it's name.
 
const char * list_lookupX (DWORD, const struct search_list *, int)
 
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)
 
void watt_large_check (const void *sock, int size, const char *file, unsigned line)
 
typedef int (MS_CDECL *CmpFunc)(const void *
 
int getch (void)
 
char * itoa (int val, char *buf, int radix)
 
BOOL init_win_misc (void)
 
BOOL WinDnsQuery_A4 (const char *name, DWORD *ip4)
 
BOOL WinDnsQuery_A6 (const char *name, void *ip6)
 
BOOL WinDnsQuery_PTR4 (DWORD ip4, TCHAR *name, size_t size)
 
BOOL WinDnsQuery_PTR6 (const void *ip6, TCHAR *name, size_t size)
 
BOOL WinDnsCachePut_A4 (const char *name, DWORD ip4)
 
BOOL WinDnsCachePut_A6 (const char *name, const void *ip6)
 
BOOL GetFileVersion (const char *file, char *buf, size_t buf_len)
 Returns the version of a PE image (.sys, .dll or .exe).
 
void print_thread_times (HANDLE thread)
 
const char * wstring_acp (const wchar_t *in_str)
 
const char * wstring_utf8 (const wchar_t *in_str)
 
const wchar_t * astring_acp (const char *in_str)
 
const wchar_t * astring_utf8 (const char *in_str)
 
BOOL tcp_cbreak_off (void)
 
int set_cbreak (int want_brk)
 Sets normal and extended BREAK mode. More...
 
void MS_CDECL sig_handler_watt (int sig)
 SIGINT/SIGBREAK handler function. More...
 
int GetCountryCode (void)
 
int GetCodePage (void)
 
void int24_init (void)
 
void int24_restore (void)
 
void dputch (char x)
 
void dmsg (const char *s)
 
void dhex1int (int x)
 
void dhex2int (int x)
 
void dhex4int (int x)
 
void dhex8int (DWORD x)
 
BOOL crc_init (void)
 
DWORD crc_bytes (const char *buf, size_t len)
 
const char * short_strerror (int errnum)
 
void intr (int int_no, IREGS *regs)
 
void STACK_SET (void far *stack)
 
void STACK_RESTORE (void)
 
void PUSHF_CLI (void)
 
void POPF (void)
 
void STACK_SET (void *stack)
 
WORD watcom_MY_CS (void)
 
WORD watcom_MY_DS (void)
 
DWORD GET_LIMIT (WORD sel)
 
DWORD get_ds_limit (void)
 
DWORD get_cs_limit (void)
 
DWORD get_ss_limit (void)
 
typedef void (cdecl interrupt *W32_IntrHandler)()
 
__inline__ WORD get_fs_reg (void)
 
__inline__ WORD get_gs_reg (void)
 
__inline__ void set_fs_reg (WORD sel)
 
__inline__ void set_gs_reg (WORD sel)
 
char * strupr (char *)
 
char * strlwr (char *)
 
char * strdup (const char *)
 
int stricmp (const char *, const char *)
 
int strnicmp (const char *, const char *, size_t)
 
voidalloca (size_t)
 
int gettimeofday (struct timeval *, struct timezone *)
 
int fileno (FILE *)
 
int isascii (int)
 
void psignal (int, const char *)
 
int vsscanf (const char *, const char *, va_list)
 

Variables

const char hex_chars_lower []
 
const char hex_chars_upper []
 
BOOL win32_dos_box
 
BOOL _watt_fatal_error
 
WORD _watt_os_ver
 
char _watt_assert_buf [256]
 
HANDLE stdin_hnd
 
HANDLE stdout_hnd
 
BOOL _watt_is_win9x
 
BOOL _watt_is_wow64
 
BOOL _watt_is_gui_app
 
BOOL _watt_use_bugtrap
 
CONSOLE_SCREEN_BUFFER_INFO console_info
 
WORD _watt_handle_cbreak
 Turn off stack-checking here because stack may be out of bounds. More...
 
volatile int _watt_cbroke
 
BYTE dbg_colour
 
WORD dbg_scrpos
 
WORD dbg_scrstart
 
DWORD * crc_table
 
int pull_neterr_module
 

Function Documentation

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.

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.

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.

int set_cbreak ( int  want_brk)

Sets normal and extended BREAK mode.

  • want_brk 0x0000: no ^BREAK checking.
  • want_brk 0x0001: normal ^BREAK checks.
  • want_brk 0x0101: extended ^BREAK checks.
Return values
normalBREAK state in LSB, extended BREAK state in MSB.

Definition at line 129 of file pc_cbrk.c.

void MS_CDECL sig_handler_watt ( int  sig)

SIGINT/SIGBREAK handler function.

The Windows runtime docs at http://msdn.microsoft.com/library/en-us/vclib/html/_crt_signal.asp specifically forbid a number of things being done from a signal handler, including IO, memory allocation and system calls, and only allow jmpbuf if you are handling SIGFPE.

Hence sig_handler_watt() on Win32 simply increments the '_watt_cbroke' variable.

Also note the behaviour of Windows with SIGINT, which says this: Note SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs, Win32 operating systems generate a new thread to specifically handle that interrupt. This can cause a single-thread application such as UNIX, to become multithreaded, resulting in unexpected behavior.

So a longjmp() from handler-thread to main-thread is out of the question.

Definition at line 73 of file pc_cbrk.c.

References _watt_cbroke, _watt_handle_cbreak, and set_cbreak().

Variable Documentation

char _watt_assert_buf[256]

Print this in dbug_exit()

Definition at line 62 of file misc.c.

volatile int _watt_cbroke

increment on SIGINT catch

Definition at line 47 of file pc_cbrk.c.

BOOL _watt_fatal_error

We're exiting via an exception handler

Definition at line 60 of file misc.c.

WORD _watt_handle_cbreak

Turn off stack-checking here because stack may be out of bounds.

longjmp() hopefully fixes that.changes operation of the break stuff

Definition at line 46 of file pc_cbrk.c.

WORD _watt_os_ver

True DOS/WinNT version MSB.LSB

Definition at line 61 of file misc.c.

BOOL win32_dos_box

Running under Windows DOS-box

Definition at line 59 of file misc.c.