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 Expand view RUN
- // 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