Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arc4 compilation debian #343

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions contrib/hbct/dattime3.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,18 @@ HB_FUNC( SETTIME )
st.wMilliseconds = ( WORD ) iTime[ 3 ] * 10;
fResult = SetLocalTime( &st );
#elif defined( HB_OS_LINUX ) && ! defined( HB_OS_ANDROID ) && ! defined( __WATCOMC__ )
/* stime() exists only in SVr4, SVID, X/OPEN and Linux */
HB_ULONG lNewTime;
time_t tm;

lNewTime = iTime[ 0 ] * 3600 + iTime[ 1 ] * 60 + iTime[ 2 ];
tm = time( NULL );
tm += lNewTime - ( tm % 86400 );
fResult = stime( &tm ) == 0;
struct timespec ts;
time_t now = time(NULL);
struct tm *tm_info = localtime(&now);

tm_info->tm_hour = iTime[ 0 ];
tm_info->tm_min = iTime[ 1 ];
tm_info->tm_sec = iTime[ 2 ];

ts.tv_sec = mktime(tm_info);
ts.tv_nsec = 0;

fResult = clock_settime(CLOCK_REALTIME, &ts) == 0;
#elif defined( HB_OS_DOS )
union REGS regs;
regs.h.ah = 45;
Expand Down Expand Up @@ -190,14 +194,13 @@ HB_FUNC( SETDATE )
st.wDayOfWeek = ( WORD ) hb_dateJulianDOW( lDate );
fResult = SetLocalTime( &st );
#elif defined( HB_OS_LINUX ) && ! defined( HB_OS_ANDROID ) && ! defined( __WATCOMC__ )
/* stime() exists only in SVr4, SVID, X/OPEN and Linux */
long lNewDate;
time_t tm;

lNewDate = lDate - hb_dateEncode( 1970, 1, 1 );
tm = time( NULL );
tm = lNewDate * 86400 + ( tm % 86400 );
fResult = stime( &tm ) == 0;
struct timespec ts;
struct tm tm_info = { .tm_year = iYear - 1900, .tm_mon = iMonth - 1, .tm_mday = iDay };

ts.tv_sec = mktime(&tm_info);
ts.tv_nsec = 0;

fResult = clock_settime(CLOCK_REALTIME, &ts) == 0;
#elif defined( HB_OS_DOS )
union REGS regs;
regs.h.ah = 43;
Expand Down
63 changes: 32 additions & 31 deletions contrib/hbfbird/firebird.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,41 +149,42 @@ HB_FUNC( FBCREATEDB )
hb_retnl( 0 );
}

HB_FUNC( FBCONNECT )
HB_FUNC(FBCONNECT)
{
ISC_STATUS_ARRAY status;
isc_db_handle db = ( isc_db_handle ) 0;
const char * db_connect = hb_parcx( 1 );
const char * user = hb_parcx( 2 );
const char * passwd = hb_parcx( 3 );
char dpb[ 128 ];
short i = 0;
int len;

/* FIXME: Possible buffer overflow. Use hb_snprintf(). */
dpb[ i++ ] = isc_dpb_version1;
dpb[ i++ ] = isc_dpb_user_name;
len = ( int ) strlen( user );
if( len > ( int ) ( sizeof( dpb ) - i - 4 ) )
len = ( int ) ( sizeof( dpb ) - i - 4 );
dpb[ i++ ] = ( char ) len;
hb_strncpy( &( dpb[ i ] ), user, len );
i += ( short ) len;
dpb[ i++ ] = isc_dpb_password;
len = ( int ) strlen( passwd );
if( len > ( int ) ( sizeof( dpb ) - i - 2 ) )
len = ( int ) ( sizeof( dpb ) - i - 2 );
dpb[ i++ ] = ( char ) len;
hb_strncpy( &( dpb[ i ] ), passwd, len );
i += ( short ) len;

if( isc_attach_database( status, 0, db_connect, &db, i, dpb ) )
hb_retnl( isc_sqlcode( status ) );
else
hb_FB_db_handle_ret( db );
ISC_STATUS_ARRAY status;
isc_db_handle db = (isc_db_handle)0;
const char *db_connect = hb_parcx(1);
const char *user = hb_parcx(2);
const char *passwd = hb_parcx(3);
char dpb[128];
short i = 0;
int len;

i += hb_snprintf(dpb + i, sizeof(dpb) - i, "%c", isc_dpb_version1);
i += hb_snprintf(dpb + i, sizeof(dpb) - i, "%c", isc_dpb_user_name);
len = (int)strlen(user);
if (len > (int)(sizeof(dpb) - i - 4))
len = (int)(sizeof(dpb) - i - 4);
i += hb_snprintf(dpb + i, sizeof(dpb) - i, "%c", (char)len);
hb_strncpy(&(dpb[i]), user, len);
i += (short)len;
i += hb_snprintf(dpb + i, sizeof(dpb) - i, "%c", isc_dpb_password);
len = (int)strlen(passwd);
if (len > (int)(sizeof(dpb) - i - 2))
len = (int)(sizeof(dpb) - i - 2);
i += hb_snprintf(dpb + i, sizeof(dpb) - i, "%c", (char)len);
hb_strncpy(&(dpb[i]), passwd, len);
i += (short)len;

if (isc_attach_database(status, 0, db_connect, &db, i, dpb))
hb_retnl(isc_sqlcode(status));
else
hb_FB_db_handle_ret(db);
}




HB_FUNC( FBCLOSE )
{
isc_db_handle db = hb_FB_db_handle_par( 1 );
Expand Down
17 changes: 9 additions & 8 deletions contrib/hbnf/setdate.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Rewritten in 2012 by Viktor Szakats and kept in the
/*
* Rewritten in 2012 by Viktor Szakats and kept in the
public domain.
This is an original work by Glenn Scott and is placed in the public domain.

Expand Down Expand Up @@ -57,14 +58,14 @@ HB_FUNC( FT_SETDATE )
}
#elif defined( HB_OS_LINUX ) && ! defined( HB_OS_ANDROID ) && ! defined( __WATCOMC__ )
{
/* stime() exists only in SVr4, SVID, X/OPEN and Linux */
long lNewDate;
time_t tm;
/* clock_settime() per a sistemes Linux moderns */
struct timespec ts;
struct tm tm_info = { .tm_year = iYear - 1900, .tm_mon = iMonth - 1, .tm_mday = iDay };

lNewDate = lDate - hb_dateEncode( 1970, 1, 1 );
tm = time( NULL );
tm = lNewDate * 86400 + ( tm % 86400 );
fResult = stime( &tm ) == 0;
ts.tv_sec = mktime(&tm_info);
ts.tv_nsec = 0;

fResult = clock_settime(CLOCK_REALTIME, &ts) == 0;
}
#elif defined( HB_OS_DOS )
{
Expand Down
22 changes: 14 additions & 8 deletions contrib/hbnf/settime.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Rewritten in 2012 by Viktor Szakats and kept in the
/*
* Rewritten in 2012 by Viktor Szakats and kept in the
public domain.
This is an original work by Glenn Scott and is placed in the public domain.

Expand Down Expand Up @@ -67,14 +68,19 @@ HB_FUNC( FT_SETTIME )
}
#elif defined( HB_OS_LINUX ) && ! defined( HB_OS_ANDROID ) && ! defined( __WATCOMC__ )
{
/* stime() exists only in SVr4, SVID, X/OPEN and Linux */
HB_ULONG lNewTime;
time_t tm;
/* clock_settime() per a sistemes Linux moderns */
struct timespec ts;
time_t now = time(NULL);
struct tm *tm_info = localtime(&now);

lNewTime = iHour * 3600 + iMinute * 60 + iSeconds;
tm = time( NULL );
tm += lNewTime - ( tm % 86400 );
fResult = stime( &tm ) == 0;
tm_info->tm_hour = iHour;
tm_info->tm_min = iMinute;
tm_info->tm_sec = iSeconds;

ts.tv_sec = mktime(tm_info);
ts.tv_nsec = 0;

fResult = clock_settime(CLOCK_REALTIME, &ts) == 0;
}
#elif defined( HB_OS_DOS )
{
Expand Down
8 changes: 5 additions & 3 deletions contrib/hbtest/core.prg
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ PROCEDURE hbtest_Call( cBlock, bBlock, xResultExpected )
cBlock := "[Preprocessor error]"
lPPError := .T.
ENDIF

cLangOld := hb_langSelect( "en" ) /* to always have RTEs in one language */


cLangOld := __hb_langSelect( "en" ) /* to always have RTEs in one language */


IF ! s_lBanner
s_lBanner := .T.
Expand All @@ -153,7 +155,7 @@ PROCEDURE hbtest_Call( cBlock, bBlock, xResultExpected )
lRTE := .T.
END SEQUENCE

hb_langSelect( cLangOld )
__hb_langSelect( cLangOld )

IF lRTE
lFailed := ! XToStr( xResult ) == XToStr( xResultExpected )
Expand Down
Loading