Index problem

Re: Index problem

Postby driessen » Tue Jun 10, 2014 4:44 pm

Antonio,

Did you receive my email I send you this morning?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Index problem

Postby Antonio Linares » Tue Jun 10, 2014 7:02 pm

Michel,

gmail took it to the spam folder due to the attached files.

Reading it right now...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Index problem

Postby Antonio Linares » Tue Jun 10, 2014 7:11 pm

Michel,

if you don't mind it, I answer you here as this code may help other xHarbour->Harbour switchers :-)

This version of DelFileCache() is properly building with Harbour and Borland.

Code: Select all  Expand view
#pragma BEGINDUMP

#include <stdio.h>
#include <Windows.h>
#include <WinINet.h>
#include <hbapi.h>
#include <hbapiitm.h>
#include <hbapifs.h>
#include <hbvm.h>
#include <hbstack.h>

static int mystrcmp( char *val1, char *val2 )
{
        int     nret = 0 ;

        for ( ; *val1 ; val1++, val2++ )  {
                if ( ! *val2 || *val1 != *val2 )  {
                        nret = 1 ;
                        break ;
                }
        }
        if ( ! nret && *val2 )
                nret = 1 ;

        return nret ;
}

HB_FUNC( DELFILECACHE )
{
        BOOL                            bResult = FALSE ;
        BOOL                            bDone = FALSE ;
        LPINTERNET_CACHE_ENTRY_INFO     lpCacheEntry = NULL ;
        DWORD                           dwTrySize, dwEntrySize = 4096 ; // start buffer size
        HANDLE                          hCacheDir = NULL ;
        DWORD                           dwError = ERROR_INSUFFICIENT_BUFFER ;
        BOOL                            bSuccess ;
        PHB_ITEM                        iFiles, iElem ;
        int                             nfile, npos ;
        char                            buffile[FILENAME_MAX] ;

        iFiles = hb_itemParam( 1 ) ;
        nfile = hb_parinfa( 1, 0 ) ;

        do  {
                switch ( dwError )  {
                        // need a bigger buffer
                        case ERROR_INSUFFICIENT_BUFFER :
                                if ( lpCacheEntry != NULL )
                                        free( (LPBYTE)lpCacheEntry ) ;
                                lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) malloc( dwEntrySize ) ;
                                lpCacheEntry->dwStructSize = dwEntrySize ;
                                dwTrySize = dwEntrySize ;

                                if ( hCacheDir == NULL )
                                        bSuccess = (hCacheDir = FindFirstUrlCacheEntry( NULL, lpCacheEntry, &dwTrySize )) != NULL ;
                                else
                                        bSuccess = FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize ) ;
                                if ( bSuccess )
                                        dwError = ERROR_SUCCESS ;
                                else  {
                                        dwError = GetLastError() ;
                                        dwEntrySize = dwTrySize ; // use new size returned
                                }
                                break ;

                        // we are done
                        case ERROR_NO_MORE_ITEMS :
                                bDone = TRUE ;
                                bResult = TRUE ;
                                break ;

                        // we have got an entry
                        case ERROR_SUCCESS:
                                // don't delete cookie entry

                                if ( !( lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY ) )  {
                                        for ( npos = 1 ; npos <= nfile ; npos++ )  {
                                                iElem = hb_itemArrayGet( iFiles, npos ) ;

                                                hb_itemCopyC( iElem, buffile, 0 ) ;
                                                buffile[hb_itemSize( iElem )] = '\0' ;

                                                if ( ! mystrcmp( (char *)(lpCacheEntry->lpszSourceUrlName), buffile ) )  {
                                                        DeleteUrlCacheEntry( lpCacheEntry->lpszSourceUrlName ) ;
                                                        break ;
                                                }
                                        }
                                }

                                // get ready for next entry
                                dwTrySize = dwEntrySize;
                                if ( FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize ) )
                                        dwError = ERROR_SUCCESS ;
                                else  {
                                        dwError = GetLastError() ;
                                        dwEntrySize = dwTrySize ; // use new size returned
                                }
                                break;

                        // unknown error
                        default:
                                bDone = TRUE ;
                                break ;
                }
                if ( bDone )  {
                        free( (LPBYTE)lpCacheEntry ) ;
                        if ( hCacheDir )
                                FindCloseUrlCache( hCacheDir ) ;
                }
        }  while ( !bDone ) ;

        hb_retnl( bResult ) ;
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Index problem

Postby driessen » Wed Jun 11, 2014 8:44 am

Antonio,

I tried out your solution. Unfortunately I got these errors :

Error: Unresolved external 'FindFirstUrlCacheEntryA' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'DeleteUrlCacheEntry' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'FindNextUrlCacheEntryA' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'FindCloseUrlCache' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ

What next?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Index problem

Postby Antonio Linares » Mon Jun 23, 2014 4:49 am

Michel,

Please link Borland's c:\bcc582\Lib\PSDK\wininet.lib also, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Index problem

Postby driessen » Tue Jun 24, 2014 12:44 pm

Antonio,

I added this last library.
Where is it for? Everything was going just fine.

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Index problem

Postby Antonio Linares » Tue Jun 24, 2014 1:24 pm

Michel,

It solves these externals that you reported:

Error: Unresolved external 'FindFirstUrlCacheEntryA' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'DeleteUrlCacheEntry' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'FindNextUrlCacheEntryA' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ
Error: Unresolved external 'FindCloseUrlCache' referenced from M:\SOFTWARE\JUDAHARB\PRG\OBJ\JUDA.OBJ


How did you solve them ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Index problem

Postby driessen » Tue Jun 24, 2014 3:33 pm

Thanks, Antonio. I misunderstood. Sorry.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests