_WCRTLINK char *getenv( const char *name ) { char **envp; char *p; /*** Find the environment string ***/ __ptr_check( name, 0 ); envp = _RWD_environ; if( (envp != NULL) && (name != NULL) ) { for( ; p = *envp; ++envp ) { const char *s = name; while( *p != '\0' ) { /* simple check is sufficient for p, not s */ if ( _mbterm( s ) ) { if( *p == '=' ) return( p + 1 ); break; } if ( _mbctoupper( _mbsnextc( p ) ) != _mbctoupper( _mbsnextc( s ) ) ) break; p = _mbsinc( p ); /* skip over character */ s = _mbsinc( s ); /* skip over character */ } } } return( NULL ); /* not found */ }
/* * @implemented */ int _mbsicmp(const unsigned char *str1, const unsigned char *str2) { unsigned char *s1 = (unsigned char *)str1; unsigned char *s2 = (unsigned char *)str2; unsigned short *short_s1, *short_s2; int l1, l2; do { if (*s1 == 0) break; l1 = _ismbblead(*s1); l2 = _ismbblead(*s2); if ( !l1 && !l2 ) { if (toupper(*s1) != toupper(*s2)) return toupper(*s1) - toupper(*s2); else { s1 += 1; s2 += 1; } } else if ( l1 && l2 ){ short_s1 = (unsigned short *)s1; short_s2 = (unsigned short *)s2; if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 )) return _mbctoupper(*short_s1) - _mbctoupper(*short_s2); else { s1 += 2; s2 += 2; } } else return *s1 - *s2; } while (*s1 != 0); return 0; while (toupper(*s1) == toupper(*s2)) { if (*s1 == 0) return 0; s1++; s2++; } return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2)); }
/* * @implemented */ int _mbsicoll(const unsigned char *str1, const unsigned char *str2) { unsigned char *s1 = (unsigned char *)str1; unsigned char *s2 = (unsigned char *)str2; unsigned short *short_s1, *short_s2; int l1, l2; while ( *s1 != 0 ) { if (*s1 == 0) break; l1 = _ismbblead(*s1); l2 = _ismbblead(*s2); if ( !l1 && !l2 ) { if (toupper(*s1) != toupper(*s2)) return colldif(*s1, *s2); else { s1 += 1; s2 += 1; } } else if ( l1 && l2 ){ short_s1 = (unsigned short *)s1; short_s2 = (unsigned short *)s2; if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 )) return colldif(*short_s1, *short_s2); else { s1 += 2; s2 += 2; } } else return colldif(*s1, *s2); } ; return 0; }
void main() { int i; unsigned int c; _setmbcp( 932 ); for( i = 0; i < SIZE; i++ ) { c = _mbctoupper( chars[ i ] ); if( c > 0xff ) printf( "%c%c", c>>8, c ); else printf( "%c", c ); }
_WCRTLINK unsigned char _FFAR *_NEARFAR(_mbsupr,_fmbsupr)( unsigned char _FFAR *string ) { #if defined(__NT__) && !defined(__FARFUNC__) CharUpper( (char _FFAR *)string ); // call the Win32 API #else unsigned int ch; unsigned char _FFAR *p; unsigned char mbc[MB_LEN_MAX+1]; p = string; while( !_NEARFAR(_mbterm,_fmbterm)( p ) ) { ch = _mbctoupper( _NEARFAR(_mbsnextc,_fmbsnextc)( p ) ); _NEARFAR(_mbvtop,_fmbvtop)( ch, mbc ); mbc[_NEARFAR(_mbclen,_fmbclen)( mbc )] = '\0'; _NEARFAR(_mbccpy,_fmbccpy)( p, mbc ); p = _NEARFAR(_mbsinc,_fmbsinc)( p ); } #endif return( string ); }