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 <nType> parameter in NETNAME() like in xHarbour
      when nType == 1 NETNAME() returns user name instead of host name.
This commit is contained in:
Przemyslaw Czerpak
2007-04-02 17:02:26 +00:00
parent 25a8855970
commit f1ba956db0
3 changed files with 45 additions and 9 deletions

View File

@@ -8,6 +8,13 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
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 <nType> 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

View File

@@ -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 )
{

View File

@@ -88,6 +88,10 @@
#elif defined(HB_OS_UNIX)
#if !defined(__WATCOMC__)
#include <pwd.h>
#include <sys/types.h>
#endif
#include <unistd.h>
#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 );
}