diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 51ac31efc7..07d6b4313b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,20 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-14 11:30 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtcrs/gtcrs.c + * harbour/source/rtl/gtcrs/gtcrs.h + * harbour/source/rtl/gtcrs/Makefile + * updated to compile with DJGPP and PDCURSES + + * harbour/source/rtl/gttrm/Makefile + * harbour/source/rtl/gttrm/gttrm.c + * updated to compile with DJGPP - warning it needs remote terminal or + at least ANSI driver for local execution + + * harbour/source/rtl/gtchrmap.c + * enabed for DOS builds + 2009-07-14 11:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/pp/Makefile ! Ugly hack added to make dos/watcom creation under NT hosts. diff --git a/harbour/source/rtl/gtchrmap.c b/harbour/source/rtl/gtchrmap.c index 769a18c48c..f7b457d1a4 100644 --- a/harbour/source/rtl/gtchrmap.c +++ b/harbour/source/rtl/gtchrmap.c @@ -57,7 +57,7 @@ #include "hbgtcore.h" #include "hbapifs.h" -#ifdef HB_OS_UNIX +#if defined( HB_OS_UNIX ) || defined( HB_OS_DOS ) #define MAX_CHAR_VAL 0xff #define HB_CHRMAP(a,c) ( ( (a) << 16 ) | (c) ) @@ -474,4 +474,4 @@ int main(int argc, char **argv) } */ -#endif /* HB_OS_UNIX */ +#endif /* HB_OS_UNIX || HB_OS_DOS */ diff --git a/harbour/source/rtl/gtcrs/Makefile b/harbour/source/rtl/gtcrs/Makefile index 2d749eeae6..caa44654cb 100644 --- a/harbour/source/rtl/gtcrs/Makefile +++ b/harbour/source/rtl/gtcrs/Makefile @@ -24,8 +24,16 @@ HB_INC_CURSES = endif HB_INC_CURSES_OK += $(foreach d, $(HB_INC_CURSES), $(if $(wildcard $(d)/curses.h),$(d),)) +HB_INC_CURSES_OK:=$(strip $(HB_INC_CURSES_OK)) -ifneq ($(strip $(HB_INC_CURSES_OK)),) +ifeq ($(HB_INC_CURSES_OK),) +ifeq ($(HB_ARCHITECTURE),dos) +HB_INC_CURSES_OK += $(foreach d, $(subst ;, ,$(PATH)), $(if $(wildcard $(d)/../include/curses.h),$(d)/../include,)) +HB_INC_CURSES_OK:=$(strip $(HB_INC_CURSES_OK)) +endif +endif + +ifneq ($(HB_INC_CURSES_OK),) HB_INC_GPM_OK = ifneq ($(HB_GPM_MOUSE),no) diff --git a/harbour/source/rtl/gtcrs/gtcrs.c b/harbour/source/rtl/gtcrs/gtcrs.c index 3ed7820d58..1dd650e166 100644 --- a/harbour/source/rtl/gtcrs/gtcrs.c +++ b/harbour/source/rtl/gtcrs/gtcrs.c @@ -169,7 +169,7 @@ static int s_iActive_ioBase = -1; static void set_tmevt(unsigned char *cMBuf, mouseEvent *); static int getMouseKey(mouseEvent *); static void destroy_ioBase(InOutBase *ioBase); -static void sig_handler(int signo); +static void set_sig_handler( int iSig ); static void curs_wrkaround( void ); @@ -376,24 +376,11 @@ static int getClipKey( int nKey ) return nRet; } -static void set_sig_handler( int iSig ) -{ - /* SA_NOCLDSTOP in #if is a hack to detect POSIX compatible environment */ -#if defined( SA_NOCLDSTOP ) - struct sigaction act; - - sigaction( iSig, 0, &act ); - act.sa_handler = sig_handler; - act.sa_flags = SA_RESTART | ( iSig == SIGCHLD ? SA_NOCLDSTOP : 0 ); - sigaction( iSig, &act, 0 ); -#endif -} - +#if defined( SA_NOCLDSTOP ) && defined( SA_RESTART ) && defined( SIGCHLD ) #if 1 static void sig_handler( int signo ) { - int e = errno, stat; - pid_t pid; + int e = errno; if ( signo < MAX_SIGNO ) { @@ -404,8 +391,12 @@ static void sig_handler( int signo ) switch ( signo ) { case SIGCHLD: + { + int stat; + pid_t pid; while ( ( pid = waitpid( -1, &stat, WNOHANG ) ) > 0 ) ; break; + } case SIGWINCH: s_WinSizeChangeFlag = TRUE; break; @@ -447,16 +438,19 @@ static void set_signals( void ) #else static void sig_handler( int signo ) { - int e = errno, stat; + int e = errno; char *pszSig; - pid_t pid; switch ( signo ) { case SIGCHLD: + { + int stat; + pid_t pid; pszSig = "SIGCHLD"; while ( ( pid = waitpid( -1, &stat, WNOHANG ) ) > 0 ) ; break; + } case SIGWINCH: pszSig = "SIGWINCH"; break; @@ -505,6 +499,27 @@ static void set_signals( void ) } } #endif +#else +static void set_signals( void ) +{ +} +#endif + +static void set_sig_handler( int iSig ) +{ + /* SA_NOCLDSTOP in #if is a hack to detect POSIX compatible environment */ +#if defined( SA_NOCLDSTOP ) && defined( SA_RESTART ) && defined( SIGCHLD ) + struct sigaction act; + + sigaction( iSig, 0, &act ); + act.sa_handler = sig_handler; + act.sa_flags = SA_RESTART | ( iSig == SIGCHLD ? SA_NOCLDSTOP : 0 ); + sigaction( iSig, &act, 0 ); +#else + HB_SYMBOL_UNUSED( iSig ); +#endif +} + static int add_efds( InOutBase * ioBase, int fd, int mode, int ( *eventFunc ) ( int, int, void * ), void *data ) diff --git a/harbour/source/rtl/gtcrs/gtcrs.h b/harbour/source/rtl/gtcrs/gtcrs.h index f9d097ff22..7ad0eb86f8 100644 --- a/harbour/source/rtl/gtcrs/gtcrs.h +++ b/harbour/source/rtl/gtcrs/gtcrs.h @@ -75,7 +75,7 @@ # define _XOPEN_SOURCE_EXTENDED # endif # include -# if defined( HB_OS_SUNOS ) +# if defined( HB_OS_SUNOS ) || defined( __PDCURSES__ ) # include # endif #endif diff --git a/harbour/source/rtl/gttrm/Makefile b/harbour/source/rtl/gttrm/Makefile index e29ff03048..2cd08d905f 100644 --- a/harbour/source/rtl/gttrm/Makefile +++ b/harbour/source/rtl/gttrm/Makefile @@ -25,6 +25,9 @@ endif ifeq ($(HB_COMPILER),cygwin) HB_WITH_GTTRM=yes endif +ifeq ($(HB_COMPILER),djgpp) +HB_WITH_GTTRM=yes +endif ifeq ($(HB_WITH_GTTRM),yes) diff --git a/harbour/source/rtl/gttrm/gttrm.c b/harbour/source/rtl/gttrm/gttrm.c index 430cc2f5ec..d3d7bfd06e 100644 --- a/harbour/source/rtl/gttrm/gttrm.c +++ b/harbour/source/rtl/gttrm/gttrm.c @@ -79,7 +79,7 @@ #include #include -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) # include # include # include @@ -151,7 +151,7 @@ static HB_GT_FUNCS SuperTable; #define MOUSE_GPM 1 #define MOUSE_XTERM 2 -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) #define TIMEVAL_GET(tv) gettimeofday(&(tv), NULL) #define TIMEVAL_LESS(tv1, tv2) (((tv1).tv_sec == (tv2).tv_sec ) ? \ @@ -264,7 +264,7 @@ typedef struct { int mbup_row, mbup_col; int mbdn_row, mbdn_col; /* to analize DBLCLK on xterm */ -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) struct timeval BL_time; struct timeval BR_time; struct timeval BM_time; @@ -342,7 +342,7 @@ typedef struct _HB_GTTRM int terminal_type; int terminal_ext; -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) struct termios saved_TIO, curr_TIO; BOOL fRestTTY; #endif @@ -391,7 +391,7 @@ typedef struct _HB_GTTRM } HB_TERM_STATE, HB_GTTRM, * PHB_GTTRM; /* static variables use by signal handler */ -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) static volatile BOOL s_WinSizeChangeFlag = FALSE; static volatile BOOL s_fRestTTY = FALSE; #endif @@ -661,7 +661,7 @@ static int hb_gt_trm_getSize( PHB_GTTRM pTerm, int * piRows, int * piCols ) { *piRows = *piCols = 0; -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( pTerm->fOutTTY ) { struct winsize win; @@ -778,7 +778,7 @@ static int add_efds( PHB_GTTRM pTerm, int fd, int mode, if( eventFunc == NULL && mode != O_RDONLY ) return -1; -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) { int fl; if( ( fl = fcntl( fd, F_GETFL, 0 ) ) == -1 ) @@ -955,7 +955,7 @@ static void chk_mevtdblck( PHB_GTTRM pTerm ) if( newbuttons != 0 ) { -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) struct timeval tv; #else double tv; @@ -1227,7 +1227,7 @@ static int get_inch( PHB_GTTRM pTerm, int milisec ) { unsigned char buf[STDIN_BUFLEN]; -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) n = read( pTerm->event_fds[i]->fd, buf, STDIN_BUFLEN - pTerm->stdin_inbuf ); #else @@ -1331,7 +1331,7 @@ static int wait_key( PHB_GTTRM pTerm, int milisec ) int nKey, esc, n, i, ch, counter; keyTab *ptr; -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( s_WinSizeChangeFlag ) { s_WinSizeChangeFlag = FALSE; @@ -1602,7 +1602,7 @@ static BOOL hb_gt_trm_XtermSetMode( PHB_GTTRM pTerm, int * piRows, int * piCols hb_gt_trm_termOut( pTerm, escseq, strlen( escseq ) ); hb_gt_trm_termFlush( pTerm ); -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) /* dirty hack - wait for SIGWINCH */ if( *piRows != iHeight || *piCols != iWidth ) sleep( 3 ); @@ -1820,7 +1820,7 @@ static BOOL hb_gt_trm_AnsiGetCursorPos( PHB_GTTRM pTerm, int * iRow, int * iCol, break; else { -#ifdef HB_OS_UNIX_COMPATIBLE +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) struct timeval tv; fd_set rdfds; int iMilliSec; @@ -3026,7 +3026,7 @@ static void hb_gt_trm_Exit( PHB_GT pGT ) if( pTerm ) { -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( pTerm->fRestTTY ) tcsetattr( pTerm->hFilenoStdin, TCSANOW, &pTerm->saved_TIO ); #endif @@ -3192,7 +3192,7 @@ static BOOL hb_gt_trm_Suspend( PHB_GT pGT ) HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_Suspend(%p)", pGT ) ); pTerm = HB_GTTRM_GET( pGT ); -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( pTerm->fRestTTY ) tcsetattr( pTerm->hFilenoStdin, TCSANOW, &pTerm->saved_TIO ); #endif @@ -3209,7 +3209,7 @@ static BOOL hb_gt_trm_Resume( PHB_GT pGT ) HB_TRACE( HB_TR_DEBUG, ( "hb_gt_trm_Resume(%p)", pGT ) ); pTerm = HB_GTTRM_GET( pGT ); -#if defined( HB_OS_UNIX_COMPATIBLE ) +#if defined( HB_OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ ) if( pTerm->fRestTTY ) tcsetattr( pTerm->hFilenoStdin, TCSANOW, &pTerm->curr_TIO ); #endif