2002-09-26 12:30 UTC-0300 Horacio Roldan <harbour_ar@yahoo.com.ar>

* include/hbapi.h
        - removed filecase() definition from Extend API
   * include/hbapifs.h
        - added filecase() definition to FS API
   * include/hbset.h
   * source/rtl/set.c
   * source/rtl/filesys.c
        ! fixed GPF, fixed MSVC typecast,
          changed settings from strings to numeric constants.
This commit is contained in:
Horacio Dario Roldan Kasimatis
2002-09-26 15:42:15 +00:00
parent 3e021a238b
commit b542248370
5 changed files with 98 additions and 18 deletions

View File

@@ -276,7 +276,6 @@ typedef USHORT ERRCODE;
extern HB_SYMB hb_symEval;
/* Extend API */
extern char HB_EXPORT * hb_filecase ( char * ); /* Convert string to environment case */
extern char HB_EXPORT * hb_parc( int iParam, ... ); /* retrieve a string parameter */
extern ULONG HB_EXPORT hb_parclen( int iParam, ... ); /* retrieve a string parameter length */
extern ULONG HB_EXPORT hb_parcsiz( int iParam, ... ); /* retrieve a by-reference string parameter length, including terminator */

View File

@@ -187,6 +187,7 @@ extern USHORT hb_fsAttrFromRaw( ULONG raw_attr );
extern ULONG hb_fsAttrToRaw( USHORT uiAttr );
extern USHORT hb_fsAttrEncode( const char * szAttr );
extern char * hb_fsAttrDecode( USHORT uiAttr, char * szAttr );
extern BYTE * hb_filecase ( char * ); /* Convert string to environment case */
#if defined(HB_EXTERN_C)
}

View File

@@ -185,13 +185,17 @@ typedef struct
BOOL HB_SET_STRICTREAD;
int HB_SET_TYPEAHEAD;
BOOL HB_SET_UNIQUE;
char * HB_SET_FILECASE;
char * HB_SET_DIRCASE;
char * HB_SET_DIRSEPARATOR;
int HB_SET_FILECASE;
int HB_SET_DIRCASE;
char HB_SET_DIRSEPARATOR;
int HB_SET_VIDEOMODE;
BOOL HB_SET_WRAP;
} HB_SET_STRUCT;
#define HB_SET_CASE_MIXED 0
#define HB_SET_CASE_LOWER 1
#define HB_SET_CASE_UPPER 2
extern HB_SET_STRUCT hb_set;
extern void hb_setInitialize( void );

View File

@@ -391,7 +391,7 @@ static void convert_create_flags_ex( USHORT uiAttr, USHORT uiFlags, int * result
#endif
char *hb_filecase(char *str) {
BYTE * hb_filecase(char *str) {
// Convert file and dir case. The allowed SET options are:
// LOWER - Convert all caracters of file to lower
// UPPER - Convert all caracters of file to upper
@@ -408,20 +408,33 @@ char *hb_filecase(char *str) {
size_t dirlen;
// Look for filename (Last "\" or DIRSEPARATOR)
if( hb_set.HB_SET_DIRSEPARATOR[0]!='\\') {
for(a=0;a<strlen(str);a++) if(str[a]=='\\') str[a]=hb_set.HB_SET_DIRSEPARATOR[0];
if( hb_set.HB_SET_DIRSEPARATOR != '\\' ) {
for(a=0;a<strlen(str);a++)
if( str[a] == '\\' )
str[a] = hb_set.HB_SET_DIRSEPARATOR;
}
if((filename=strrchr( str, hb_set.HB_SET_DIRSEPARATOR[0] ))!=NULL) filename++; else filename=str;
if(( filename = strrchr( str, hb_set.HB_SET_DIRSEPARATOR )) != NULL)
filename++;
else
filename=str;
dirlen=filename-str;
// FILECASE
if( hb_stricmp( hb_set.HB_SET_FILECASE, "LOWER" ) == 0 ) hb_strLower(filename,strlen(filename));
else if( hb_stricmp( hb_set.HB_SET_FILECASE, "UPPER" ) == 0 ) hb_strUpper(filename,strlen(filename));
// if( hb_stricmp( hb_set.HB_SET_FILECASE, "LOWER" ) == 0 ) hb_strLower(filename,strlen(filename));
// else if( hb_stricmp( hb_set.HB_SET_FILECASE, "UPPER" ) == 0 ) hb_strUpper(filename,strlen(filename));
if( hb_set.HB_SET_FILECASE == HB_SET_CASE_LOWER )
hb_strLower( filename, strlen(filename) );
else if( hb_set.HB_SET_FILECASE == HB_SET_CASE_UPPER )
hb_strUpper( filename, strlen(filename) );
// DIRCASE
if( hb_stricmp( hb_set.HB_SET_DIRCASE, "LOWER" ) == 0 ) hb_strLower(dirname,dirlen);
else if( hb_stricmp( hb_set.HB_SET_DIRCASE, "UPPER" ) == 0 ) hb_strUpper(dirname,dirlen);
return str;
// if( hb_stricmp( hb_set.HB_SET_DIRCASE, "LOWER" ) == 0 ) hb_strLower(dirname,dirlen);
// else if( hb_stricmp( hb_set.HB_SET_DIRCASE, "UPPER" ) == 0 ) hb_strUpper(dirname,dirlen);
if( hb_set.HB_SET_DIRCASE == HB_SET_CASE_LOWER )
hb_strLower(dirname,dirlen);
else if( hb_set.HB_SET_DIRCASE == HB_SET_CASE_UPPER )
hb_strUpper(dirname,dirlen);
return (( BYTE * ) str);
}
/*

View File

@@ -764,21 +764,78 @@ HB_FUNC( SET )
if( args > 1 ) hb_set.HB_SET_IDLEREPEAT = set_logical( pArg2 );
break;
case HB_SET_FILECASE :
if( hb_set.HB_SET_FILECASE ) hb_retc( hb_set.HB_SET_FILECASE );
hb_retni( hb_set.HB_SET_FILECASE );
if( args > 1 )
{
if( HB_IS_STRING( pArg2 ) )
{
if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) )
hb_set.HB_SET_FILECASE = HB_SET_CASE_LOWER;
else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) )
hb_set.HB_SET_FILECASE = HB_SET_CASE_UPPER;
else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) )
hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED;
else
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
else if( HB_IS_NUMERIC( pArg2 ) )
{
if( set_number( pArg2, hb_set.HB_SET_FILECASE ) < 0 )
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
else
hb_set.HB_SET_FILECASE = set_number( pArg2, hb_set.HB_SET_FILECASE );
}
else
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
/*
if( hb_set.HB_SET_FILECASE )
hb_retc( hb_set.HB_SET_FILECASE );
else hb_retc( NULL );
if( args > 1 ) hb_set.HB_SET_FILECASE = set_string( pArg2, hb_set.HB_SET_FILECASE );
if( hb_stricmp( hb_set.HB_SET_FILECASE, "LOWER" ) == 0 )
if( args > 1 )
hb_set.HB_SET_FILECASE = set_string( pArg2, hb_set.HB_SET_FILECASE );
*/
break;
case HB_SET_DIRCASE :
hb_retni( hb_set.HB_SET_DIRCASE );
if( args > 1 )
{
if( HB_IS_STRING( pArg2 ) )
{
if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) )
hb_set.HB_SET_DIRCASE = HB_SET_CASE_LOWER;
else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) )
hb_set.HB_SET_DIRCASE = HB_SET_CASE_UPPER;
else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) )
hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED;
else
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
else if( HB_IS_NUMERIC( pArg2 ) )
{
if( set_number( pArg2, hb_set.HB_SET_DIRCASE ) < 0 )
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
else
hb_set.HB_SET_DIRCASE = set_number( pArg2, hb_set.HB_SET_DIRCASE );
}
else
hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
/*
if( hb_set.HB_SET_DIRCASE ) hb_retc( hb_set.HB_SET_DIRCASE );
else hb_retc( NULL );
if( args > 1 ) hb_set.HB_SET_DIRCASE = set_string( pArg2, hb_set.HB_SET_DIRCASE );
*/
break;
case HB_SET_DIRSEPARATOR :
/*
if( hb_set.HB_SET_DIRSEPARATOR ) hb_retc( hb_set.HB_SET_DIRSEPARATOR );
else hb_retc( NULL );
if( args > 1 ) hb_set.HB_SET_DIRSEPARATOR = set_string( pArg2, hb_set.HB_SET_DIRSEPARATOR );
break;
default :
*/
/* Return NIL if called with invalid SET specifier */
break;
}
@@ -858,12 +915,18 @@ void hb_setInitialize( void )
hb_set.HB_SET_STRICTREAD = FALSE;
hb_set.HB_SET_TYPEAHEAD = 50; hb_inkeyReset( TRUE ); /* Allocate keyboard typeahead buffer */
hb_set.HB_SET_UNIQUE = FALSE;
/*
hb_set.HB_SET_FILECASE = ( char * ) hb_xgrab( 6 );
memcpy( hb_set.HB_SET_FILECASE, "MIXED", 6 );
hb_set.HB_SET_DIRCASE = ( char * ) hb_xgrab( 6 );
memcpy( hb_set.HB_SET_DIRCASE, "MIXED", 6 );
hb_set.HB_SET_DIRSEPARATOR = ( char * ) hb_xgrab( 2 );
memcpy( hb_set.HB_SET_DIRSEPARATOR, "\\", 2 );
*/
hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED;
hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED;
hb_set.HB_SET_DIRSEPARATOR = '\\';
hb_set.HB_SET_VIDEOMODE = 0;
hb_set.HB_SET_WRAP = FALSE;
@@ -901,9 +964,9 @@ void hb_setRelease( void )
if( hb_set.HB_SET_MFILEEXT ) hb_xfree( hb_set.HB_SET_MFILEEXT );
if( hb_set.HB_SET_PATH ) hb_xfree( hb_set.HB_SET_PATH );
if( hb_set.HB_SET_PRINTFILE ) hb_xfree( hb_set.HB_SET_PRINTFILE );
if( hb_set.HB_SET_FILECASE ) hb_xfree( hb_set.HB_SET_FILECASE );
if( hb_set.HB_SET_DIRCASE ) hb_xfree( hb_set.HB_SET_FILECASE );
if( hb_set.HB_SET_DIRSEPARATOR ) hb_xfree( hb_set.HB_SET_FILECASE );
// if( hb_set.HB_SET_FILECASE ) hb_xfree( hb_set.HB_SET_FILECASE );
// if( hb_set.HB_SET_DIRCASE ) hb_xfree( hb_set.HB_SET_FILECASE );
// if( hb_set.HB_SET_DIRSEPARATOR ) hb_xfree( hb_set.HB_SET_FILECASE );
hb_set.HB_SET_TYPEAHEAD = -1; hb_inkeyReset( TRUE ); /* Free keyboard typeahead buffer */