Hi Pritpal,

The libharu object is one example in hbhpdf, or SSL_CONTEXT in
hbssl/sslctx.c from line 80 to line 140 (except hb_ssl_method_id_to_ptr()
which is unrelated). There are many other uses, but these are two
quite pure ones.

Or here is a file find API (where the object is HB_FFIND), which I've been
planning to add to Harbour for some time:

---
static HB_GARBAGE_FUNC( PHB_FFIND_release )
{
   void ** ph = ( void ** ) Cargo;

   /* Check if pointer is not NULL to avoid multiple freeing */
   if( ph && * ph )
   {
      /* Destroy the object */
      hb_fsFindClose( ( PHB_FFIND ) * ph );

      /* set pointer to NULL just in case */
      * ph = NULL;
   }
}

static PHB_FFIND PHB_FFIND_par( int iParam )
{
   void ** ph = ( void ** ) hb_parptrGC( PHB_FFIND_release, iParam );

   return ph ? ( PHB_FFIND ) * ph : NULL;
}

HB_FUNC( FILEFINDFIRST )
{
   if( ISCHAR( 1 ) && ISBYREF( 2 ) )
   {
      void ** ph = ( void ** ) hb_gcAlloc( sizeof( PHB_FFIND ),
PHB_FFIND_release );

      PHB_FFIND ffind = hb_fsFindFirst( hb_parc( 1 ), ISNUM( 3 ) ? hb_parnl(
3 ) : HB_FA_ALL );

      * ph = ( void * ) ffind;

      hb_storptrGC( ph, 2 );

      hb_retl( ffind != NULL );
   }
   else
      hb_retl( FALSE );
}

HB_FUNC( FILEFINDNEXT )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retl( ffind && hb_fsFindNext( ffind ) );
}

HB_FUNC( FILEFINDNAME )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retc( ffind ? ffind->szName : NULL );
}

HB_FUNC( FILEFINDATTR )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retnl( ffind ? ffind->attr : 0 );
}

HB_FUNC( FILEFINDSIZE )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retnint( ffind ? ffind->size : 0 );
}

HB_FUNC( FILEFINDDATE )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retds( ffind ? ffind->szDate : NULL );
}

HB_FUNC( FILEFINDTIME )
{
   PHB_FFIND ffind = PHB_FFIND_par( 1 );

   hb_retc( ffind ? ffind->szTime : NULL );
}
---

Brgds,
Viktor

On Sat, Jan 31, 2009 at 10:44 PM, Pritpal Bedi <[email protected]>wrote:

>
> Viktor
>
>
> Viktor Szakáts wrote:
> >
> > Create a custom C level object, with constructor and destructor
> > (hb_retptrGC()/hb_parptrGC()), and
> > some support functions to
> > retrieve the values on .prg level, and you're pretty much done.
> >
> >
>
> May be I am not so gifted a developer. Any example or hints?
>
> Regards
> Pritpal Bedi
>
> --
> View this message in context:
> http://www.nabble.com/Date-Time-Functions---Revisited-tp21767870p21768632.html
> Sent from the Harbour - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> Harbour mailing list
> [email protected]
> http://lists.harbour-project.org/mailman/listinfo/harbour
>
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to