diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 484e35cd8a..4bab17913d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +19990727-02:22 EDT Paul Tucker + * include/gtapi.h + + added definition of gtSetAttribute + * source/rtl/dates.c + * hb__seconds - fixed MSC support for correct hundreths. + * source/rtl/dir.c + * Directory() now works under msc. Other platform users should + review the code and add defined()'s or code as needed. + * source/rtl/gt/gtwin.c + + gtSetAttribute() + * source/rtl/gt/gtdos.c source/rtl/gt/gtos2.c + + Empty gtSetAttribute() + * source/rtl/console.c + + empty SAVESCREEN,RESTSCREEN + + SHADOW() and DBGSHADOW() now implimented + 19990727-07:50 CET Felipe Coury * tests/working/hscript/dir.hs; tests/working/hscript/hello.hs; tests/working/hscript/hscript.prg; tests/working/hscript/multiply.hs; diff --git a/harbour/include/gtapi.h b/harbour/include/gtapi.h index 6d1036a4e5..dc34477a78 100644 --- a/harbour/include/gtapi.h +++ b/harbour/include/gtapi.h @@ -119,5 +119,6 @@ int gtGetCursorStyle(void); void gtPuts(char x, char y, char attr, char *str, int len); void gtGetText(char x1, char y1, char x2, char y2, char *dest); void gtPutText(char x1, char y1, char x2, char y2, char *srce); +void gtSetAttribute( char x1, char y1, char x2, char y2, char attribute ); #endif /* HB_GTAPI_H_ */ diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 3a0b83c826..8aac09f95b 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -73,7 +73,9 @@ #endif HARBOUR HB___ACCEPT(void); +HARBOUR HB___EJECT( void ); HARBOUR HB_COL( void ); +HARBOUR HB_DBGSHADOW( void ); HARBOUR HB_DEVOUT( void ); HARBOUR HB_DEVOUTPICT( void ); HARBOUR HB_DEVPOS( void ); @@ -82,7 +84,6 @@ HARBOUR HB_DISPBOX( void ); HARBOUR HB_DISPCOUNT( void ); HARBOUR HB_DISPEND( void ); HARBOUR HB_DISPOUT( void ); -HARBOUR HB___EJECT( void ); HARBOUR HB_ISCOLOR( void ); HARBOUR HB_MAXCOL( void ); HARBOUR HB_MAXROW( void ); @@ -95,12 +96,14 @@ HARBOUR HB_ROW( void ); HARBOUR HB_SCROLL( void ); HARBOUR HB_SETPOS( void ); HARBOUR HB_SETPRC( void ); +HARBOUR HB_SHADOW( void ); HARBOUR HB_QOUT( void ); HARBOUR HB_QQOUT( void ); HB_INIT_SYMBOLS_BEGIN( Console__InitSymbols ) { "__ACCEPT" , FS_PUBLIC, HB___ACCEPT , 0 }, { "__EJECT" , FS_PUBLIC, HB___EJECT , 0 }, +{ "DBGSHADOW" , FS_PUBLIC, HB_DBGSHADOW , 0 }, { "DEVOUT" , FS_PUBLIC, HB_DEVOUT , 0 }, { "DEVOUTPICT", FS_PUBLIC, HB_DEVOUTPICT, 0 }, { "DISPBEGIN" , FS_PUBLIC, HB_DISPBEGIN , 0 }, @@ -117,6 +120,7 @@ HB_INIT_SYMBOLS_BEGIN( Console__InitSymbols ) { "SCROLL" , FS_PUBLIC, HB_SCROLL , 0 }, { "SETPOS" , FS_PUBLIC, HB_SETPOS , 0 }, { "SETPRC" , FS_PUBLIC, HB_SETPRC , 0 }, +{ "SHADOW" , FS_PUBLIC, HB_SHADOW , 0 }, { "QOUT" , FS_PUBLIC, HB_QOUT , 0 }, { "QQOUT" , FS_PUBLIC, HB_QQOUT , 0 } HB_INIT_SYMBOLS_END( Console__InitSymbols ); @@ -969,3 +973,24 @@ HARBOUR HB_NOSNOW (void) } #endif } + +HARBOUR HB_SHADOW (void) +{ +#ifdef HARBOUR_USE_GTAPI + if( hb_pcount() == 5 ) + gtSetAttribute(hb_parni(1)+1,hb_parni(2)+1,hb_parni(3)+1,hb_parni(4)+1,hb_parni(5)); +#endif +} + +HARBOUR HB_DBGSHADOW (void) +{ + HB_SHADOW(); +} + +HARBOUR HB_SAVESCREEN (void) +{ +} + +HARBOUR HB_RESTSCREEN (void) +{ +} diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index a55f4810d0..4ca7577841 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -46,7 +46,9 @@ #if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) #include #endif - +#if defined( _MSC_VER ) + #include +#endif #ifndef HARBOUR_STRICT_CLIPPER_COMPATIBILITY #define HB_OPTIMIZE_DTOS #endif @@ -82,11 +84,21 @@ HB_INIT_SYMBOLS_END( Dates__InitSymbols ); double hb__seconds( void ) { -#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) || defined(_MSC_VER) +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) // || defined(_MSC_VER) struct time t; gettime( &t ); - return( ( ( t.ti_hour * 3600 ) + ( t.ti_min * 60 ) + t.ti_sec ) + t.ti_hund / 100.0 ); -#else + return( ( ( t.ti_hour * 3600 ) + ( t.ti_min * 60 ) + t.ti_sec ) + (double)t.ti_hund /100 ); +#elif defined(_MSC_VER) + struct _timeb tb; + struct tm *oTime; + + _ftime( &tb ); + oTime = localtime(&tb.time); + return( ( oTime->tm_hour * 3600 ) + + ( oTime->tm_min * 60 ) + + oTime->tm_sec + + ( (double) tb.millitm /1000 ) ); +#else time_t t; struct tm *oTime; time(&t); diff --git a/harbour/source/rtl/dir.c b/harbour/source/rtl/dir.c index 6dab1e83e9..10c69dede8 100644 --- a/harbour/source/rtl/dir.c +++ b/harbour/source/rtl/dir.c @@ -2,6 +2,18 @@ * $Id$ */ +/* + * DIR.C: Returns a Harbour array of specified directory contents filtered + * by the optional file and attribute mask. + * + * Latest mods: + * 1.21 19990722 ptucker Implimented directory for MSVC + * Includes new attributes + * 1.20 19990722 ptucker Corrected hang when attribute types have + * been requested. + * + */ + #include #include #include @@ -30,7 +42,7 @@ #endif -#if defined(__WATCOMC__) +#if defined(__WATCOMC__) || defined( _MSC_VER ) #include #include #include @@ -83,6 +95,16 @@ #define FA_LABEL 8 #define FA_DIREC 16 #define FA_ARCH 32 +/* this may not work, but lets find out (only implimented for msvc) */ + #define FA_ENCRYPTED 64 + #define FA_NORMAL 128 + #define FA_TEMPORARY 256 + #define FA_SPARSE 512 + #define FA_REPARSE 1024 + #define FA_COMPRESSED 2048 + #define FA_OFFLINE 4096 + #define FA_NOTINDEXED 8192 + #define FA_VOLCOMP 32764 #endif HARBOUR HB_DIRECTORY(void); @@ -100,19 +122,27 @@ static BOOL hb_strMatchDOS (char *pszString, char *pszMask); HARBOUR HB_DIRECTORY( void ) { #if defined(HAVE_POSIX_IO) + extern STACK stack; + PHB_ITEM arg1_it = hb_param(1,IT_STRING); PHB_ITEM arg2_it = hb_param(2,IT_STRING); - extern STACK stack; - struct stat statbuf; - struct dirent *entry; struct tm *ft; +#if defined(_MSC_VER ) + struct _finddata_t entry; + long hFile; +#else + struct dirent *entry; + DIR * dir; +#endif + char fullfile[_POSIX_PATH_MAX+1]; + char filename[_POSIX_PATH_MAX+1]; char pattern[_POSIX_PATH_MAX+1]; char dirname[_POSIX_PATH_MAX+1]; - char filename[_POSIX_PATH_MAX+1]; + char string[_POSIX_PATH_MAX+1]; char pfname[_POSIX_PATH_MAX+1]; char pfext[_POSIX_PATH_MAX+1]; char fname[_POSIX_PATH_MAX+1]; @@ -120,13 +150,10 @@ HARBOUR HB_DIRECTORY( void ) char filesize[10]; char ddate[9]; char ttime[9]; - int attrib; char aatrib[8]; - char string[_POSIX_PATH_MAX+1]; - char * pos; - long fsize; - DIR * dir; + int attrib; time_t ftime; + char * pos; PHB_ITEM pdir; PHB_ITEM psubarray; @@ -139,7 +166,6 @@ HARBOUR HB_DIRECTORY( void ) dirname[0] = '\0'; pattern[0] = '\0'; - if( arg1_it ) { strcpy(string, hb_parc(1)); @@ -181,8 +207,12 @@ HARBOUR HB_DIRECTORY( void ) pfext[0] = '\0'; } } + +/* redundant if (strlen(pfext) < 1) pfext[0] = '\0'; +*/ + if (strlen(pfname) < 1) strcpy(pfname,"*"); @@ -195,9 +225,23 @@ HARBOUR HB_DIRECTORY( void ) tzset(); pdir = hb_itemArrayNew(0); + +#if defined(_MSC_VER) + + strcpy(string,dirname); + strcat(string,pattern); + if( (hFile = _findfirst( string, &entry )) != -1L ) + { + + do + { + strcpy(string,entry.name); + +#else dir = opendir( dirname ); if (NULL == dir) { + /* TODO: proper error handling */ printf("\n invalid dirname %s ",dirname); while(0==getchar()); } @@ -205,8 +249,9 @@ HARBOUR HB_DIRECTORY( void ) /* now put everything into an array */ while ((entry = readdir( dir )) != NULL) { - strcpy(string,entry->d_name); + +#endif pos = strrchr(string,'.'); if( pos ) { @@ -219,47 +264,60 @@ HARBOUR HB_DIRECTORY( void ) strcpy(fname,string); fext[0] = '\0'; } + +/* redundant if (strlen(fext) < 1) fext[0] = '\0'; + */ + if (strlen(fname) < 1) strcpy(fname,"*"); /* debug code printf("\n fname fext %s %s ",fname,fext); while(0==getchar()); -*/ + */ if (hb_strMatchDOS( fname,pfname) && hb_strMatchDOS( fext,pfext)) { - - aatrib[0] = '\0'; + attrib = 0; + aatrib[0] = '\0'; filesize[0] = '\0'; - filename[0] = '\0'; - attrib = 0; - fullfile[0] = '\0'; - strcat(filename,entry->d_name); - strcat(fullfile,dirname); - strcat(fullfile,entry->d_name); + +#if defined(_MSC_VER) + strcpy(filename,entry.name); +#else + strcpy(filename,entry->d_name); +#endif + strcpy(fullfile,dirname); + strcat(fullfile,filename); if (-1 == stat(fullfile,&statbuf)) { + /* TODO: proper error handling */ printf("\n invalid file %s ",fullfile); while(0==getchar()); } + else + { +/* This might be a problem under Novell when the file is a directory */ +/* needs test */ + sprintf(filesize, "%ld", statbuf.st_size); - fsize = statbuf.st_size; - sprintf(filesize, "%ld", fsize); - ftime = statbuf.st_mtime; - ft = localtime(&ftime); + ftime = statbuf.st_mtime; + ft = localtime(&ftime); + sprintf(ddate, "%04d%02d%02d", + ft->tm_year+1900, ft->tm_mon + 1, ft->tm_mday); - sprintf(ddate, "%04d%02d%02d", - ft->tm_year+1900, ft->tm_mon + 1, ft->tm_mday); - sprintf(ttime, "%02d:%02d:%02d", - ft->tm_hour, ft->tm_min, ft->tm_sec); + sprintf(ttime, "%02d:%02d:%02d", + ft->tm_hour, ft->tm_min, ft->tm_sec); /* debug code - printf("\n name date time %s %s %s ",entry,ddate,ttime); - while(0==getchar()); -*/ + + printf("\n name date time %s %s %s ",filename,ddate,ttime); + while(0==getchar()); + */ + + } #if defined(OS_UNIX_COMPATIBLE) /* GNU C on Linux or on other UNIX */ @@ -279,22 +337,43 @@ HARBOUR HB_DIRECTORY( void ) if( S_ISSOCK(statbuf.st_mode) ) strcat( aatrib, "K" ); #else - /* TODO: seems to not clear on root entries ? */ - attrib = _chmod(fullfile,0); + attrib = entry.attrib; if (attrib & FA_ARCH) strcat(aatrib,"A"); if (attrib & FA_DIREC) strcat(aatrib,"D"); if (attrib & FA_HIDDEN) strcat(aatrib,"H"); - if (attrib & FA_LABEL) - strcat(aatrib,"V"); if (attrib & FA_RDONLY) strcat(aatrib,"R"); if (attrib & FA_SYSTEM) strcat(aatrib,"S"); -#endif + if (attrib & FA_LABEL) + { + strcat(aatrib,"V"); + if (attrib & FA_VOLCOMP) + strcat(aatrib,"L"); /* volume supports compression. */ + } +/* some of these are known to work under NT - I picked the letters to use.*/ +/* needs testing on a Novell drive */ + if (attrib & FA_ENCRYPTED) + strcat(aatrib,"E"); +// if (attrib & FA_NORMAL) +// strcat(aatrib,"N"); + if (attrib & FA_TEMPORARY) + strcat(aatrib,"T"); + if (attrib & FA_SPARSE) + strcat(aatrib,"P"); + if (attrib & FA_REPARSE) + strcat(aatrib,"Z"); + if (attrib & FA_COMPRESSED) + strcat(aatrib,"C"); + if (attrib & FA_OFFLINE) + strcat(aatrib,"O"); + if (attrib & FA_NOTINDEXED) + strcat(aatrib,"X"); +#endif /* TODO: attribute match rtn */ pos = string; if( arg2_it && hb_parclen(2) >= 1) @@ -302,13 +381,11 @@ HARBOUR HB_DIRECTORY( void ) strcpy(string, hb_parc(2)); while (*pos != '\0') { - *pos = toupper(*pos); + *pos = (char)toupper(*pos); pos++; } pos = strchr(string,*aatrib); } - else - pos = string; if ( pos ) { @@ -336,14 +413,23 @@ HARBOUR HB_DIRECTORY( void ) } } } +#if defined(_MSC_VER) + while( _findnext( hFile, &entry ) == 0 ); + + _findclose( hFile ); +#else closedir( dir ); +#endif ItemCopy( &stack.Return, pdir ); /* DIRECTORY() returns an array */ hb_itemRelease(pdir); +#if defined(_MSC_VER) + + } +#endif #endif /* HAVE_POSIX_IO */ - return; } static BOOL hb_strMatchDOS (char *pszString, char *pszMask) @@ -386,4 +472,3 @@ static BOOL hb_strMatchDOS (char *pszString, char *pszMask) return !((!(*pszString) && *pszMask && *pszMask != '*') || (!(*pszMask) && *pszString)); } - diff --git a/harbour/source/rtl/gt/gtdos.c b/harbour/source/rtl/gt/gtdos.c index 7cc82a1144..943ca321dc 100644 --- a/harbour/source/rtl/gt/gtdos.c +++ b/harbour/source/rtl/gt/gtdos.c @@ -294,6 +294,10 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce) } } +void gtSetAttribute( char x1, char y1, char x2, char y2, char attribute ) +{ +} + char gtWhereX(void) { #if defined(__TURBOC__) diff --git a/harbour/source/rtl/gt/gtos2.c b/harbour/source/rtl/gt/gtos2.c index 401f67b479..b0b3f6fccb 100644 --- a/harbour/source/rtl/gt/gtos2.c +++ b/harbour/source/rtl/gt/gtos2.c @@ -126,3 +126,7 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce) srce += width; } } + +void gtSetAttribute(char x, char y, char attr, char *str, int len) +{ +} diff --git a/harbour/source/rtl/gt/gtwin.c b/harbour/source/rtl/gt/gtwin.c index 72d4201078..48ad9c7e81 100644 --- a/harbour/source/rtl/gt/gtwin.c +++ b/harbour/source/rtl/gt/gtwin.c @@ -5,8 +5,8 @@ /* * GTWIN.C: Video subsystem for Windows 95/NT compilers. * - * This module is based on VIDMGR by Andrew Clarke and modified for - * the Harbour project + * This module is based (somewhat) on VIDMGR by + * Andrew Clarke and modified for the Harbour project */ #include @@ -53,6 +53,7 @@ void gtInit(void) HOutput = GetStdHandle(STD_OUTPUT_HANDLE); } +/* TODO: this can very likely be removed */ HARBOUR GTINIT( void ) { gtInit(); @@ -80,7 +81,7 @@ char gtGetScreenHeight(void) { CONSOLE_SCREEN_BUFFER_INFO csbi; - LOG("GetScreenWidth"); + LOG("GetScreenHeight"); GetConsoleScreenBufferInfo(HOutput, &csbi); return (char)csbi.dwSize.Y; } @@ -274,6 +275,34 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce) hb_xfree(pstr); } +void gtSetAttribute( char x1, char y1, char x2, char y2, char attribute ) +{ +/* ptucker */ + + DWORD len, i, width; + COORD coord; + LPWORD pwattr; + width = (y2 - y1 + 1); + + pwattr = (LPWORD) hb_xgrab(width * sizeof(*pwattr)); + if (!pwattr) + return; + memset( pwattr, attribute, width *sizeof(*pwattr) ); + + coord.X = (DWORD) (y1); /* note */ + coord.Y = (DWORD) (x2); + WriteConsoleOutputAttribute(HOutput, pwattr, width, coord, &len); + + coord.X = (DWORD)( y2 ); + for( i=x1;i<=x2;i++) + { + coord.Y = (DWORD) (i); + WriteConsoleOutputAttribute(HOutput, pwattr, 1, coord, &len); + } + + hb_xfree( pwattr ); +} + char gtWhereX(void) { CONSOLE_SCREEN_BUFFER_INFO csbi;