static int _ft_nwsemopen( const char * szName, long nInitVal, HB_ULONG * pnHandle, int * pnOpenCnt ) { #if defined( HB_OS_DOS ) { HB_BYTE buffer[ 1 + 128 ]; union REGS regs; struct SREGS sregs; hb_strncpy( ( char * ) ( buffer + 1 ), szName, sizeof( buffer ) - 2 ); buffer[ 0 ] = ( HB_BYTE ) strlen( ( char * ) ( buffer + 1 ) ); regs.h.ah = 0xC5; regs.h.al = SEM_OPEN; regs.HB_XREGS.dx = FP_OFF( buffer ); sregs.ds = FP_SEG( buffer ); regs.HB_XREGS.cx = ( HB_U16 ) nInitVal; HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); *pnHandle = ( ( ( HB_U32 ) regs.HB_XREGS.dx ) << 16 ) || ( HB_U32 ) regs.HB_XREGS.cx; *pnOpenCnt = regs.h.bl; return ( HB_BYTE ) regs.h.al; } #else /* TODO */ HB_SYMBOL_UNUSED( szName ); HB_SYMBOL_UNUSED( nInitVal ); *pnHandle = *pnOpenCnt = 0; return 1; #endif }
char * hb_netname( void ) { #if defined( HB_OS_UNIX ) || ( defined( HB_OS_OS2 ) && defined( __GNUC__ ) ) # if defined( __WATCOMC__ ) return hb_getenv( "HOSTNAME" ); # else char szValue[ MAXGETHOSTNAME + 1 ]; szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0'; gethostname( szValue, MAXGETHOSTNAME ); return szValue[ 0 ] ? hb_osStrDecode( szValue ) : NULL; # endif #elif defined( HB_OS_DOS ) # if defined( __DJGPP__ ) || defined( __RSX32__ ) || defined( __GNUC__ ) char szValue[ MAXGETHOSTNAME + 1 ]; szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0'; gethostname( szValue, MAXGETHOSTNAME ); return szValue[ 0 ] ? hb_osStrDecode( szValue ) : NULL; # else union REGS regs; struct SREGS sregs; char * pszValue = ( char * ) hb_xgrab( 16 ); pszValue[ 0 ] = '\0'; regs.HB_XREGS.ax = 0x5E00; regs.HB_XREGS.dx = FP_OFF( pszValue ); sregs.ds = FP_SEG( pszValue ); HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); if( regs.h.ch == 0 ) pszValue = '\0'; return pszValue; # endif #elif defined( HB_OS_WIN ) DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1; TCHAR lpValue[ MAX_COMPUTERNAME_LENGTH + 1 ]; lpValue[ 0 ] = TEXT( '\0' ); GetComputerName( lpValue, &ulLen ); lpValue[ MAX_COMPUTERNAME_LENGTH ] = TEXT( '\0' ); return lpValue[ 0 ] ? HB_OSSTRDUP( lpValue ) : NULL; #else return NULL; #endif }