Problem with FWPPC

Post Reply
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Problem with FWPPC

Post by Maurizio »

Hello Antonio

With a old version of fwppc (before 2008) I use this code without error
With FWPPC of October 2008 I have this error

Code: Select all

// TEST.PRG
#include "FWCE.ch"
Function Main()
Local aIp
 inetinit()

   aIP:=InetGetHosts(Getenv("ComputerName"))
   inetcleanup()
   for i:=1 to len(aIP)
      MsgInfo(aIP[i])
   next



Return .T.
#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>

#include <WinSock2.h>
#include <inet.h>
#include <thread.h>
#include "hbapiitm.h"

static volatile int s_iSessions = 0;

/*** Utilty to access host DNS */
struct hostent *hb_getHosts( char *name, HB_SOCKET_STRUCT *Socket )
{
   struct hostent *Host = NULL;

   /* let's see if name is an IP address; not necessary on linux */
   #if defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
   ULONG ulAddr;

   ulAddr = inet_addr( name );
   if( ulAddr == INADDR_NONE )
   {
      if( strcmp( "255.255.255.255", name ) == 0 )
      {
         Host = gethostbyaddr( (const char*) &ulAddr, sizeof( ulAddr ), AF_INET );
      }
   }
   else
   {
      Host = gethostbyaddr( (const char*)  &ulAddr, sizeof( ulAddr ), AF_INET );
   }
   #endif

   if( Host == NULL )
   {
      Host = gethostbyname( name );
   }

   if( Host == NULL && Socket != NULL )
   {
      #if defined(HB_OS_WIN_32)
         HB_SOCKET_SET_ERROR2( Socket, WSAGetLastError() , "Generic error in GetHostByName()" );
         WSASetLastError( 0 );
      #elif defined(HB_OS_OS2)
         HB_SOCKET_SET_ERROR2( Socket, h_errno, "Generic error in GetHostByName()" );
      #else
         HB_SOCKET_SET_ERROR2( Socket, h_errno, (char *) hstrerror( h_errno ) );
      #endif
   }
   return Host;
}



HB_FUNC( INETINIT )
{
   if( s_iSessions )
   {
      s_iSessions++;
   }
   else
   {
      #if defined(HB_OS_WIN_32)
         WSADATA wsadata;
         WSAStartup( MAKEWORD(1,1), &wsadata );
      #elif defined( HB_OS_LINUX )
         signal( HB_INET_LINUX_INTERRUPT, hb_inetLinuxSigusrHandle );
      #endif
      s_iSessions = 1;
   }
}

HB_FUNC( INETCLEANUP )
{
   if( --s_iSessions == 0 )
   {
      #if defined(HB_OS_WIN_32)
         WSACleanup();
      #endif
   }
}
#define _HB_API_INTERNAL_
#include "hbapiitm.h"


HB_FUNC( INETGETHOSTS )
{
   PHB_ITEM pHost = hb_param( 1, HB_IT_STRING );
   PHB_ITEM aHosts, Tmp;
   struct hostent *Host;
   char **cHosts;
   if( pHost == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, "INETGETHOSTS", 1, hb_paramError(1) );
      return;
   }
   HB_STACK_UNLOCK;
   HB_TEST_CANCEL_ENABLE_ASYN;
   Host = hb_getHosts( pHost->item.asString.value, NULL );
   HB_DISABLE_ASYN_CANC;
   HB_STACK_LOCK;
   aHosts.type = HB_IT_NIL;
   Tmp.type = HB_IT_NIL;
   hb_arrayNew( &aHosts, 0 );
   if( Host == NULL )
   {
      hb_itemReturnForward( &aHosts );
      return;
   }
   cHosts = Host->h_addr_list;
   while( *cHosts ) {
      hb_arrayAddForward( &aHosts, hb_itemPutC( &Tmp, inet_ntoa( *( (struct in_addr *)*cHosts ) ) ) );
      cHosts++;
   }
   hb_itemReturnForward( &aHosts );
}
#pragma ENDDUMP

 
+----------------------------------------------------------------------------+
¦ FiveWin for Pocket PC - October 2008 Harbour development power ¦_
¦ (c) FiveTech, 1993-2008 for Microsoft Windows Pocket PC ¦¦
+----------------------------------------------------------------------------+¦
  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Compiling...
Harbour 1.0.1dev Intl. (Rev. 9361)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'newsock.prg' and generating preprocessed output to 'newsock.ppo'...
Lines 1901, Functions/Procedures 1
Generating C source output to 'newsock.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

newsock.c
newsock.prg(103) : error C2065: 'HB_ITEM' : undeclared identifier
newsock.prg(103) : error C2146: syntax error : missing ';' before identifier 'aHosts'
newsock.prg(103) : error C2065: 'aHosts' : undeclared identifier
newsock.prg(103) : error C2065: 'Tmp' : undeclared identifier
newsock.prg(121) : error C2227: left of '->item' must point to class/struct/union
newsock.prg(121) : error C2228: left of '.asString' must have class/struct/union type
newsock.prg(121) : error C2228: left of '.value' must have class/struct/union type
newsock.prg(126) : error C2228: left of '.type' must have class/struct/union type
newsock.prg(127) : error C2228: left of '.type' must have class/struct/union type
LINK : fatal error LNK1181: cannot open input file 'newsock.obj'
* Linking errors *

CE:C:\FWPPCnew\SAMPLES>

Regards Maurizio
Last edited by Maurizio on Fri Jun 18, 2010 6:55 am, edited 1 time in total.
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Problem with FWPPC

Post by Daniel Garcia-Gil »

Hello...

change HB_ITEM aHosts by PHB_ITEM aHosts ( line 103 )
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: Problem with FWPPC

Post by Maurizio »

Thank Daniel

Now I have this

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Pocket PC - October 2008 Harbour development power │▄
│ (c) FiveTech, 1993-2008 for Microsoft Windows Pocket PC │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 1.0.1dev Intl. (Rev. 9361)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'NEWSOCK.prg' and generating preprocessed output to 'NEWSOCK.ppo'...
Lines 1901, Functions/Procedures 1
Generating C source output to 'NEWSOCK.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

NEWSOCK.c
NEWSOCK.prg(121) : error C2227: left of '->item' must point to class/struct/union
NEWSOCK.prg(121) : error C2228: left of '.asString' must have class/struct/union type
NEWSOCK.prg(121) : error C2228: left of '.value' must have class/struct/union type
NEWSOCK.prg(126) : error C2228: left of '.type' must have class/struct/union type
NEWSOCK.prg(127) : error C2228: left of '.type' must have class/struct/union type
LINK : fatal error LNK1181: cannot open input file 'NEWSOCK.obj'

Regards Maurizio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Problem with FWPPC

Post by Antonio Linares »

Maurizio,

You have to specify this define so Harbour lets you access to the internals of HB_ITEMS:

#define _HB_API_INTERNAL_
#include "hbapiitm.h"

This was implemented in Harbour in order to enforce the security and stability of applications, avoiding the access to internals.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: Problem with FWPPC

Post by Maurizio »

Thank Antonio
I have the same error

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Pocket PC - October 2008 Harbour development power │▄
│ (c) FiveTech, 1993-2008 for Microsoft Windows Pocket PC │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 1.0.1dev Intl. (Rev. 9361)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'newsock.prg' and generating preprocessed output to 'newsock.ppo'...
Lines 1888, Functions/Procedures 1
Generating C source output to 'newsock.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

newsock.c
newsock.prg(116) : error C2227: left of '->item' must point to class/struct/union
newsock.prg(116) : error C2228: left of '.asString' must have class/struct/union type
newsock.prg(116) : error C2228: left of '.value' must have class/struct/union type
newsock.prg(119) : error C2228: left of '.type' must have class/struct/union type
newsock.prg(120) : error C2228: left of '.type' must have class/struct/union type
LINK : fatal error LNK1181: cannot open input file 'newsock.obj'
* Linking errors *
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Problem with FWPPC

Post by Antonio Linares »

Maurizio,

What source code there is in newsock.prg(116) ? and the others ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: Problem with FWPPC

Post by Maurizio »

Antonio,

In my first message there is the source

116 - HB_TEST_CANCEL_ENABLE_ASYN;
119 HB_STACK_LOCK;
120 aHosts.type = HB_IT_NIL;

Regards Maurizio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Problem with FWPPC

Post by Antonio Linares »

Maurizio,

We don't find the translation for HB_TEST_CANCEL_ENABLE_ASYN in Harbour header files,

what it translates to ?

And the other defines ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: Problem with FWPPC

Post by Maurizio »

Antonio
I have in
C:\harbour_ce\include\thread.h(408):
#define HB_TEST_CANCEL_ENABLE_ASYN pthread_testcancel();
#define HB_STACK_LOCK

C:\harbour_ce\include\extend.api(68): #define UNDEF HB_IT_NIL
Trovato 'HB_IT_NIL' 1 volte.

Regards Maurizio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Problem with FWPPC

Post by Antonio Linares »

Maurizio,

We don't find that thread.h file in Harbour

Could you please email it to me ? thanks
regards, saludos

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

Re: Problem with FWPPC

Post by Antonio Linares »

Maurizio,

I got your file by email.

That thread.h file belongs to xHarbour. It is not a Harbour file.

See its copyright:

* xHarbour Project source code:
* The MT support
*
* Copyright 2002 Giancarlo Niccolai [gian@niccolai.ws]
* www - http://www.xharbour.org

You can not use it with Harbour. Neither with FWPPC.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply