📄 msc.h
字号:
// MSC.H
#ifndef MSC_H
#define MSC_H
////////////////////////////////////////////
// NON-ANSI NAMES //
////////////////////////////////////////////
// Non-ANSI names for compatibility
// <stdio.h>
#define wfopen _wfopen
#define fsopen _fsopen
#define wfsopen _wfsopen
#define snprintf _snprintf
#define snwprintf _snwprintf
#define vsnprintf _vsnprintf
#define vsnwprintf _vsnwprintf
// <conio.h>
#define outp _outp
#define inp _inp
// <stdlib.h>
#define wtoi _wtoi
#define wtol _wtol
#define wtof _wtof
// <ctype.h>
#ifndef isascii
#define isascii __isascii
#endif
// <string.h>
#define strrev _strrev
#define wcsrev _wcsrev
#define strdup _strdup
#define wcsdup _wcsdup
// <mbctype.h>
#define ismbblead _ismbblead
#define ismbbtrail _ismbbtrail
#define ismbbkana _ismbbkana
#ifndef __cplusplus
#define inline __inline
#endif
////////////////////////////////////////////
// BORLAND //
////////////////////////////////////////////
// for Borland C++ 5.5.1
#if defined __BORLANDC__
#pragma option -w-8008 // 忦審偑忢偵恀傑偨偼婾
#pragma option -w-8027 // 僀儞儔僀儞揥奐偱偒側偄
#pragma option -w-8057 // 堷偒悢偑堦搙傕巊梡偝傟偰偄側偄
#pragma option -w-8060 // 偍偦傜偔晄惓側戙擖
#pragma option -w-8066 // 幚峴偝傟側偄僐乕僪
// <stdio.h>
#define _base buffer // inside of FILE
#define _ptr curp // inside of FILE
#ifdef FILENAME_MAX
#include <stdarg.h>
#endif
// <io.h>
#define _isatty isatty
#define _setmode setmode
// <share.h>
#define _SH_DENYNO SH_DENYNO
#define _SH_DENYWR SH_DENYWR
// <stdlib.h>
#define __wargv wargv_dummy_
// <string.h>
#define _strrev strrev
#define _strdup strdup
// "stringex.h"
#undef strlwr
#undef strupr
#define strlwr strlwr_by_stringex
#define strupr strupr_by_stringex
#define stricmp stricmp_by_stringex
#define strnicmp strnicmp_by_stringex
#define memicmp memicmp_by_stringex
#endif // __BORLANDC__
////////////////////////////////////////////
// DIGITAL MARS //
////////////////////////////////////////////
// for Digital Mars C++ 8.36
#if defined __DMC__
// for wcstol,wcstoul,wcstod
#ifdef _WCHAR_T_DEFINED
#include <wchar.h>
#endif
// variable arguments functions
#ifdef FILENAME_MAX // stdio.h
#include <stdarg.h>
static int __cdecl swprintf_ ( wchar_t *buffer, const wchar_t *format,... ) {
va_list args ;
va_start ( args, format ) ;
int result = vswprintf ( buffer, 0x7FFFFFFF, format, args ) ;
va_end ( args ) ;
return result ;
}
#define swprintf swprintf_
#define vswprintf(s,f,a) vswprintf(s,0x7FFFFFFF,f,a)
#endif
// "stringex.h"
#define wmemchr wmemchr_by_stringex
#define wmemset wmemset_by_stringex
#endif // __DMC__
////////////////////////////////////////////
// WATCOM C //
////////////////////////////////////////////
// for Watcom C++ 1.4
#if defined __WATCOMC__
#define __cdecl
// <stdio.h>
#define _base _ptr // inside of FILE
// <io.h>
#define _isatty isatty
#define _setmode setmode
#define _fileno fileno
// <conio.h>
#define _outp outp
#define _inp inp
// <share.h>
#define _SH_DENYNO SH_DENYNO
#define _SH_DENYWR SH_DENYWR
// variable arguments functions
#ifdef FILENAME_MAX // stdio.h
#include <stdarg.h>
static int __cdecl swprintf_ ( wchar_t *buffer, const wchar_t *format,... ) {
va_list args ;
va_start ( args, format ) ;
int result = vswprintf ( buffer, 0x7FFFFFFF, format, args ) ;
va_end ( args ) ;
return result ;
}
#define swprintf swprintf_
#define vswprintf(s,f,a) vswprintf(s,0x7FFFFFFF,f,a)
#endif
// "stringex.h"
#define strlcpy strlcpy_by_stringex
#define wcslcpy wcslcpy_by_stringex
// SEH
#define __try if(1)
#define __except(x) else
#define __finally
#endif // __WATCOMC__
////////////////////////////////////////////
// GCC //
////////////////////////////////////////////
// for MinGW G++ 1.4
#if defined __GNUC__
// <stdio.h>
#ifdef FILENAME_MAX
#include <stdarg.h>
#endif
// SEH
#define __try if(1)
#define __except(x) else
#define __finally
#endif // __GNUC__
////////////////////////////////////////////
// DEBUG //
////////////////////////////////////////////
#if defined DEBUG_CONST_STRING
#undef NOCRT
#endif
////////////////////////////////////////////
// STDDEF.H //
////////////////////////////////////////////
#include <stddef.h>
#if defined _MSC_VER && _MSC_VER < 1300 || defined __BORLANDC__ && __BORLANDC__ < 1370
typedef int intptr_t ;
typedef unsigned int uintptr_t ;
#elif defined __BORLANDC__ || defined __DMC__ || defined __WATCOMC__ || defined __GNUC__
#include <stdint.h>
#endif
////////////////////////////////////////////
// STDIO.H/IO.H //
////////////////////////////////////////////
#ifdef FILENAME_MAX // stdio.h
#include <io.h>
#include <fcntl.h>
#include <share.h>
#endif
#ifdef FILENAME_MAX // stdio.h
#ifndef MAX_PATH
#define MAX_PATH FILENAME_MAX
#endif
#endif
// 僗僩儕乕儉偑抂枛偐偳偆偐専嵏
// 抂枛側傜 0 埲奜傪丄抂枛偱側偗傟偽 0 傪曉偡
// is associated with tele-typewriter
#define fisatty(stream) _isatty(_fileno(stream))
// 僗僩儕乕儉偺曄姺儌乕僪傪曄峏
// 捈慜偺曄姺儌乕僪傪曉偡
#define fsetmode(stream,mode) _setmode(_fileno(stream),mode)
// OS偺僼傽僀儖僴儞僪儖傪曉偡
#define fget_osfhandle(stream) ((void*)_get_osfhandle(_fileno(stream)))
#ifdef __cplusplus
extern "C" {
#endif
#ifdef FILENAME_MAX // stdio.h
#if defined _MSC_VER
int __cdecl _fseeki64 ( FILE *stream, __int64 offset, int origin ) ;
__int64 __cdecl _ftelli64 ( FILE *stream ) ;
#define fseek64 _fseeki64
#define ftell64 _ftelli64
#else
#define fseek64 fseek
#define ftell64 ftell
#endif
#endif
#ifdef __cplusplus
}
#endif
// oemio.cpp
#define wprintf oem_wprintf
#define fwprintf oem_fwprintf
#define vfwprintf oem_vfwprintf
#define fputws oem_fputws
#define fgetws oem_fgetws
////////////////////////////////////////////
// CTYPE.H //
////////////////////////////////////////////
#define toupper toupper_inline
#define tolower tolower_inline
static inline int toupper ( int c ) { return ( c >= 'a' && c <= 'z' ) ? ( c - 'a' + 'A' ) : c ; }
static inline int tolower ( int c ) { return ( c >= 'A' && c <= 'Z' ) ? ( c - 'A' + 'a' ) : c ; }
#define isblank isblank_inline
static inline int isblank ( int c ) { return c == 0x20 || c == '\t' ; }
#if ! defined __BORLANDC__
#undef __iscsym
#undef __iscsymf
#endif
#define iscsym __iscsym
#define iscsymf __iscsymf
// for MSC or DMC
#if defined _MSC_VER || defined __DMC__
#undef isalpha
#undef isupper
#undef islower
#undef isdigit
#undef isxdigit
#undef isspace
#undef ispunct
#undef isalnum
#undef isprint
#undef isgraph
#undef iscntrl
// These macros are faster than functions in MSC's <ctype.h>.
#define isalpha(c) ( _pctype[c] & (_UPPER|_LOWER) )
#define isupper(c) ( _pctype[c] & (_UPPER) )
#define islower(c) ( _pctype[c] & (_LOWER) )
#define isdigit(c) ( _pctype[c] & (_DIGIT) )
#define isxdigit(c) ( _pctype[c] & (_HEX) )
#define isspace(c) ( _pctype[c] & (_SPACE) )
#define ispunct(c) ( _pctype[c] & (_PUNCT) )
#define isalnum(c) ( _pctype[c] & (_UPPER|_LOWER|_DIGIT) )
#define isprint(c) ( _pctype[c] & (_BLANK|_PUNCT|_UPPER|_LOWER|_DIGIT) )
#define isgraph(c) ( _pctype[c] & (_PUNCT|_UPPER|_LOWER|_DIGIT) )
#define iscntrl(c) ( _pctype[c] & (_CONTROL) )
#endif // MSC, DMC
////////////////////////////////////////////
// STRING.H //
////////////////////////////////////////////
// 暥帤楍偺枛旜乮僰儖暥帤乯傪曉偡
#if defined _MSC_VER && ! defined DEBUG_CONST_STRING
static inline char *strend ( const char *s ) {
while ( *s ) s ++ ;
return (char*) s ;
}
static inline wchar_t *wcsend ( const wchar_t *s ) {
while ( *s ) s ++ ;
return (wchar_t*) s ;
}
#else
#define strend(s) strchr ( s, 0 )
#define wcsend(s) wcschr ( s, 0 )
#endif
#define memzero(p,n) memset ( p, 0, n )
#if defined DEBUG_CONST_STRING && defined __cplusplus && defined _INC_STRING // for debug
#define FUNC_STR_STR(func,type) \
static inline const type *func##_ ( const type *s1, const type *s2 ) { return func ( s1, s2 ) ; } \
static inline type *func##_ ( type *s1, const type *s2 ) { return func ( s1, s2 ) ; }
#define FUNC_STR_INT(func,type) \
static inline const type *func##_ ( const type *s, int c ) { return func ( s, c ) ; } \
static inline type *func##_ ( type *s, int c ) { return func ( s, c ) ; }
#define FUNC_STR_INT_SIZET(func,type) \
static inline const type *func##_ ( const type *s, int c, size_t i ) { return func ( s, c, i ) ; } \
static inline type *func##_ ( type *s, int c, size_t i ) { return func ( s, c, i ) ; }
FUNC_STR_STR ( strstr, char )
FUNC_STR_STR ( wcsstr, wchar_t )
FUNC_STR_STR ( strpbrk, char )
FUNC_STR_STR ( wcspbrk, wchar_t )
FUNC_STR_INT ( strchr, char )
FUNC_STR_INT ( wcschr, wchar_t )
FUNC_STR_INT ( strrchr, char )
FUNC_STR_INT ( wcsrchr, wchar_t )
FUNC_STR_INT_SIZET ( memchr, void )
#undef FUNC_STR_STR
#undef FUNC_STR_INT
#undef FUNC_STR_INT_SIZET
#define strstr strstr_
#define wcsstr wcsstr_
#define strchr strchr_
#define wcschr wcschr_
#define strrchr strrchr_
#define wcsrchr wcsrchr_
#endif // defined DEBUG_CONST_STRING && defined __cplusplus && defined _INC_STRING
////////////////////////////////////////////
// STDARG.H //
////////////////////////////////////////////
#ifdef va_start
#ifndef va_copy
#define va_copy(dst,src) ((void)((dst)=(src)))
#endif
#endif // va_start
////////////////////////////////////////////
// STDLIB.H //
////////////////////////////////////////////
#ifdef EXIT_SUCCESS // stdlib.h
#ifndef __max
#define __max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef __min
#define __min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif
// execute.cpp
#define system ExecuteViaComspecA
#define wsystem ExecuteViaComspecW
#define _wsystem ExecuteViaComspecW
// environ.cpp
#define getenv GetEnvA
#define wgetenv GetEnvW
#define _wgetenv GetEnvW
#define putenv PutEnvA
#define _putenv PutEnvA
#define wputenv PutEnvW
#define _wputenv PutEnvW
#define setenv SetEnvA
#define _setenv SetEnvA
#define wsetenv SetEnvW
#define _wsetenv SetEnvW
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -