diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 82048a8336..1b1f3b9803 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-04-02 19:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/hbregex.c + + added HB_REGEXHAS() and HB_REGEXLIKE() + * harbour/source/rtl/net.c + * added support for parameter in NETNAME() like in xHarbour + when nType == 1 NETNAME() returns user name instead of host name. + 2007-04-02 16:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/htmllib/counter.prg * harbour/contrib/htmllib/htmbrows.prg diff --git a/harbour/source/rtl/hbregex.c b/harbour/source/rtl/hbregex.c index 4b54df078a..a495a3b9f1 100644 --- a/harbour/source/rtl/hbregex.c +++ b/harbour/source/rtl/hbregex.c @@ -323,7 +323,7 @@ static BOOL hb_regex( int iRequest ) ( ULONG ) aMatches[0].rm_eo == ulLen; break; - case 2: /* MATCH */ + case 2: /* MATCH ( HAS ) */ fResult = TRUE; break; @@ -525,6 +525,16 @@ HB_FUNC( HB_REGEXMATCH ) hb_retl( hb_regex( hb_parl( 3 ) ? 1 /* LIKE */ : 2 /* HAS */ ) ); } +HB_FUNC( HB_REGEXLIKE ) +{ + hb_retl( hb_regex( 1 ) ); +} + +HB_FUNC( HB_REGEXHAS ) +{ + hb_retl( hb_regex( 2 ) ); +} + /* Splits the string in an array of matched expressions */ HB_FUNC( HB_REGEXSPLIT ) { diff --git a/harbour/source/rtl/net.c b/harbour/source/rtl/net.c index 9bc09bafc2..e007e83260 100644 --- a/harbour/source/rtl/net.c +++ b/harbour/source/rtl/net.c @@ -88,6 +88,10 @@ #elif defined(HB_OS_UNIX) + #if !defined(__WATCOMC__) + #include + #include + #endif #include #define MAXGETHOSTNAME 256 /* should be enough for a host name */ @@ -100,19 +104,31 @@ HB_FUNC( NETNAME ) { + BOOL fGetUser = hb_parni( 1 ) == 1; + #if defined(HB_OS_UNIX) || ( defined(HB_OS_OS2) && defined(__GNUC__) ) { #if defined(__WATCOMC__) - char * pszValue = hb_getenv( "HOSTNAME" ); + char * pszValue = hb_getenv( fGetUser ? "USER" : "HOSTNAME" ); hb_retc_buffer( pszValue ); #else - char szValue[ MAXGETHOSTNAME + 1 ]; - szValue[ 0 ] = '\0'; - - gethostname( szValue, MAXGETHOSTNAME ); - - hb_retc( szValue ); + if( fGetUser ) + { + struct passwd * pwd; + pwd = getpwuid( getuid() ); + if( pwd ) + hb_retc( pwd->pw_name ); + else + hb_retc_buffer( hb_getenv( "USER" ) ); + } + else + { + char szValue[ MAXGETHOSTNAME + 1 ]; + szValue[ 0 ] = '\0'; + gethostname( szValue, MAXGETHOSTNAME ); + hb_retc( szValue ); + } #endif } @@ -155,7 +171,10 @@ HB_FUNC( NETNAME ) char szValue[ MAX_COMPUTERNAME_LENGTH + 1 ]; szValue[ 0 ] = '\0'; - GetComputerName( szValue, &ulLen ); + if( fGetUser ) + GetUserName( pszValue, &ulLen ); + else + GetComputerName( szValue, &ulLen ); hb_retc( szValue ); }