Hi ,
after a frustrating weekend :
there is a existing c interface with a sample. The interface himselve is a dll file. For my understanding, i need to convert ( I'm still waiting for a wonder ) th *.h file into a pas unit. After this, i must include this file to my new dll delphi project and it should work .... possible the first error ? okay , i have no experience with c .... i searched for some explanations / tools or so on, what i found was headconv from the jedi project ... a old tool to convert a header file. But there was no success. Possible someone have a tip / tutorial ? attached the header :
/*----------------------------------------------------------------------------
// ServiceCenter plugin interface definition
//---------------------------------------------------------------------------*/
#if !defined( SCPLUGIN_H )
#define SCPLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#if (_MSC_VER >= 800)
/* calling convention for windows is cdecl */
#define SC_EXPORT __declspec(dllexport)
#else
/* default calling convention is whatever the compiler likes */
#define SC_EXPORT
#endif
#ifndef _INCLUDE_INCLUDED
#define PDATUM void *
#define RC_SUCCESS 0
#define RC_ERROR -1
#define DA_NUMBER 1
#define DA_STRING 2
#define DA_TIME 3
#define DA_BOOLEAN 4
#define DA_FILE 6
#define DA_ARRAY 8
#define DA_STRUCTURE 9
#endif /* _INCLUDE_INCLUDED */
/* an array of DATUM pointers */
typedef PDATUM * PDATUMARRAY;
typedef struct plugin_vtable
{
int (* daType) ( PDATUM p );
char * (* daGetTypeName) ( int n );
int (* daIsNull) ( PDATUM p );
int (* daIsAggregate) ( PDATUM p );
int (* daLength) ( PDATUM p );
PDATUM (* daFirst) ( PDATUM pdAggregate );
PDATUM (* daLast) ( PDATUM pdAggregate );
PDATUM (* daNext) ( PDATUM pdAggregate, PDATUM pdPrevious );
PDATUM (* daItem) ( PDATUM pdAggregate, int index );
double (* daGetNumber) ( PDATUM p );
void (* daSetNumber) ( PDATUM pd, double dNumber );
int (* daGetBool) ( PDATUM p );
void (* daSetBool) ( PDATUM p, int nValue );
char * (* daGetTimeAsString) ( PDATUM p );
void (* daSetTime) ( PDATUM p );
int (* daSetTimeFromString) ( PDATUM p, char * pszTimeString );
char * (* daGetSzString) ( PDATUM p );
void (* daSetSzString) ( PDATUM pd, const char * pszValue );
void (* FreeString) ( char * s );
char * (* daGetFileName) ( PDATUM pdFile );
char * (* daGetFieldName) ( PDATUM pdFile, char * pszFieldRef );
PDATUM (* daGetField) ( PDATUM pdFile, char * pszFieldRef );
void (*log_print) ( const char * pszFormat, ... );
} PLUGIN_VTABLE;
/*----------------------------------------------------------------------------
// DATUM interface
//---------------------------------------------------------------------------*/
#define DA_TYPE(pd) ( penv->pvtable->daType(pd) )
#define DA_GETTYPENAME ( penv->pvtable->daGetTypeName )
#ifdef __cplusplus
#define DA_ISNULL(pd) ( (bool) penv->pvtable->daIsNull(pd) )
#else
#define DA_ISNULL(pd) ( penv->pvtable->daIsNull(pd) )
#endif
/*-----------------------------------------
// macros for manipulating compound types
//----------------------------------------*/
#ifdef __cplusplus
#define DA_ISAGGREGATE(pd) ( (bool) penv->pvtable->daIsAggregate(pd) )
#else
#define DA_ISAGGREGATE(pd) ( penv->pvtable->daIsAggregate(pd) )
#endif
#define DA_LENGTH(pdAgg) ( penv->pvtable->daLength(pdAgg) )
#define DA_FIRST(pdAgg) ( penv->pvtable->daFirst(pdAgg) )
#define DA_LAST(pdAgg) ( penv->pvtable->daLast(pdAgg) )
/* retrieve next datum from an aggregate (2nd argument must have been returned by DA_FIRST, DA_LAST, or DA_ITEM) */
#define DA_NEXT(pdAgg,pdPrev) ( penv->pvtable->daNext(pdAgg, pdPrev) )
/* let the plugin developer choose whether to use one or zero-based indexing for aggregates */
/* by defining SCPLUGIN_USE_ZERO_BASED_AGGREGATES or not. Use one-based indexing by default. */
#ifndef SCPLUGIN_USE_ZERO_BASED_AGGREGATES
#define SCPLUGIN_ONE_BASED 1
#else
#define SCPLUGIN_ONE_BASED 0
#endif
/* retrieve the "ith" item from an aggregate datum (one-based index by default) */
#define DA_ITEM(pd,i) ( penv->pvtable->daItem(pd,i-SCPLUGIN_ONE_BASED) )
/*--------------------------------------
// macros for manipulating basic types
//-------------------------------------*/
#define DA_GETNUMBER(pd) ( penv->pvtable->daGetNumber(pd) )
#define DA_SETNUMBER(pd,n) ( penv->pvtable->daSetNumber(pd, (double) n )
/* not safe to actually return bool since plugins can be written in "C", */
/* so we return "int", but cast to "bool" if C++ */
#ifdef __cplusplus
#define DA_GETBOOLEAN(pd) ( (bool) penv->pvtable->daGetBool(pd) )
#define DA_SETBOOLEAN(pd, b) ( penv->pvtable->daSetBool(pd,(int)b) )
#else
#define DA_GETBOOLEAN(pd) ( penv->pvtable->daGetBool(pd) )
#define DA_SETBOOLEAN(pd, b) ( penv->pvtable->daSetBool(pd,b) )
#endif
#define DA_GETTIMESTRING(pd) ( penv->pvtable->daGetTimeAsString(pd) )
#define DA_SETTIMESTRING(pd,s) ( penv->pvtable->daSetTimeFromString(pd,s) )
#define DA_SETCURRENTTIME(pd) ( penv->pvtable->daSetTime(pd) )
#define DA_GETSTRING(pd) ( penv->pvtable->daGetSzString(pd) )
#define DA_FREESTRING(s) ( penv->pvtable->FreeString(s) )
#define DA_SETSTRING(pd, pszValue) ( penv->pvtable->daSetSzString(pd, pszValue) )
/*--------------------------------------
// macros for manipulating file data
//--------------------------------------*/
/* Get the name of the file for a datum representing a file */
#define DA_GETFILENAME(pdFile) ( penv->pvtable->daGetFileName(pdFile) )
/* Get field name given dbdict field reference such as "header,1" or "1 in $file"
// For flat files, column names can be retrieved using just the relative field number in string form,
// e.g. "1", "2", "3". Expressions such as "header,1" are only needed when the file
// contains arrays or structures such as "header" or "trailer" like the problem file does. */
#define DA_GETFIELDNAME(pdFile,pszFldRef) ( penv->pvtable->daGetFieldName(pdFile,pszFldRef) )
/* Get field datum given dbdict field reference such as "header,1" or "1 in $file" or "1" */
#define DA_GETFIELD(pdFile, pszFldRef) ( penv->pvtable->daGetField(pdFile, pszFldRef) )
/*----------------------------------------------------------------------------
// other macros
//----------------------------------------------------------------------------*/
/* Note: to use the SC_LOGPRINT macro, enclose all values in parens, for example: */
/* */
/* SC_LOGPRINT( ( "Field has string value of '%s'\n", pString ) ); */
#define SC_LOGPRINT(printfStyleParms) ( penv->pvtable->log_print printfStyleParms )
/*----------------------------------------------------------------------------
// Environment passed for communication between ServiceCenter and the
// plug-in
//
// The plug-in keeps its private data in the void pointer pPrivate
//----------------------------------------------------------------------------*/
typedef struct scplugin_env
{
char * pszName; /* plugin name */
void * pPrivate; /* plugin private memory pointer */
/* vector of callback routines */
PLUGIN_VTABLE * pvtable;
} SCPLUGIN_ENV;
typedef SCPLUGIN_ENV * PSCPLUGIN_ENV;
SC_EXPORT int SCPluginInitialize(PSCPLUGIN_ENV penv);
SC_EXPORT int SCPluginTerminate(PSCPLUGIN_ENV penv);
SC_EXPORT int SCPluginExecute(PSCPLUGIN_ENV penv, int iArgCount, PDATUMARRAY pdArray);
#ifdef __cplusplus
}
#endif
#endif
Thanks for any tips
after a frustrating weekend :
there is a existing c interface with a sample. The interface himselve is a dll file. For my understanding, i need to convert ( I'm still waiting for a wonder ) th *.h file into a pas unit. After this, i must include this file to my new dll delphi project and it should work .... possible the first error ? okay , i have no experience with c .... i searched for some explanations / tools or so on, what i found was headconv from the jedi project ... a old tool to convert a header file. But there was no success. Possible someone have a tip / tutorial ? attached the header :
/*----------------------------------------------------------------------------
// ServiceCenter plugin interface definition
//---------------------------------------------------------------------------*/
#if !defined( SCPLUGIN_H )
#define SCPLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#if (_MSC_VER >= 800)
/* calling convention for windows is cdecl */
#define SC_EXPORT __declspec(dllexport)
#else
/* default calling convention is whatever the compiler likes */
#define SC_EXPORT
#endif
#ifndef _INCLUDE_INCLUDED
#define PDATUM void *
#define RC_SUCCESS 0
#define RC_ERROR -1
#define DA_NUMBER 1
#define DA_STRING 2
#define DA_TIME 3
#define DA_BOOLEAN 4
#define DA_FILE 6
#define DA_ARRAY 8
#define DA_STRUCTURE 9
#endif /* _INCLUDE_INCLUDED */
/* an array of DATUM pointers */
typedef PDATUM * PDATUMARRAY;
typedef struct plugin_vtable
{
int (* daType) ( PDATUM p );
char * (* daGetTypeName) ( int n );
int (* daIsNull) ( PDATUM p );
int (* daIsAggregate) ( PDATUM p );
int (* daLength) ( PDATUM p );
PDATUM (* daFirst) ( PDATUM pdAggregate );
PDATUM (* daLast) ( PDATUM pdAggregate );
PDATUM (* daNext) ( PDATUM pdAggregate, PDATUM pdPrevious );
PDATUM (* daItem) ( PDATUM pdAggregate, int index );
double (* daGetNumber) ( PDATUM p );
void (* daSetNumber) ( PDATUM pd, double dNumber );
int (* daGetBool) ( PDATUM p );
void (* daSetBool) ( PDATUM p, int nValue );
char * (* daGetTimeAsString) ( PDATUM p );
void (* daSetTime) ( PDATUM p );
int (* daSetTimeFromString) ( PDATUM p, char * pszTimeString );
char * (* daGetSzString) ( PDATUM p );
void (* daSetSzString) ( PDATUM pd, const char * pszValue );
void (* FreeString) ( char * s );
char * (* daGetFileName) ( PDATUM pdFile );
char * (* daGetFieldName) ( PDATUM pdFile, char * pszFieldRef );
PDATUM (* daGetField) ( PDATUM pdFile, char * pszFieldRef );
void (*log_print) ( const char * pszFormat, ... );
} PLUGIN_VTABLE;
/*----------------------------------------------------------------------------
// DATUM interface
//---------------------------------------------------------------------------*/
#define DA_TYPE(pd) ( penv->pvtable->daType(pd) )
#define DA_GETTYPENAME ( penv->pvtable->daGetTypeName )
#ifdef __cplusplus
#define DA_ISNULL(pd) ( (bool) penv->pvtable->daIsNull(pd) )
#else
#define DA_ISNULL(pd) ( penv->pvtable->daIsNull(pd) )
#endif
/*-----------------------------------------
// macros for manipulating compound types
//----------------------------------------*/
#ifdef __cplusplus
#define DA_ISAGGREGATE(pd) ( (bool) penv->pvtable->daIsAggregate(pd) )
#else
#define DA_ISAGGREGATE(pd) ( penv->pvtable->daIsAggregate(pd) )
#endif
#define DA_LENGTH(pdAgg) ( penv->pvtable->daLength(pdAgg) )
#define DA_FIRST(pdAgg) ( penv->pvtable->daFirst(pdAgg) )
#define DA_LAST(pdAgg) ( penv->pvtable->daLast(pdAgg) )
/* retrieve next datum from an aggregate (2nd argument must have been returned by DA_FIRST, DA_LAST, or DA_ITEM) */
#define DA_NEXT(pdAgg,pdPrev) ( penv->pvtable->daNext(pdAgg, pdPrev) )
/* let the plugin developer choose whether to use one or zero-based indexing for aggregates */
/* by defining SCPLUGIN_USE_ZERO_BASED_AGGREGATES or not. Use one-based indexing by default. */
#ifndef SCPLUGIN_USE_ZERO_BASED_AGGREGATES
#define SCPLUGIN_ONE_BASED 1
#else
#define SCPLUGIN_ONE_BASED 0
#endif
/* retrieve the "ith" item from an aggregate datum (one-based index by default) */
#define DA_ITEM(pd,i) ( penv->pvtable->daItem(pd,i-SCPLUGIN_ONE_BASED) )
/*--------------------------------------
// macros for manipulating basic types
//-------------------------------------*/
#define DA_GETNUMBER(pd) ( penv->pvtable->daGetNumber(pd) )
#define DA_SETNUMBER(pd,n) ( penv->pvtable->daSetNumber(pd, (double) n )
/* not safe to actually return bool since plugins can be written in "C", */
/* so we return "int", but cast to "bool" if C++ */
#ifdef __cplusplus
#define DA_GETBOOLEAN(pd) ( (bool) penv->pvtable->daGetBool(pd) )
#define DA_SETBOOLEAN(pd, b) ( penv->pvtable->daSetBool(pd,(int)b) )
#else
#define DA_GETBOOLEAN(pd) ( penv->pvtable->daGetBool(pd) )
#define DA_SETBOOLEAN(pd, b) ( penv->pvtable->daSetBool(pd,b) )
#endif
#define DA_GETTIMESTRING(pd) ( penv->pvtable->daGetTimeAsString(pd) )
#define DA_SETTIMESTRING(pd,s) ( penv->pvtable->daSetTimeFromString(pd,s) )
#define DA_SETCURRENTTIME(pd) ( penv->pvtable->daSetTime(pd) )
#define DA_GETSTRING(pd) ( penv->pvtable->daGetSzString(pd) )
#define DA_FREESTRING(s) ( penv->pvtable->FreeString(s) )
#define DA_SETSTRING(pd, pszValue) ( penv->pvtable->daSetSzString(pd, pszValue) )
/*--------------------------------------
// macros for manipulating file data
//--------------------------------------*/
/* Get the name of the file for a datum representing a file */
#define DA_GETFILENAME(pdFile) ( penv->pvtable->daGetFileName(pdFile) )
/* Get field name given dbdict field reference such as "header,1" or "1 in $file"
// For flat files, column names can be retrieved using just the relative field number in string form,
// e.g. "1", "2", "3". Expressions such as "header,1" are only needed when the file
// contains arrays or structures such as "header" or "trailer" like the problem file does. */
#define DA_GETFIELDNAME(pdFile,pszFldRef) ( penv->pvtable->daGetFieldName(pdFile,pszFldRef) )
/* Get field datum given dbdict field reference such as "header,1" or "1 in $file" or "1" */
#define DA_GETFIELD(pdFile, pszFldRef) ( penv->pvtable->daGetField(pdFile, pszFldRef) )
/*----------------------------------------------------------------------------
// other macros
//----------------------------------------------------------------------------*/
/* Note: to use the SC_LOGPRINT macro, enclose all values in parens, for example: */
/* */
/* SC_LOGPRINT( ( "Field has string value of '%s'\n", pString ) ); */
#define SC_LOGPRINT(printfStyleParms) ( penv->pvtable->log_print printfStyleParms )
/*----------------------------------------------------------------------------
// Environment passed for communication between ServiceCenter and the
// plug-in
//
// The plug-in keeps its private data in the void pointer pPrivate
//----------------------------------------------------------------------------*/
typedef struct scplugin_env
{
char * pszName; /* plugin name */
void * pPrivate; /* plugin private memory pointer */
/* vector of callback routines */
PLUGIN_VTABLE * pvtable;
} SCPLUGIN_ENV;
typedef SCPLUGIN_ENV * PSCPLUGIN_ENV;
SC_EXPORT int SCPluginInitialize(PSCPLUGIN_ENV penv);
SC_EXPORT int SCPluginTerminate(PSCPLUGIN_ENV penv);
SC_EXPORT int SCPluginExecute(PSCPLUGIN_ENV penv, int iArgCount, PDATUMARRAY pdArray);
#ifdef __cplusplus
}
#endif
#endif
Thanks for any tips