xhb

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\contrib\xhb
cstructc.c
TypeFunctionSourceLine
STATIC PHB_ITEMhb_itemPutCRaw( PHB_ITEM pItem, const char * szText, ULONG ulLen )
static PHB_ITEM hb_itemPutCRaw( PHB_ITEM pItem, const char * szText, ULONG ulLen )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemPutCRaw(%p, %s, %lu)", pItem, szText, ulLen));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   if( ulLen == 0 )
   {
      if( szText )
         hb_xfree( ( void * ) szText );
      szText = "";
   }
   pItem->type = HB_IT_STRING;
   pItem->item.asString.length    = ulLen;
   pItem->item.asString.value     = ( char * ) szText;
   pItem->item.asString.allocated = ulLen;

   return pItem;
}
cstructc.c64
STATIC PHB_ITEMhb_itemPutCRawStatic( PHB_ITEM pItem, const char * szText, ULONG ulLen )
static PHB_ITEM hb_itemPutCRawStatic( PHB_ITEM pItem, const char * szText, ULONG ulLen )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemPutCRawStatic(%p, %s, %lu)", pItem, szText, ulLen));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_STRING;
   pItem->item.asString.allocated = 0;
   pItem->item.asString.length    = ulLen;
   pItem->item.asString.value     = ( char * ) szText;

   return pItem;
}
cstructc.c93
HB_EXPORT VOIDhb_retclenAdoptRaw( const char * szText, ULONG ulLen )
HB_EXPORT void hb_retclenAdoptRaw( const char * szText, ULONG ulLen )
{
   hb_itemPutCRaw( hb_stackReturnItem(), szText, ulLen );
}
cstructc.c116
HB_EXPORT VOIDhb_retclenStatic( const char * szText, ULONG ulLen )
HB_EXPORT void hb_retclenStatic( const char * szText, ULONG ulLen )
{
   hb_itemPutCRawStatic( hb_stackReturnItem(), szText, ulLen );
}
cstructc.c124
STATIC UNSIGNED INTSizeOfCStructure( PHB_ITEM aDef, unsigned int uiAlign )
static unsigned int SizeOfCStructure( PHB_ITEM aDef, unsigned int uiAlign )
{
   PHB_BASEARRAY pBaseDef = aDef->item.asArray.value;
   unsigned long ulLen = pBaseDef->ulLen;
   unsigned long ulIndex;
   unsigned int uiSize = 0, uiMemberSize;
   BYTE cShift;
   unsigned int uiPad;

   for( ulIndex = 0; ulIndex < ulLen; ulIndex++ )
   {
      if( ( pBaseDef->pItems + ulIndex )->type != HB_IT_INTEGER )
      {
         hb_errRT_BASE( EG_ARG, 2023, NULL, "SizeOfCStructure", 1, hb_paramError( 1 ) );
         return 0;
      }

      switch( ( pBaseDef->pItems + ulIndex )->item.asInteger.value )
      {
         case CTYPE_CHAR : /* char */
         case CTYPE_UNSIGNED_CHAR : /* unsigned char */
            uiMemberSize = sizeof( char );
            break;

         case CTYPE_CHAR_PTR : /* char * */
         case CTYPE_UNSIGNED_CHAR_PTR : /* unsigned char * */
            uiMemberSize = sizeof( char * );
            break;

         case CTYPE_SHORT : /* short */
         case CTYPE_UNSIGNED_SHORT : /* unsigned short */
            uiMemberSize = sizeof( short );
            break;

         case CTYPE_SHORT_PTR : /* short */
         case CTYPE_UNSIGNED_SHORT_PTR : /* unsigned short */
            uiMemberSize = sizeof( short * );
            break;

         case CTYPE_INT : /* int */
         case CTYPE_UNSIGNED_INT : /* unsigned int */
            uiMemberSize = sizeof( int );
            break;

         case CTYPE_INT_PTR : /* int * */
         case CTYPE_UNSIGNED_INT_PTR : /* unsigned int * */
            uiMemberSize = sizeof( int * );
            break;

         case CTYPE_LONG : /* long */
         case CTYPE_UNSIGNED_LONG : /* unsigned long */
            uiMemberSize = sizeof( long );
            break;

         case CTYPE_LONG_PTR : /* long * */
         case CTYPE_UNSIGNED_LONG_PTR : /* unsigned long * */
            uiMemberSize = sizeof( long * );
            break;

         case CTYPE_FLOAT : /* float */
            uiMemberSize = sizeof( float );
            break;

         case CTYPE_FLOAT_PTR : /* float * */
            uiMemberSize = sizeof( float * );
            break;

         case CTYPE_DOUBLE : /* double */
            uiMemberSize = sizeof( double );
            break;

         case CTYPE_DOUBLE_PTR : /* double * */
            uiMemberSize = sizeof( double * );
            break;

         case CTYPE_VOID_PTR : /* void * (pointer) */
            uiMemberSize = sizeof( void * );
            break;

         default:
         {
            if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value >= CTYPE_STRUCTURE_PTR )
            {
               uiMemberSize = sizeof( void * );
            }
            else if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value >= CTYPE_STRUCTURE )
            {
               PHB_ITEM pID = hb_itemPutNI( NULL, ( pBaseDef->pItems + ulIndex )->item.asInteger.value );
               PHB_ITEM pStructure = hb_itemDoC( "HB_CSTRUCTUREFROMID", 1, pID );

               hb_itemRelease( pID );

               if( HB_IS_OBJECT( pStructure ) )
               {
                  hb_objSendMsg( pStructure, "SizeOf", 0 );
                  uiMemberSize = (unsigned int) hb_parnl( -1 );
                  hb_itemRelease( pStructure );
               }
               else
               {
                  hb_itemRelease( pStructure );
                  hb_errRT_BASE( EG_ARG, 2023, NULL, "SizeOfCStructure", 1, hb_paramError( 1 ) );
                  return 0;
               }
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "SizeOfCStructure", 1, hb_paramError( 1 ) );
               return 0;
            }
         }
      }

      if( uiSize )
      {
         uiPad = ( ( uiMemberSize < uiAlign ) ? uiMemberSize : uiAlign );

         if( ( cShift = ( BYTE ) ( uiSize % uiPad ) ) > 0 )
         {
            uiSize += ( uiPad - cShift );
         }
      }

      uiSize += uiMemberSize;

      /* printf( "#%lu Size: %u Align: %u Pad: %u Shift %i Size: %u\n", ulIndex, uiMemberSize, uiAlign, uiPad, cShift, uiSize ); */

   }

   if( ( cShift = ( BYTE ) ( uiSize % uiAlign ) ) > 0 )
   {
      uiSize += ( uiAlign - cShift );
   }

   /* printf( "#%lu Size: %u Align: %u Pad: %u Shift %i Size: %u\n", ulIndex, uiMemberSize, uiAlign, uiPad, cShift, uiSize ); */

   return uiSize;
}
cstructc.c129
HB_FUNCHB_SIZEOFCSTRUCTURE(void)
HB_FUNC( HB_SIZEOFCSTRUCTURE )
{
   PHB_ITEM aDef = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pAlign = hb_param( 2, HB_IT_INTEGER );
   unsigned int uiAlign;

   if( aDef )
   {
      if( pAlign )
      {
         uiAlign = (BYTE) pAlign->item.asInteger.value;
      }
      else
      {
         uiAlign = 8;
      }

      hb_retni( SizeOfCStructure( aDef, uiAlign ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2023, NULL, "SizeOfCStructure", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
   }
}
cstructc.c268
STATIC BYTE *ArrayToStructure( PHB_ITEM aVar, PHB_ITEM aDef, unsigned int uiAlign, unsigned int * puiSize )
static BYTE * ArrayToStructure( PHB_ITEM aVar, PHB_ITEM aDef, unsigned int uiAlign, unsigned int * puiSize )
{
   PHB_BASEARRAY pBaseVar = aVar->item.asArray.value;
   PHB_BASEARRAY pBaseDef = aDef->item.asArray.value;
   unsigned long ulLen = pBaseDef->ulLen;
   unsigned long ulIndex;
   BYTE  *Buffer;
   unsigned int uiOffset = 0, uiMemberSize;
   BYTE cShift;

   *puiSize = SizeOfCStructure( aDef, uiAlign ) ;

   /* printf( "Size: %i\n", *puiSize ); */

   Buffer = (BYTE *) hb_xgrab( *puiSize + 1 );

   for( ulIndex = 0; ulIndex < ulLen; ulIndex++ )
   {
      /* printf( "#: %i\n", ulIndex ); */

      switch( ( pBaseDef->pItems + ulIndex )->item.asInteger.value )
      {
         case CTYPE_CHAR : /* char */
         case CTYPE_UNSIGNED_CHAR : /* unsigned char */
            if( ( pBaseVar->pItems + ulIndex  )->type && ! HB_IS_NUMERIC( pBaseVar->pItems + ulIndex  ) )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( char );
            break;

         case CTYPE_CHAR_PTR : /* char * */
         case CTYPE_UNSIGNED_CHAR_PTR : /* unsigned char * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_STRING
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( char * );
            break;

         case CTYPE_SHORT : /* short */
         case CTYPE_UNSIGNED_SHORT : /* unsigned short */
            /* Type check performed in actual translation... */
            uiMemberSize = sizeof( short );
            break;

         case CTYPE_SHORT_PTR : /* short * */
         case CTYPE_UNSIGNED_SHORT_PTR : /* unsigned short * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( short * );
            break;

         case CTYPE_INT : /* int */
         case CTYPE_UNSIGNED_INT : /* unsigned int */
            /* Type check performed in actual translation... */
            uiMemberSize = sizeof( int );
            break;

         case CTYPE_INT_PTR : /* int * */
         case CTYPE_UNSIGNED_INT_PTR : /* unsigned int * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( int * );
            break;

         case CTYPE_LONG : /* long */
         case CTYPE_UNSIGNED_LONG : /* unsigned long */
            /* Type check performed in actual translation... */
            uiMemberSize = sizeof( long );
            break;

         case CTYPE_LONG_PTR : /* long * */
         case CTYPE_UNSIGNED_LONG_PTR : /* unsigned long * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( long * );
            break;

         case CTYPE_FLOAT : /* float */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_DOUBLE )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( float );
            break;

         case CTYPE_FLOAT_PTR : /* float * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_DOUBLE
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( float * );
            break;

         case CTYPE_DOUBLE : /* double */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_DOUBLE )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( double );
            break;

         case CTYPE_DOUBLE_PTR : /* double * */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_DOUBLE
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( double * );
            break;

         case CTYPE_VOID_PTR : /* void * (pointer) */
            if( ( pBaseVar->pItems + ulIndex  )->type && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_POINTER
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_LONG
                                                      && ( pBaseVar->pItems + ulIndex  )->type != HB_IT_STRING )
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            uiMemberSize = sizeof( void * );
            break;

         default:
         {
            if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value >= CTYPE_STRUCTURE_PTR )
            {
               uiMemberSize = sizeof( void * );
            }
            else if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value >= CTYPE_STRUCTURE )
            {
               PHB_ITEM pID = hb_itemPutNI( NULL, ( pBaseDef->pItems + ulIndex )->item.asInteger.value );
               PHB_ITEM pStructure = hb_itemDoC( "HB_CSTRUCTUREFROMID", 1, pID );

               hb_itemRelease( pID );

               if( HB_IS_OBJECT( pStructure ) )
               {
                  hb_objSendMsg( pStructure, "SizeOf", 0 );
                  uiMemberSize = (unsigned int) hb_parnl( -1 );
                  hb_itemRelease( pStructure );
               }
               else
               {
                  hb_itemRelease( pStructure );
                  hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
                  return NULL;
               }
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
         }
      }

      if( uiOffset )
      {
         unsigned int uiPad = ( ( uiMemberSize < uiAlign ) ? uiMemberSize : uiAlign );

         if( ( cShift = ( BYTE ) ( uiOffset % uiPad ) ) > 0 )
         {
            uiOffset += ( uiPad - cShift );
         }
      }

      /* printf( "* Size: %i Offset: %i\n", uiMemberSize, uiOffset ); */

      switch( ( pBaseDef->pItems + ulIndex )->item.asInteger.value )
      {
         case CTYPE_CHAR : /* char */
            if( ( pBaseVar->pItems + ulIndex  )->type )
            {
               *( (char *) ( Buffer + uiOffset ) ) = (char) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else
            {
               *( (char *) ( Buffer + uiOffset ) ) = 0;
            }
            break;

         case CTYPE_UNSIGNED_CHAR : /* unsigned char */
            if( ( pBaseVar->pItems + ulIndex  )->type )
            {
               *( (BYTE*) ( Buffer + uiOffset ) ) = (BYTE) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else
            {
               *( (BYTE*) ( Buffer + uiOffset ) ) = 0;
            }
            break;

         case CTYPE_CHAR_PTR : /* char * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_STRING:
                  *( (char **) ( Buffer + uiOffset ) ) = ( pBaseVar->pItems + ulIndex  )->item.asString.value;
                  break;

               case HB_IT_POINTER:
                  *( (char **) ( Buffer + uiOffset ) ) = (char *) ( pBaseVar->pItems + ulIndex  )->item.asPointer.value;
                  break;
#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (char **) ( Buffer + uiOffset ) ) = (char *) ( HB_PTRDIFF ) ( pBaseVar->pItems + ulIndex  )->item.asInteger.value;
                  break;
#endif
               case HB_IT_LONG:
                  *( (char **) ( Buffer + uiOffset ) ) = (char *) ( HB_PTRDIFF ) ( pBaseVar->pItems + ulIndex  )->item.asLong.value;
                  break;

               default:
                 *( (char **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_UNSIGNED_CHAR_PTR : /* unsigned char * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_STRING:
                  *( (BYTE **) ( Buffer + uiOffset ) ) = (BYTE *) ( ( pBaseVar->pItems + ulIndex  )->item.asString.value );
                  break;

               case HB_IT_POINTER:
                  *( (BYTE **) ( Buffer + uiOffset ) ) = (BYTE *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (BYTE **) ( Buffer + uiOffset ) ) = (BYTE *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (BYTE **) ( Buffer + uiOffset ) ) = (BYTE *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (BYTE **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_SHORT : /* short */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (short *) ( Buffer + uiOffset ) ) = (short) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (short *) ( Buffer + uiOffset ) ) = (short) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (short *) ( Buffer + uiOffset ) ) = (short) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (short *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
            break;

         case CTYPE_UNSIGNED_SHORT : /* unsigned short */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (unsigned short *) ( Buffer + uiOffset ) ) = (unsigned short) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (unsigned short *) ( Buffer + uiOffset ) ) = (unsigned short) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (unsigned short *) ( Buffer + uiOffset ) ) = (unsigned short) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (unsigned short *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
            break;

         case CTYPE_SHORT_PTR : /* short * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (short **) ( Buffer + uiOffset ) ) = (short *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (short **) ( Buffer + uiOffset ) ) = (short *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (short **) ( Buffer + uiOffset ) ) = (short *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (short **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_UNSIGNED_SHORT_PTR : /* unsigned short * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (unsigned short **) ( Buffer + uiOffset ) ) = (unsigned short *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (unsigned short **) ( Buffer + uiOffset ) ) = (unsigned short *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (unsigned short **) ( Buffer + uiOffset ) ) = (unsigned short *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (unsigned short **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_INT : /* int */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (int *) ( Buffer + uiOffset ) ) = (int) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (int *) ( Buffer + uiOffset ) ) = (int) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (int *) ( Buffer + uiOffset ) ) = (int) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (int *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
            break;

         case CTYPE_UNSIGNED_INT : /* unsigned int */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (unsigned int *) ( Buffer + uiOffset ) ) = (unsigned int) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (unsigned int *) ( Buffer + uiOffset ) ) = (unsigned int) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (unsigned int *) ( Buffer + uiOffset ) ) = (unsigned int) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (unsigned int *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }

            break;

         case CTYPE_INT_PTR : /* int * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (int **) ( Buffer + uiOffset ) ) = (int *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (int **) ( Buffer + uiOffset ) ) = (int *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (int **) ( Buffer + uiOffset ) ) = (int *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (int **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_UNSIGNED_INT_PTR : /* unsigned int * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (unsigned int **) ( Buffer + uiOffset ) ) = (unsigned int *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (unsigned int **) ( Buffer + uiOffset ) ) = (unsigned int *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (unsigned int **) ( Buffer + uiOffset ) ) = (unsigned int *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (unsigned int **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_LONG : /* long */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (long *) ( Buffer + uiOffset ) ) = (long) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (long *) ( Buffer + uiOffset ) ) = (long) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (long *) ( Buffer + uiOffset ) ) = (long) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (long *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
            break;

         case CTYPE_UNSIGNED_LONG : /* unsigned long */
            if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_INTEGER )
            {
               *( (unsigned long *) ( Buffer + uiOffset ) ) = (unsigned long) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_LONG )
            {
               *( (unsigned long *) ( Buffer + uiOffset ) ) = (unsigned long) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_DOUBLE )
            {
               *( (unsigned long *) ( Buffer + uiOffset ) ) = (unsigned long) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
            }
            else if( ( pBaseVar->pItems + ulIndex  )->type == HB_IT_NIL )
            {
               *( (unsigned long *) ( Buffer + uiOffset ) ) = 0;
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return NULL;
            }
            break;

         case CTYPE_LONG_PTR : /* long * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (long **) ( Buffer + uiOffset ) ) = (long *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (long **) ( Buffer + uiOffset ) ) = (long *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (long **) ( Buffer + uiOffset ) ) = (long *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (long **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_UNSIGNED_LONG_PTR : /* unsigned long * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (unsigned long **) ( Buffer + uiOffset ) ) = (unsigned long *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (unsigned long **) ( Buffer + uiOffset ) ) = (unsigned long *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (unsigned long **) ( Buffer + uiOffset ) ) = (unsigned long *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (unsigned long **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_FLOAT : /* float */
            if( ( pBaseVar->pItems + ulIndex  )->type )
            {
               *( (float *) ( Buffer + uiOffset ) ) = (float) ( pBaseVar->pItems + ulIndex  )->item.asDouble.value;
            }
            else
            {
               *( (float *) ( Buffer + uiOffset ) ) = 0;
            }
            break;

         case CTYPE_FLOAT_PTR : /* float * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (float **) ( Buffer + uiOffset ) ) = (float *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (float **) ( Buffer + uiOffset ) ) = (float *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (float **) ( Buffer + uiOffset ) ) = (float *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               /* Is this correct??? IMHO It's a bug */
               case HB_IT_DOUBLE:
                  **( (float **) ( Buffer + uiOffset ) ) = (float) ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
                  break;

               default:
                 *( (float **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_DOUBLE : /* double */
            if( ( pBaseVar->pItems + ulIndex  )->type )
            {
               *( (double *) ( Buffer + uiOffset ) ) = ( pBaseVar->pItems + ulIndex  )->item.asDouble.value;
            }
            else
            {
               *( (double *) ( Buffer + uiOffset ) ) = 0;
            }
            break;

         case CTYPE_DOUBLE_PTR : /* double * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (double **) ( Buffer + uiOffset ) ) = (double *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (double **) ( Buffer + uiOffset ) ) = (double *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (double **) ( Buffer + uiOffset ) ) = (double *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               /* Is this correct??? IMHO It's a bug */
               case HB_IT_DOUBLE:
                  **( (double **) ( Buffer + uiOffset ) ) = ( ( pBaseVar->pItems + ulIndex  )->item.asDouble.value );
                  break;

               default:
                 *( (double **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         case CTYPE_VOID_PTR : /* void * */
            switch( ( pBaseVar->pItems + ulIndex  )->type )
            {
               case HB_IT_POINTER:
                  *( (void **) ( Buffer + uiOffset ) ) = (void *) ( ( pBaseVar->pItems + ulIndex  )->item.asPointer.value );
                  break;

#if UINT_MAX == ULONG_MAX
               case HB_IT_INTEGER:
                  *( (void **) ( Buffer + uiOffset ) ) = (void *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asInteger.value );
                  break;
#endif
               case HB_IT_LONG:
                  *( (void **) ( Buffer + uiOffset ) ) = (void *) ( HB_PTRDIFF ) ( ( pBaseVar->pItems + ulIndex  )->item.asLong.value );
                  break;

               default:
                 *( (void **) ( Buffer + uiOffset ) ) = NULL;
                  break;
            }
            break;

         default:
         {
            if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE )
            {
               PHB_ITEM pStructure = pBaseVar->pItems + ulIndex;

               if( HB_IS_LONG( pStructure ) )
               {
                  if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
                  {
                     *( (void **) ( Buffer + uiOffset ) ) = (void *) ( HB_PTRDIFF ) pStructure->item.asLong.value;
                  }
                  else
                  {
                     memcpy( (void *) ( Buffer + uiOffset ), (void *) ( HB_PTRDIFF ) pStructure->item.asLong.value, uiMemberSize );
                  }
               }
#if UINT_MAX == ULONG_MAX
               else if( HB_IS_INTEGER( pStructure ) )
               {
                  if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
                  {
                     *( (void **) ( Buffer + uiOffset ) ) = (void *) ( HB_PTRDIFF ) pStructure->item.asInteger.value;
                  }
                  else
                  {
                     memcpy( (void *) ( Buffer + uiOffset ), (void *) ( HB_PTRDIFF ) pStructure->item.asInteger.value, uiMemberSize );
                  }
               }
#endif
               else if( HB_IS_NIL( pStructure ) )
               {
                  if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
                  {
                     *( (void **) ( Buffer + uiOffset ) ) = NULL;
                  }
                  else
                  {
                     /* TraceLog( NULL,"ArrayToStructure() - Empty Inplace\n" ); */
                     memset( (void *) ( Buffer + uiOffset ), 0, uiMemberSize );
                  }
               }
               else if( strncmp( hb_objGetClsName( pStructure ), "C Structure", 11 ) == 0 )
               {
                  PHB_BASEARRAY pBaseStructure = pStructure->item.asArray.value;
                  PHB_ITEM pInternalBuffer = pBaseStructure->pItems + pBaseStructure->ulLen - 1;

                  hb_objSendMsg( pStructure, "VALUE", 0 );

                  if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
                  {
                     *( (void **) ( Buffer + uiOffset ) ) = (void *) pInternalBuffer->item.asString.value;
                  }
                  else
                  {
                     memcpy( (void *) ( Buffer + uiOffset ), (void *) pInternalBuffer->item.asString.value, uiMemberSize );
                  }
               }
               else
               {
                  hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               }
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
            }
         }
      }

      /* printf( "Wrote %i bytes at Offset %i\n", uiMemberSize, uiOffset ); */

      uiOffset += uiMemberSize;
   }

   return Buffer;
}
cstructc.c293
HB_FUNCHB_ARRAYTOSTRUCTURE(void)
HB_FUNC( HB_ARRAYTOSTRUCTURE )
{
   PHB_ITEM aVar = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM aDef = hb_param( 2, HB_IT_ARRAY );
   PHB_ITEM pAlign = hb_param( 3, HB_IT_INTEGER );

   if( aVar && aDef )
   {
      unsigned int uiSize;
      unsigned int uiAlign;
      BYTE *Buffer;

      if( pAlign )
      {
         uiAlign = (BYTE) pAlign->item.asInteger.value;
      }
      else
      {
         uiAlign = 8;
      }

      Buffer = ArrayToStructure( aVar, aDef, uiAlign, &uiSize );
      hb_retclen_buffer( ( char * ) Buffer, uiSize );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2023, NULL, "ArrayToStructure", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
   }
}
cstructc.c1023
STATIC PHB_ITEMStructureToArray( BYTE* Buffer, unsigned long ulBufferLen, PHB_ITEM aDef, unsigned int uiAlign, BOOL bAdoptNested, PHB_ITEM pRet )
static PHB_ITEM StructureToArray( BYTE* Buffer, unsigned long ulBufferLen, PHB_ITEM aDef, unsigned int uiAlign, BOOL bAdoptNested, PHB_ITEM pRet )
{
   PHB_BASEARRAY pBaseDef = aDef->item.asArray.value;
   unsigned long ulLen = pBaseDef->ulLen;
   unsigned long ulIndex;
   unsigned int uiOffset, uiMemberSize;
   BYTE cShift;
   /* PHB_ITEM pRet = hb_itemNew( NULL ); */
   PHB_BASEARRAY pBaseVar;

   /* TraceLog( NULL, "StructureToArray(%p, %p, %u, %i) ->%u\n", Buffer, aDef, uiAlign, bAdoptNested, ulLen ); */

   /* hb_arrayNew( pRet, ulLen ); */
   pBaseVar = pRet->item.asArray.value;

   uiOffset = 0;
   for( ulIndex = 0; ulIndex < ulLen; ulIndex++ )
   {
      switch( ( pBaseDef->pItems + ulIndex )->item.asInteger.value )
      {
         case CTYPE_CHAR : /* char */
         case CTYPE_UNSIGNED_CHAR : /* unsigned char */
            uiMemberSize = sizeof( char );
            break;

         case CTYPE_CHAR_PTR : /* char * */
         case CTYPE_UNSIGNED_CHAR_PTR : /* unsigned char * */
            uiMemberSize = sizeof( char * );
            break;

         case CTYPE_SHORT : /* short */
         case CTYPE_UNSIGNED_SHORT : /* unsigned short */
            uiMemberSize = sizeof( short );
            break;

         case CTYPE_SHORT_PTR : /* short * */
         case CTYPE_UNSIGNED_SHORT_PTR : /* unsigned short * */
            uiMemberSize = sizeof( short * );
            break;

         case CTYPE_INT : /* int */
         case CTYPE_UNSIGNED_INT : /* unsigned int */
            uiMemberSize = sizeof( int );
            break;

         case CTYPE_INT_PTR : /* int * */
         case CTYPE_UNSIGNED_INT_PTR : /* unsigned int * */
            uiMemberSize = sizeof( int * );
            break;

         case CTYPE_LONG : /* long */
         case CTYPE_UNSIGNED_LONG : /* unsigned long */
            uiMemberSize = sizeof( long );
            break;

         case CTYPE_LONG_PTR : /* long * */
         case CTYPE_UNSIGNED_LONG_PTR : /* unsigned long * */
            uiMemberSize = sizeof( long * );
            break;

         case CTYPE_FLOAT : /* float */
            uiMemberSize = sizeof( float );
            break;

         case CTYPE_FLOAT_PTR : /* float * */
            uiMemberSize = sizeof( float * );
            break;

         case CTYPE_DOUBLE : /* double */
            uiMemberSize = sizeof( double );
            break;

         case CTYPE_DOUBLE_PTR : /* double * */
            uiMemberSize = sizeof( double * );
            break;

         case CTYPE_VOID_PTR : /* void * (pointer) */
            uiMemberSize = sizeof( void * );
            break;

         default:
         {
            if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
            {
               uiMemberSize = sizeof( void * );
            }
            else if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE )
            {
               PHB_ITEM pID = hb_itemPutNI( NULL, ( pBaseDef->pItems + ulIndex )->item.asInteger.value );
               PHB_ITEM pStructure = hb_itemDoC( "HB_CSTRUCTUREFROMID", 1, pID );

               hb_itemRelease( pID );

               if( HB_IS_OBJECT( pStructure ) )
               {
                  hb_objSendMsg( pStructure, "SizeOf", 0 );
                  uiMemberSize = (unsigned int) hb_parnl( -1 );
                  hb_itemRelease( pStructure );
               }
               else
               {
                  hb_itemRelease( pStructure );
                  hb_errRT_BASE( EG_ARG, 2023, NULL, "StructureToArray", 1, hb_paramError( 1 ) );
                  return pRet;
               }
            }
            else
            {
               hb_errRT_BASE( EG_ARG, 2023, NULL, "StructureToArray", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError(3) );
               return pRet;
            }
         }
      }

      if( uiOffset )
      {
         unsigned int uiPad = ( ( uiMemberSize < uiAlign ) ? uiMemberSize : uiAlign );

         if( ( cShift = ( BYTE ) ( uiOffset % uiPad ) ) > 0 )
         {
            uiOffset += ( uiPad - cShift );
         }

         /* TraceLog( NULL, "* Size: %i Offset: %i Pad: %i\n", uiMemberSize, uiOffset, uiPad ); */
      }
      else
      {
         /* TraceLog( NULL, "* Size: %i Offset: %i\n", uiMemberSize, uiOffset ); */
      }

      if( ( uiOffset + uiMemberSize ) > ulBufferLen )
      {
         break;
      }

      switch( ( pBaseDef->pItems + ulIndex )->item.asInteger.value )
      {
         case CTYPE_CHAR : /* char */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , (int) *( (char *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_UNSIGNED_CHAR : /* unsigned char */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , (int) *( (BYTE *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_CHAR_PTR : /* char * */
            if( HB_IS_STRING( pBaseVar->pItems + ulIndex ) && ( pBaseVar->pItems + ulIndex )->item.asString.value == *( (char **) ( Buffer + uiOffset ) ) )
            {
               /* TraceLog( NULL, "IDENTICAL: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
            }
            else if( !bAdoptNested )
            {
               /* TraceLog( NULL, "Static: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
               hb_itemPutCStatic( pBaseVar->pItems + ulIndex , *( (char **) ( Buffer + uiOffset ) ) );
            }
            else
            {
               /* TraceLog( NULL, "Adopt: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
               hb_itemPutC( pBaseVar->pItems + ulIndex , *( (char **) ( Buffer + uiOffset ) ) );
            }
            break;

         case CTYPE_UNSIGNED_CHAR_PTR : /* unsigned char * */
            if( HB_IS_STRING( pBaseVar->pItems + ulIndex ) && ( pBaseVar->pItems + ulIndex )->item.asString.value == *( (char **) ( Buffer + uiOffset ) ) )
            {
               /* TraceLog( NULL, "IDENTICAL: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
            }
            else if( !bAdoptNested )
            {
               /* TraceLog( NULL, "Static: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
               hb_itemPutCStatic( pBaseVar->pItems + ulIndex , *( (char **) ( Buffer + uiOffset ) ) );
            }
            else
            {
               /* TraceLog( NULL, "Adopt: %s\n", *( (char **) ( Buffer + uiOffset ) ) ); */
               hb_itemPutC( pBaseVar->pItems + ulIndex , *( (char **) ( Buffer + uiOffset ) ) );
            }
            break;

         case CTYPE_SHORT : /* short */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , *( (short *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_UNSIGNED_SHORT : /* unsigned short */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , (short) *( (unsigned short *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_SHORT_PTR : /* short * */
         case CTYPE_UNSIGNED_SHORT_PTR : /* unsigned short * */
            hb_itemPutPtr( pBaseVar->pItems + ulIndex , (void *) ( Buffer + uiOffset ) );
            break;

         case CTYPE_INT : /* int */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , *( (int *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_UNSIGNED_INT : /* unsigned int */
            hb_itemPutNI( pBaseVar->pItems + ulIndex , (int) *( (unsigned int *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_INT_PTR : /* int * */
         case CTYPE_UNSIGNED_INT_PTR : /* unsigned int * */
            hb_itemPutPtr( pBaseVar->pItems + ulIndex , (void *) ( Buffer + uiOffset ) );
            break;

         case CTYPE_LONG : /* long */
            hb_itemPutNL( pBaseVar->pItems + ulIndex , *( (long *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_UNSIGNED_LONG : /* unsigned long */
            hb_itemPutNL( pBaseVar->pItems + ulIndex , (long) *( (unsigned long  *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_LONG_PTR : /* long * */
         case CTYPE_UNSIGNED_LONG_PTR : /* unsigned long * */
            hb_itemPutPtr( pBaseVar->pItems + ulIndex , (void *) ( Buffer + uiOffset ) );
            break;

         case CTYPE_FLOAT : /* float */
            hb_itemPutND( pBaseVar->pItems + ulIndex , (double) *( (float *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_FLOAT_PTR : /* float * */
            hb_itemPutPtr( pBaseVar->pItems + ulIndex , (void *) ( Buffer + uiOffset ) );
            break;

         case CTYPE_DOUBLE : /* double */
            hb_itemPutND( pBaseVar->pItems + ulIndex , *( (double *) ( Buffer + uiOffset ) ) );
            break;

         case CTYPE_DOUBLE_PTR : /* double * */
         case CTYPE_VOID_PTR : /* void * */
            hb_itemPutPtr( pBaseVar->pItems + ulIndex , (void *) ( Buffer + uiOffset ) );
            break;

         default:
         {
            unsigned int uiNestedSize /*, uiNestedAlign */ ;
            PHB_ITEM pID = hb_itemPutNI( NULL, ( pBaseDef->pItems + ulIndex )->item.asInteger.value );
            PHB_ITEM pStructure = hb_itemDoC( "HB_CSTRUCTUREFROMID", 1, pID );

            hb_itemRelease( pID );

            if( ! HB_IS_OBJECT( pStructure ) )
            {
               hb_itemRelease( pStructure );
               hb_errRT_BASE( EG_ARG, 2023, NULL, "StructureToArray", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
               return pRet;
            }

            hb_objSendMsg( pStructure, "NALIGN", 0 );
            hb_objSendMsg( pStructure, "SizeOf", 0 );
            uiNestedSize = (unsigned int) hb_parnl( -1 );

            /* TraceLog( NULL, "* NestedSize: %i Offset: %i\n", uiNestedSize, uiOffset ); */

            if( ( pBaseDef->pItems + ulIndex )->item.asInteger.value > CTYPE_STRUCTURE_PTR )
            {
               /* printf( "Offset %i Pointer: %p\n", uiOffset, *(char **) ( (long ** )( Buffer + uiOffset ) ) ); */

               if( *(char **) ( (long ** )( Buffer + uiOffset ) ) )
               {
                  PHB_BASEARRAY pBaseStructure = pStructure->item.asArray.value;
                  PHB_ITEM pInternalBuffer = pBaseStructure->pItems + pBaseStructure->ulLen - 1;

                  if( !bAdoptNested )
                  {
                     hb_itemPutCRawStatic( pInternalBuffer, *(char **) ( (long **)( Buffer + uiOffset ) ), uiNestedSize );
                  }
                  else
                  {
                     hb_itemPutCRaw( pInternalBuffer, *(char **) ( (long **)( Buffer + uiOffset ) ), uiNestedSize );
                  }

                  hb_objSendMsg( pStructure, "DEVALUE", 0 );
               }
               else
               {
                  /* hb_objSendMsg( pStructure, "RESET", 0 ); */
                  hb_itemClear( pStructure );
               }
            }
            else
            {
               PHB_BASEARRAY pBaseStructure = pStructure->item.asArray.value;
               PHB_ITEM pInternalBuffer = pBaseStructure->pItems + pBaseStructure->ulLen - 1;
               HB_ITEM Adopt;

               Adopt.type = HB_IT_LOGICAL;
               Adopt.item.asLogical.value = bAdoptNested;

               /* TraceLog( NULL, "Before Devalue\n" ); */

               hb_itemPutCRawStatic( pInternalBuffer, (char *) (BYTE *)( Buffer + uiOffset ), uiNestedSize );

               hb_objSendMsg( pStructure, "DEVALUE", 1, &Adopt );

               /* TraceLog( NULL, "After Devalue\n" ); */
            }

            hb_itemForwardValue( pBaseVar->pItems + ulIndex, pStructure );

            hb_itemRelease( pStructure );
         }
      }

      uiOffset += uiMemberSize;

      /* TraceLog( NULL, "AFTER Size: %i Offset: %i\n", uiMemberSize, uiOffset ); */
   }

   return pRet;
}
cstructc.c1053
HB_FUNCHB_STRUCTURETOARRAY(void)
HB_FUNC( HB_STRUCTURETOARRAY )
{
   PHB_ITEM Structure = hb_param( 1, HB_IT_STRING );
   PHB_ITEM aDef      = hb_param( 2, HB_IT_ARRAY );
   PHB_ITEM pAlign    = hb_param( 3, HB_IT_INTEGER );
   PHB_ITEM pAdopt    = hb_param( 4, HB_IT_LOGICAL );
   PHB_ITEM pRet      = hb_param( 5, HB_IT_ARRAY );
   BOOL bAdopt;

   if( Structure && aDef )
   {
      BYTE  *Buffer = (BYTE *) Structure->item.asString.value;
      unsigned int uiAlign;

      if( pAlign )
      {
         uiAlign = (BYTE) pAlign->item.asInteger.value;
      }
      else
      {
         uiAlign = 8;
      }

      if( pAdopt )
      {
         bAdopt = pAdopt->item.asLogical.value;
      }
      else
      {
         bAdopt = FALSE;
      }

      hb_itemReturnForward( StructureToArray( Buffer, Structure->item.asString.length, aDef, uiAlign, bAdopt, pRet ) );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 2023, NULL, "StructureToArray", 2, hb_paramError( 1 ), hb_paramError( 2 ) );
   }
}
cstructc.c1367
HB_FUNCHB_POINTER2STRING(void)
HB_FUNC( HB_POINTER2STRING )
{
   PHB_ITEM pPointer = hb_param( 1, HB_IT_ANY );
   PHB_ITEM pLen     = hb_param( 2, HB_IT_NUMERIC );

   if( HB_IS_POINTER( pPointer ) && pLen )
   {
      hb_retclen( (char *) hb_itemGetPtr( pPointer ), (ULONG) hb_itemGetNL( pLen ) );
   }
   else if( HB_IS_INTEGER( pPointer ) && pLen )
   {
      hb_retclen( (char *) (HB_PTRDIFF) hb_itemGetNI( pPointer ), (ULONG) hb_itemGetNL( pLen ) );
   }
   else if( HB_IS_LONG( pPointer ) && pLen )
   {
      hb_retclen( (char *) (HB_PTRDIFF) hb_itemGetNL( pPointer ), (ULONG) hb_itemGetNL( pLen ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, 2, hb_paramError( 1 ), hb_paramError( 2 ) );
}
cstructc.c1407
HB_FUNCHB_STRING2POINTER(void)
HB_FUNC( HB_STRING2POINTER )
{
   char * pszString = hb_parc( 1 );

   if( pszString )
      hb_retptr( ( void * ) pszString );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
}
cstructc.c1428
HB_FUNC__CSTR_COPYTO(void)
HB_FUNC( __CSTR_COPYTO )
{
   static PHB_DYNS s_pVALUE = NULL;
   PHB_ITEM pTarget = hb_param( 1, HB_IT_ANY );
   PHB_ITEM pStructure;
   void *pPointer;

   if( s_pVALUE == NULL )
      s_pVALUE = hb_dynsymGetCase( "VALUE" );

   if( HB_IS_LONG( pTarget ) )
      pPointer = ( void * ) ( HB_PTRDIFF ) hb_itemGetNInt( pTarget );
#if UINT_MAX == ULONG_MAX
   else if( HB_IS_INTEGER( pTarget ) )
      pPointer = ( void * ) ( HB_PTRDIFF ) hb_itemGetNInt( pTarget );
#endif
   else if( HB_IS_POINTER( pTarget ) )
      pPointer = hb_itemGetPtr( pTarget );
   else
   {
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "C Structure:CopyTo()", 1, hb_paramError( 1 ) );
      return;
   }

   pStructure = hb_stackSelfItem();
   hb_vmPushDynSym( s_pVALUE );
   hb_vmPush( pStructure );
   hb_vmSend(0);

   memcpy( pPointer, (void *) hb_parc( -1 ), hb_arrayGetNI( pStructure, hb_arrayLen( pStructure ) - 2 ) );
}
cstructc.c1439
freadlin.c
TypeFunctionSourceLine
BYTE *hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL * bEOF )
BYTE * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL * bEOF )
{
   USHORT uiPosTerm = 0, iPos, uiPosition;
   USHORT nTries;
   LONG lRead = 0, lOffset, lSize;
   BYTE * pBuff;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLine(%p, %ld, %p, %p, %hu, %i, %i)", hFileHandle, *plBuffLen, Term, iTermSizes, iTerms, *bFound, *bEOF ));

   *bFound  = FALSE;
   *bEOF    = FALSE;
   nTries   = 0;
   lOffset  = 0;
   lSize    = *plBuffLen;

   if( *plBuffLen < 10 )
      *plBuffLen = READING_BLOCK;

   pBuff = ( BYTE * ) hb_xgrab( *plBuffLen );

   do
   {
      if( nTries > 0 )
      {
         /* pBuff can be enlarged to hold the line as needed.. */
         lSize = ( *plBuffLen * ( nTries + 1 ) ) + 1;
         pBuff = ( BYTE * ) hb_xrealloc( pBuff, lSize );
         lOffset += lRead;
      }

      /* read from file */
      lRead = hb_fsReadLarge( hFileHandle, pBuff + lOffset, lSize - lOffset );

      /* scan the read buffer */

      if( lRead > 0 )
      {
         for( iPos = 0; iPos < lRead; iPos++ )
         {
            for( uiPosTerm = 0; uiPosTerm < iTerms; uiPosTerm++ )
            {
               /* Compare with the LAST terminator byte */
               if( pBuff[lOffset+iPos] == Term[uiPosTerm][iTermSizes[uiPosTerm]-1] && (iTermSizes[uiPosTerm]-1) <= (iPos+lOffset) )
               {
                  *bFound = TRUE;

                  for(uiPosition=0; uiPosition < (iTermSizes[uiPosTerm]-1); uiPosition++)
                  {
                     if(Term[uiPosTerm][uiPosition] != pBuff[ lOffset+(iPos-iTermSizes[uiPosTerm])+uiPosition+1 ])
                     {
                        *bFound = FALSE;
                        break;
                     }
                  }

                  if( *bFound )
                     break;
               }
            }

            if( *bFound )
               break;
         }

         if( *bFound )
         {
            *plBuffLen = lOffset + iPos - iTermSizes[ uiPosTerm ] + 1;

            pBuff[ *plBuffLen ] = '\0';

            /* Set handle pointer in the end of the line */
            hb_fsSeek( hFileHandle, (((lRead-((LONG)iPos)))*-1)+1, FS_RELATIVE );

            return( pBuff );
         }
      }
      else
      {
         if( ! *bFound )
         {
            if( nTries == 0 )
            {
               pBuff[ 0 ] = '\0';
               *plBuffLen = 0;
            }
            else
            {
               pBuff[ lOffset + lRead ] = '\0';
               *plBuffLen = lOffset + lRead;
            }

            *bEOF = TRUE;
         }
      }

      nTries++;
   }
   while( ( ! *bFound ) && lRead > 0 );

   return( pBuff );
}
freadlin.c63
HB_FUNCHB_FREADLINE(void)
HB_FUNC( HB_FREADLINE )
{
   PHB_ITEM pTerm1;
   HB_FHANDLE hFileHandle  = ( HB_FHANDLE ) hb_parnl( 1 );
   char ** Term;
   BYTE * pBuffer;
   int * iTermSizes;
   LONG lSize = hb_parnl( 4 );
   USHORT i, iTerms;
   BOOL bFound, bEOF;

   if( ( !ISBYREF( 2 ) ) || ( !ISNUM( 1 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 4, 
         hb_paramError( 1 ), 
         hb_paramError( 2 ), 
         hb_paramError( 3 ), 
         hb_paramError( 4 ) );
      return;
   }

   if( ISARRAY( 3 ) || ISCHAR( 3 ) )
   {
      if( ISARRAY( 3 ) )
      {
         pTerm1 = hb_param( 3, HB_IT_ARRAY );
         iTerms = ( USHORT ) hb_arrayLen( pTerm1 );

         if( iTerms <= 0 )
         {
            hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 4,
               hb_paramError( 1 ), 
               hb_paramError( 2 ), 
               hb_paramError( 3 ), 
               hb_paramError( 4 ) );
            return;
         }

         Term = ( char ** ) hb_xgrab( sizeof( char * ) * iTerms );
         iTermSizes = ( int * ) hb_xgrab( sizeof( int ) * iTerms );

         for( i = 0; i < iTerms; i++ )
         {
            Term[ i ]       = hb_arrayGetCPtr( pTerm1, i + 1 );
            iTermSizes[ i ] = hb_arrayGetCLen( pTerm1, i + 1 );
         }
      }
      else
      {
         pTerm1          = hb_param( 3, HB_IT_STRING );
         Term            = ( char ** ) hb_xgrab( sizeof( char * ) );
         iTermSizes      = ( int * ) hb_xgrab( sizeof( int ) );
         Term[ 0 ]       = ( char * ) hb_itemGetCPtr( pTerm1 );
         iTermSizes[ 0 ] = hb_itemGetCLen( pTerm1 );
         iTerms          = 1;
      }
   }
   else
   {
      Term            = ( char ** ) hb_xgrab( sizeof( char * ) );
      iTermSizes      = ( int * ) hb_xgrab( sizeof( int ) );
      Term[ 0 ]       = ( char * ) "\r\n";    /* Should be preplaced with the default EOL sequence */
      iTerms          = 1;
      iTermSizes[ 0 ] = 2;
   }

   if( lSize == 0 )
      lSize = READING_BLOCK;

   pBuffer = hb_fsReadLine( hFileHandle, &lSize, Term, iTermSizes, iTerms, &bFound, &bEOF );

   if( ! hb_storclen_buffer( ( char * ) pBuffer, lSize, 2 ) )
      hb_xfree( pBuffer );
   hb_retnl( bEOF ? -1 : 0 );
   hb_xfree( Term );
   hb_xfree( iTermSizes );
}
freadlin.c167
hbcomprs.c
TypeFunctionSourceLine
ULONGhb_destBuflen( ULONG srclen )
ULONG hb_destBuflen( ULONG srclen )
{
   ULONG ret = srclen;

   ret += ret / 100*15 + 12;
   if ( srclen % 100 != 0 ) ret+=15;
   return ret;
}
hbcomprs.c67
HB_FUNCHB_COMPRESS(void)
HB_FUNC( HB_COMPRESS )
{
   char *cDest, *cSource;
   ULONG ulSrclen, ulDstlen, ulBufLen;
   PHB_ITEM pSource, pDest =NULL, pDestLen = NULL;
   int nCompFactor, iFirst;
   int cerr;

   if ( ISNUM(1) )
   {
      nCompFactor = hb_parni( 1 );
      iFirst = 1;
   }
   else
   {
      nCompFactor = Z_DEFAULT_COMPRESSION;
      iFirst = 0;
   }

   pSource = hb_param( iFirst + 1, HB_IT_STRING );

   if( pSource == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) );
      return;
   }

   cSource = hb_itemGetCPtr( pSource ); 
   if (hb_pcount() > iFirst + 1 )
   {
      ulSrclen = (ULONG) hb_parnl( iFirst + 2 );
   }
   else
   {
      ulSrclen = hb_itemGetCLen( pSource ); 
   }

   /* Allocation mode: user provided or allocated here */
   if ( hb_pcount() == iFirst + 4 )
   {
      pDest = hb_param( iFirst + 3, HB_IT_BYREF);
      pDestLen = hb_param( iFirst + 4, HB_IT_BYREF);
      ulDstlen = hb_parnl( iFirst + 4 );
      cDest = NULL;
      ulBufLen = 0;
      if( pDest && pDestLen && ulDstlen > 0 )
      {
         pDest = hb_itemUnShare( pDest );
         if( HB_IS_STRING( pDest ) )
         {
            cDest = hb_itemGetCPtr( pDest );
            ulBufLen = hb_itemGetCLen( pDest );
         }
      }
      if( cDest == NULL || ulBufLen < ulDstlen )
      {
         hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) );
         return;
      }
   }
   else
   {
      ulDstlen = hb_destBuflen( ulSrclen );
      cDest = (char *) hb_xgrab( ulDstlen + 1 );
   }

   cerr = compress2( ( Bytef * ) cDest, &ulDstlen, ( const Bytef * ) cSource, ulSrclen, nCompFactor );

   if ( cerr != Z_OK )
   {
      if ( pDest != NULL )
      {
         hb_retni( cerr );
      }
      else
      {
         hb_xfree( cDest );
         hb_ret();
      }
   }
   else
   {
      if (pDestLen != NULL )
      {
         hb_stornl( iFirst + 4, ( LONG ) ulDstlen );
         hb_retni( Z_OK );
      }
      else
      {
         hb_retclenAdopt( cDest, ulDstlen );
      }
   }
   s_hb_compress_error = cerr;
}
hbcomprs.c83
HB_FUNCHB_UNCOMPRESS(void)
HB_FUNC( HB_UNCOMPRESS )
{
   char *cDest, *cSource;
   ULONG ulSrclen, ulDstlen, ulBufLen;
   PHB_ITEM pSource, pDest;
   int cerr;

   pSource = hb_param( 2, HB_IT_STRING );

   if( ! ISNUM(1) || pSource == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) );
      return;
   }

   cSource = hb_itemGetCPtr( pSource ); 
   ulDstlen = (ULONG) hb_parnl( 1 );
   if (hb_pcount() > 2 )
   {
      ulSrclen = (ULONG) hb_parnl( 3 );
   }
   else
   {
      ulSrclen = hb_itemGetCLen( pSource ); 
   }

   /* Allocation mode: user provided or allocated here */
   if ( hb_pcount() == 4 )
   {
      pDest = hb_param( 4, HB_IT_BYREF);
      cDest = NULL;
      ulBufLen = 0;
      if( pDest )
      {
         pDest = hb_itemUnShare( pDest );
         if( HB_IS_STRING( pDest ) )
         {
            cDest = hb_itemGetCPtr( pDest );
            ulBufLen = hb_itemGetCLen( pDest );
         }
      }
      if( cDest == NULL || ulBufLen < ulDstlen )
      {
         hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) );
         return;
      }
   }
   else
   {
      cDest = (char *) hb_xgrab( ulDstlen + 1 );
   }

   cerr = uncompress( ( Bytef * ) cDest, &ulDstlen, ( const Bytef * ) cSource, ulSrclen );

   if ( cerr != Z_OK )
   {
      if ( hb_pcount() == 4 )
      {
         hb_retni( cerr );
      }
      else
      {
         hb_xfree( cDest );
         hb_ret();
      }
   }
   else
   {
      if ( hb_pcount() == 4 )
      {
         hb_retni( Z_OK );
      }
      else
      {
         hb_retclenAdopt( cDest, ulDstlen );
      }
   }
   s_hb_compress_error = cerr;
}
hbcomprs.c184
HB_FUNCHB_COMPRESSERROR(void)
HB_FUNC( HB_COMPRESSERROR )
{
   hb_retni( s_hb_compress_error );
}
hbcomprs.c264
HB_FUNCHB_COMPRESSERRORDESC(void)
HB_FUNC( HB_COMPRESSERRORDESC )
{
   hb_retcAdopt( hb_strdup( zError( hb_parni( 1 ) ) ) );
}
hbcomprs.c276
HB_FUNCHB_COMPRESSBUFLEN(void)
HB_FUNC( HB_COMPRESSBUFLEN )
{
   hb_retnl( (LONG) hb_destBuflen( hb_parni(1) ) );
}
hbcomprs.c285
hbcrypt.c
TypeFunctionSourceLine
VOIDnxs_crypt( const unsigned char *source, ULONG srclen, const unsigned char *key, ULONG keylen, BYTE *cipher )
void nxs_crypt(
   const unsigned char *source, ULONG srclen,
   const unsigned char *key, ULONG keylen,
   BYTE *cipher )
{

   if(keylen > NXS_MAX_KEYLEN )
   {
      keylen = NXS_MAX_KEYLEN;
   }

#ifdef DEBUG_0
   memcpy( cipher, source, srclen );
#endif

   /* pass one: scramble the source using the key */
   nxs_scramble( source, srclen, key, keylen, cipher );

   /* pass two: xor the source with the key
      threebit mutual shift is done also here */
   nxs_xorcode( cipher, srclen, key, keylen );

   /* pass three: xor the source with the cyclic key */
   nxs_xorcyclic( cipher, srclen, key, keylen );
}
hbcrypt.c82
VOIDnxs_decrypt( const unsigned char *cipher, ULONG cipherlen, const unsigned char *key, ULONG keylen, BYTE *result )
void nxs_decrypt(
   const unsigned char *cipher, ULONG cipherlen,
   const unsigned char *key, ULONG keylen,
   BYTE *result )
{
   if(keylen > NXS_MAX_KEYLEN )
   {
      keylen = NXS_MAX_KEYLEN;
   }

   memcpy( result, cipher, cipherlen );

   /* pass one: xor the source with the cyclic key */
   nxs_xorcyclic( result, cipherlen, key, keylen );

   /* pass two: xor the source with the key
      threebit mutual shift is done also here */
   nxs_xordecode( result, cipherlen, key, keylen );

   /* pass three: unscramble the source using the key */
   nxs_unscramble( result, cipherlen, key, keylen );
}
hbcrypt.c110
VOIDnxs_scramble( const unsigned char *source, ULONG srclen, const unsigned char *key, ULONG keylen, BYTE *cipher )
void nxs_scramble(
      const unsigned char *source, ULONG srclen,
      const unsigned char *key, ULONG keylen,
      BYTE *cipher )
{
   int scramble[ NXS_MAX_KEYLEN ];
   ULONG len;

   if ( keylen > NXS_MAX_KEYLEN )
   {
      keylen = NXS_MAX_KEYLEN;
   }

   if ( keylen > srclen )
   {
      keylen = srclen;
   }

   /* First step: find key ordering */
   nxs_make_scramble( scramble, key, keylen );

   /* Leave alone the last block */
   len = (srclen / keylen) * keylen;
   nxs_partial_scramble( source, cipher, scramble, len, keylen );

   keylen = srclen - len;
   nxs_make_scramble( scramble, key, keylen );
   nxs_partial_scramble( source + len, cipher + len, scramble, keylen, keylen );
}
hbcrypt.c133
VOIDnxs_partial_scramble( const unsigned char *source, BYTE *cipher, int *scramble, ULONG len, ULONG keylen )
void nxs_partial_scramble(
   const unsigned char *source, BYTE *cipher,
   int *scramble,
   ULONG len, ULONG keylen )
{
   ULONG pos;
   USHORT kpos;

   pos = 0l;
   kpos = 0;
   while( pos + kpos < len )
   {
      cipher[ pos + scramble[ kpos ] ] = source[ pos + kpos ];
      kpos++;
      if ( kpos >= (USHORT) keylen )
      {
         kpos = 0;
         pos += keylen;
      }
   }
}
hbcrypt.c166
VOIDnxs_unscramble( BYTE *cipher, ULONG cipherlen, const unsigned char *key, ULONG keylen)
void nxs_unscramble(
      BYTE *cipher, ULONG cipherlen,
      const unsigned char *key, ULONG keylen)
{
   int scramble[ NXS_MAX_KEYLEN ];
   ULONG len;

   if ( keylen > NXS_MAX_KEYLEN )
   {
      keylen = NXS_MAX_KEYLEN;
   }

   if ( keylen > cipherlen )
   {
      keylen = cipherlen;
   }

   /* First step: find key ordering */
   nxs_make_scramble( scramble, key, keylen );

   /* Leave alone the last block */
   len = (cipherlen / keylen) * keylen;
   nxs_partial_unscramble( cipher, scramble, len , keylen );

   keylen = cipherlen - len;
   nxs_make_scramble( scramble, key, keylen );
   nxs_partial_unscramble( cipher+len, scramble, keylen, keylen );
}
hbcrypt.c188
VOIDnxs_partial_unscramble( BYTE *cipher, int *scramble, ULONG len, ULONG keylen )
void nxs_partial_unscramble(
   BYTE *cipher,
   int *scramble,
   ULONG len, ULONG keylen )
{
   ULONG pos;
   USHORT kpos;
   BYTE buf[ NXS_MAX_KEYLEN ];

   pos = 0l;
   kpos = 0;
   while( pos + kpos < len )
   {
      buf[ kpos ] = cipher[ pos + scramble[ kpos ]  ];
      kpos++;
      if ( kpos >= (USHORT) keylen )
      {
         memcpy( cipher + pos, buf, keylen );
         kpos = 0;
         pos += keylen;
      }
   }
}
hbcrypt.c219
VOIDnxs_xorcode( BYTE *cipher, ULONG cipherlen, const unsigned char *key, ULONG keylen )
void nxs_xorcode(
   BYTE *cipher, ULONG cipherlen,
   const unsigned char *key, ULONG keylen )
{
   ULONG pos = 0l;
   USHORT keypos = 0;
   BYTE c_bitrest;

   c_bitrest = cipher[ 0 ] >>5;

   while ( pos < cipherlen )
   {
      cipher[pos] <<= 3;

      if (keypos == (USHORT) keylen-1 || pos == cipherlen -1 )
      {
         cipher[pos] |= c_bitrest;
      }
      else
      {
         cipher[pos] |= cipher[pos+1] >> 5;
      }

      cipher[pos] ^= key[ keypos ];
      keypos ++;
      pos++;

      if (keypos == (USHORT) keylen )
      {
         keypos = 0;
         c_bitrest = cipher[ pos ] >>5;
      }
   }
}
hbcrypt.c243
VOIDnxs_xordecode( BYTE *cipher, ULONG cipherlen, const unsigned char *key, ULONG keylen )
void nxs_xordecode(
   BYTE *cipher, ULONG cipherlen,
   const unsigned char *key, ULONG keylen )
{
   ULONG pos = 0l;
   USHORT keypos = 0;
   BYTE c_bitrest, c_bitleft;

   /* A very short block? */
   if ( keylen > cipherlen - pos )
   {
      keylen = ( USHORT ) ( cipherlen - pos);
   }
   c_bitleft = ( cipher[ keylen -1 ] ^ key[ keylen -1 ])<< 5;

   while ( pos < cipherlen )
   {
      cipher[pos] ^= key[ keypos ];

      c_bitrest = cipher[ pos ] <<5;
      cipher[pos] >>= 3;
      cipher[pos] |= c_bitleft;
      c_bitleft = c_bitrest;

      keypos ++;
      pos ++;

      if (keypos == (USHORT) keylen )
      {
         keypos = 0;
         /* last block */
         if ( keylen > cipherlen - pos )
         {
            keylen = ( USHORT ) (cipherlen - pos);
         }

         c_bitleft = ( cipher[ pos + keylen -1 ] ^ key[ keylen -1 ])<< 5;
      }
   }
}
hbcrypt.c280
VOIDnxs_xorcyclic( BYTE *cipher, ULONG cipherlen, const unsigned char *key, ULONG keylen )
void nxs_xorcyclic(
   BYTE *cipher, ULONG cipherlen,
   const unsigned char *key, ULONG keylen )
{
   ULONG pos=0l, crcpos=0l;
   ULONG crc1, crc2, crc3;
   ULONG crc1l, crc2l, crc3l;

   /* Build the cyclic key seed */
   crc1 = keylen >= 2 ? hb_adler32( 0, key + 0, keylen - 2 ) : 1;
   crc2 = keylen >= 4 ? hb_adler32( 0, key + 2, keylen - 4 ) : 1;
   crc3 = keylen >= 2 ? hb_adler32( 0, key + 1, keylen - 2 ) : 1;

   crc1l = crc1 = nxs_cyclic_sequence( crc1 );
   crc2l = crc2 = nxs_cyclic_sequence( crc2 );
   crc3l = crc3 = nxs_cyclic_sequence( crc3 );

   while ( pos < cipherlen)
   {
      if ( crcpos < 4 )
      {
         /* this ensures portability across platforms */
         cipher[ pos ] ^= (BYTE) (crc1l % 256 );
         crc1l /= 256l;
      }
      else if ( crcpos < 8 )
      {
         cipher[ pos ] ^= (BYTE) (crc2l % 256 );
         crc2l /= 256l;
      }
      else {
         cipher[ pos ] ^= (BYTE) (crc3l % 256 );
         crc3l /= 256l;
      }
      crcpos++;
      pos++;

      if (crcpos == 12 )
      {
         crcpos = 0;
         crc1l = crc1 = nxs_cyclic_sequence( crc1 );
         crc2l = crc2 = nxs_cyclic_sequence( crc2 );
         crc3l = crc3 = nxs_cyclic_sequence( crc3 );
      }
   }
}
hbcrypt.c321
ULONGnxs_cyclic_sequence( ULONG input )
ULONG nxs_cyclic_sequence( ULONG input )
{
   ULONG first = input & 0xffff;
   ULONG second = input >> 16;
   ULONG ret = ( ( second * BASE * BASE ) & 0xffff ) |
         ( (first * BASE * BASE) &0xffff0000);

   return ret;
}
hbcrypt.c369
VOIDnxs_make_scramble( int *scramble, const unsigned char *key, ULONG keylen )
void nxs_make_scramble( int *scramble, const unsigned char *key, ULONG keylen )
{
   ULONG i,j, tmp;

   for (i = 0; i < keylen; i ++ )
   {
      scramble[ i ] = i;
   }

   for( i = 0; i < keylen; i ++ )
   {
      for( j = i + 1; j < keylen; j ++ )
      {
         if( key[ scramble[ j ] ] < key[ scramble[ i ] ] )
         {
            tmp = scramble[ j ];
            scramble[ j ] = scramble[ i ];
            scramble[ i ] = tmp;
            j = i;
         }
      }
   }
}

/*
* END OF NXS
*/

hbcrypt.c380
HB_FUNCHB_CRYPT(void)
HB_FUNC( HB_CRYPT )
{
   PHB_ITEM pSource = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pKey = hb_param( 2, HB_IT_STRING );
   BYTE *cRes;

   if ( pSource == NULL || hb_itemGetCLen( pSource ) == 0 ||
        pKey == NULL || hb_itemGetCLen( pKey ) == 0 )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 2,
            hb_param(1,HB_IT_ANY), hb_param(2,HB_IT_ANY) );
      return;
   }

   cRes = (BYTE *) hb_xgrab( hb_itemGetCLen( pSource ) + 8 );

   nxs_crypt(
      (BYTE *) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ),
      (BYTE *) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ),
      cRes);

   hb_retclenAdopt( (char *)cRes, hb_itemGetCLen( pSource ) );
}
hbcrypt.c418
HB_FUNCHB_DECRYPT(void)
HB_FUNC( HB_DECRYPT )
{
   PHB_ITEM pSource = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pKey = hb_param( 2, HB_IT_STRING );
   BYTE *cRes;

   if ( pSource == NULL || hb_itemGetCLen( pSource ) == 0 ||
        pKey == NULL || hb_itemGetCLen( pKey ) == 0 )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 2,
            hb_param(1,HB_IT_ANY), hb_param(2,HB_IT_ANY) );
      return;
   }

   cRes = ( BYTE * ) hb_xgrab( hb_itemGetCLen( pSource ) + 8 );

   nxs_decrypt(
      (BYTE *) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ),
      (BYTE *) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ),
      cRes);

   hb_retclenAdopt( (char *)cRes, hb_itemGetCLen( pSource ) );
}
hbcrypt.c448
hboutdbg.c
TypeFunctionSourceLine
STATIC VOIDdebugInit( void )
static void debugInit( void )
{
   int iPid, iFifoResult;
   char szDebugTitle[30];
   PHB_FNAME pFileName = NULL;
   char szDebugName[128];

   if( ! s_iUseDebugName )
   {
      int iRand = (int) (hb_random_num()*1000000);
      pFileName = hb_fsFNameSplit( hb_cmdargARGV()[0] );
      snprintf( szDebugName, 127, "/tmp/%s%d_dbg", pFileName->szName, iRand );
   }
   else
   {
      snprintf(szDebugName, 127, "/tmp/%s_dbg", s_szDebugName );
      pFileName = hb_fsFNameSplit( szDebugName );
   }

   iFifoResult = mkfifo( szDebugName, 0666 );
   if ( iFifoResult == -1 )
   {
      iFifoResult = errno;
   }   
   if ( iFifoResult == 0 || iFifoResult == EEXIST )
   {
      if ( strlen( pFileName->szName ) > 20 )
      {
         ( ( char * ) pFileName->szName )[20] = 0;
      }
      snprintf( szDebugTitle, sizeof( szDebugTitle ), "%s - Debug", pFileName->szName );


      iPid = fork();
      if ( iPid != 0 )
      {
         s_iDebugFd = open( szDebugName, O_WRONLY );
         s_iXtermPid = iPid;
      }
      else
      {
         if ( iFifoResult != EEXIST ) {
            s_iXtermPid = execlp( "xterm", "xterm", "-T", szDebugTitle, "-e",
               "cat", szDebugName, NULL );

            if ( s_iXtermPid <= 0 ) {
               int lastresort = open( szDebugName, O_RDONLY );
               if ( lastresort >= 0 )
               {
                  close( lastresort );
               }
            }

         }
      }
   }
   hb_xfree( pFileName );
}
hboutdbg.c81
HB_FUNCHB_OUTDEBUGNAME(void)
HB_FUNC( HB_OUTDEBUGNAME )
{
#if defined(HB_OS_UNIX)
   PHB_ITEM pName = hb_param( 1, HB_IT_STRING );

   if ( s_iDebugFd == 0 && pName != NULL)
   {
      hb_strncpy( s_szDebugName, hb_itemGetCPtr( pName ), sizeof( s_szDebugName ) - 1 );
      s_iUseDebugName = 1;

      hb_retl( TRUE );
   }
   else if ( pName == NULL)
   {
      s_iUseDebugName = 0;
      hb_retl( TRUE );
   }
   else
   {
      hb_retl( FALSE );
   }
#endif
}
hboutdbg.c142
HB_FUNCHB_OUTDEBUG(void)
HB_FUNC( HB_OUTDEBUG )
{
   #if defined(HB_OS_UNIX)
   int iStatus, iPid;

   /* Are we under X? */
   if ( getenv("DISPLAY") != NULL)
   {
      if ( s_iDebugFd <= 0 || s_iXtermPid == 0 )
      {
         debugInit();
      }

      /* On error, drop it */
      if ( s_iDebugFd <= 0 || s_iXtermPid == 0 )
      {
         return;
      }

      /* Chech if display process has terminated in the meanwhile */
      if (! s_iUseDebugName )
      {
         iPid = waitpid( s_iXtermPid, &iStatus,  WNOHANG );
         if ( iPid == s_iXtermPid || iPid == -1 )
         {
            s_iXtermPid = 0;
            /* close( s_iDebugFd ); */
            s_iDebugFd = 0;
            return;
         }
      }

      if ( s_iDebugFd > 0 && ISCHAR(1) )
      {
         fd_set wrds;
         struct timeval tv = { 0, 100000 }; /* wait each time a tenth of second */
         FD_ZERO(&wrds);
         FD_SET(s_iDebugFd, &wrds);

         if( select( s_iDebugFd + 1, NULL, &wrds, NULL, &tv ) > 0 )
         {
            write( s_iDebugFd, hb_parcx(1), hb_parclen(1) );
            write( s_iDebugFd, "\n", 1 );
         }
      }
   }
   #elif defined(__WIN32__)

   if( ISCHAR(1) )
   {
      LPTSTR lpMsg = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
      OutputDebugString( lpMsg );
      HB_TCHAR_FREE( lpMsg );
   }

   #endif
}
hboutdbg.c166
hbsyslog.c
TypeFunctionSourceLine
HB_FUNCHB_SYSLOGOPEN(void)
HB_FUNC( HB_SYSLOGOPEN )
{
   #if defined( HB_OS_WIN_32 )
      #if (WINVER >= 0x0400)
      /* Ok, we compiled under NT, but we must not use this function
         when RUNNING on a win98. */
      if( hb_iswinnt() )
      {
         s_RegHandle = RegisterEventSource(NULL, (LPCTSTR) hb_parcx(1));
         hb_retl( TRUE );
      }
      else {
         hb_retl( FALSE );
      }
      #else
         s_RegHandle = NULL;
         hb_retl( FALSE );
      #endif
   #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
      openlog( hb_parcx(1), LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER );
      hb_retl( TRUE );
   #else
      hb_retl( FALSE );
   #endif
}
hbsyslog.c23
HB_FUNCHB_SYSLOGCLOSE(void)
HB_FUNC( HB_SYSLOGCLOSE )
{
   #if defined( HB_OS_WIN_32 )
      #if (WINVER >= 0x0400)
      if( hb_iswinnt() )
      {
         DeregisterEventSource( s_RegHandle);
         hb_retl( TRUE );
      }
      else
      {
         hb_retl( FALSE );
      }
      #else
         hb_retl( FALSE );
      #endif
   #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
      closelog();
      hb_retl( TRUE );
   #else
      hb_retl( FALSE );
   #endif
}
hbsyslog.c49
HB_FUNCHB_SYSLOGMESSAGE(void)
HB_FUNC( HB_SYSLOGMESSAGE )
{
   #if defined( HB_OS_WIN_32 )
      #if (WINVER >= 0x0400)
      WORD logval;
      if( hb_iswinnt() )
      {
         LPTSTR lpMsg = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
         switch( hb_parni( 2 ) )
         {
            case HB_LOG_CRITICAL: logval = EVENTLOG_ERROR_TYPE; break;
            case HB_LOG_ERROR: logval = EVENTLOG_ERROR_TYPE; break;
            case HB_LOG_WARN: logval = EVENTLOG_WARNING_TYPE; break;
            case HB_LOG_INFO: logval = EVENTLOG_INFORMATION_TYPE; break;
            default:
               logval = EVENTLOG_AUDIT_SUCCESS;
         }
         hb_retl( ReportEvent(s_RegHandle,         /* event log handle */
                              logval,              /* event type */
                              0,                   /* category zero */
                              (DWORD) hb_parnl(3), /* event identifier */
                              NULL,                /* no user security identifier */
                              1,                   /* one substitution string */
                              0,                   /* no data */
                              (LPCTSTR *) &lpMsg,  /* pointer to string array */
                              NULL                 /* pointer to data */
                             ) ? TRUE : FALSE );
         HB_TCHAR_FREE( lpMsg );
      }
      else
      {
         hb_retl( FALSE );
      }

      #else
         hb_retl( FALSE );
      #endif
   #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ )
      int logval;

      switch( hb_parni(2) )
      {
         case HB_LOG_CRITICAL: logval = LOG_CRIT; break;
         case HB_LOG_ERROR: logval = LOG_ERR; break;
         case HB_LOG_WARN: logval = LOG_WARNING; break;
         case HB_LOG_INFO: logval = LOG_INFO; break;
         default:
            logval = LOG_DEBUG;
      }

      syslog( logval, "[%lX]: %s", hb_parnl(3), hb_parcx(1) );
      hb_retl( TRUE );
   #else
      hb_retl( FALSE );
   #endif
}
hbsyslog.c73
hbxml.c
TypeFunctionSourceLine
STATIC VOIDhbxml_set_doc_status( MXML_REFIL *ref, PHB_ITEM doc, PHB_ITEM pNode, int status, int error )
static void hbxml_set_doc_status( MXML_REFIL *ref, PHB_ITEM doc, PHB_ITEM pNode, int status, int error )
{
   PHB_ITEM pNumber = hb_itemPutNI( NULL, 1 );

   hb_objSendMsg( doc, "_NSTATUS", 1 , pNumber );
   hb_itemPutNI( pNumber, error );
   hb_objSendMsg( doc, "_NERROR", 1 , pNumber );
   hb_objSendMsg( doc, "_OERRORNODE", 1 , pNode );
   hb_itemRelease( pNumber );

   /* ref->status is often used as an error marker even if the error wasn't from i/o */
   ref->status = (MXML_STATUS) status;
   ref->error = (MXML_ERROR_CODE) error;
}
hbxml.c163
STATIC VOIDhbxml_doc_new_line( PHB_ITEM pDoc )
static void hbxml_doc_new_line( PHB_ITEM pDoc )
{
   PHB_ITEM pNumber;

   hb_objSendMsg( pDoc, "NLINE", 0 );
   pNumber = hb_itemPutNI( NULL, hb_parni( -1 ) + 1 );
   hb_objSendMsg( pDoc, "_NLINE", 1 , pNumber );
   hb_itemRelease( pNumber );
}
hbxml.c179
STATIC VOIDhbxml_doc_new_node( PHB_ITEM pDoc, int amount )
static void hbxml_doc_new_node( PHB_ITEM pDoc, int amount )
{
   PHB_ITEM pNumber;

   hb_objSendMsg( pDoc, "NNODECOUNT", 0 );
   pNumber = hb_itemPutNI( NULL, hb_parni( -1 ) + amount );
   hb_objSendMsg( pDoc, "_NNODECOUNT", 1 , pNumber );
   hb_itemRelease( pNumber );

   /* TODO: launch a callback */
}
hbxml.c189
STATIC MXML_STATUSmxml_attribute_read( MXML_REFIL *ref, PHB_ITEM pDoc, PHB_ITEM pNode, PHBXML_ATTRIBUTE pDest, int style )
static MXML_STATUS mxml_attribute_read( MXML_REFIL *ref, PHB_ITEM pDoc, PHB_ITEM pNode, PHBXML_ATTRIBUTE pDest, int style )
{
   int chr, quotechr = '"';
   MXML_SGS *buf_name;
   MXML_SGS *buf_attrib;
   int iStatus = 0;
   int iPosAmper = 0;
   int iLenName, iLenAttrib;

   buf_name = mxml_sgs_new();
   buf_attrib = mxml_sgs_new();
   HB_SYMBOL_UNUSED( style );

   while ( iStatus < 6 )
   {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF ) break;

      switch ( iStatus ) {
         /* begin */
         case 0:
            switch ( chr ) {
               case MXML_LINE_TERMINATOR: hbxml_doc_new_line( pDoc ); break;
               /* We repeat line terminator here for portability */
               case MXML_SOFT_LINE_TERMINATOR: break;
               case ' ': case '\t': break;
               /* no attributes found */
               case '>': case '/':
                  mxml_sgs_destroy( buf_name );
                  mxml_sgs_destroy( buf_attrib );
                  return MXML_STATUS_DONE;

               default:
                  if ( isalpha( chr ) )
                  {
                     if ( mxml_sgs_append_char( buf_name, ( char ) chr ) != MXML_STATUS_OK )
                     {
                        hbxml_set_doc_status( ref, pDoc, pNode,
                           MXML_STATUS_MALFORMED, MXML_ERROR_NAMETOOLONG );
                        return MXML_STATUS_MALFORMED;
                     }
                     iStatus = 1;
                  }
                  else {
                     hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_INVATT );
                     return MXML_STATUS_MALFORMED;
                  }
            }
         break;

         /* scanning for a name */
         case 1:
            if ( isalnum( chr ) || chr == '_' || chr == '-' || chr == ':' )
            {
               if ( mxml_sgs_append_char( buf_name, ( char ) chr ) != MXML_STATUS_OK )
               {
                  hbxml_set_doc_status( ref, pDoc, pNode,
                     MXML_STATUS_MALFORMED, MXML_ERROR_NAMETOOLONG );
                  return MXML_STATUS_MALFORMED;
               }
            }
            else if( chr == MXML_LINE_TERMINATOR )
            {
               hbxml_doc_new_line( pDoc );
               iStatus = 2; /* waiting for a '=' */
            }
            /* We repeat line terminator here for portability */
            else if ( chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r' )
            {
               iStatus = 2;
            }
            else if ( chr == '=' ) {
               iStatus = 3;
            }
            else {
               hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_MALFATT );
               return MXML_STATUS_MALFORMED;
            }
         break;

         /* waiting for '=' */
         case 2:
            if ( chr == '=' )
            {
               iStatus = 3;
            }
            else if( chr == MXML_LINE_TERMINATOR )
            {
               hbxml_doc_new_line( pDoc );
            }
            /* We repeat line terminator here for portability */
            else if ( chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r' )
            {
            }
            else {
               hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_MALFATT );
               return MXML_STATUS_MALFORMED;
            }
         break;

         /* waiting for ' or " */
         case 3:
            if ( chr == '\'' || chr == '"' )
            {
               iStatus = 4;
               quotechr = chr;
            }
            else if( chr == MXML_LINE_TERMINATOR )
             {
               hbxml_doc_new_line( pDoc );
            }
            /* We repeat line terminator here for portability */
            else if ( chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r' )
            {
            }
            else {
               hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_MALFATT );
               return MXML_STATUS_MALFORMED;
            }
         break;

         /* scanning the attribute content ( until next quotechr ) */
         case 4:
            if ( chr == quotechr )
            {
               iStatus = 6;
            }
            else if ( chr == '&' && !( style & MXML_STYLE_NOESCAPE) )
            {
               iStatus = 5;
               iPosAmper = buf_attrib->length;
               mxml_sgs_append_char( buf_attrib, ( char ) chr ); /* we'll need it */
            }
            else if( chr == MXML_LINE_TERMINATOR )
            {
               hbxml_doc_new_line( pDoc );
               if ( mxml_sgs_append_char( buf_attrib, ( char ) chr ) != MXML_STATUS_OK )
               {
                  hbxml_set_doc_status( ref, pDoc, pNode,
                     MXML_STATUS_MALFORMED, MXML_ERROR_ATTRIBTOOLONG );
                  return MXML_STATUS_MALFORMED;
               }
            }
            /* We repeat line terminator here for portability */
            else
            {
               if ( mxml_sgs_append_char( buf_attrib, ( char ) chr ) != MXML_STATUS_OK )
               {
                  hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_ATTRIBTOOLONG );
                  return MXML_STATUS_MALFORMED;
               }
            }
         break;

         case 5:
            if ( chr == ';' )
            {
               int iAmpLen = buf_attrib->length - iPosAmper - 2;
               /* Taking the address of a sgs buffer is legal */
               char *bp = buf_attrib->buffer + iPosAmper + 1;

               if ( iAmpLen <= 0 )
               {
                  /* error! - we have "&;" */
                  hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_WRONGENTITY );
                  return MXML_STATUS_MALFORMED;
               }

               iStatus = 4;

               /* we see if we have a predef entity (also known as escape) */
               if ( strncmp( bp, "amp", iAmpLen ) == 0 ) chr = '&';
               else if ( strncmp( bp, "lt", iAmpLen ) == 0 ) chr = '<';
               else if ( strncmp( bp, "gt", iAmpLen ) == 0 ) chr = '>';
               else if ( strncmp( bp, "quot", iAmpLen ) == 0 ) chr = '"';
               else if ( strncmp( bp, "apos", iAmpLen ) == 0 ) chr = '\'';
               /** Reducing an SGS length is legal */
               buf_attrib->length = iPosAmper;
               mxml_sgs_append_char( buf_attrib, ( char ) chr );
            }
            else if ( ! isalpha( chr ) )
            {
               /* error - we have something like & & */
               hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_WRONGENTITY );
               return MXML_STATUS_MALFORMED;
            }
            else
            {
               if ( mxml_sgs_append_char( buf_attrib, ( char ) chr ) != MXML_STATUS_OK )
               {
                  hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_ATTRIBTOOLONG );
                  return MXML_STATUS_MALFORMED;
               }
            }
         break;
      }

   }

   if ( ref->status != MXML_STATUS_OK )
   {
      return ref->status;
   }

   if ( iStatus < 6 )
   {
      hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED,MXML_ERROR_MALFATT);
      mxml_sgs_destroy( buf_name );
      mxml_sgs_destroy( buf_attrib );
      return MXML_STATUS_MALFORMED;
   }

   /* time to create the attribute */
   iLenName = buf_name->length;
   iLenAttrib = buf_attrib->length;

   pDest->pName  = hb_itemPutCL( pDest->pName,  mxml_sgs_extract( buf_name ),   iLenName );
   pDest->pValue = hb_itemPutCL( pDest->pValue, mxml_sgs_extract( buf_attrib ), iLenAttrib );

   return MXML_STATUS_OK;
}
hbxml.c207
STATIC MXML_STATUSmxml_attribute_write( MXML_OUTPUT *out, PHBXML_ATTRIBUTE pAttr, int style )
static MXML_STATUS mxml_attribute_write( MXML_OUTPUT *out, PHBXML_ATTRIBUTE pAttr, int style )
{
   char *name = hb_itemGetCPtr( pAttr->pName );

   mxml_output_string_len( out, name, hb_itemGetCLen( pAttr->pName ) );
   mxml_output_char( out, '=' );
   mxml_output_char( out, '"' );

   if ( style & MXML_STYLE_NOESCAPE )
   {
      mxml_output_string_escape( out, hb_itemGetCPtr( pAttr->pValue ) );
   }
   else
   {
      mxml_output_string_len( out, hb_itemGetCPtr( pAttr->pValue ),
                                   hb_itemGetCLen( pAttr->pValue ) );
   }
   mxml_output_char( out, '"' );

   return out->status;
}
hbxml.c429
STATIC PHB_ITEMmxml_node_new( PHB_ITEM pDoc )
static PHB_ITEM mxml_node_new( PHB_ITEM pDoc )
{
   PHB_ITEM pNode;
   PHB_DYNS pExecSym;

   pExecSym = hb_dynsymGetCase( "TXMLNODE" );
   hb_vmPushDynSym( pExecSym );
   hb_vmPushNil();
   hb_vmDo( 0 );

   /* The node is in the return */
   hb_objSendMsg( hb_param( -1, HB_IT_ANY ), "NEW", 0 );
   pNode = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   /* Sets also current node line begin value, if the node is from a document */
   if( pDoc != NULL )
   {
      hb_objSendMsg( pDoc, "NLINE", 0 );
      hb_objSendMsg( pNode, "_NBEGINLINE", 1 , hb_param( -1, HB_IT_ANY ) );
   }
   /* Else, leaves nBeginLine at 0 */

   return pNode;
}
hbxml.c459
STATIC VOIDmxml_node_unlink( PHB_ITEM pNode )
static void mxml_node_unlink( PHB_ITEM pNode )
{
   PHB_ITEM pPrev, pNext, pParent, pNil;

   pNil = hb_itemNew( NULL );

   hb_objSendMsg( pNode, "OPREV", 0 );
   pPrev = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   hb_objSendMsg( pNode, "ONEXT", 0 );
   pNext = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   hb_objSendMsg( pNode, "OPARENT", 0 );
   pParent = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   /* Detaching from previous */
   if( !HB_IS_NIL( pPrev ) )
   {
      hb_objSendMsg( pPrev, "_ONEXT", 1, pNext );
      hb_objSendMsg( pNode, "_ONEXT", 1, pNil );
   }

   /* Detaching from Next */
   if( !HB_IS_NIL( pNext ) )
   {
      hb_objSendMsg( pNext, "_OPREV", 1, pPrev );
      hb_objSendMsg( pNode, "_OPREV", 1, pNil );
   }

   /* Detaching from parent */
   if( !HB_IS_NIL( pParent ) )
   {
      /* Eventually set the next node as first child */
      if( HB_IS_NIL( pPrev ) ) /* was I the first node? */
         hb_objSendMsg( pParent , "_OCHILD", 1, pNext );
      hb_objSendMsg( pNode, "_OPARENT", 1, pNil);
   }

   hb_itemRelease( pPrev );
   hb_itemRelease( pNext );
   hb_itemRelease( pParent );
   hb_itemRelease( pNil );
}
hbxml.c494
HB_FUNCHBXML_NODE_UNLINK(void)
HB_FUNC( HBXML_NODE_UNLINK )
{
   mxml_node_unlink( hb_param( 1, HB_IT_OBJECT ) );
}
hbxml.c538
STATIC VOIDmxml_node_insert_before( PHB_ITEM pTg, PHB_ITEM pNode )
static void mxml_node_insert_before( PHB_ITEM pTg, PHB_ITEM pNode )
{
   PHB_ITEM pParent;

   /* Move tg->prev into node->prev */
   hb_objSendMsg( pTg, "OPREV", 0 );
   hb_objSendMsg( pNode, "_OPREV", 1, hb_param( -1, HB_IT_ANY ) );

   /* tg->prev is now pnode! */
   hb_objSendMsg( pTg, "_OPREV", 1, pNode );

   /* pNode->next is TG */
   hb_objSendMsg( pNode, "_ONEXT", 1, pTg );

   /* pNode->parent is the same as tg */
   hb_objSendMsg( pTg, "OPARENT", 0 );
   pParent = hb_itemNew( hb_param( -1, HB_IT_ANY ) );
   hb_objSendMsg( pNode, "_OPARENT", 1, pParent );

   /* if the parent is not null, and if it's child was tg, we must update to node */
   if( !HB_IS_NIL( pParent ) )
   {
      hb_objSendMsg( pParent, "OCHILD", 0 );
      if( hb_arrayId( hb_param( -1, HB_IT_ANY ) ) == hb_arrayId( pTg ) )
      {
         hb_objSendMsg( pParent, "_OCHILD", 1, pNode );
      }
   }

   hb_itemRelease( pParent );
}
hbxml.c544
HB_FUNCHBXML_NODE_INSERT_BEFORE(void)
HB_FUNC( HBXML_NODE_INSERT_BEFORE )
{
   mxml_node_insert_before( hb_param( 1, HB_IT_OBJECT ), hb_param( 2, HB_IT_OBJECT ) );
}
hbxml.c576
STATIC VOIDmxml_node_insert_after( PHB_ITEM pTg, PHB_ITEM pNode )
static void mxml_node_insert_after( PHB_ITEM pTg, PHB_ITEM pNode )
{
   /* Move tg->next into node->next */
   hb_objSendMsg( pTg, "ONEXT", 0 );
   hb_objSendMsg( pNode, "_ONEXT", 1, hb_param( -1, HB_IT_ANY ) );

   /* tg->NEXT is now pnode! */
   hb_objSendMsg( pTg, "_ONEXT", 1, pNode );

   /* pNode->prev is TG */
   hb_objSendMsg( pNode, "_OPREV", 1, pTg );

   /* pNode->parent is the same as tg */
   hb_objSendMsg( pTg, "OPARENT", 0 );
   hb_objSendMsg( pNode, "_OPARENT", 1, hb_param( -1, HB_IT_ANY ) );
}
hbxml.c582
HB_FUNCHBXML_NODE_INSERT_AFTER(void)
HB_FUNC( HBXML_NODE_INSERT_AFTER )
{
   mxml_node_insert_after( hb_param( 1, HB_IT_OBJECT ), hb_param( 2, HB_IT_OBJECT ) );
}
hbxml.c599
STATIC VOIDmxml_node_insert_below( PHB_ITEM pTg, PHB_ITEM pNode )
static void mxml_node_insert_below( PHB_ITEM pTg, PHB_ITEM pNode )
{
   PHB_ITEM pChild;

   /* Move tg->child into node->child */
   hb_objSendMsg( pTg, "OCHILD", 0 );
   pChild = hb_itemNew( hb_param( -1, HB_IT_ANY ) );
   hb_objSendMsg( pNode, "_OCHILD", 1, pChild );

   /* Parent of pNode is now TG */
   hb_objSendMsg( pNode, "_OPARENT", 1, pTg );

   /* All children parents are moved to pNode */
   while( !HB_IS_NIL( pChild ) )
   {
      hb_objSendMsg( pChild, "_OPARENT", 1, pNode );
      hb_objSendMsg( pChild, "ONEXT", 0);
      hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );
   }
   hb_itemRelease( pChild );
}
hbxml.c609
HB_FUNCHBXML_NODE_INSERT_BELOW(void)
HB_FUNC( HBXML_NODE_INSERT_BELOW )
{
   mxml_node_insert_below( hb_param( 1, HB_IT_OBJECT ), hb_param( 2, HB_IT_OBJECT ) );
}
hbxml.c632
STATIC VOIDmxml_node_add_below( PHB_ITEM pTg, PHB_ITEM pNode )
static void mxml_node_add_below( PHB_ITEM pTg, PHB_ITEM pNode )
{
   PHB_ITEM pChild;

   /* Parent of pNode is now TG */
   hb_objSendMsg( pNode, "_OPARENT", 1, pTg );

   /* Get the TG child */
   hb_objSendMsg( pTg, "OCHILD", 0 );
   pChild = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   if( !HB_IS_NIL( pChild ) )
   {
      /* Scanning up to the last child */
      while ( 1 )
      {
         hb_objSendMsg( pChild, "ONEXT", 0);
         if( HB_IS_NIL( hb_param( -1, HB_IT_ANY ) ) )
            break;
         hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );
      }
      /* linking the child with pnode */
      hb_objSendMsg( pChild, "_ONEXT", 1, pNode );
      hb_objSendMsg( pNode, "_OPREV", 1, pChild );
   }
   else
   {
      /* if we are the first child, we notify pTg of this */
      hb_objSendMsg( pTg, "_OCHILD", 1, pNode );
   }
   hb_itemRelease( pChild );
}
hbxml.c640
HB_FUNCHBXML_NODE_ADD_BELOW(void)
HB_FUNC( HBXML_NODE_ADD_BELOW )
{
   mxml_node_add_below( hb_param( 1, HB_IT_OBJECT ), hb_param( 2, HB_IT_OBJECT ) );
}
hbxml.c673
STATIC PHB_ITEMmxml_node_clone( PHB_ITEM pTg )
static PHB_ITEM mxml_node_clone( PHB_ITEM pTg )
{
   /* Node is not from a real document, so is right to leave nBeginLine at 0 */
   PHB_ITEM pNode = mxml_node_new( NULL );
   PHB_ITEM pArrayClone;

   /* sets clone type */
   hb_objSendMsg( pTg, "NTYPE", 0 );
   hb_objSendMsg( pNode, "_NTYPE", 1, hb_param( -1, HB_IT_ANY ) );

   /* sets clone name */
   hb_objSendMsg( pTg, "CNAME", 0 );
   hb_objSendMsg( pNode, "_CNAME", 1, hb_param( -1, HB_IT_ANY ) );

   /* sets clone data */
   hb_objSendMsg( pTg, "CDATA", 0 );
   hb_objSendMsg( pNode, "_CDATA", 1, hb_param( -1, HB_IT_ANY ) );

   /* clone attributes */
   hb_objSendMsg( pTg, "AATTRIBUTES", 0 );
   pArrayClone = hb_arrayClone( hb_param( -1, HB_IT_ANY ) );
   hb_objSendMsg( pNode, "_AATTRIBUTES", 1, pArrayClone );
   hb_itemRelease( pArrayClone );

   return pNode;
}
hbxml.c682
HB_FUNCHBXML_NODE_CLONE(void)
HB_FUNC( HBXML_NODE_CLONE )
{
   PHB_ITEM pClone = mxml_node_clone( hb_param( 1, HB_IT_OBJECT ) );

   hb_itemRelease( hb_itemReturn( pClone ) );
}
hbxml.c709
STATIC PHB_ITEMmxml_node_clone_tree( PHB_ITEM pTg )
static PHB_ITEM mxml_node_clone_tree( PHB_ITEM pTg )
{
   PHB_ITEM pClone = mxml_node_clone( pTg );
   PHB_ITEM pNode;

   /* Get the TG child */
   hb_objSendMsg( pTg, "OCHILD", 0 );
   pNode = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   while( !HB_IS_NIL( pNode ) )
   {
      PHB_ITEM pSubTree;

      pSubTree = mxml_node_clone_tree( pNode );
      /* the subtree is the child of the clone */
      hb_objSendMsg( pClone, "_OCHILD", 1, pSubTree );

      /* the parent of the subtree is the clone */
      hb_objSendMsg( pSubTree, "_OPARENT", 1, pClone );

      /* go to the next node */
      hb_objSendMsg( pNode, "ONEXT", 0 );
      hb_itemMove( pNode, hb_param( -1, HB_IT_ANY ) );
   }
   hb_itemRelease( pNode );

   return pClone;
}
hbxml.c721
HB_FUNCHBXML_NODE_CLONE_TREE(void)
HB_FUNC( HBXML_NODE_CLONE_TREE )
{
   PHB_ITEM pClone = mxml_node_clone_tree( hb_param( 1, HB_IT_OBJECT ) );

   hb_itemRelease( hb_itemReturn( pClone ) );
}
hbxml.c750
STATIC VOIDmxml_node_read_data( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc, int iStyle )
static void mxml_node_read_data( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc, int iStyle )
{
   char *buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   int iAllocated = MXML_ALLOC_BLOCK;
   int iPos = 0;
   int chr;
   PHB_ITEM pItem;
   int iStatus = 0, iPosAmper = 0;

   chr = mxml_refil_getc( ref );
   while ( chr != MXML_EOF ) {

      /* still in a data element */
      if ( chr != '<' ) {

         /* verify entity or escape */
         if ( chr == '&' && ! (iStyle & MXML_STYLE_NOESCAPE)) {

            if ( iStatus == 0 ) {
               iStatus = 1;
               iPosAmper = iPos;
            }
            else {
               /* error - we have something like & & */
               MXML_DELETOR( buf );
               hbxml_set_doc_status( ref, doc, pNode,
                        MXML_STATUS_MALFORMED, MXML_ERROR_UNCLOSEDENTITY );
               return;
            }
         }

         /* rightful closing of an entity */
         if ( chr == ';' && iStatus == 1 ) {
            int iAmpLen = iPos - iPosAmper - 2;
            char *bp = buf + iPosAmper + 1;

            if ( iAmpLen <= 0 ) {
               /* error! - we have "&;" */
               MXML_DELETOR( buf );
               hbxml_set_doc_status( ref, doc, pNode,
                        MXML_STATUS_MALFORMED, MXML_ERROR_WRONGENTITY );
               return;
            }

            iStatus = 0;

            /* we see if we have a predef entity (also known as escape) */
            if ( strncmp( bp, "amp", iAmpLen ) == 0 ) chr = '&';
            else if ( strncmp( bp, "lt", iAmpLen ) == 0 ) chr = '<';
            else if ( strncmp( bp, "gt", iAmpLen ) == 0 ) chr = '>';
            else if ( strncmp( bp, "quot", iAmpLen ) == 0 ) chr = '"';
            else if ( strncmp( bp, "apos", iAmpLen ) == 0 ) chr = '\'';

            /* if yes, we must put it at the place of the amper, and restart
               from there */
            if ( chr != ';' ) iPos = iPosAmper;
         }

         if ( chr == MXML_LINE_TERMINATOR )
         {
            hbxml_doc_new_line( doc );
         }

         buf[ iPos++ ] = ( char ) chr;

         if ( iPos >= iAllocated ) {
            iAllocated += MXML_ALLOC_BLOCK;
            buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
         }

      }
      else {
         mxml_refil_ungetc( ref, chr );
         break;
      }

      chr = mxml_refil_getc( ref );
   }

   if ( iStatus != 0  )
   {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_UNCLOSEDENTITY );
      return;
   }

   if ( ref->status != MXML_STATUS_OK )
   {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
      return;
   }

   /* trimming unneded spaces */
   while ( iPos >1 && isspace( (BYTE) buf[iPos-1] ) )
   {
      iPos--;
   }

   buf[ iPos ] = 0;

   pItem = hb_itemPutNI( NULL, MXML_TYPE_DATA );
   hb_objSendMsg( pNode, "_NTYPE", 1, pItem );

   if ( iAllocated > iPos + 1 )
   {
      buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
   }

   hb_itemPutCL( pItem, buf, iPos );
   hb_objSendMsg( pNode,"_CDATA", 1, pItem );
   hb_itemRelease( pItem );
}
hbxml.c757
STATIC MXML_STATUSmxml_node_read_name( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
static MXML_STATUS mxml_node_read_name( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
{
   PHB_ITEM pItem;
   char *buf;
   int iAllocated;
   int iPos = 0;
   int chr;
   int iStatus = 0;

   buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   iAllocated = MXML_ALLOC_BLOCK;

   while ( iStatus < 2 )
   {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF )
      {
         break;
      }

      switch ( iStatus )
      {
         case 0:
            if ( isalpha( chr ) ) {
               /* can't cause reallocations */
               buf[ iPos++ ] = ( char ) chr;
               iStatus = 1;
            }
            else
            {
               MXML_DELETOR( buf );
               hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_INVNODE );
               return MXML_STATUS_MALFORMED;
            }
         break;

         case 1:
            if ( isalnum( chr ) || chr == '_' || chr == '-' || chr == ':' )
            {
               /* can't cause reallocations */
               buf[ iPos++ ] = ( char ) chr;
            }
            else if ( chr == '>' || chr == ' ' || chr == '/' || chr == '\r'
                  || chr == '\t' || chr == '\n' )
            {
               mxml_refil_ungetc( ref, chr );
               iStatus = 2;
            }
            else
            {
               MXML_DELETOR( buf );
               hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_INVNODE );
               return MXML_STATUS_MALFORMED;
            }
         break;
      }

      if ( iPos >= iAllocated ) {
         iAllocated += MXML_ALLOC_BLOCK;
         buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
         if (! buf )
         {
            hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_NAMETOOLONG );
            return MXML_STATUS_MALFORMED;
         }
      }
  }

   if ( ref->status != MXML_STATUS_OK )
   {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
      return ref->status;
   }

   buf[ iPos ] = 0;
   if ( iAllocated > iPos + 1 )
   {
      buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
   }
   pItem = hb_itemPutCL( NULL, buf, iPos );
   hb_objSendMsg( pNode,"_CNAME", 1, pItem );
   hb_itemRelease( pItem );

   return MXML_STATUS_OK;
}
hbxml.c872
STATIC MXML_STATUSmxml_node_read_attributes( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc, int style )
static MXML_STATUS mxml_node_read_attributes( MXML_REFIL *ref,
         PHB_ITEM pNode, PHB_ITEM doc, int style )
{
   HBXML_ATTRIBUTE hbAttr;
   PHB_ITEM attributes;
   PHB_ITEM hbName;
   PHB_ITEM hbValue;
   MXML_STATUS ret;

   hbName = hb_itemNew( NULL );
   hbValue = hb_itemNew( NULL );
   attributes = hb_hashNew( NULL );

   hbAttr.pName = hbName;
   hbAttr.pValue = hbValue;

   ret = mxml_attribute_read( ref, doc, pNode, &hbAttr, style );
   while ( ret == MXML_STATUS_OK ) {
      hb_hashAdd( attributes, hbAttr.pName, hbAttr.pValue );
      ret = mxml_attribute_read( ref, doc, pNode, &hbAttr, style );
   }

   hb_objSendMsg( pNode,"_AATTRIBUTES", 1, attributes );
   /* Error already set.
   if ( ref->status != MXML_STATUS_OK )
   {
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
   } */
   hb_itemRelease( attributes );
   hb_itemRelease( hbValue );
   hb_itemRelease( hbName );

   return ref->status;
}
hbxml.c959
STATIC VOIDmxml_node_read_directive( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
static void mxml_node_read_directive( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
{
   char *buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   int iAllocated = MXML_ALLOC_BLOCK;
   int iPos = 0;
   int chr;

   if ( mxml_node_read_name( ref, pNode, doc ) == MXML_STATUS_OK )
   {
      chr = mxml_refil_getc( ref );
      while ( chr != MXML_EOF && chr != '>') {
         if ( iPos > 0 || ( chr != ' ' && chr != '\t' && chr != '\r' && chr != '\n' ) )
            buf[ iPos++ ] = ( char ) chr;

         if ( iPos >= iAllocated ) {
            iAllocated += MXML_ALLOC_BLOCK;
            buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
         }

         if ( chr == MXML_LINE_TERMINATOR )
         {
            hbxml_doc_new_line( doc );
         }

         chr = mxml_refil_getc( ref );
      }

      if ( ref->status == MXML_STATUS_OK ) {
         PHB_ITEM pItem = hb_itemPutNI( NULL, MXML_TYPE_DIRECTIVE );
         buf[ iPos ] = 0;
         hb_objSendMsg( pNode,"_NTYPE", 1, pItem );
         if ( iAllocated > iPos + 1 )
         {
            buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
         }
         hb_itemPutCL( pItem, buf, iPos );
         hb_objSendMsg( pNode,"_CDATA", 1, pItem );
         hb_itemRelease( pItem );
      }
      else {
         MXML_DELETOR( buf );
         hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
         return;
      }
   }
   else
   {
      MXML_DELETOR( buf );
   }
}
hbxml.c994
STATIC VOIDmxml_node_read_pi( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
static void mxml_node_read_pi( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
{
   int iPos = 0, iAllocated;
   int chr;
   char *buf;
   int iStatus = 0;

   /* let's read the xml PI instruction */
   if ( mxml_node_read_name( ref, pNode, doc ) != MXML_STATUS_OK )
   {
      return;
   }

   /* and then we'll put all the "data" into the data member, up to ?> */

   buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   iAllocated = MXML_ALLOC_BLOCK ;

   while ( iStatus < 2 ) {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF ) break;

      switch ( iStatus ) {
         /* scanning for ?> */
         case 0:
            if ( chr == MXML_LINE_TERMINATOR )
            {
               hbxml_doc_new_line( doc );
               buf[ iPos ++ ] = ( char ) chr;
            }
            else if ( chr == '?' )
               iStatus = 1;
            else {
               if ( iPos > 0 || ( chr != ' ' && chr != '\n' ) )
                  buf[ iPos++ ] = ( char ) chr;
            }
         break;

         case 1:
            if ( chr == '>' )
               iStatus = 2;
            else {
               iStatus = 0;
               buf[ iPos++ ] = '?';
               mxml_refil_ungetc( ref, chr );
            }
         break;

      }

      if ( iPos == iAllocated ) {
         iAllocated += MXML_ALLOC_BLOCK;
         buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
      }
   }

   if ( ref->status == MXML_STATUS_OK ) {
      PHB_ITEM pItem = hb_itemPutNI( NULL, MXML_TYPE_PI );
      buf[iPos] = 0;
      hb_objSendMsg( pNode,"_NTYPE", 1, pItem );
      if ( iAllocated > iPos + 1 )
      {
         buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
      }
      hb_itemPutCL( pItem, buf, iPos );
      hb_objSendMsg( pNode,"_CDATA", 1, pItem );
      hb_itemRelease( pItem );
   }
   else {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
   }
}
hbxml.c1045
STATIC VOIDmxml_node_read_tag( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc, int style )
static void mxml_node_read_tag( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc,
      int style )
{
   char chr;
   PHB_ITEM pItem;

   pItem = hb_itemPutNI( NULL, MXML_TYPE_TAG );
   hb_objSendMsg( pNode,"_NTYPE", 1, pItem );
   hb_itemRelease( pItem );

   if ( mxml_node_read_name( ref, pNode, doc ) == MXML_STATUS_OK )
   {
      if ( mxml_node_read_attributes( ref, pNode, doc, style ) != MXML_STATUS_OK )
      {
         return;
      }
   }

   /* if the list of attributes terminates with a '/', the last '>' is
      left unread. This means the current node is complete. */
   chr = ( char ) mxml_refil_getc( ref );
   if ( ref->status == MXML_STATUS_OK && chr != '>' )
   {
      mxml_refil_ungetc( ref, chr );
      /* recurse */
      if ( mxml_node_read( ref, pNode, doc, style ) != MXML_STATUS_OK )
      {
         return;
      }
   }
   else if ( ref->status != MXML_STATUS_OK )
   {
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
   }

   /* else the node is complete */
}
hbxml.c1119
STATIC VOIDmxml_node_read_comment( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
static void mxml_node_read_comment( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
{
   int iPos = 0, iAllocated;
   int chr;
   char *buf;
   int iStatus = 0;
   PHB_ITEM pItem;

   pItem = hb_itemPutNI( NULL, MXML_TYPE_COMMENT );
   hb_objSendMsg( pNode,"_NTYPE", 1, pItem );

   /* we'll put all the comment into the data member, up to -> */

   buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   iAllocated = MXML_ALLOC_BLOCK ;

   while ( iStatus < 3 ) {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF ) break;

      switch ( iStatus ) {
         /* scanning for -> */
         case 0:
            if ( chr == MXML_LINE_TERMINATOR )
            {
               hbxml_doc_new_line( doc );
               buf[ iPos ++ ] = ( char ) chr;
            }
            else if ( chr == '-' )
               iStatus = 1;
            else
               buf[ iPos++ ] = ( char ) chr;
         break;

         case 1:
            if ( chr == '-' )
               iStatus = 2;
            else {
               iStatus = 0;
               buf[ iPos++ ] = '-';
               mxml_refil_ungetc( ref, chr );
            }
         break;

         case 2:
            if ( chr == '>' )
               iStatus = 3;
            else {
               iStatus = 0;
               buf[ iPos++ ] = '-';
               mxml_refil_ungetc( ref, chr );
            }
         break;

      }

      if ( iPos == iAllocated )
      {
         iAllocated += MXML_ALLOC_BLOCK;
         buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
      }
   }

   if ( ref->status == MXML_STATUS_OK ) {
      buf[ iPos ] = 0;
      if ( iAllocated > iPos + 1 )
      {
         buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
      }
      hb_itemPutCL( pItem, buf, iPos );
      hb_objSendMsg( pNode,"_CDATA", 1, pItem );
   }
   else {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
   }
   hb_itemRelease( pItem );
}
hbxml.c1157
STATIC VOIDmxml_node_read_cdata( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM pDoc )
static void mxml_node_read_cdata( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM pDoc )
{
   int iPos = 0, iAllocated;
   int chr;
   char *buf;
   int iStatus = 0;
   PHB_ITEM pItem;

   pItem = hb_itemPutNI( NULL, MXML_TYPE_CDATA );
   hb_objSendMsg( pNode,"_NTYPE", 1, pItem );

   /* we'll put all the cdata into the data member, up to ]]>
      however, we are not still sure that this is really a cdata.
      we must finish to read it: */

   while ( iStatus < 6 ) {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF ) break;

      if ( chr == MXML_LINE_TERMINATOR )
      {
         hbxml_doc_new_line( pDoc );
         /* but is an error, so */
         iStatus = 100;
      }

      switch ( iStatus ) {
         /* scanning for C */
         case 0:
            if ( chr == 'C' )
            {
               iStatus = 1;
            }
            else
            {
               iStatus = 100; /* error */
            }
         break;

         case 1:
            if ( chr == 'D' )
            {
               iStatus = 2;
            }
            else
            {
               iStatus = 100;
            }
         break;

         case 2:
            if ( chr == 'A' )
            {
               iStatus = 3;
            }
            else
            {
               iStatus = 100;
            }
         break;

         case 3:
            if ( chr == 'T' )
            {
               iStatus = 4;
            }
            else
            {
               iStatus = 100;
            }
         break;

         case 4:
            if ( chr == 'A' )
            {
               iStatus = 5;
            }
            else
            {
               iStatus = 100;
            }
         break;

         case 5:
            if ( chr == '[' )
            {
               iStatus = 6;
            }
            else
            {
               iStatus = 100;
            }
         break;
      }

   }

   if ( iStatus == 100 )
   {
      hbxml_set_doc_status( ref, pDoc, pNode,
         MXML_STATUS_MALFORMED, MXML_ERROR_INVNODE );
   }
   else
   {
      iStatus = 0;

      buf = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
      iAllocated = MXML_ALLOC_BLOCK ;

      /* now we can read the node */
      while ( iStatus < 3 ) {
         chr = mxml_refil_getc( ref );
         if ( chr == MXML_EOF ) break;

         switch ( iStatus ) {
            /* scanning for -> */
            case 0:
               if ( chr == MXML_LINE_TERMINATOR )
               {
                  hbxml_doc_new_line( pDoc );
                  buf[ iPos ++ ] = ( char ) chr;
               }
               else if ( chr == ']' )
                  iStatus = 1;
               else
                  buf[ iPos++ ] = ( char ) chr;
            break;

            case 1:
               if ( chr == ']' )
                  iStatus = 2;
               else {
                  iStatus = 0;
                  buf[ iPos++ ] = ']';
                  mxml_refil_ungetc( ref, chr );
               }
            break;

            case 2:
               if ( chr == '>' )
                  iStatus = 3;
               else {
                  iStatus = 0;
                  buf[ iPos++ ] = ']';
                  mxml_refil_ungetc( ref, chr );
               }
            break;

         }

         if ( iPos == iAllocated )
         {
            iAllocated += MXML_ALLOC_BLOCK;
            buf = (char *) MXML_REALLOCATOR( buf, iAllocated );
         }
      }

      if ( ref->status == MXML_STATUS_OK ) {
         buf[ iPos ] = 0;
         if ( iAllocated > iPos + 1 )
         {
            buf = (char *) MXML_REALLOCATOR( buf, iPos + 1 );
         }
         hb_itemPutCL( pItem, buf, iPos );
         hb_objSendMsg( pNode,"_CDATA", 1, pItem );
      }
      else {
         MXML_DELETOR( buf );
         hbxml_set_doc_status( ref, pDoc, pNode, ref->status, ref->error );
      }
   }
   hb_itemRelease( pItem );
}
hbxml.c1236
STATIC INTmxml_node_read_closing( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
static int mxml_node_read_closing( MXML_REFIL *ref, PHB_ITEM pNode, PHB_ITEM doc )
{
   char *buf;
   int iPos = 0;
   int chr;
   int iLen;

   hb_objSendMsg( pNode,"CNAME", 0 );
   iLen = hb_parclen( -1 ) + 1;
   buf = (char *) MXML_ALLOCATOR( iLen );

   chr = mxml_refil_getc( ref );
   while ( chr != MXML_EOF && chr != '>' && iPos < iLen) {
      buf[ iPos++ ] = ( char ) chr;
      chr = mxml_refil_getc( ref );
   }

   if ( ref->status != MXML_STATUS_OK )
   {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error );
      return ref->status;
   }

   if ( chr != '>' || iPos == iLen || (strncmp( hb_parcx( -1 ), buf, iLen-1 ) != 0) )
   {
      MXML_DELETOR( buf );
      hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_UNCLOSED );
      return MXML_STATUS_MALFORMED;
   }
   /* all fine */
   MXML_DELETOR( buf );
   return MXML_STATUS_OK;
}
hbxml.c1410
STATIC MXML_STATUSmxml_node_read( MXML_REFIL *ref, PHB_ITEM pNode,PHB_ITEM doc, int style )
static MXML_STATUS mxml_node_read( MXML_REFIL *ref, PHB_ITEM pNode,PHB_ITEM doc, int style )
{
   PHB_ITEM node;

   int chr;
   /* Stateful machine status */
   int iStatus = 0;

   while ( iStatus >= 0 ) {
      chr = mxml_refil_getc( ref );
      if ( chr == MXML_EOF )
      {
         break;
      }

      if ( ref->status != MXML_STATUS_OK )
      {
         hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_INVNODE );
         return MXML_STATUS_MALFORMED;
      }
      /* resetting new node foundings */
      node = NULL;

      switch( iStatus )
      {

         case 0:  /* outside nodes */
            switch ( chr ) {
               case MXML_LINE_TERMINATOR: hbxml_doc_new_line( doc ); break;
               /* We repeat line terminator here for portability */
               case MXML_SOFT_LINE_TERMINATOR: break;
               case ' ': case '\t': break;
               case '<': iStatus = 1; break;
               default:  /* it is a data node */
                  mxml_refil_ungetc( ref, chr );
                  node = mxml_node_new( doc );
                  mxml_node_read_data( ref, node, doc, style );
            }
         break;

         case 1: /* inside a node, first character */
            if ( chr == '/' )
            {
               /* This can be met only inside current tag */
               iStatus = -1; /* done */
            }
            else if ( chr == '!' )
            {
               iStatus = 2;
            }
            else if ( chr == '?' )
            {
               node = mxml_node_new( doc );
               mxml_node_read_pi( ref, node, doc );
            }
            else if ( isalpha( chr ) )
            {
               mxml_refil_ungetc( ref, chr );
               node = mxml_node_new( doc );
               mxml_node_read_tag( ref, node, doc, style );
            }
            else
            {
               hbxml_set_doc_status( ref, doc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_INVNODE );
               return MXML_STATUS_MALFORMED;
            }
         break;

         case 2: /* inside a possible comment (status == MXML_STATUS_OK )
         {
            mxml_node_add_below( pNode, node );
            hb_itemRelease( node );
            /* beginning again - a new node is born */
            hbxml_doc_new_node( doc, 1 );
            iStatus = 0;
         }
         else
         {
            /* Error is already set in ref->status; it can't be an hard error, we catch it before.*/
            hb_itemRelease( node );
            /* node will be destroyed by GC when needed */
            return ref->status;
         }
      }

   }

   /* We can't have errors here; we would have been already returned */

   if ( iStatus == -1 )  /* ARE WE DONE ?*/
   {
      PHB_ITEM child_node, data_node = NULL;

      /* Time to close current node. We must verify:
         1) If the closing tag is coherent with the opened tag name.
         2) If the tag has just one data node as child.
         if we have only one data node among the children, the data
         node is destroyed and the data element is moved to the
         "data" field of current node, to simplify the tree structure
         in the most common config oriented XML files.
      */

      /* I/O error or malformed error during closing? */
      mxml_node_read_closing( ref, pNode, doc );
      if ( ref->status != MXML_STATUS_OK )
      {
         return ref->status;
      }

      /* checking for data nodes */
      hb_objSendMsg( pNode, "OCHILD", 0 );
      child_node = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

      while ( !HB_IS_NIL( child_node ) ) {
         hb_objSendMsg( child_node, "NTYPE", 0 );
         if ( hb_parni( -1 ) == MXML_TYPE_DATA )
         {
            /* first data node ? */
            if( data_node == NULL )
            {
               data_node = hb_itemNew( child_node );
            }
            /* ... or have we more than a data node? */
            else
            {
               hb_itemRelease( data_node );
               data_node = NULL;
               break;
            }
         }
         hb_objSendMsg( child_node, "ONEXT", 0 );
         hb_itemMove( child_node, hb_param( -1, HB_IT_ANY ) );
      }

      if ( data_node ) {
         hb_objSendMsg( data_node, "CDATA", 0 );
         hb_objSendMsg( pNode, "_CDATA", 1, hb_param( -1, HB_IT_ANY ) );

         mxml_node_unlink( data_node );
         /* garbage will take care of destroying it */
         hbxml_doc_new_node( doc, -1 );
         hb_itemRelease( data_node );
      }
      hb_itemRelease( child_node );

   }

   return MXML_STATUS_OK;
}
hbxml.c1446
STATIC VOIDmxml_node_write_attributes( MXML_OUTPUT *out, PHB_ITEM pAttr, int style )
static void mxml_node_write_attributes( MXML_OUTPUT *out, PHB_ITEM pAttr, int style )
{
   ULONG iLen = hb_hashLen( pAttr );
   ULONG i;
   HBXML_ATTRIBUTE hbAttr;

   for ( i = 1; i <= iLen; i ++ )
   {
      mxml_output_char( out, ' ' );
      hbAttr.pName = hb_hashGetKeyAt( pAttr, i );
      hbAttr.pValue = hb_hashGetValueAt( pAttr, i );

      mxml_attribute_write( out, &hbAttr, style );
   }
}
hbxml.c1634
STATIC VOIDmxml_node_file_indent( MXML_OUTPUT *out, int depth, int style )
static void mxml_node_file_indent( MXML_OUTPUT *out, int depth, int style )
{
   int i;

   for ( i = 0; i < depth; i++ ) {
      if ( style & MXML_STYLE_TAB )
         mxml_output_char( out, '\t');
      else if (  style & MXML_STYLE_THREESPACES )
         mxml_output_string_len( out, "   ", 3 );
      else
         mxml_output_char( out, ' ' );
   }
}
hbxml.c1650
STATIC MXML_STATUSmxml_node_write( MXML_OUTPUT *out, PHB_ITEM pNode, int style )
static MXML_STATUS mxml_node_write( MXML_OUTPUT *out, PHB_ITEM pNode, int style )
{
   PHB_ITEM pChild, pItem;
   int depth = 0;
   int mustIndent = 0;

   pChild = hb_itemNew( NULL );
   pItem = hb_itemNew( NULL );

   if ( style & MXML_STYLE_INDENT ) {
      hb_objSendMsg( pNode, "DEPTH", 0 );
      depth = hb_parni( -1 ) - 1;
      mxml_node_file_indent( out, depth, style );
   }

   hb_objSendMsg( pNode, "NTYPE", 0 );
   switch( hb_parni( -1 ) ) {
      case MXML_TYPE_TAG:

         mxml_output_char( out, '<' );
         hb_objSendMsg( pNode,"CNAME", 0 );
         mxml_output_string_len( out,
            hb_parc( -1 ), hb_parclen( -1 ) );

         hb_objSendMsg( pNode, "AATTRIBUTES", 0 );
         mxml_node_write_attributes( out, hb_param( -1, HB_IT_ANY ), style );

         hb_objSendMsg( pNode, "CDATA", 0 );
         /* itemcopy should not be applied to strings, as it rises the
            holders, and we don't want this */
         hb_itemMove( pItem, hb_param( -1, HB_IT_ANY ) );
         hb_objSendMsg( pNode, "OCHILD", 0 );
         hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );

         if( HB_IS_NIL( pItem ) && HB_IS_NIL( pChild ) )
         {
            mxml_output_string_len( out, "/>", 2 );
            mxml_output_string( out, hb_conNewLine() );
         }
         else
         {
            mxml_output_char( out, '>' );

            if ( !HB_IS_NIL( pChild ) ) {
               mustIndent = 1;
               mxml_output_string( out, hb_conNewLine() );

               while( !HB_IS_NIL( pChild ) )
               {
                  mxml_node_write( out, pChild, style );
                  hb_objSendMsg( pChild, "ONEXT", 0 );
                  hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );
               }
            }

            if ( !HB_IS_NIL( pItem ) )
            {
               if ( mustIndent && ( style & MXML_STYLE_INDENT ) )
               {
                     mxml_node_file_indent( out, depth+1, style );
               }

               if ( ! ( style & MXML_STYLE_NOESCAPE ) )
               {
                  mxml_output_string_escape( out, hb_itemGetCPtr( pItem ) );
               }
               else
               {
                  mxml_output_string_len( out, hb_itemGetCPtr( pItem ),
                                               hb_itemGetCLen( pItem ) );
               }
            }

            if ( mustIndent && ( style & MXML_STYLE_INDENT ))
               mxml_node_file_indent( out, depth, style );


            mxml_output_string_len( out, "' );
            mxml_output_string( out, hb_conNewLine() );
         }
      break;

      case MXML_TYPE_COMMENT:
            mxml_output_string_len( out, "", 4 );
            mxml_output_string( out, hb_conNewLine() );
      break;

      case MXML_TYPE_CDATA:
            mxml_output_string_len( out, "", 4 );
            mxml_output_string( out, hb_conNewLine() );
      break;

      case MXML_TYPE_DATA:
         hb_objSendMsg( pNode, "CDATA", 0 );
         if ( ! (style & MXML_STYLE_NOESCAPE) )
         {
            mxml_output_string_escape( out, hb_parcx( -1 ) );
         }
         else
         {
            mxml_output_string_len( out, hb_parcx( -1 ), hb_parclen( -1 ) );
         }
         mxml_output_string( out, hb_conNewLine() );
      break;

      case MXML_TYPE_DIRECTIVE:
         mxml_output_string_len( out, "' );
         mxml_output_string( out, hb_conNewLine() );
      break;

      case MXML_TYPE_PI:
         mxml_output_string_len( out, "", 2 );
         mxml_output_string( out, hb_conNewLine() );
      break;

      case MXML_TYPE_DOCUMENT:
         hb_objSendMsg( pNode, "OCHILD", 0 );
         hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );

         while( !HB_IS_NIL( pChild ) )
         {
            mxml_node_write( out, pChild, style );
            hb_objSendMsg( pChild, "ONEXT", 0 );
            hb_itemMove( pChild, hb_param( -1, HB_IT_ANY ) );
         }
         mxml_output_string( out, hb_conNewLine() );
      break;

   }

   hb_itemRelease( pItem );
   hb_itemRelease( pChild );

   if ( out->status != MXML_STATUS_OK ) {
      return out->status;
   }

   /* just for progress indicators */
   out->node_done++;

   return MXML_STATUS_OK;
}



/***********************************************************
   HBXML lib
   Virtual stream input/output routines
***********************************************************/

/**
* Creates a new output object
* In this case, the func member is required.
* Node count is optional, but highly wanted for progress indicators.
*/
hbxml.c1664
STATIC MXML_STATUSmxml_output_setup( MXML_OUTPUT *out, MXML_OUTPUT_FUNC func, int node_count)
static MXML_STATUS mxml_output_setup( MXML_OUTPUT *out, MXML_OUTPUT_FUNC func, int node_count)
{
   if ( func == NULL ) {
      return MXML_STATUS_ERROR;
   }

   out->output_func = func;
   out->node_count = node_count;
   out->node_done = 0;

   out->status = MXML_STATUS_OK;
   out->error = MXML_ERROR_NONE;
   return MXML_STATUS_ERROR;
}

/* Currently not used
static void mxml_output_destroy( MXML_OUTPUT *out )
{
   MXML_DELETOR( out );
}
*/

hbxml.c1869
STATIC MXML_STATUSmxml_output_char( MXML_OUTPUT *out, int c )
static MXML_STATUS mxml_output_char( MXML_OUTPUT *out, int c )
{
   char chr = (char) c;
   out->output_func( out, &chr, 1 );
   return out->status;
}
hbxml.c1894
STATIC MXML_STATUSmxml_output_string_len( MXML_OUTPUT *out, const char *s, int len )
static MXML_STATUS mxml_output_string_len( MXML_OUTPUT *out, const char *s, int len )
{
   out->output_func( out, s, len );
   return out->status;
}
hbxml.c1901
STATIC MXML_STATUSmxml_output_string( MXML_OUTPUT *out, const char *s)
static MXML_STATUS mxml_output_string( MXML_OUTPUT *out, const char *s)
{
   out->output_func( out, s, strlen(s) );
   return out->status;
}
hbxml.c1914
STATIC MXML_STATUSmxml_output_string_escape( MXML_OUTPUT *out, const char *s )
static MXML_STATUS mxml_output_string_escape( MXML_OUTPUT *out, const char *s )
{

   while ( *s ) {
      switch ( *s ) {
         case '"': mxml_output_string_len( out, """, 6 ); break;
         case '\'': mxml_output_string_len( out, "'", 6 ); break;
         case '&': mxml_output_string_len( out, "&", 5 ); break;
         case '<': mxml_output_string_len( out, "<", 4 ); break;
         case '>': mxml_output_string_len( out, ">", 4 ); break;
         default: mxml_output_char( out, *s );
      }

      if ( out->status != MXML_STATUS_OK ) break;
      s++;
   }

   return out->status;
}

hbxml.c1921
STATIC VOIDmxml_output_func_to_handle( MXML_OUTPUT *out, const char *s, int len )
static void mxml_output_func_to_handle( MXML_OUTPUT *out, const char *s, int len )
{
   HB_FHANDLE fh = out->u.hFile;
   int olen;

   olen = hb_fsWriteLarge( fh, (BYTE *) s, len );

   if ( olen < len )
   {
      out->status = MXML_STATUS_ERROR;
      out->error = MXML_ERROR_IO;
   }
}
hbxml.c1961
STATIC VOIDmxml_output_func_to_sgs( MXML_OUTPUT *out, const char *s, int len )
static void mxml_output_func_to_sgs( MXML_OUTPUT *out, const char *s, int len )
{
   MXML_SGS *sgs = (MXML_SGS *) out->u.vPtr;

   MXML_STATUS stat;

   if ( len == 1 )
      stat = mxml_sgs_append_char( sgs, *s );
   else
      stat = mxml_sgs_append_string_len( sgs, s, len );

   if ( stat != MXML_STATUS_OK )
   {
      out->status = MXML_STATUS_ERROR;
      out->error = MXML_ERROR_NOMEM;
   }
}


/***********************************************************
   HBXML lib
   Refiller routines
***********************************************************/


/**
* Creates a new refiller object.
* If buf is null, then buflen is ignored and set to 0; the first retrival
* of a character will then lead to refil func calling.
* If the function is null, once the data has been read the reader returns
* eof. If both func and buf are NULL, the creation fails, and the function
* retunrs NULL.
*/
hbxml.c1978
STATIC MXML_STATUSmxml_refil_setup( MXML_REFIL *ref, MXML_REFIL_FUNC func, char *buf, int buflen, int bufsize )
static MXML_STATUS mxml_refil_setup( MXML_REFIL *ref, MXML_REFIL_FUNC func,
   char *buf, int buflen, int bufsize )
{

   if ( buf == NULL && func == NULL )
      return MXML_STATUS_ERROR;

   ref->refil_func = func;
   ref->buffer = (BYTE*) buf;

   ref->status = MXML_STATUS_OK;
   ref->error = MXML_ERROR_NONE;

   if (buf == NULL)
      ref->buflen = ref->bufsize = 0;
   else
   {
      ref->buflen = buflen;
      ref->bufsize = bufsize;
   }

   ref->bufpos = 0;

   /* stream length is left for the program to implement progress indicators */
   ref->streamlen = 0;
   ref->streampos = 0;

   /* theese are for ungetc operations */
   ref->sparechar = MXML_EOF;

   /* data is left to fill for the program */
   return MXML_STATUS_OK;
}
hbxml.c2043
STATIC INTmxml_refil_getc( MXML_REFIL *ref )
static int mxml_refil_getc( MXML_REFIL *ref )
{
   if ( ref->sparechar != MXML_EOF )
   {
      int chr = ref->sparechar;
      ref->sparechar = MXML_EOF;
      return chr;
   }

   if ( ref->bufpos >= ref->buflen )
   {
      if ( ref->refil_func != NULL )
      {
         ref->refil_func( ref );
         if ( ref->status != MXML_STATUS_OK || ref->buflen == 0)
            return MXML_EOF;
      }
      else
         return MXML_EOF;
   }

   return ref->buffer[ ref->bufpos++ ];
}


hbxml.c2083
STATIC VOIDmxml_refill_from_handle_func( MXML_REFIL *ref )
static void mxml_refill_from_handle_func( MXML_REFIL *ref )
{
   HB_FHANDLE fh = ( HB_FHANDLE ) ref->u.hFile;
   int len;

   len = hb_fsReadLarge( fh, (BYTE *) ref->buffer, ref->bufsize );

   if ( len == -1 )
   {
      ref->status = MXML_STATUS_ERROR;
      ref->error = MXML_ERROR_IO;
   }
   else
   {
      ref->buflen = len;
      ref->bufpos = 0;
   }
}
hbxml.c2119
STATIC MXML_SGS mxml_sgs_new()
static MXML_SGS *mxml_sgs_new()
{
   MXML_SGS * ret = (MXML_SGS* ) MXML_ALLOCATOR( sizeof( MXML_SGS ) );

   if ( ret == NULL )
      return NULL;

   ret->buffer = (char *) MXML_ALLOCATOR( MXML_ALLOC_BLOCK );
   if ( ret->buffer == NULL ) {
      MXML_DELETOR( ret );
      return NULL;
   }

   ret->allocated = MXML_ALLOC_BLOCK;
   ret->length = 0;

   return ret;
}
hbxml.c2145
STATIC VOIDmxml_sgs_destroy( MXML_SGS *sgs )
static void mxml_sgs_destroy( MXML_SGS *sgs )
{
   if ( sgs->buffer != NULL )
      MXML_DELETOR( sgs->buffer );

   MXML_DELETOR( sgs );
}
hbxml.c2168
STATIC MXML_STATUSmxml_sgs_append_char( MXML_SGS *sgs, char c )
static MXML_STATUS mxml_sgs_append_char( MXML_SGS *sgs, char c )
{
   char *buf;
   sgs->buffer[ sgs->length++ ] = c;

   if ( sgs->length >= sgs->allocated ) {
      buf = (char *) MXML_REALLOCATOR( sgs->buffer, sgs->allocated + MXML_ALLOC_BLOCK );
      if ( buf == NULL )
      {
         return MXML_STATUS_ERROR;
      }
      sgs->allocated += MXML_ALLOC_BLOCK;
      sgs->buffer = buf;
   }

   return MXML_STATUS_OK;
}
hbxml.c2178
STATIC MXML_STATUSmxml_sgs_append_string_len( MXML_SGS *sgs, const char *s, int slen )
static MXML_STATUS mxml_sgs_append_string_len( MXML_SGS *sgs, const char *s, int slen )
{
   char *buf;

   if ( slen > 0 )
   {
      if ( sgs->length + slen >= sgs->allocated )
      {
         int blklen = ( ( sgs->length + slen ) / MXML_ALLOC_BLOCK + 1) * MXML_ALLOC_BLOCK;
         buf = (char *) MXML_REALLOCATOR( sgs->buffer, blklen );

         if ( buf == NULL )
            return MXML_STATUS_ERROR;

         sgs->allocated = blklen;
         sgs->buffer = buf;
      }

      memcpy( sgs->buffer + sgs->length , s, slen + 1 ); /* include also the trailing space */
      sgs->length += slen;
   }

   return MXML_STATUS_OK;
}
hbxml.c2196
STATIC CHAR *mxml_sgs_extract( MXML_SGS *sgs )
static char * mxml_sgs_extract( MXML_SGS *sgs )
{
   char *ret;
   sgs->buffer[ sgs->length ] = 0;

   if ( sgs->allocated > sgs->length + 1 )
   {
      ret = (char *) MXML_REALLOCATOR( sgs->buffer, sgs->length +1 );
   }
   else
   {
      ret = sgs->buffer;
   }

   MXML_DELETOR( sgs );

   return ret;
}

/***********************************************************
   HBXML lib
   Error code routines
***********************************************************/

static const char *edesc[] =
{
   "Input/output error",
   "Not enough memory",
   "Character outside tags",
   "Invalid character as tag name",
   "Invalid character as attribute name",
   "Malformed attribute definition",
   "Invalid character",
   "Name of tag too long",
   "Name of attribute too long",
   "Value of attribute too long",
   "Unbalanced tag closeure",
   "Unbalanced entity opening",
   "Escape/entity '&;' found"
};
hbxml.c2229
STATIC CONST CHAR mxml_error_desc( MXML_ERROR_CODE code )
static const char *mxml_error_desc( MXML_ERROR_CODE code )
{
   int iCode = ((int)code) - 1;
   if ( iCode < 0 || iCode > (signed) (sizeof( edesc ) / sizeof( char * ) ) )
      return NULL;

   return edesc[ iCode ];
}




hbxml.c2270
HB_FUNCHBXML_DATAREAD(void)
HB_FUNC( HBXML_DATAREAD )
{
   PHB_ITEM pParam = hb_param( 2, HB_IT_ANY );
   PHB_ITEM pDoc = hb_param( 1, HB_IT_OBJECT );
   int iStyle = hb_parni(3);
   PHB_ITEM pRoot;
   MXML_REFIL refil;
   char buffer[512];

   if( pDoc == NULL || pParam == NULL ||
       ( !HB_IS_STRING( pParam ) && !HB_IS_NUMERIC( pParam ) ) )
   {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }


   if( HB_IS_STRING( pParam ) )
   {
      ULONG ulLen = hb_itemGetCLen( pParam );
      mxml_refil_setup( &refil, NULL, hb_itemGetCPtr( pParam ), ulLen, ulLen );
   }
   else /* can only be an integer, that is, a file handle */
   {
      mxml_refil_setup( &refil,
         mxml_refill_from_handle_func,
         buffer, 0, 512 );

      refil.u.vPtr = (void *) hb_itemGetNL( pParam );
   }

   /* Now we can get the root node */
   hb_objSendMsg( pDoc, "OROOT", 0 );
   pRoot = hb_itemNew( hb_param( -1, HB_IT_ANY ) );
   hb_retni( mxml_node_read( &refil, pRoot, pDoc, iStyle ));
   hb_itemRelease( pRoot );
}
hbxml.c2295
HB_FUNCHB_XMLERRORDESC(void)
HB_FUNC( HB_XMLERRORDESC )
{
   PHB_ITEM pNum = hb_param(1, HB_IT_NUMERIC );

   if( pNum )
      hb_retc( mxml_error_desc( (MXML_ERROR_CODE) hb_itemGetNI( pNum ) ) );
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbxml.c2334
HB_FUNCHBXML_NODE_TO_STRING(void)
HB_FUNC( HBXML_NODE_TO_STRING )
{
   PHB_ITEM pNode = hb_param(1, HB_IT_OBJECT );
   PHB_ITEM pStyle = hb_param(2, HB_IT_NUMERIC );
   MXML_SGS *sgs;
   MXML_OUTPUT out;
   int iStyle;

   if( pNode == NULL )
   {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   if ( pStyle == NULL )
      iStyle = 0;
   else
      iStyle = hb_itemGetNI( pStyle );

   sgs = mxml_sgs_new();
   mxml_output_setup( &out, mxml_output_func_to_sgs , 0 );
   out.u.vPtr = ( void * ) sgs;

   if( mxml_node_write( &out, pNode, iStyle ) == MXML_STATUS_OK )
   {
      int iLen = sgs->length;
      char *buffer = mxml_sgs_extract( sgs );
      hb_retclen_buffer( buffer, iLen );
   }
   else
   {
      mxml_sgs_destroy( sgs );
      hb_ret();
   }
}
hbxml.c2356
HB_FUNCHBXML_NODE_WRITE(void)
HB_FUNC( HBXML_NODE_WRITE )
{
   PHB_ITEM pNode = hb_param(1, HB_IT_OBJECT );
   PHB_ITEM pHandle = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pStyle = hb_param(3, HB_IT_NUMERIC );
   MXML_OUTPUT out;
   int iStyle, iRet;

   if( pNode == NULL || pHandle == NULL )
   {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   if ( pStyle == NULL )
      iStyle = 0;
   else
      iStyle = hb_itemGetNI( pStyle );

   mxml_output_setup( &out, mxml_output_func_to_handle , 0 );
   out.u.hFile = ( HB_FHANDLE ) hb_itemGetNL( pHandle );

   iRet = mxml_node_write( &out, pNode, iStyle );
   hb_retni( iRet );
}
hbxml.c2398
xhbcopyf.c
TypeFunctionSourceLine
STATIC BOOLhb_fsCopy( char * szSource, char * szDest, PHB_ITEM pBlock )
static BOOL hb_fsCopy( char * szSource, char * szDest, PHB_ITEM pBlock )
{
   BOOL bRetVal = FALSE;
   HB_FHANDLE fhndSource;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCopy(%s, %s)", szSource, szDest));

   while( ( fhndSource = hb_spOpen( ( BYTE * ) szSource, FO_READ | FO_SHARED | FO_PRIVATE ) ) == FS_ERROR )
   {
      USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

      if( uiAction != E_RETRY )
         break;
   }

   if( fhndSource != FS_ERROR )
   {
      HB_FHANDLE fhndDest;

      while( ( fhndDest = hb_spCreate( ( BYTE * ) szDest, FC_NORMAL ) ) == FS_ERROR )
      {
         USHORT uiAction = hb_errRT_BASE_Ext1( EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

         if( uiAction != E_RETRY )
            break;
      }

      if( fhndDest != FS_ERROR )
      {
#if defined(HB_OS_UNIX_COMPATIBLE)
         struct stat struFileInfo;
         int iSuccess = fstat( fhndSource, &struFileInfo );
#endif
         BYTE * buffer = ( BYTE * ) hb_xgrab( BUFFER_SIZE );
         USHORT usRead;

         bRetVal = TRUE;

         if( hb_itemType( pBlock ) != HB_IT_BLOCK )
            pBlock = NULL;

         while( ( usRead = hb_fsRead( fhndSource, buffer, BUFFER_SIZE ) ) != 0 )
         {
            while( hb_fsWrite( fhndDest, buffer, usRead ) != usRead )
            {
               USHORT uiAction = hb_errRT_BASE_Ext1( EG_WRITE, 2016, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

               if( uiAction != E_RETRY )
               {
                  bRetVal = FALSE;
                  break;
               }
            }

            if( pBlock )
            {
               PHB_ITEM pCnt = hb_itemPutNL( NULL, usRead );

               hb_vmEvalBlockV( pBlock, 1, pCnt );

               hb_itemRelease( pCnt );
            }
         }

         hb_xfree( buffer );

#if defined(HB_OS_UNIX_COMPATIBLE)
         if( iSuccess == 0 )
            fchmod( fhndDest, struFileInfo.st_mode );
#endif

         hb_fsClose( fhndDest );
      }

      hb_fsClose( fhndSource );
   }

   return bRetVal;
}
xhbcopyf.c66
HB_FUNCXHB_COPYFILE(void)
HB_FUNC( XHB_COPYFILE )
{
   if( ISCHAR( 1 ) && ISCHAR( 2 ) )
   {
      if( ! hb_fsCopy( hb_parc( 1 ), hb_parc( 2 ), hb_param( 3, HB_IT_BLOCK ) ) )
         hb_retl( FALSE );
   }
   else
      hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); /* NOTE: Undocumented but existing Clipper Run-time error */
}
xhbcopyf.c148
xhbenum.c
TypeFunctionSourceLine
HB_FUNCHB_ENUMINDEX(void)
HB_FUNC( HB_ENUMINDEX )
{
   LONG lFuncOffset = hb_stackBaseOffset() - 1, lIndex = 0;
   while( --lFuncOffset > 0 )
   {
      PHB_ITEM pItem = hb_stackItem( lFuncOffset );
      if( HB_IS_ENUM( pItem ) )
      {
         lIndex = pItem->item.asEnum.offset;
         break;
      }
   }
   hb_retnl( lIndex );
}
xhbenum.c58
xhbfunc.c
TypeFunctionSourceLine
HB_FUNCXHB__KEYBOARD(void)
HB_FUNC( XHB__KEYBOARD )
{
   /* Clear the typeahead buffer without reallocating the keyboard buffer */
   if( !hb_parl( 2 ) )
   {
      hb_inkeyReset();
   }

   if( ISNUM( 1 ) )
   {
      hb_inkeyPut( hb_parni( 1 ) );
   }
   else if( ISCHAR( 1 ) )
   {
      hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
   }
   else if( ISARRAY( 1 ) )
   {
      PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
      ULONG ulIndex;
      ULONG ulElements = hb_arrayLen( pArray );

      for( ulIndex = 1; ulIndex <= ulElements; ulIndex++ )
      {
         PHB_ITEM pItem = hb_arrayGetItemPtr( pArray, ulIndex );

         if( HB_IS_NUMBER( pItem ) )
         {
            hb_inkeyPut( hb_itemGetNI( pItem ) );
         }
         else if( HB_IS_STRING( pItem ) )
         {
            hb_inkeySetText( ( const char * ) hb_itemGetCPtr( pItem ), hb_itemGetCLen( pItem ) );
         }
      }
   }
}

HB_FUNC_EXTERN( HB_DESERIALIZE );
xhbfunc.c58
HB_FUNCHB_DESERIALBEGIN(void)
HB_FUNC( HB_DESERIALBEGIN )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
   if( pItem )
      hb_itemReturn( pItem );
}
xhbfunc.c98
HB_FUNCHB_DESERIALNEXT(void)
HB_FUNC( HB_DESERIALNEXT )
{
   HB_FUNC_EXEC( HB_DESERIALIZE );
}


HB_FUNC_EXTERN( HB_WILDMATCH );
xhbfunc.c105
HB_FUNCWILDMATCH(void)
HB_FUNC( WILDMATCH )
{
   HB_FUNC_EXEC( HB_WILDMATCH );
}

HB_FUNC_EXTERN( HB_ADLER32 );
xhbfunc.c113
HB_FUNCHB_CHECKSUM(void)
HB_FUNC( HB_CHECKSUM )
{
   HB_FUNC_EXEC( HB_ADLER32 );
}
xhbfunc.c120
HB_FUNCHB_ARRAYID(void)
HB_FUNC( HB_ARRAYID )  /* for debugging: returns the array's "address" so dual references to same array can be seen */
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   hb_retptr( pArray ? hb_arrayId( pArray ) : NULL );
}

/* Hash utem functions */
HB_FUNC_EXTERN( HB_HASH );
HB_FUNC_EXTERN( HB_HHASKEY );
HB_FUNC_EXTERN( HB_HPOS );
HB_FUNC_EXTERN( HB_HGET );
HB_FUNC_EXTERN( HB_HSET );
HB_FUNC_EXTERN( HB_HDEL );
HB_FUNC_EXTERN( HB_HKEYAT );
HB_FUNC_EXTERN( HB_HVALUEAT );
HB_FUNC_EXTERN( HB_HVALUEAT );
HB_FUNC_EXTERN( HB_HPAIRAT );
HB_FUNC_EXTERN( HB_HDELAT );
HB_FUNC_EXTERN( HB_HKEYS );
HB_FUNC_EXTERN( HB_HVALUES );
HB_FUNC_EXTERN( HB_HFILL );
HB_FUNC_EXTERN( HB_HCLONE );
HB_FUNC_EXTERN( HB_HCOPY );
HB_FUNC_EXTERN( HB_HMERGE );
HB_FUNC_EXTERN( HB_HEVAL );
HB_FUNC_EXTERN( HB_HSCAN );
HB_FUNC_EXTERN( HB_HCASEMATCH );
HB_FUNC_EXTERN( HB_HCASEMATCH );
HB_FUNC_EXTERN( HB_HAUTOADD );
HB_FUNC_EXTERN( HB_HAUTOADD );
HB_FUNC_EXTERN( HB_HALLOCATE );
HB_FUNC_EXTERN( HB_HDEFAULT );

HB_FUNC( HASH )               { HB_FUNC_EXEC( HB_HASH ); }
HB_FUNC( HHASKEY )            { HB_FUNC_EXEC( HB_HHASKEY ); }
HB_FUNC( HGETPOS )            { HB_FUNC_EXEC( HB_HPOS ); }
HB_FUNC( HGET )               { HB_FUNC_EXEC( HB_HGET ); }
HB_FUNC( HSET )               { HB_FUNC_EXEC( HB_HSET ); }
HB_FUNC( HDEL )               { HB_FUNC_EXEC( HB_HDEL ); }
HB_FUNC( HGETKEYAT )          { HB_FUNC_EXEC( HB_HKEYAT ); }
HB_FUNC( HGETVALUEAT )        { HB_FUNC_EXEC( HB_HVALUEAT ); }
HB_FUNC( HSETVALUEAT )        { HB_FUNC_EXEC( HB_HVALUEAT ); }
HB_FUNC( HGETPAIRAT )         { HB_FUNC_EXEC( HB_HPAIRAT ); }
HB_FUNC( HDELAT )             { HB_FUNC_EXEC( HB_HDELAT ); }
HB_FUNC( HGETKEYS )           { HB_FUNC_EXEC( HB_HKEYS ); }
HB_FUNC( HGETVALUES )         { HB_FUNC_EXEC( HB_HVALUES ); }
HB_FUNC( HFILL )              { HB_FUNC_EXEC( HB_HFILL ); }
HB_FUNC( HCLONE )             { HB_FUNC_EXEC( HB_HCLONE ); }
HB_FUNC( HCOPY )              { HB_FUNC_EXEC( HB_HCOPY ); }
HB_FUNC( HMERGE )             { HB_FUNC_EXEC( HB_HMERGE ); }
HB_FUNC( HEVAL )              { HB_FUNC_EXEC( HB_HEVAL ); }
HB_FUNC( HSCAN )              { HB_FUNC_EXEC( HB_HSCAN ); }
HB_FUNC( HSETCASEMATCH )      { HB_FUNC_EXEC( HB_HCASEMATCH ); hb_itemReturn( hb_param( 1, HB_IT_HASH ) ); }
HB_FUNC( HGETCASEMATCH )      { HB_FUNC_EXEC( HB_HCASEMATCH ); }
HB_FUNC( HSETAUTOADD )        { HB_FUNC_EXEC( HB_HAUTOADD ); hb_itemReturn( hb_param( 1, HB_IT_HASH ) ); }
HB_FUNC( HGETAUTOADD )        { HB_FUNC_EXEC( HB_HAUTOADD ); hb_retl( hb_parni( -1 ) == HB_HASH_AUTOADD_ALWAYS ); }
HB_FUNC( HALLOCATE )          { HB_FUNC_EXEC( HB_HALLOCATE ); }
HB_FUNC( HDEFAULT )           { HB_FUNC_EXEC( HB_HDEFAULT ); }

#if defined( HB_OS_DOS ) && !defined( HB_NO_DEFAULT_INET )
#  define HB_NO_DEFAULT_INET
#endif

#if !defined( HB_NO_DEFAULT_INET )

/* Inet*() functions */
HB_FUNC_EXTERN( HB_INETINIT );
HB_FUNC_EXTERN( HB_INETCLEANUP );
HB_FUNC_EXTERN( HB_INETCREATE );
HB_FUNC_EXTERN( HB_INETCLOSE );
HB_FUNC_EXTERN( HB_INETFD );
HB_FUNC_EXTERN( HB_INETSTATUS );
HB_FUNC_EXTERN( HB_INETERRORCODE );
HB_FUNC_EXTERN( HB_INETERRORDESC );
HB_FUNC_EXTERN( HB_INETCLEARERROR );
HB_FUNC_EXTERN( HB_INETCOUNT );
HB_FUNC_EXTERN( HB_INETADDRESS );
HB_FUNC_EXTERN( HB_INETPORT );
HB_FUNC_EXTERN( HB_INETTIMEOUT );
HB_FUNC_EXTERN( HB_INETTIMEOUT );
HB_FUNC_EXTERN( HB_INETCLEARTIMEOUT );
HB_FUNC_EXTERN( HB_INETTIMELIMIT );
HB_FUNC_EXTERN( HB_INETTIMELIMIT );
HB_FUNC_EXTERN( HB_INETCLEARTIMELIMIT );
HB_FUNC_EXTERN( HB_INETPERIODCALLBACK );
HB_FUNC_EXTERN( HB_INETPERIODCALLBACK );
HB_FUNC_EXTERN( HB_INETCLEARPERIODCALLBACK );
HB_FUNC_EXTERN( HB_INETRECV );
HB_FUNC_EXTERN( HB_INETRECVALL );
HB_FUNC_EXTERN( HB_INETRECVLINE );
HB_FUNC_EXTERN( HB_INETRECVENDBLOCK );
HB_FUNC_EXTERN( HB_INETDATAREADY );
HB_FUNC_EXTERN( HB_INETSEND );
HB_FUNC_EXTERN( HB_INETSENDALL );
HB_FUNC_EXTERN( HB_INETGETHOSTS );
HB_FUNC_EXTERN( HB_INETGETALIAS );
HB_FUNC_EXTERN( HB_INETSERVER );
HB_FUNC_EXTERN( HB_INETACCEPT );
HB_FUNC_EXTERN( HB_INETCONNECT );
HB_FUNC_EXTERN( HB_INETCONNECTIP );
HB_FUNC_EXTERN( HB_INETDGRAMBIND );
HB_FUNC_EXTERN( HB_INETDGRAM );
HB_FUNC_EXTERN( HB_INETDGRAMSEND );
HB_FUNC_EXTERN( HB_INETDGRAMRECV );
HB_FUNC_EXTERN( HB_INETCRLF );
HB_FUNC_EXTERN( HB_INETISSOCKET );

HB_FUNC( INETINIT )                 { HB_FUNC_EXEC( HB_INETINIT ); }
HB_FUNC( INETCLEANUP )              { HB_FUNC_EXEC( HB_INETCLEANUP ); }
HB_FUNC( INETCREATE )               { HB_FUNC_EXEC( HB_INETCREATE ); }
HB_FUNC( INETCLOSE )                { HB_FUNC_EXEC( HB_INETCLOSE ); }
HB_FUNC( INETFD )                   { HB_FUNC_EXEC( HB_INETFD ); }
HB_FUNC( INETSTATUS )               { HB_FUNC_EXEC( HB_INETSTATUS ); }
HB_FUNC( INETERRORCODE )            { HB_FUNC_EXEC( HB_INETERRORCODE ); }
HB_FUNC( INETERRORDESC )            { HB_FUNC_EXEC( HB_INETERRORDESC ); }
HB_FUNC( INETCLEARERROR )           { HB_FUNC_EXEC( HB_INETCLEARERROR ); }
HB_FUNC( INETCOUNT )                { HB_FUNC_EXEC( HB_INETCOUNT ); }
HB_FUNC( INETADDRESS )              { HB_FUNC_EXEC( HB_INETADDRESS ); }
HB_FUNC( INETPORT )                 { HB_FUNC_EXEC( HB_INETPORT ); }
HB_FUNC( INETSETTIMEOUT )           { HB_FUNC_EXEC( HB_INETTIMEOUT ); }
HB_FUNC( INETGETTIMEOUT )           { HB_FUNC_EXEC( HB_INETTIMEOUT ); }
HB_FUNC( INETCLEARTIMEOUT )         { HB_FUNC_EXEC( HB_INETCLEARTIMEOUT ); }
HB_FUNC( INETSETTIMELIMIT )         { HB_FUNC_EXEC( HB_INETTIMELIMIT ); }
HB_FUNC( INETGETTIMELIMIT )         { HB_FUNC_EXEC( HB_INETTIMELIMIT ); }
HB_FUNC( INETCLEARTIMELIMIT )       { HB_FUNC_EXEC( HB_INETCLEARTIMELIMIT ); }
HB_FUNC( INETSETPERIODCALLBACK )    { HB_FUNC_EXEC( HB_INETPERIODCALLBACK ); }
HB_FUNC( INETGETPERIODCALLBACK )    { HB_FUNC_EXEC( HB_INETPERIODCALLBACK ); }
HB_FUNC( INETCLEARPERIODCALLBACK )  { HB_FUNC_EXEC( HB_INETCLEARPERIODCALLBACK ); }
HB_FUNC( INETRECV )                 { HB_FUNC_EXEC( HB_INETRECV ); }
HB_FUNC( INETRECVALL )              { HB_FUNC_EXEC( HB_INETRECVALL ); }
HB_FUNC( INETRECVLINE )             { HB_FUNC_EXEC( HB_INETRECVLINE ); }
HB_FUNC( INETRECVENDBLOCK )         { HB_FUNC_EXEC( HB_INETRECVENDBLOCK ); }
HB_FUNC( INETDATAREADY )            { HB_FUNC_EXEC( HB_INETDATAREADY ); }
HB_FUNC( INETSEND )                 { HB_FUNC_EXEC( HB_INETSEND ); }
HB_FUNC( INETSENDALL )              { HB_FUNC_EXEC( HB_INETSENDALL ); }
HB_FUNC( INETGETHOSTS )             { HB_FUNC_EXEC( HB_INETGETHOSTS ); }
HB_FUNC( INETGETALIAS )             { HB_FUNC_EXEC( HB_INETGETALIAS ); }
HB_FUNC( INETSERVER )               { HB_FUNC_EXEC( HB_INETSERVER ); }
HB_FUNC( INETACCEPT )               { HB_FUNC_EXEC( HB_INETACCEPT ); }
HB_FUNC( INETCONNECT )              { HB_FUNC_EXEC( HB_INETCONNECT ); }
HB_FUNC( INETCONNECTIP )            { HB_FUNC_EXEC( HB_INETCONNECTIP ); }
HB_FUNC( INETDGRAMBIND )            { HB_FUNC_EXEC( HB_INETDGRAMBIND ); }
HB_FUNC( INETDGRAM )                { HB_FUNC_EXEC( HB_INETDGRAM ); }
HB_FUNC( INETDGRAMSEND )            { HB_FUNC_EXEC( HB_INETDGRAMSEND ); }
HB_FUNC( INETDGRAMRECV )            { HB_FUNC_EXEC( HB_INETDGRAMRECV ); }
HB_FUNC( INETCRLF )                 { HB_FUNC_EXEC( HB_INETCRLF ); }
HB_FUNC( ISINETSOCKET )             { HB_FUNC_EXEC( HB_INETISSOCKET ); }
xhbfunc.c125
}HB_FUNC( INETDESTROY )
HB_FUNC( INETDESTROY )              { }
xhbfunc.c273
xhbmsgs.c
TypeFunctionSourceLine
HB_FUNCXHB_HASHERROR(void)
HB_FUNC( XHB_HASHERROR )
{
   const char * szMessage = hb_itemGetSymbol( hb_stackBaseItem() )->szName;
   int iPCount = hb_pcount();

   if( iPCount == 1 )
   {
      if( szMessage[ 0 ] == '_' )
      {  /* ASSIGN */
         PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), szMessage + 1 );
         PHB_ITEM pDest = hb_hashGetItemPtr( hb_stackSelfItem(), pIndex, HB_HASH_AUTOADD_ASSIGN );
         hb_stackPop();
         if( pDest )
         {
            PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );
            hb_itemCopyFromRef( pDest, pValue );
            hb_itemReturn( pValue );
            return;
         }
      }
   }
   else if( iPCount == 0 )
   {  /* ACCESS */
      PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), szMessage );
      PHB_ITEM pValue = hb_hashGetItemPtr( hb_stackSelfItem(), pIndex, HB_HASH_AUTOADD_ACCESS );
      hb_stackPop();
      if( pValue )
      {
         hb_itemReturn( pValue );
         return;
      }
   }

   if( szMessage[0] == '_' )
      hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, szMessage + 1, HB_ERR_ARGS_SELFPARAMS );
   else
      hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, szMessage, HB_ERR_ARGS_SELFPARAMS );
}
xhbmsgs.c59
HB_FUNCXHB_INCLUDE(void)
HB_FUNC( XHB_INCLUDE )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pKey = hb_param( 1, HB_IT_ANY );

   if( HB_IS_ARRAY( pSelf ) )
   {
      hb_retl( hb_arrayScan( pSelf, pKey, NULL, NULL, TRUE ) != 0 );
   }
   else if( HB_IS_HASH( pSelf ) && ( HB_IS_HASHKEY( pKey ) || hb_hashLen( pKey ) == 1 ) )
   {
      hb_retl( hb_hashScan( pSelf, pKey, NULL ) );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1109, NULL, "$", 2, pKey, pSelf );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c98
HB_FUNCXHB_INDEX(void)
HB_FUNC( XHB_INDEX )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pIndex = hb_param( 1, HB_IT_ANY );

   if( hb_pcount() == 2 )
   {  /* ASSIGN */
      PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );
      if( HB_IS_NUMERIC( pIndex ) )
      {
         ULONG ulIndex = hb_itemGetNL( pIndex );
         if( HB_IS_ARRAY( pSelf ) )
         {
            ULONG ulLen = hb_arrayLen( pSelf );
            if( HB_IS_VALID_INDEX( ulIndex, ulLen ) )
            {
               hb_itemMoveRef( hb_arrayGetItemPtr( pSelf, ulIndex ), pValue );
            }
            else
               hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
         }
         else if( HB_IS_STRING( pSelf ) )
         {
            ULONG ulLen = hb_itemGetCLen( pSelf );
            if( HB_IS_VALID_INDEX( ulIndex, ulLen ) )
            {
               char cValue = HB_IS_STRING( pValue ) ? hb_itemGetCPtr( pValue )[0] :
                             ( char ) hb_itemGetNI( pValue );
               if( ulLen == 1 )
                  hb_itemPutCL( pSelf, &cValue, 1 );
               else
               {
                  hb_itemUnShareString( pSelf );
                  hb_itemGetCPtr( pSelf )[ ulIndex - 1 ] = cValue;
               }
            }
            else
               hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
         }
         else
            hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
      }
      else
      {
         hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
      }
      hb_itemReturn( pSelf );
   }
   else
   {  /* ACCESS */
      if( HB_IS_NUMERIC( pIndex ) )
      {
         ULONG ulIndex = hb_itemGetNL( pIndex );
         if( HB_IS_ARRAY( pSelf ) )
         {
            ULONG ulLen = hb_arrayLen( pSelf );
            if( HB_IS_VALID_INDEX( ulIndex, ulLen ) )
               hb_itemReturn( hb_arrayGetItemPtr( pSelf, ulIndex ) );
            else
               hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pSelf, pIndex );
         }
         else if( HB_IS_STRING( pSelf ) )
         {
            ULONG ulLen = hb_itemGetCLen( pSelf );
            if( HB_IS_VALID_INDEX( ulIndex, ulLen ) )
               hb_retclen( hb_itemGetCPtr( pSelf ) + ulIndex - 1, 1 );
            else
               hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pSelf, pIndex );
         }
         else
            hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pSelf, pIndex );
      }
      else
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pSelf, pIndex );
         if( pResult )
            hb_itemReturnRelease( pResult );
      }
   }
}
xhbmsgs.c127
HB_FUNCXHB_PLUS(void)
HB_FUNC( XHB_PLUS )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      int iDec;
      double dValue = hb_itemGetNDDec( pSelf, &iDec );
      hb_retnlen( dValue + uc, 0, iDec  );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      uc += ( UCHAR ) hb_itemGetNI( pValue );
      hb_retclen( ( char * ) &uc, 1 );
   }
   else if( HB_IS_HASH( pSelf ) && HB_IS_HASH( pValue ) )
   {
      PHB_ITEM pHash = hb_hashClone( pSelf );
      hb_hashJoin( pHash, pValue, HB_HASH_UNION );
      hb_itemReturnRelease( pHash );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1081, NULL, "+", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c208
HB_FUNCXHB_MINUS(void)
HB_FUNC( XHB_MINUS )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      int iDec;
      double dValue = hb_itemGetNDDec( pSelf, &iDec );
      hb_retnlen( dValue - uc, 0, iDec  );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      uc -= ( UCHAR ) hb_itemGetNI( pValue );
      hb_retclen( ( char * ) &uc, 1 );
   }
   else if( HB_IS_HASH( pSelf ) && HB_IS_HASH( pValue ) )
   {
      PHB_ITEM pHash = hb_hashClone( pSelf );
      hb_hashRemove( pHash, pValue );
      hb_itemReturnRelease( pHash );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1082, NULL, "-", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c241
HB_FUNCXHB_INC(void)
HB_FUNC( XHB_INC )
{
   PHB_ITEM pSelf = hb_stackSelfItem();

   if( HB_IS_NUMERIC( pSelf ) )
      hb_retnd( hb_itemGetND( pSelf ) + 1 );
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0] + 1;
      hb_retclen( ( char * ) &uc, 1 );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1086, NULL, "++", 1, pSelf );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c274
HB_FUNCXHB_DEC(void)
HB_FUNC( XHB_DEC )
{
   PHB_ITEM pSelf = hb_stackSelfItem();

   if( HB_IS_NUMERIC( pSelf ) )
      hb_retnd( hb_itemGetND( pSelf ) - 1 );
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0] - 1;
      hb_retclen( ( char * ) &uc, 1 );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1087, NULL, "--", 1, pSelf );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c293
HB_FUNCXHB_MULT(void)
HB_FUNC( XHB_MULT )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      int iDec;
      double dValue = hb_itemGetNDDec( pSelf, &iDec );
      hb_retndlen( dValue * uc, 0, iDec );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      int iDec;
      double dValue = hb_itemGetNDDec( pValue, &iDec );
      hb_retndlen( ( double ) uc * dValue, 0, iDec );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1083, NULL, "*", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c312
HB_FUNCXHB_DIV(void)
HB_FUNC( XHB_DIV )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      if( uc == 0 )
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1340, NULL, "/", 2, pSelf, pValue );
         if( pResult )
            hb_itemReturnRelease( pResult );
      }
      else
         hb_retnd( hb_itemGetND( pSelf ) / uc );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      double dDivisor = hb_itemGetND( pValue );

      if( dDivisor == 0 )
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1340, NULL, "/", 2, pSelf, pValue );
         if( pResult )
            hb_itemReturnRelease( pResult );
      }
      else
         hb_retnd( ( double ) uc / dDivisor );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1084, NULL, "/", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c340
HB_FUNCXHB_MOD(void)
HB_FUNC( XHB_MOD )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      if( uc == 0 )
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", 2, pSelf, pValue );
         if( pResult )
            hb_itemReturnRelease( pResult );
      }
      else
         hb_retnd( fmod( hb_itemGetND( pSelf ), ( double ) uc ) );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      double dDivisor = hb_itemGetND( pValue );

      if( dDivisor == 0 )
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", 2, pSelf, pValue );
         if( pResult )
            hb_itemReturnRelease( pResult );
      }
      else
         hb_retnd( fmod( ( double ) uc, dDivisor ) );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1085, NULL, "%", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c380
HB_FUNCXHB_POW(void)
HB_FUNC( XHB_POW )
{
   PHB_ITEM pSelf = hb_stackSelfItem();
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );

   if( HB_IS_NUMERIC( pSelf ) && hb_itemGetCLen( pValue ) == 1 )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pValue )[0];
      hb_retnd( pow( hb_itemGetND( pSelf ), ( double ) uc ) );
   }
   else if( HB_IS_STRING( pSelf ) && hb_itemGetCLen( pSelf ) == 1 &&
            pValue && HB_IS_NUMERIC( pValue ) )
   {
      UCHAR uc = ( UCHAR ) hb_itemGetCPtr( pSelf )[0];
      hb_retnd( pow( ( double ) uc, hb_itemGetND( pValue ) ) );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1088, NULL, "^", 2, pSelf, pValue );
      if( pResult )
         hb_itemReturnRelease( pResult );
   }
}
xhbmsgs.c420
xhbqself.c
TypeFunctionSourceLine
HB_FUNCHB_QSELF(void)
HB_FUNC( HB_QSELF )
{
   LONG lOffset = hb_stackBaseProcOffset( 1 );

   if( lOffset > 0 )
   {
      PHB_ITEM pSelf = hb_stackItem( lOffset + 1 );

      if( lOffset > 0 && HB_IS_BLOCK( pSelf ) &&
         hb_itemGetSymbol( hb_stackItem( lOffset ) ) == &hb_symEval )
      {
         pSelf = hb_stackItem( hb_stackItem( lOffset )->
                               item.asSymbol.stackstate->lBaseItem + 1 );
      }
      hb_itemReturn( pSelf );
   }
}
xhbqself.c59
xhbwith.c
TypeFunctionSourceLine
STATIC PHB_ITEMhb_vmWithObjectItem( LONG lLevel )
static PHB_ITEM hb_vmWithObjectItem( LONG lLevel )
{
   LONG lOffset = hb_stackWithObjectOffset();

   while( lOffset && lLevel > 0 )
   {
      LONG * plOffset = ( LONG * ) hb_itemGetPtr( hb_stackItem( lOffset + 1 ) );
      if( !plOffset )
         break;
      --lLevel;
      lOffset = *plOffset;
   }

   return ( lOffset && !lLevel ) ? hb_stackItem( lOffset ) : NULL;
}
xhbwith.c59
STATIC LONGhb_vmWithObjectCount( void )
static LONG hb_vmWithObjectCount( void )
{
   LONG lOffset = hb_stackWithObjectOffset(), lCount = 0;

   while( lOffset )
   {
      LONG * plOffset = ( LONG * ) hb_itemGetPtr( hb_stackItem( lOffset + 1 ) );
      if( !plOffset )
         break;
      ++lCount;
      lOffset = *plOffset;
   }

   return lCount;
}
xhbwith.c75
HB_FUNCHB_QWITH(void)
HB_FUNC( HB_QWITH )
{
   hb_itemReturn( hb_vmWithObjectItem( hb_parnl( 1 ) ) );
}
xhbwith.c93
HB_FUNCHB_WITHOBJECTCOUNTER(void)
HB_FUNC( HB_WITHOBJECTCOUNTER )
{
   hb_retnl( hb_vmWithObjectCount() );
}
xhbwith.c98
HB_FUNCHB_RESETWITH(void)
HB_FUNC( HB_RESETWITH )
{
   PHB_ITEM pItem = hb_vmWithObjectItem( 0 );

   if( hb_pcount() >= 1 && pItem )
      hb_itemMove( pItem, hb_stackItemFromBase( 1 ) );
   else
      hb_errRT_BASE( EG_ARG, 1607, NULL, HB_ERR_FUNCNAME, 0, NULL );
}
xhbwith.c103
xstrdel.c
TypeFunctionSourceLine
HB_FUNCSTRDEL(void)
HB_FUNC( STRDEL )
{
   if( ISCHAR( 1 ) && ISCHAR( 2 ) )
   {
      char * szText = hb_parcx( 1 );
      ULONG ulText = hb_parclen( 1 );
      ULONG ulDel = hb_parclen( 2 );

      if( ulDel > 0 && ulText > 0 )
      {
         char * szDel = hb_parcx( 2 );
         ULONG ulPosTxt = 0;
         ULONG ulResult = 0;
         ULONG ulPosDel = 0;
         char * szResult = ( char * ) hb_xgrab( ulText + 1 );

         for( ; ( ulPosDel < ulText && ulPosDel < ulDel ); ulPosDel++ )
         {
            if( szDel[ ulPosDel ] != ' ' )
            {
               hb_xmemcpy( szResult + ulResult, szText + ulPosTxt, ulPosDel - ulPosTxt );
               ulResult += ulPosDel - ulPosTxt;
               ulPosTxt = ulPosDel + 1;
            }
         }
         hb_xmemcpy( szResult + ulResult, szText + ulPosTxt, ulText - ulPosTxt );
         ulResult += ulText - ulPosTxt;

         szResult[ ulResult ] = '\0';
         hb_retclenAdopt( szResult, ulResult );
      }
      else
         hb_retc( szText );
   }
   else
      hb_retc( NULL );
}
xstrdel.c55
arrayblk.prg
TypeFunctionSourceLine
FUNCTIONHB_ARRAYBLOCK( aArray, nIndex )
FUNCTION HB_ARRAYBLOCK( aArray, nIndex )

   RETURN {| x | iif( PCount() == 0, aArray[ nIndex ], aArray[ nIndex ] := x )}
arrayblk.prg54
cstruct.prg
TypeFunctionSourceLine
PROCEDURE__INIT_LONGLONGS
PROCEDURE __INIT_LONGLONGS
   HB_CStructureCSyntax( "ULONGLONG", { "-4", "ulong[2]", }, , , 8 )
   __ClsSetModule( __ActiveStructure() )

   HB_CStructureCSyntax( "LONGLONG", { "4", "long[2]", } , , , 8 )
   __ClsSetModule( __ActiveStructure() )

RETURN
cstruct.prg66
FUNCTION__ActiveStructure( cStructure, nAlign )
Function __ActiveStructure( cStructure, nAlign )

   /* LOCAL oErr */
   LOCAL acMembers, aCTypes, hClass, Counter, cMember

   IF s_lInitLongs
      s_lInitLongs := .F.
      __INIT_LONGLONGS()
   ENDIF

   IF PCount() == 2
      cStructure := Upper( cStructure )

      IF aScan( s_aClasses, { | aClassInfo | aClassInfo[1] == cStructure } ) > 0
         /* In most cases we can simply ignore the reduefinition, by returning a FAKED Structure Array!
         oErr := ErrorNew()
         oErr:Args := { cStructure, nAlign }
         oErr:CanDefault    := .F.
         oErr:CanRetry      := .F.
         oErr:CanSubstitute := .T.
         oErr:Description  := "Structure already defined."
         oErr:Operation     := "__ActiveStructure()"
         oErr:Severity      := ES_ERROR
         oErr:SubCode       := 1
         oErr:SubSystem     := "C Structure"

         RETURN Eval( ErrorBlock(), oErr )
         */

         // In most cases we can simply ignore the redefinition, by returning a FAKED Structure Array!
         //TraceLog( "Redefinition of C Structure: " + cStructure )
         RETURN ( s_aActiveStructure := { cStructure, NIL, {}, {}, IIF( ValType( nAlign ) == "N", nAlign, 8 ) } )
      END

      aAdd( s_aClasses, { cStructure, NIL, {}, {}, IIF( ValType( nAlign ) == "N", nAlign, 8 ) } )
      //TraceLog( "Registered: " + cStructure, s_aClasses[-1][5] )

      s_aActiveStructure := atail(s_aClasses)
   ELSE
      //TraceLog( "Created: " + Str( nId ) )

      acMembers := s_aActiveStructure[3]
      aCTypes   := s_aActiveStructure[4]
      nAlign    := s_aActiveStructure[5]

      hClass := __clsNew( "C Structure " + s_aActiveStructure[1] , Len( acMembers ) + CLASS_PROPERTIES )
      //__clsDelMsg( hClass, "C" )

      s_aActiveStructure[2] := hClass

      __clsAddMsg( hClass,  "Reset"     , @Reset()         , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Buffer"    , @Buffer()        , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Value"     , @Value()         , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "DeValue"   , @DeValue()       , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Array"     , @ArrayMethod()   , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "SayMembers", @SayMembers()    , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Init"      , @Init()          , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Pointer"   , @Pointer()       , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "GetPointer", @GetPointer()    , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "CopyTo"    , @__CSTR_CopyTo() , HB_OO_MSG_METHOD )

      FOR EACH cMember IN acMembers
         __clsAddMsg( hClass,       cMember, cMember:__enumIndex(), HB_OO_MSG_PROPERTY )
      NEXT

      Counter := Len( acMembers )
      __clsAddMsg( hClass,  "aCTypes"       , ++Counter, HB_OO_MSG_PROPERTY, acTypes )
      __clsAddMsg( hClass,  "aCMembers"     , ++Counter, HB_OO_MSG_PROPERTY, acMembers, HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "nAlign"        , ++Counter, HB_OO_MSG_PROPERTY, nAlign, HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "SizeOf"        , ++Counter, HB_OO_MSG_PROPERTY, HB_SizeOfCStructure( aCTypes, nAlign ), HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "_nID"          , ++Counter, HB_OO_MSG_PROPERTY, Len( s_aClasses ) )
      // WARNING InternalBuffer *MUST* remain the *LAST* Property!!!
      __clsAddMsg( hClass,  "InternalBuffer", ++Counter, HB_OO_MSG_PROPERTY, , HB_OO_CLSTP_READONLY )

      //TraceLog( Len( aCTypes ), aCTypes[1], aCTypes )
      RETURN hClass
   ENDIF

RETURN s_aActiveStructure
cstruct.prg76
PROCEDUREHB_Member( cMember, CType )
Procedure HB_Member( cMember, CType )

  LOCAL nLen, nAt

  IF right(cMember,1) == "]"
     nAt := At( "[", cMember )
     //nLen := Val( SubStr( cMember, nAt + 1, Len( cMember ) ) )
     // Support expressions like x + y, x - y, x * y
     nLen := &( SubStr( cMember, nAt + 1, Len( cMember ) - nAt - 1 ) )

     aAdd( s_aActiveStructure[3], Left( cMember, nAt - 1 ) )
     aAdd( s_aActiveStructure[4], HB_CTypeArrayID( CType, nLen ) )
  ELSE
     aAdd( s_aActiveStructure[3], cMember )
     aAdd( s_aActiveStructure[4], CType )
  ENDIF

Return
cstruct.prg157
FUNCTIONHB_CStructureID( cStructure, lInplace )
Function HB_CStructureID( cStructure, lInplace )

   LOCAL nID
   LOCAL oErr

   cStructure := Upper( cStructure )

   nID := aScan( s_aClasses, { | aClassInfo | aClassInfo[1] == cStructure } )

   IF nID == 0
      nID := aScan( s_aSynonyms, {|aSynonym| aSynonym[1] == cStructure } )
      IF nID == 0
         oErr := ErrorNew()
         oErr:Args          := { cStructure, lInplace }
         oErr:CanDefault    := .F.
         oErr:CanRetry      := .F.
         oErr:CanSubstitute := .T.
         oErr:Description   := "Structure not found: '" + cStructure + "'"
         oErr:Operation     := "HB_CStructureID()"
         oErr:Severity      := ES_ERROR
         oErr:SubCode       := 3
         oErr:SubSystem     := "C Structure"

         RETURN Eval( ErrorBlock(), oErr )
      ELSE
         nID := s_aSynonyms[nID][2]
      ENDIF

      nID += IIF( lInplace, 0, CTYPE_STRUCTURE_PTR - CTYPE_STRUCTURE )
   ELSE
      nID += IIF( lInplace, CTYPE_STRUCTURE, CTYPE_STRUCTURE_PTR )
   ENDIF

   //TraceLog( cStructure, nID )

RETURN nID
cstruct.prg177
PROCEDUREHB_CStructureCSyntax( cStructure, aDefinitions, cTag, cSynonList, nAlign )
Procedure HB_CStructureCSyntax( cStructure, aDefinitions, cTag, cSynonList, nAlign )

   LOCAL cElem, nAt, nIndex := 1
   LOCAL nLen, Counter, CType
   LOCAL oErr
   LOCAL nID, cSynon

   FOR EACH cElem IN aDefinitions
       // *** PP bug - remove when possible! ***
       IF cElem == NIL
          aSize( aDefinitions, nIndex - 1 )
          EXIT
       ENDIF

       IF ( nAt := At( "*", cElem ) ) > 1
          IF nIndex < Len( aDefinitions )
             aIns( aDefinitions, nIndex + 1, SubStr( cElem, nAt + 1 ), .T. )
          ELSE
             aAdd( aDefinitions, SubStr( cElem, nAt + 1 ) )
          ENDIF

          aDefinitions[nIndex] := StrTran( Left( cElem, nAt ), " ", "" )
       ELSEIF ( nAt := At( "-", cElem ) ) > 1
          IF nIndex < Len( aDefinitions )
             aIns( aDefinitions, nIndex + 1, SubStr( cElem, nAt ), .T. )
          ELSE
             aAdd( aDefinitions, SubStr( cElem, nAt ) )
          ENDIF

          aDefinitions[nIndex] := RTrim( Left( cElem, nAt - 1 ) )
       ENDIF

       nIndex++
   NEXT

   __ActiveStructure( cStructure, nAlign )
   nID := Len( s_aClasses )

   IF ! Empty( cTag )
      aAdd( s_aSynonyms, { Upper( cTag ), nID + CTYPE_STRUCTURE } )
      //Tracelog( s_aSynonyms[-1][1], s_aSynonyms[-1][2] )
   ENDIF

   IF ! Empty( cSynonList )
      FOR EACH cSynon IN HB_aTokens( cSynonList )
         IF left( cSynon,1 ) == '*'
            aAdd( s_aSynonyms, { Upper( SubStr( cSynon, 2 ) ), nID + CTYPE_STRUCTURE_PTR } )
         ELSE
            aAdd( s_aSynonyms, { Upper( cSynon ), nID + CTYPE_STRUCTURE } )
         ENDIF

         //Tracelog( s_aSynonyms[-1][1], s_aSynonyms[-1][2] )
      NEXT
   ENDIF

   nLen := Len( aDefinitions )

   FOR Counter := 1 TO nLen STEP 2
      //TraceLog( "Member: " + aDefinitions[Counter + 1], "Type: " + aDefinitions[Counter] )

      CType := aDefinitions[Counter]
      IF Val( CType ) != 0
         HB_Member( aDefinitions[Counter + 1], Val( aDefinitions[Counter] ) )
      ELSE
         IF right(CType,1) == '*'
            CType := HB_CStructureID( Left( CType, Len( CType ) - 1 ), .F. )
         ELSE
            CType := HB_CStructureID( CType, .T. )

            IF CType == CTYPE_STRUCTURE .OR. CType == CTYPE_STRUCTURE_PTR
               oErr := ErrorNew()
               oErr:Args          := { cStructure, aDefinitions, cTag, cSynonList, nAlign }
               oErr:CanDefault    := .F.
               oErr:CanRetry      := .F.
               oErr:CanSubstitute := .T.
               oErr:Description   := "Undefined CType: '" + aDefinitions[Counter] + "'"
               oErr:Operation     := "HB_CStructureCSyntax()"
               oErr:Severity      := ES_ERROR
               oErr:SubCode       := 2
               oErr:SubSystem     := "C Structure"

               CType := Eval( ErrorBlock(), oErr )
            ENDIF
         ENDIF

         HB_Member( aDefinitions[Counter + 1], CType )
      ENDIF
   NEXT

RETURN
cstruct.prg215
FUNCTIONHB_CStructure( cStructure, nAlign )
Function HB_CStructure( cStructure, nAlign )

   LOCAL hClass
   LOCAL oStructure
   LOCAL nID
   LOCAL oErr

   cStructure := Upper( cStructure )
   nID        := aScan( s_aClasses, { | aClassInfo | aClassInfo[1] == cStructure } )

   IF nID == 0
      oErr := ErrorNew()
      oErr:Args          := { cStructure, nAlign }
      oErr:CanDefault    := .F.
      oErr:CanRetry      := .F.
      oErr:CanSubstitute := .T.
      oErr:Description   := "Structure not initialized with __ActiveStructure()"
      oErr:Operation     := "HB_CStructure()"
      oErr:Severity      := ES_ERROR
      oErr:SubCode       := 3
      oErr:SubSystem     := "C Structure"

      RETURN Eval( ErrorBlock(), oErr )
   ENDIF

   hClass := s_aClasses[nId][2]
   oStructure := __clsInst( hClass )

   AllocateMembers( oStructure )

RETURN oStructure
cstruct.prg307
STATIC PROCEDUREAllocateMembers( oStructure )
static Procedure AllocateMembers( oStructure )

   LOCAL aCTypes, CType
   aCTypes := oStructure:aCTypes

   //TraceLog( "Scaning: " + oStructure:ClassName )

   FOR EACH CType IN aCTypes
      IF CType > CTYPE_STRUCTURE .AND. CType < CTYPE_STRUCTURE_PTR
         oStructure[ CType:__enumIndex() ] := HB_CStructureFromID( CType, , .F. )
         AllocateMembers( oStructure[ CType:__enumIndex() ] )
      ENDIF
   NEXT

   //TraceLog( "Finished: " + oStructure:ClassName )

Return
cstruct.prg340
FUNCTIONHB_CStructureFromID( nID, nAlign )
Function HB_CStructureFromID( nID, nAlign )

   LOCAL hClass, oStructure, lInplace
   LOCAL oErr

   //TraceLog( nId, s_aClasses )

   IF nID > CTYPE_STRUCTURE_PTR
      lInplace := .F.
      nID -= CTYPE_STRUCTURE_PTR
   ELSEIF nID > CTYPE_STRUCTURE
      lInplace := .T.
      nID -= CTYPE_STRUCTURE
   ELSE
      oErr := ErrorNew()
      oErr:Args          := { nID, nAlign }
      oErr:CanDefault    := .F.
      oErr:CanRetry      := .F.
      oErr:CanSubstitute := .T.
      oErr:Description  := "ID out of range."
      oErr:Operation     := "HB_CStructureFromID()"
      oErr:Severity      := ES_ERROR
      oErr:SubCode       := 4
      oErr:SubSystem     := "C Structure"

      RETURN Eval( ErrorBlock(), oErr )
   ENDIF

   IF s_aClasses[nID][2] == NIL
      // Meta class was not created yet.
      RETURN HB_CStructure( s_aClasses[nId][1] )
   ELSE
      hClass := s_aClasses[nId][2]

      oStructure := __clsInst( hClass )
   ENDIF

RETURN oStructure
cstruct.prg359
FUNCTIONHB_CTypeArrayID( CType, nLen )
Function HB_CTypeArrayID( CType, nLen )

   LOCAL hClass
   LOCAL Counter
   LOCAL nID
   LOCAL aCTypes, acMembers, cMember
   LOCAL cArrayClassName := "C Array of [" + LTrim( Str( nLen ) ) + "] CType: " + Str( CType )

   nID := aScan( s_aArrayClasses, { | aArrayDefinitions | aArrayDefinitions[1] == CType .AND. aArrayDefinitions[2] == nLen } )

   IF nID == 0
      hClass := __clsNew( "C Structure " + cArrayClassName, nLen + CLASS_PROPERTIES )
      //__clsDelMsg( hClass, "C" )

      __ClsSetModule( hClass )
      aAdd( s_aClasses, { cArrayClassName, hClass, Array( nLen ), Array( nLen ), 1 } )
      nID := Len( s_aClasses )

      acMembers := s_aClasses[nID][3]
      aCTypes   := s_aClasses[nID][4]

      // Sames as s_aClasses[nID][4]
      aFill( aCTypes, CType )

      aAdd( s_aArrayClasses, { CType, nLen, nID } )

      __clsAddMsg( hClass,  "Reset"     , @Reset()         , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Buffer"    , @Buffer()        , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Value"     , @Value()         , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "DeValue"   , @DeValue()       , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Array"     , @ArrayMethod()   , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "SayMembers", @SayMembers()    , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Init"      , @Init()          , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "Pointer"   , @Pointer()       , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "GetPointer", @GetPointer()    , HB_OO_MSG_METHOD )
      __clsAddMsg( hClass,  "CopyTo"    , @__CSTR_CopyTo() , HB_OO_MSG_METHOD )

      //IF Abs( CType ) == 1
         __clsAddMsg( hClass, "AsString", @AsString()   , HB_OO_MSG_METHOD )
      //ENDIF

      FOR Counter := 1 TO nLen
         cMember := LTrim( Str( Counter ) )
         acMembers[Counter] := cMember
         __clsAddMsg( hClass,       cMember, Counter, HB_OO_MSG_PROPERTY )
      NEXT

      __clsAddMsg( hClass,  "aCTypes"       , Counter++, HB_OO_MSG_PROPERTY, aCTypes )
      __clsAddMsg( hClass,  "aCMembers"     , Counter++, HB_OO_MSG_PROPERTY, acMembers, HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "nAlign"        , Counter++, HB_OO_MSG_PROPERTY, 1, HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "SizeOf"        , Counter++, HB_OO_MSG_PROPERTY, HB_SizeOfCStructure( aCTypes, 1 ), HB_OO_CLSTP_READONLY )
      __clsAddMsg( hClass,  "_nID", Counter++, HB_OO_MSG_PROPERTY, nID )
      // WARNING InternalBuffer *MUST* remain the *LAST* Property!!!
      __clsAddMsg( hClass,  "InternalBuffer", Counter++, HB_OO_MSG_PROPERTY, , HB_OO_CLSTP_READONLY )
      //TraceLog( "Registered: " + cArrayClassName, nID, Len( s_aArrayClasses ), HB_SizeOfCStructure( aCTypes, 1 ), nLen )
   ELSE
      nID := s_aArrayClasses[nID][3]
      //TraceLog( "Reused: " + s_aClasses[nID][1], nID )
   ENDIF

RETURN nID + CTYPE_STRUCTURE
cstruct.prg399
FUNCTIONHB_IS_CStructure( x )
Function HB_IS_CStructure( x )

RETURN Left( x:ClassName(), 11 ) == "C Structure"
cstruct.prg462
STATIC FUNCTIONSayMembers( cPad, lShowMembers, lReturnString )
Static Function SayMembers( cPad, lShowMembers, lReturnString )

   LOCAL xProperty, cOut := ""

   IF cPad == NIL
      cPad := ""
   ENDIF
   IF lShowMembers == NIL
      lShowMembers := .F.
   ENDIF
   IF lReturnString == NIL
      lReturnString := .F.
   ENDIF

   //QOut( cPad + SubStr( QSelf():ClassName, 13 ) )
   //QOut( cPad + Replicate( "-", Len( SubStr( QSelf():ClassName, 13 ) ) ) )

   cOut += cPad + SubStr( QSelf():ClassName, 13 )
   cOut += hb_OSNewLine() + cPad + Replicate( "-", Len( SubStr( QSelf():ClassName, 13 ) ) )

   FOR EACH xProperty IN QSelf():Array
      IF HB_IS_CStructure( xProperty )
         IF lReturnString
            cOut += hb_OSNewLine() + hb_OSNewLine() + xProperty:SayMembers( cPad + cPad, lShowMembers, lReturnString )
         ELSE
            xProperty:SayMembers( cPad + cPad, lShowMembers )
         ENDIF
      ELSE
         //QOut( cPad + IIF( lShowMembers, acMembers[ xProperty:__enumIndex() ], "" ) + ":", xProperty )
         cOut += hb_OSNewLine() + cPad + IIF( lShowMembers, QSelf():acMembers[ xProperty:__enumIndex() ], "" ) + ":" + hb_cStr( xProperty )
      END
   NEXT

   IF !lReturnString
      QOut( cOut )
   ENDIF

RETURN IIF( lReturnString, cOut, QSelf() )
cstruct.prg467
STATIC FUNCTIONReset()
STATIC Function Reset()

   LOCAL xProperty, nProperties := Len( QSelf() ) - CLASS_PROPERTIES

   FOR EACH xProperty IN QSelf()
      IF xProperty:__enumIndex() > nProperties
         EXIT
      ENDIF

      IF HB_IS_CStructure( xProperty )
         xProperty:Reset()
      ELSE
         xProperty := NIL
      END
   NEXT

RETURN QSelf()
cstruct.prg507
STATIC FUNCTIONBuffer( Buffer, lAdopt )
STATIC Function Buffer( Buffer, lAdopt )

   IF ValType( Buffer ) == "C"
      IF Len( Buffer ) < QSelf():SizeOf
         //TraceLog( Buffer )
         Buffer := PadR( Buffer, QSelf():SizeOf, Chr(0) )
      ENDIF

      QSelf():InternalBuffer := Buffer
      QSelf():DeValue( lAdopt )
   ENDIF

   IF ValType( QSelf():InternalBuffer ) != "C"
      QSelf():InternalBuffer := QSelf():Value()
   ENDIF

RETURN QSelf()
cstruct.prg526
STATIC FUNCTIONGetPointer()
STATIC Function GetPointer()

   QSelf():InternalBuffer := HB_ArrayToStructure( QSelf(), QSelf():aCTypes, QSelf():nAlign )

RETURN hb_String2Pointer( QSelf():InternalBuffer )
cstruct.prg545
STATIC FUNCTIONValue()
STATIC Function Value()

   //LOCAL aValues := {}

   //aEval( QSelf(), {|xVal| aAdd( aValues, xVal ) }, 1, Len( QSelf() ) - CLASS_PROPERTIES )

   QSelf():InternalBuffer := HB_ArrayToStructure( QSelf(), QSelf():aCTypes, QSelf():nAlign )

RETURN QSelf():InternalBuffer
cstruct.prg553
STATIC FUNCTIONDeValue( lAdopt )
STATIC Function DeValue( lAdopt )

   //LOCAL aValues := {}
   LOCAL nLen := Len( QSelf() ) - CLASS_PROPERTIES
   LOCAL Buffer := QSelf():InternalBuffer

   //TraceLog( QSelf():ClassName(), QSelf():nAlign, Buffer, Len( Buffer ), lAdopt )

   //aEval( QSelf(), {|xVal| aAdd( aValues, xVal ) }, 1, Len( QSelf() ) - CLASS_PROPERTIES )

   IF ValType( Buffer ) != "C" .OR. Len( Buffer ) == 0
      //TraceLog( "EMPTY Buffer passed to " + ProcName() )
   ELSEIF Len( Buffer ) < QSelf():SizeOf
      //TraceLog( "Should have been caught at ::Buffer()!!!", Buffer )
      Buffer := PadR( Buffer, QSelf():SizeOf, Chr(0) )
   ELSE
      HB_StructureToArray( Buffer, QSelf():aCTypes, QSelf():nAlign, lAdopt, QSelf()  )
   ENDIF

RETURN QSelf()
cstruct.prg565
STATIC FUNCTIONArrayMethod()
STATIC Function ArrayMethod()

   LOCAL aValues := {}

   aEval( QSelf(), {|xVal| aAdd( aValues, xVal ) }, 1, Len( QSelf() ) - CLASS_PROPERTIES )

RETURN aValues
cstruct.prg587
STATIC FUNCTIONInit( aValues )
STATIC Function Init( aValues )

   LOCAL xProperty, nLen := Len( aValues )

   FOR EACH xProperty IN QSelf()
      IF xProperty:__enumIndex() > nLen
         EXIT
      ENDIF

      IF Left( xProperty:ClassName, 11 ) == "C Structure"
         xProperty:Init( aValues[ xProperty:__enumIndex() ] )
      ELSE
         xProperty := aValues[ xProperty:__enumIndex() ]
      ENDIF
   NEXT

RETURN QSelf()
cstruct.prg596
STATIC FUNCTIONPointer( nNewPointer, lAdopt )
STATIC Function Pointer( nNewPointer, lAdopt )

   IF nNewPointer != NIL
      QSelf():Buffer( HB_Pointer2String( nNewPointer, QSelf():SizeOf ), lAdopt )
   ENDIF

RETURN QSelf()
cstruct.prg615
STATIC FUNCTIONAsString()
STATIC Function AsString()

   LOCAL cChar, nLen := Len( QSelf() ) - CLASS_PROPERTIES, cString := Space( nLen )

   FOR EACH cChar IN QSelf()
      IF cChar:__enumIndex() > nLen
         EXIT
      ENDIF

      IF cChar == 0
         cString := Left( cString, cChar:__enumIndex() - 1 )
         EXIT
      ENDIF

      cString[ cChar:__enumIndex() ] := cChar
   NEXT

RETURN cString
cstruct.prg624
dirrec.prg
TypeFunctionSourceLine
FUNCTIONDirectoryRecurse( cPath, cAttr )
FUNCTION DirectoryRecurse( cPath, cAttr )

   LOCAL aResult
   LOCAL cFilePath, cExt, cMask

   hb_FNameSplit( cPath, @cFilePath, @cMask, @cExt )
   cMask += cExt
   IF !ValType( cAttr ) == "C"
      cAttr := ""
   ENDIF
   /* The trick with StrTran() below if for strict xHarbour
    * compatibility though it should be reverted when it will
    * be fixed in xHarbour
    */
   aResult := HB_DirScan( cFilePath, cMask + cExt, ;
                          StrTran( Upper( cAttr ), "D" ) )

   AEval( aResult, { |x| x[ 1 ] := cFilePath + x[ 1 ] } )

   RETURN aResult
dirrec.prg73
hblog.prg
TypeFunctionSourceLine
PROCEDUREHB_InitStandardLog( ... )
PROCEDURE HB_InitStandardLog( ... )

   LOCAL Param

   StdLogger := HB_Logger():New()

   #ifdef HB_THREAD_SUPPORT
      StdLogMutex := HB_MutexCreate()
   #endif

   FOR EACH Param in HB_aParams()
      #ifdef HB_THREAD_SUPPORT
         HB_MutexLock( StdLogMutex )
      #endif

      StdLogger:AddChannel( Param )

      #ifdef HB_THREAD_SUPPORT
         HB_MutexUnlock( StdLogMutex )
      #endif
   NEXT

   #ifdef HB_THREAD_SUPPORT
      HB_MutexLock( StdLogMutex )
   #endif

   StdLogger:SetStyle( HB_LOG_ST_DATE + HB_LOG_ST_ISODATE + HB_LOG_ST_TIME + HB_LOG_ST_LEVEL )

   #ifdef HB_THREAD_SUPPORT
      HB_MutexUnlock( StdLogMutex )
   #endif
RETURN
hblog.prg69
PROCEDUREHB_OpenStandardLog()
PROCEDURE HB_OpenStandardLog()

   StdLogger:Open()

RETURN
hblog.prg102
PROCEDUREHB_StandardLogAdd( oChannel )
PROCEDURE HB_StandardLogAdd( oChannel )

   IF StdLogger != NIL
      #ifdef HB_THREAD_SUPPORT
         HB_MutexLock( StdLogMutex )
      #endif

      StdLogger:AddChannel( oChannel )

      #ifdef HB_THREAD_SUPPORT
         HB_MutexUnlock( StdLogMutex )
      #endif
   ENDIF

RETURN
hblog.prg108
PROCEDUREHB_CloseStandardLog()
PROCEDURE HB_CloseStandardLog()

   // If the logger is NIL also the mutex is NIL
   IF StdLogger != NIL
      #ifdef HB_THREAD_SUPPORT
         HB_MutexLock( StdLogMutex )
      #endif

      StdLogger:Close()

      #ifdef HB_THREAD_SUPPORT
         HB_MutexUnlock( StdLogMutex )
      #endif
   ENDIF

RETURN
hblog.prg124
PROCEDUREHB_SetStandardLogStyle( nStyle )
PROCEDURE HB_SetStandardLogStyle( nStyle )

   IF StdLogger != NIL
      #ifdef HB_THREAD_SUPPORT
         HB_MutexLock( StdLogMutex )
      #endif

      StdLogger:SetStyle( nStyle )

      #ifdef HB_THREAD_SUPPORT
         HB_MutexUnlock( StdLogMutex )
      #endif
   ENDIF

RETURN
hblog.prg142
PROCEDUREHB_StandardLogName( cName )
PROCEDURE HB_StandardLogName( cName )

   #ifdef HB_THREAD_SUPPORT
      HB_MutexLock( StdLogMutex )
   #endif

   StdLogger:cProgName := cName

   #ifdef HB_THREAD_SUPPORT
      HB_MutexUnlock( StdLogMutex )
   #endif

RETURN
hblog.prg158
PROCEDUREHB_StandardLog( cMsg, nPrio )
PROCEDURE HB_StandardLog( cMsg, nPrio )

   IF StdLogger != NIL
      #ifdef HB_THREAD_SUPPORT
         HB_MutexLock( StdLogMutex )
      #endif

      StdLogger:Log( cMsg, nPrio )

      #ifdef HB_THREAD_SUPPORT
         HB_MutexUnlock( StdLogMutex )
      #endif
   ENDIF

RETURN
hblog.prg172
FUNCTIONHB_BldLogMsg( ... )
FUNCTION HB_BldLogMsg( ... )

   LOCAL xVar
   LOCAL cMsg := ""

   FOR EACH xVar IN HB_aParams()
      IF ValType( xVar ) == "N"
         cMsg += AllTrim( CStr( xVar ) )
      ELSEIF ValType( xVar ) != "C"
         cMsg += CStr( xVar )
      ELSE
         cMsg += xVar
      ENDIF

      IF xVar:__enumIndex() < PCount()
         cMsg += " "
      ENDIF
   NEXT

RETURN cMsg
hblog.prg188
FUNCTIONHB_LogDateStamp()
FUNCTION HB_LogDateStamp()

   LOCAL dToday := Date()

RETURN  Str(Year( dToday ), 4 ) +"-"+ Padl( Month( dToday ) , 2, "0" ) + "-" + Padl( Day( dToday ), 2, "0" )
hblog.prg209
CLASSHB_Logger
CLASS HB_Logger
   DATA cProgName
   DATA aLogToChannel                  INIT  {}
   DATA nStyle                         INIT  -1
   DATA nDefaultPriority               INIT  HB_LOG_INFO

   METHOD New()
hblog.prg219
HB_LOGGER:METHODAddChannel( oChannel )
   METHOD AddChannel( oChannel )       INLINE Aadd( ::aLogToChannel, oChannel )
hblog.prg226
HB_LOGGER:METHODSetStyle( nStyle )
   METHOD SetStyle( nStyle )           INLINE ::nStyle := nStyle

   METHOD Open()
   METHOD Close()

   METHOD Log( cMessage, nPriority )

ENDCLASS
hblog.prg228
HB_LOGGER:METHODNew() CLASS HB_Logger
METHOD New() CLASS HB_Logger
   LOCAL nCount

   FOR nCount := 1 TO PCount()
      ::AddChannel( PValue( nCount ) )
   NEXT
RETURN Self
hblog.prg244
PROCEDUREOpen() CLASS HB_Logger
PROCEDURE Open() CLASS HB_Logger

   LOCAL oChannel

   IF ::cProgName == NIL
      HB_FnameSplit( hb_argv(0),,@::cProgName )
   ENDIF

   FOR EACH oChannel IN ::aLogToChannel
      oChannel:Open( ::cProgName )
   NEXT

RETURN
hblog.prg256
PROCEDUREClose() CLASS HB_Logger
PROCEDURE Close() CLASS HB_Logger

   LOCAL oChannel

   IF ::cProgName == NIL
      HB_FnameSplit( hb_argv(0),,@::cProgName )
   ENDIF

   FOR EACH oChannel IN ::aLogToChannel
      oChannel:Close( ::cProgName )
   NEXT

RETURN
hblog.prg273
PROCEDURELog( cMessage, nPriority ) CLASS HB_Logger
PROCEDURE Log( cMessage, nPriority ) CLASS HB_Logger
   LOCAL oChannel
   LOCAL cPrefix := ""

   IF nPriority == NIL
      nPriority := ::nDefaultPriority
   ENDIF

   FOR EACH oChannel IN ::aLogToChannel
      /* Channels may want to have something to say about the format,
         so message formatting is done by the channels */
      oChannel:Log( ::nStyle, cMessage, ::cProgName, nPriority )
   NEXT

RETURN
hblog.prg290
CLASSHB_LogChannel
CLASS HB_LogChannel
   DATA lOpened                  INIT .F.

   METHOD New( nLevel )          CONSTRUCTOR
   METHOD Open( cName )          VIRTUAL
   METHOD Close( cName )         VIRTUAL

   METHOD Log( nStyle, cMessage, cName, nPriority )
hblog.prg310
HB_LOGCHANNEL:METHODSetActive( lAct )
   METHOD SetActive( lAct )      INLINE   ::lActive := lAct

   METHOD Format( nStyle, cMessage, cName, nPriority )

PROTECTED:
   METHOD Send( nStyle, cMessage, cName, nPriority )    VIRTUAL

HIDDEN:
   DATA nLevel
   DATA lActive                  INIT .T.

ENDCLASS
hblog.prg318
HB_LOGCHANNEL:METHODNew( nLevel ) CLASS HB_LogChannel
METHOD New( nLevel ) CLASS HB_LogChannel

   IF nLevel == NIL
      // log everything by default
      nLevel := HB_LOG_ALL
   ENDIF

   ::nLevel := nLevel
RETURN Self
hblog.prg335
PROCEDURELog( nStyle, cMessage, cName, nPriority ) CLASS HB_LogChannel
PROCEDURE Log( nStyle, cMessage, cName, nPriority ) CLASS HB_LogChannel

   IF nPriority <= ::nLevel .and. ::lActive
      ::Send( nStyle, cMessage, cName, nPriority )
   ENDIF

RETURN
hblog.prg350
HB_LOGCHANNEL:METHODFormat( nStyle, cMessage, cName, nPriority ) CLASS HB_LogChannel
METHOD Format( nStyle, cMessage, cName, nPriority ) CLASS HB_LogChannel

   LOCAL cPrefix := ""

   IF HB_BitAnd( nStyle, HB_LOG_ST_DATE ) > 0
      IF HB_BitAnd( nStyle, HB_LOG_ST_ISODATE ) > 0
         cPrefix += HB_LogDateStamp()
      ELSE
         cPrefix += DtoC( Date() )
      ENDIF
      cPrefix += " "
   ENDIF

   IF HB_BitAnd( nStyle, HB_LOG_ST_NAME ) > 0
      cPrefix += cName + " "
   ENDIF

   IF HB_BitAnd( nStyle, HB_LOG_ST_TIME ) > 0
      cPrefix += Time() + " "
   ENDIF

   IF HB_BitAnd( nStyle, HB_LOG_ST_LEVEL ) > 0
      SWITCH nPriority
         CASE HB_LOG_CRITICAL
            cPrefix += "CRITICAL: "
         EXIT

         CASE HB_LOG_ERROR
            cPrefix += "ERROR: "
         EXIT

         CASE HB_LOG_WARNING
            cPrefix += "WARNING: "
         EXIT

         CASE HB_LOG_INFO
            cPrefix += "INFO: "
         EXIT

         CASE HB_LOG_DEBUG
            cPrefix += "DEBUG: "
         EXIT

         OTHERWISE
            cPrefix += "DEBUG" + Alltrim( Str(nPriority - HB_LOG_DEBUG) )+  ": "
      END
   ENDIF

RETURN cPrefix + cMessage
hblog.prg363
CLASSHB_LogConsole FROM HB_LogChannel
CLASS HB_LogConsole FROM HB_LogChannel

   METHOD New( nLevel )
   METHOD Open( cName )
   METHOD Close( cName )
hblog.prg417
HB_LOGCONSOLE:METHODLogOnVt( ldo )
   METHOD LogOnVt( ldo )      INLINE ::lRealConsole := ldo

PROTECTED:
   METHOD Send( nStyle, cMessage, nPriority )
   DATA lRealConsole    INIT .T.

ENDCLASS
hblog.prg423
HB_LOGCONSOLE:METHODNew( nLevel ) CLASS HB_LogConsole
METHOD New( nLevel ) CLASS HB_LogConsole
   ::Super:New( nLevel )
RETURN Self
hblog.prg431
HB_LOGCONSOLE:METHODOpen( cName ) CLASS HB_LogConsole
METHOD Open( cName ) CLASS HB_LogConsole

   IF ::lOpened
      RETURN .F.
   ENDIF

   IF ::lRealConsole
      OutStd( HB_LogDateStamp(), Time(), "--", cName, "start --", HB_OSnewLine() )
   ELSE
      QOut( HB_LogDateStamp(), Time(), "--", cName, "start --" )
   ENDIF
   ::lOpened := .T.

RETURN .T.
hblog.prg435
HB_LOGCONSOLE:METHODClose( cName ) CLASS HB_LogConsole
METHOD Close( cName ) CLASS HB_LogConsole

   IF .not. ::lOpened
      RETURN .F.
   ENDIF

   IF ::lRealConsole
      OutStd( HB_LogDateStamp(), Time(), "--", cName, "end --", HB_OSnewLine() )
   ELSE
      QOut( HB_LogDateStamp(), Time(), "--", cName, "end --" )
   ENDIF
   ::lOpened := .F.

RETURN .T.
hblog.prg450
PROCEDURESend( nStyle, cMessage, cName, nPriority ) CLASS HB_LogConsole
PROCEDURE Send( nStyle, cMessage, cName, nPriority ) CLASS HB_LogConsole

   IF ::lRealConsole
      OutStd( ::Format( nStyle, cMessage, cName, nPriority ), HB_OSnewLine() )
   ELSE
      QOut( ::Format( nStyle, cMessage, cName, nPriority ) )
   ENDIF

RETURN
hblog.prg465
CLASSHB_LogFile FROM HB_LogChannel
CLASS HB_LogFile FROM HB_LogChannel

   DATA cFileName
   DATA nFileHandle
   DATA nFileLimit         INIT -1
   DATA nBackup            INIT 5

   METHOD New( nLevel, cName, cFile, nMaxSize, nBackup )
   METHOD Open( cName )
   METHOD Close( cName )

PROTECTED:
   METHOD Send( nStyle, cMessage, nPriority )

ENDCLASS
hblog.prg478
HB_LOGFILE:METHODNew( nLevel, cFilename, nMaxSize, nBackup ) CLASS HB_LogFile
METHOD New( nLevel, cFilename, nMaxSize, nBackup ) CLASS HB_LogFile

   ::Super:New( nLevel )
   ::cFileName := cFileName

   IF nMaxSize != NIL
      ::nFileLimit := nMaxSize
   ENDIF

   IF nBackup != NIL
      ::nBackup := nBackup
   ENDIF

RETURN Self
hblog.prg495
HB_LOGFILE:METHODOpen( cProgName ) CLASS HB_LogFile
METHOD Open( cProgName ) CLASS HB_LogFile

   IF ::lOpened
      RETURN .F.
   ENDIF

   IF File( ::cFileName )
      ::nFileHandle := FOpen( ::cFileName, FO_READWRITE )
      IF ::nFileHandle > 0
         Fseek( ::nFileHandle, 0 ,FS_END )
      END
   ELSE
      ::nFileHandle := FCreate( ::cFileName )
   ENDIF

   IF ::nFileHandle < 0
      RETURN .F.
   ENDIF

   Fwrite( ::nFileHandle, HB_BldLogMsg( HB_LogDateStamp(), Time(), "--", cProgName, "start --", HB_OsNewLine() ) )

   HB_Fcommit( ::nFileHandle )
   ::lOpened := .T.

RETURN .T.
hblog.prg510
HB_LOGFILE:METHODClose( cProgName ) CLASS HB_LogFile
METHOD Close( cProgName ) CLASS HB_LogFile

   IF .not. ::lOpened
      RETURN .F.
   ENDIF

   Fwrite( ::nFileHandle, HB_BldLogMsg( HB_LogDateStamp(), Time(), "--", cProgName, "end --", HB_OsNewLine() ) )

   FClose( ::nFileHandle )
   ::nFileHandle := -1

   ::lOpened := .F.

RETURN .T.
hblog.prg536
HB_LOGFILE:METHODSend( nStyle, cMessage, cProgName, nPrio ) CLASS HB_LogFile
METHOD Send( nStyle, cMessage, cProgName, nPrio ) CLASS HB_LogFile

   LOCAL nCount

   FWrite( ::nFileHandle, ::Format( nStyle, cMessage, cProgName, nPrio ) + HB_OsNewLine() )
   HB_FCommit( ::nFileHandle );

   // see file limit and eventually swap file.
   IF ::nFileLimit > 0
      IF FSeek( ::nFileHandle, 0, FS_RELATIVE ) > ::nFileLimit * 1024
         Fwrite( ::nFileHandle, HB_BldLogMsg( HB_LogDateStamp(), Time(), "LogFile: Closing file due to size limit breaking", HB_OsNewLine() ) )
         FClose( ::nFileHandle )

         IF ::nBackup > 1
            IF File( ::cFileName +"." + Padl( ::nBackup-1, 3,"0" ) )
               FErase( ::cFileName +"." + Padl( ::nBackup-1, 3,"0" ) )
            ENDIF
            FOR nCount := ::nBackup -1 TO 1 STEP -1
               FRename( ::cFileName +"." + Padl( nCount-1, 3,"0" ), ::cFileName + "." + Padl( nCount, 3,"0" ) )
            NEXT
         ENDIF

         IF FRename( ::cFileName, ::cFileName + ".000" ) == 0
            ::nFileHandle := FCreate( ::cFileName )
            Fwrite( ::nFileHandle, HB_BldLogMsg( HB_LogDateStamp(), Time(), "LogFile: Reopening file due to size limit breaking", HB_OsNewLine() ) )
         ENDIF
      ENDIF
   ENDIF

RETURN Ferror() == 0
hblog.prg551
CLASSHB_LogSyslog FROM HB_LogChannel
CLASS HB_LogSyslog FROM HB_LogChannel

   DATA nId

   METHOD New( nLevel, nId )
   METHOD Open()
   METHOD Close()

PROTECTED:
   METHOD Send( cMessage, nPrio )

ENDCLASS
hblog.prg588
HB_LOGSYSLOG:METHODNew( nLevel, nId ) CLASS HB_LogSyslog
METHOD New( nLevel, nId ) CLASS HB_LogSyslog

   ::Super:New( nLevel )
   ::nId := nId

RETURN SELF
hblog.prg601
HB_LOGSYSLOG:METHODOpen( cName ) CLASS HB_LogSyslog
METHOD Open( cName ) CLASS HB_LogSyslog

   IF ::lOpened
      RETURN .F.
   ENDIF

   IF HB_SyslogOpen( cName )
      ::lOpened := .T.
      RETURN .T.
   ENDIF

RETURN .F.
hblog.prg608
HB_LOGSYSLOG:METHODClose( cName ) CLASS HB_LogSyslog
METHOD Close( cName ) CLASS HB_LogSyslog

   IF .not. ::lOpened
      RETURN .F.
   ENDIF

   IF HB_SyslogClose( cName )
      ::lOpened := .F.
      RETURN .T.
   ENDIF

RETURN .F.
hblog.prg621
HB_LOGSYSLOG:METHODSend( nType, cMessage, cName, nPrio ) CLASS HB_LogSyslog
METHOD Send( nType, cMessage, cName, nPrio ) CLASS HB_LogSyslog

   HB_SYMBOL_UNUSED( nType )
   // Syslog does not need timestamp, nor priority
RETURN HB_SyslogMessage( ::Format( HB_LOG_ST_LEVEL, cMessage, cName, nPrio ), nPrio, ::nId )
hblog.prg634
CLASSHB_LogDebug FROM HB_LogChannel
CLASS HB_LogDebug FROM HB_LogChannel
   DATA nMaxLevel

   METHOD New( nLevel, nMaxLevel )
hblog.prg644
HB_LOGDEBUG:METHODOpen()
   METHOD Open()    INLINE .T.
hblog.prg649
HB_LOGDEBUG:METHODClose()
   METHOD Close()   INLINE .T.
PROTECTED:
   METHOD Send( nStyle, cMessage, nPriority )

ENDCLASS
hblog.prg650
HB_LOGDEBUG:METHODNew( nLevel, nMaxLevel ) CLASS HB_LogDebug
METHOD New( nLevel, nMaxLevel ) CLASS HB_LogDebug

   ::Super:New( nLevel )
   ::nMaxLevel := nMaxLevel

RETURN Self
hblog.prg656
PROCEDURESend( nStyle, cMessage, cName, nPriority ) CLASS HB_LogDebug
PROCEDURE Send( nStyle, cMessage, cName, nPriority ) CLASS HB_LogDebug

   IF .not. Empty( ::nMaxLevel )
      IF nPriority < ::nMaxLevel
         RETURN
      ENDIF
   ENDIF

   HB_OutDebug( ::Format( nStyle, cMessage, cName, nPriority ) )

RETURN
hblog.prg663
hblognet.prg
TypeFunctionSourceLine
CLASSHB_LogEmail FROM HB_LogChannel
CLASS HB_LogEmail FROM HB_LogChannel
   DATA cServer
   DATA cAddress        INIT "log@xharbour.org"
   DATA cSubject        INIT "Log message from xharbour application"
   DATA cSendTo
   DATA cHelo           INIT "XHarbour E-mail Logger"
   DATA nPort           INIT 25

   DATA cPrefix
   DATA cPostfix

   METHOD New( nLevel, cHelo, cServer, cSendTo, cSubject, cFrom )
   METHOD Open()
   METHOD Close()

PROTECTED:
   METHOD Send( nStyle, cMessage, cProgName, nPrio )

HIDDEN:
   METHOD GetOk()
   METHOD Prepare( nStyle, cMessage, cProgName, nPrio )

ENDCLASS
hblognet.prg56
HB_LOGEMAIL:METHODNew( nLevel, cHelo, cServer, cSendTo, cSubject, cFrom ) CLASS HB_LogEmail
METHOD New(  nLevel, cHelo, cServer, cSendTo, cSubject, cFrom ) CLASS HB_LogEmail
   LOCAL nPos

   ::Super:New( nLevel )

   nPos := At( ":", cServer )
   IF nPos > 0
      ::nPort := Val(Substr( cServer, nPos + 1 ) )
      cServer := Substr( cServer , 1, nPos -1 )
   ENDIF

   ::cServer := cServer
   ::cSendTo := cSendTo

   IF cHelo != NIL
      ::cHelo := cHelo
   ENDIF

   IF cSubject != NIL
      ::cSubject := cSubject
   ENDIF

   IF cFrom != NIL
      ::cAddress := cFrom
   ENDIF

RETURN SELF
hblognet.prg80
HB_LOGEMAIL:METHODOpen( cName ) CLASS HB_LogEmail
METHOD Open( cName ) CLASS HB_LogEmail
   HB_SYMBOL_UNUSED( cName )
   InetInit()
RETURN .T.
hblognet.prg111
HB_LOGEMAIL:METHODClose( cName ) CLASS HB_LogEmail
METHOD Close( cName ) CLASS HB_LogEmail
   HB_SYMBOL_UNUSED( cName )
   InetCleanup()
RETURN .T.
hblognet.prg119
HB_LOGEMAIL:METHODSend( nStyle, cMessage, cName, nPrio ) CLASS HB_LogEmail
METHOD Send( nStyle, cMessage, cName, nPrio ) CLASS HB_LogEmail
   LOCAL skCon := InetCreate()


   InetSetTimeout( skCon, 10000 )

   InetConnect( ::cServer, ::nPort, skCon )

   IF InetErrorCode( skCon ) != 0 .or. .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   InetSendAll( skCon, "HELO " + ::cHelo + InetCRLF() )
   IF .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   InetSendAll( skCon, "MAIL FROM: <" + ::cAddress +">" + InetCRLF() )
   IF .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   InetSendAll( skCon, "RCPT TO: <" + ::cSendTo +">" + InetCRLF() )
   IF .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   InetSendAll( skCon, "DATA" + InetCRLF() )
   IF .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   cMessage := ::Prepare( nStyle, cMessage, cName, nPrio )

   InetSendAll( skCon,  cMessage + InetCRLF() + "." + InetCRLF() )
   IF .not. ::GetOk( skCon )
      RETURN .F.
   ENDIF

   InetSendAll( skCon, "QUIT" + InetCRLF() )

RETURN ::GetOk( skCon )  // if quit fails, the mail does not go!
hblognet.prg129
HB_LOGEMAIL:METHODGetOk( skCon ) CLASS HB_LogEmail
METHOD GetOk( skCon ) CLASS HB_LogEmail
   LOCAL nLen, cReply

   cReply := InetRecvLine( skCon, @nLen, 128 )
   IF InetErrorCode( skcon ) != 0 .or. Substr( cReply, 1, 1 ) == '5'
      RETURN .F.
   ENDIF
RETURN .T.
hblognet.prg176
HB_LOGEMAIL:METHODPrepare( nStyle, cMessage, cName, nPrio ) CLASS HB_LogEmail
METHOD Prepare( nStyle, cMessage, cName, nPrio ) CLASS HB_LogEmail
   LOCAL cPre
   cPre := "FROM: " + ::cAddress + InetCRLF() + ;
               "TO: " + ::cSendTo + InetCRLF() +;
               "Subject:" + ::cSubject + InetCRLF() + InetCRLF()

   IF .not. Empty( ::cPrefix )
      cPre += ::cPrefix + InetCRLF() + InetCRLF()
   ENDIF

   cPre += ::Format( nStyle, cMessage, cName, nPrio )

   IF .not. Empty( ::cPostfix )
      cPre += InetCRLF() +InetCRLF() + ::cPostfix + InetCRLF()
   ENDIF

RETURN cPre
hblognet.prg185
CLASSHB_LogInetPort FROM HB_LogChannel
CLASS HB_LogInetPort FROM HB_LogChannel
   DATA nPort           INIT 7761
   DATA aListeners      INIT {}
   DATA skIn

#ifdef HB_THREAD_SUPPORT
   DATA bTerminate      INIT .F.
   DATA nThread
   DATA mtxBusy
#endif

   METHOD New( nLevel, nPort )
   METHOD Open( cName )
   METHOD Close( cName )

PROTECTED:
   METHOD Send( nStyle, cMessage, cName, nPrio )

#ifdef HB_THREAD_SUPPORT
HIDDEN:
   METHOD AcceptCon()
#endif

ENDCLASS
hblognet.prg209
HB_LOGINETPORT:METHODNew( nLevel, nPort ) CLASS HB_LogInetPort
METHOD New( nLevel, nPort ) CLASS HB_LogInetPort

   ::Super:New( nLevel )

   IF nPort != NIL
      ::nPort := nPort
   ENDIF

RETURN Self
hblognet.prg235
HB_LOGINETPORT:METHODOpen( cName ) CLASS HB_LogInetPort
METHOD Open( cName ) CLASS HB_LogInetPort

   HB_SYMBOL_UNUSED( cName )

   InetInit()

   ::skIn := InetServer( ::nPort )

   IF ::skIn == NIL
      RETURN .F.
   ENDIF

#ifdef HB_THREAD_SUPPORT
   ::mtxBusy := HB_MutexCreate()
   ::nThread := StartThread( Self, "AcceptCon" )
#else
   // If we have not threads, we have to sync accept incoming connection
   // when we log a message
   InetSetTimeout( ::skIn, 50 )
#endif

RETURN .T.
hblognet.prg246
HB_LOGINETPORT:METHODClose( cName ) CLASS HB_LogInetPort
METHOD Close( cName ) CLASS HB_LogInetPort
   LOCAL sk

   HB_SYMBOL_UNUSED( cName )

   IF ::skIn == NIL
      RETURN .F.
   ENDIF

#ifdef HB_THREAD_SUPPORT
   // kind termination request
   ::bTerminate := .T.
   JoinThread( ::nThread )
#endif

   InetClose( ::skIn )

   // we now are sure that incoming thread index is not used.

   DO WHILE  Len( ::aListeners ) > 0
      sk := ATail( ::aListeners )
      ASize( ::aListeners, Len( ::aListeners ) - 1 )
      InetClose( sk )
   ENDDO

   InetCleanup()
RETURN .T.
hblognet.prg270
HB_LOGINETPORT:METHODSend( nStyle, cMessage, cName, nPrio ) CLASS HB_LogInetPort
METHOD Send( nStyle, cMessage, cName, nPrio ) CLASS HB_LogInetPort
   LOCAL sk, nCount

#ifdef HB_THREAD_SUPPORT
   // be sure thread is not busy now
   HB_MutexLock( ::mtxBusy )
#else
   // IF we have not a thread, we must see if there is a new connection
   sk := InetAccept( ::skIn )  //timeout should be short

   IF sk != NIL
      Aadd( ::aListeners, sk )
   ENDIF
#endif

   // now we transmit the message to all the available channels
   cMessage := ::Format( nStyle, cMessage, cName, nPrio )

   nCount := 1
   DO WHILE nCount <= Len( ::aListeners )
      sk := ::aListeners[ nCount ]
      InetSendAll( sk, cMessage + InetCRLF() )
      // if there is an error, we remove the listener
      IF InetErrorCode( sk ) != 0
         ADel( ::aListeners, nCount )
         ASize( ::aListeners , Len( ::aListeners ) - 1)
      ELSE
         nCount ++
      ENDIF
   ENDDO

#ifdef HB_THREAD_SUPPORT
   HB_MutexUnlock( ::mtxBusy )
#endif

RETURN .T.
hblognet.prg299
HB_LOGINETPORT:METHODAcceptCon() CLASS HB_LogInetPort
METHOD AcceptCon() CLASS HB_LogInetPort
   LOCAL sk

   InetSetTimeout( ::skIn, 250 )
   DO WHILE .not. ::bTerminate
      sk := InetAccept( ::skIn )
      // A gentle termination request, or an error
      IF sk != NIL
         HB_MutexLock( ::mtxBusy )
         AAdd( ::aListeners, sk )
         HB_MutexUnlock( ::mtxBusy )
      ENDIF
   ENDDO
RETURN .T.
hblognet.prg338
hbstruct.prg
TypeFunctionSourceLine
PROCEDUREHB_HashAddMember( aName, cType, uInit, oObj )
procedure HB_HashAddMember( aName, cType, uInit, oObj )

   local cName

   if !( cType == nil )

      switch Upper( Left( cType, 1 ) )

         case "S" // STRING

              if uInit == nil
                 uInit = ""
              endif

              exit

         case "N" // NUMERIC

              if uInit == nil
                 uInit = 0
              endif

              exit

         case "L" // LOGICAL

              if uInit == nil
                 uInit = .f.
              endif

              exit

         case "D" // DATE

              if uInit == nil
                 uInit = CtoD( "" )
              endif

              exit

         case "C" // CODEBLOCK

              if uInit == nil
                 uInit = { || nil }
              endif

              exit

         case "A" // ARRAY

              if uInit == nil
                 uInit = {}
              endif

              exit

         case "O" // OBJECT
              exit

      end switch

   endif

   for each cName in aName
       oObj[ cName ] = uInit
   next

return
hbstruct.prg53
txml.prg
TypeFunctionSourceLine
CLASSTXMLNode
CLASS TXMLNode
   DATA nType
   DATA cName
   DATA aAttributes
   DATA nBeginLine
   DATA cData

   DATA oNext
   DATA oPrev
   DATA oParent
   DATA oChild

   METHOD New( nType, cName, aAttributes, cData ) CONSTRUCTOR
txml.prg59
TXMLNODE:METHODClone()
   METHOD Clone()                      INLINE HBXml_node_clone( Self )
txml.prg72
TXMLNODE:METHODCloneTree()
   METHOD CloneTree()                  INLINE HBXml_node_clone_tree( Self )
txml.prg73
TXMLNODE:METHODUnlink()
   METHOD Unlink()                     INLINE HBXml_node_unlink( Self )
   METHOD NextInTree()
txml.prg75
TXMLNODE:METHODInsertBefore( oNode )
   METHOD InsertBefore( oNode )        INLINE HBXml_node_insert_before( Self, oNode )
txml.prg78
TXMLNODE:METHODInsertAfter( oNode )
   METHOD InsertAfter( oNode )         INLINE HBXml_node_insert_after( Self, oNode )
txml.prg79
TXMLNODE:METHODInsertBelow( oNode )
   METHOD InsertBelow( oNode )         INLINE HBXml_node_insert_below( Self, oNode )
txml.prg80
TXMLNODE:METHODAddBelow( oNode )
   METHOD AddBelow( oNode )            INLINE HBXml_node_add_below( Self, oNode )
txml.prg81
TXMLNODE:METHODGetAttribute( cAttrib )
   METHOD GetAttribute( cAttrib )         INLINE IIF ( cAttrib $ ::aAttributes, ::aAttributes[ cAttrib ], NIL )
txml.prg83
TXMLNODE:METHODSetAttribute( cAttrib, xValue )
   METHOD SetAttribute( cAttrib, xValue ) INLINE ::aAttributes[ cAttrib ] := xValue

   METHOD Depth()
   METHOD Path()
txml.prg84
TXMLNODE:METHODToString( nStyle )
   METHOD ToString( nStyle )        INLINE HBXml_node_to_string( Self, nStyle )
txml.prg89
TXMLNODE:METHODWrite( fHandle, nStyle )
   METHOD Write( fHandle, nStyle )  INLINE HBXml_node_write( Self, fHandle, nStyle )
txml.prg90
TXMLNODE:METHODToArray()
   METHOD ToArray()                 INLINE;
             { ::nType, ::cName, ::aAttributes, ::cData }
ENDCLASS
txml.prg93
TXMLNODE:METHODNew( nType, cName, aAttributes, cData ) class TXmlNode
METHOD New( nType, cName, aAttributes, cData ) class TXmlNode
   IF nType == NIL
      ::nType := HBXML_TYPE_TAG
   ELSE
      ::nType := nType
   ENDIF

   IF aAttributes == NIL
      ::aAttributes := {=>}
   ELSE
      ::aAttributes := aAttributes
   ENDIF

   ::cName := cName
   ::cData := cData
RETURN Self
txml.prg97
TXMLNODE:METHODNextInTree() CLASS TXmlNode
METHOD NextInTree() CLASS TXmlNode
   LOCAL oNext := NIL, oTemp

   IF ::oChild != NIL
      oNext := ::oChild
   ELSEIF ::oNext != NIL
      oNext := ::oNext
   ELSE
      oTemp := ::oParent
      DO WHILE oTemp != NIL
         IF oTemp:oNext != NIL
            oNext := oTemp:oNext
            EXIT
         ENDIF
         oTemp := oTemp:oParent
      ENDDO
   ENDIF

RETURN oNext
txml.prg115
TXMLNODE:METHODDepth() CLASS TXmlNode
METHOD Depth() CLASS TXmlNode
   IF ::oParent != NIL
      RETURN ::oParent:Depth() + 1
   ENDIF
RETURN 0
txml.prg136
TXMLNODE:METHODPath() CLASS TXmlNode
METHOD Path() CLASS TXmlNode
   IF ::nType == HBXML_TYPE_DOCUMENT
      RETURN ""
   ENDIF

   IF ::cName != NIL
      IF ::oParent != NIL
         IF ::oParent:Path() != NIL
            RETURN ::oParent:Path() + "/" + ::cName
         ENDIF
      ELSE
         RETURN "/" + ::cName
      ENDIF
   ENDIF
RETURN NIL
txml.prg143
CLASSTXmlIterator
CLASS TXmlIterator
   METHOD New( oNodeTop )           CONSTRUCTOR
   METHOD Next()
txml.prg162
TXMLITERATOR:METHODRewind()
   METHOD Rewind()                  INLINE   ::oNode := ::oTop
   METHOD Find( cName, cAttribute, cValue, cData )
txml.prg165
TXMLITERATOR:METHODGetNode()
   METHOD GetNode()                 INLINE   ::oNode
   METHOD SetContext()
   METHOD Clone()

PROTECTED:
   METHOD MatchCriteria()

   DATA cName
   DATA cAttribute
   DATA cValue
   DATA cData

HIDDEN:
   DATA nTopLevel

   DATA oNode
   DATA oTop

ENDCLASS
txml.prg168
TXMLITERATOR:METHODNew( oNodeTop ) CLASS TXmlIterator
METHOD New( oNodeTop ) CLASS TXmlIterator
   ::oTop  := oNodeTop
   ::oNode := oNodeTop
   ::nTopLevel := oNodeTop:Depth()
RETURN Self
txml.prg189
TXMLITERATOR:METHODClone() CLASS TXmlIterator
METHOD Clone() CLASS TXmlIterator
   LOCAL oRet

   oRet := TXmlIterator():New( ::oNodeTop )
   oRet:cName := ::cName
   oRet:cAttribute := ::cAttribute
   oRet:cValue := ::cValue
   oRet:cData := ::cData
RETURN oRet
txml.prg196
TXMLITERATOR:METHODSetContext() CLASS TXmlIterator
METHOD SetContext() CLASS TXmlIterator
   ::oTop := ::oNode
RETURN Self
txml.prg206
TXMLITERATOR:METHODFind( cName, cAttribute, cValue, cData ) CLASS TXmlIterator
METHOD Find( cName, cAttribute, cValue, cData ) CLASS TXmlIterator
   ::cName := cName
   ::cAttribute := cAttribute
   ::cValue := cValue
   ::cData := cData

   IF ::oNode:nType == HBXML_TYPE_DOCUMENT
      IF ::oNode:oChild == NIL
         RETURN NIL
      ENDIF
      ::oNode := ::oNode:oChild
   ENDIF

   IF ::MatchCriteria( ::oNode )
      RETURN ::oNode
   ENDIF

RETURN ::Next()
txml.prg210
TXMLITERATOR:METHODNext() CLASS TXmlIterator
METHOD Next() CLASS TXmlIterator
   LOCAL oFound := ::oNode:NextInTree()

   DO WHILE oFound != NIL
      IF oFound:Depth() <= ::nTopLevel
         RETURN NIL
      ENDIF

      IF ::MatchCriteria( oFound )
         ::oNode := oFound
         RETURN oFound
      ENDIF

      oFound := oFound:NextInTree()
   ENDDO

RETURN NIL
txml.prg230
TXMLITERATOR:METHODMatchCriteria( oNode ) CLASS TXmlIterator
METHOD MatchCriteria( oNode ) CLASS TXmlIterator
   HB_SYMBOL_UNUSED( oNode )
RETURN .T.
txml.prg248
CLASSTXmlIteratorScan FROM TXmlIterator
CLASS TXmlIteratorScan FROM TXmlIterator
   METHOD New( oNodeTop ) CONSTRUCTOR
PROTECTED:
   METHOD MatchCriteria( oFound )
ENDCLASS
txml.prg257
TXMLITERATORSCAN:METHODNew( oNodeTop ) CLASS TXmlIteratorScan
METHOD New( oNodeTop ) CLASS TXmlIteratorScan
   ::Super:New( oNodeTop )
RETURN Self
txml.prg263
TXMLITERATORSCAN:METHODMatchCriteria( oFound ) CLASS TXmlIteratorScan
METHOD MatchCriteria( oFound ) CLASS TXmlIteratorScan

   IF ::cName != NIL .and. ( oFound:cName == NIL .or. ::cName != oFound:cName )
      RETURN .F.
   ENDIF

   IF ::cAttribute != NIL .and. .not. ::cAttribute $ oFound:aAttributes
      RETURN .F.
   ENDIF

   IF ::cValue != NIL .and. ;
      hb_HScan( oFound:aAttributes, {| xKey, cValue| HB_SYMBOL_UNUSED( xKey ), ::cValue == cValue}) == 0
      RETURN .F.
   ENDIF

   IF ::cData != NIL .and. ( oFound:cData == NIL .or. ::cData != oFound:cData )
      RETURN .F.
   ENDIF

RETURN .T.
txml.prg267
CLASSTXmlIteratorRegex FROM TXmlIterator
CLASS TXmlIteratorRegex FROM TXmlIterator
   METHOD New( oNodeTop ) CONSTRUCTOR
PROTECTED:
   METHOD MatchCriteria( oFound )
ENDCLASS
txml.prg292
TXMLITERATORREGEX:METHODNew( oNodeTop ) CLASS TXmlIteratorRegex
METHOD New( oNodeTop ) CLASS TXmlIteratorRegex
   ::Super:New( oNodeTop )
RETURN Self
txml.prg299
TXMLITERATORREGEX:METHODMatchCriteria( oFound ) CLASS TXmlIteratorRegex
METHOD MatchCriteria( oFound ) CLASS TXmlIteratorRegex

   IF ::cName != NIL .and. ;
         ( oFound:cName == NIL .or. .not. HB_REGEXMATCH( ::cName, oFound:cName, .t. ) )
      RETURN .F.
   ENDIF

   IF ::cAttribute != NIL .and. ;
         hb_hScan( oFound:aAttributes, {|cKey| HB_REGEXMATCH( ::cAttribute, cKey, .t. ) } ) == 0
      RETURN .F.
   ENDIF

   IF ::cValue != NIL .and. ;
         hb_hScan( oFound:aAttributes, {|xKey, cValue| HB_SYMBOL_UNUSED( xKey ), HB_REGEXMATCH( ::cValue, cValue, .t. ) } ) == 0
      RETURN .F.
   ENDIF

   IF ::cData != NIL .and. ;
         ( oFound:cData == NIL .or. .not. HB_REGEXMATCH( ::cData, oFound:cData, .f. ) )
      RETURN .F.
   ENDIF

RETURN .T.
txml.prg303
CLASSTXmlDocument
CLASS TXmlDocument
   DATA oRoot
   DATA nStatus
   DATA nError
   DATA nLine
   DATA oErrorNode
   DATA nNodeCount

   METHOD New( xElem, nStyle )        CONSTRUCTOR
txml.prg332
TXMLDOCUMENT:METHODRead( xData, nStyle )
   METHOD Read( xData, nStyle )       INLINE HBXML_DATAREAD( Self, xData, nStyle )
txml.prg341
TXMLDOCUMENT:METHODToString( nStyle )
   METHOD ToString( nStyle )          INLINE ::oRoot:ToString( nStyle )
txml.prg342
TXMLDOCUMENT:METHODWrite( fHandle, nStyle )
   METHOD Write( fHandle, nStyle )    INLINE ::oRoot:Write( fHandle, nStyle )

   METHOD FindFirst( cName, cAttrib, cValue, cData )
   METHOD FindFirstRegex( cName, cAttrib, cValue, cData )
txml.prg343
TXMLDOCUMENT:METHODFindNext()
   METHOD FindNext()                   INLINE ::oIterator:Next()

   METHOD GetContext()
HIDDEN:
   DATA oIterator

ENDCLASS
txml.prg347
TXMLDOCUMENT:METHODNew( xElem, nStyle ) CLASS TXmlDocument
METHOD New( xElem, nStyle ) CLASS TXmlDocument
   ::nStatus := HBXML_STATUS_OK
   ::nError := HBXML_ERROR_NONE
   ::nLine := 1
   ::nNodeCount := 0

   IF xElem == NIL
      ::oRoot := TXmlNode():New( HBXML_TYPE_DOCUMENT )
   ELSE
      SWITCH ValType( xElem )
         CASE 'O'
            ::oRoot := xElem
            EXIT

         CASE 'N'
         CASE 'C'
            ::oRoot := TXmlNode():New( HBXML_TYPE_DOCUMENT )
            ::Read( xElem, nStyle )
      ENDSWITCH
   ENDIF

RETURN Self
txml.prg355
TXMLDOCUMENT:METHODFindFirst( cName, cAttrib, cValue, cData ) CLASS TXmlDocument
METHOD FindFirst( cName, cAttrib, cValue, cData ) CLASS TXmlDocument
   ::oIterator := TXmlIteratorScan():New( ::oRoot )
RETURN ::oIterator:Find( cName, cAttrib, cValue, cData )
txml.prg378
TXMLDOCUMENT:METHODFindFirstRegex( cName, cAttrib, cValue, cData ) CLASS TXmlDocument
METHOD FindFirstRegex( cName, cAttrib, cValue, cData ) CLASS TXmlDocument
   ::oIterator := TXmlIteratorRegex():New( ::oRoot )
RETURN ::oIterator:Find( cName, cAttrib, cValue, cData )
txml.prg382
TXMLDOCUMENT:METHODGetContext() CLASS TXmlDocument
METHOD GetContext() CLASS TXmlDocument
   LOCAL oDoc

   oDoc := TXmlDocument():New()
   oDoc:oRoot := ::oIterator:GetNode()

RETURN oDoc
txml.prg387
xhbcomp.prg
TypeFunctionSourceLine
INIT PROCEDURExhb_Init()
INIT PROCEDURE xhb_Init()
   /* Add calls to do initial settings to Harbour to be more compatible with xhb. */

   ASSOCIATE CLASS _Character    WITH TYPE Character
   ASSOCIATE CLASS _Numeric      WITH TYPE Numeric
   ASSOCIATE CLASS _Array        WITH TYPE Array
   ASSOCIATE CLASS _Hash         WITH TYPE Hash

RETURN

CREATE CLASS Character FUNCTION _Character
   OPTIONAL INHERIT HBCharacter
   OPERATOR "[]" FUNCTION XHB_INDEX()
   OPERATOR "+"  FUNCTION XHB_PLUS()
   OPERATOR "-"  FUNCTION XHB_MINUS()
   OPERATOR "*"  FUNCTION XHB_MULT()
   OPERATOR "/"  FUNCTION XHB_DIV()
   OPERATOR "%"  FUNCTION XHB_MOD()
   OPERATOR "^"  FUNCTION XHB_POW()
   OPERATOR "++" FUNCTION XHB_INC()
   OPERATOR "--" FUNCTION XHB_DEC()
ENDCLASS

CREATE CLASS Numeric FUNCTION _Numeric
   OPTIONAL INHERIT HBNumeric
   OPERATOR "+"  FUNCTION XHB_PLUS()
   OPERATOR "-"  FUNCTION XHB_MINUS()
   OPERATOR "*"  FUNCTION XHB_MULT()
   OPERATOR "/"  FUNCTION XHB_DIV()
   OPERATOR "%"  FUNCTION XHB_MOD()
   OPERATOR "^"  FUNCTION XHB_POW()
   OPERATOR "++" FUNCTION XHB_INC()
   OPERATOR "--" FUNCTION XHB_DEC()
ENDCLASS

CREATE CLASS Array FUNCTION _Array
   OPTIONAL INHERIT HBArray
   OPERATOR "[]" FUNCTION XHB_INDEX()
   OPERATOR "$$" FUNCTION XHB_INCLUDE()
ENDCLASS

CREATE CLASS Hash INHERIT __HBHash FUNCTION _Hash
   OPTIONAL INHERIT HBHash
   ON ERROR FUNCTION XHB_HASHERROR()
   OPERATOR "+"  FUNCTION XHB_PLUS()
   OPERATOR "-"  FUNCTION XHB_MINUS()
   OPERATOR "$$" FUNCTION XHB_INCLUDE()
ENDCLASS
xhbcomp.prg68

Page url: http://www.yourdomain.com/help/index.html?xhb.htm