#ifdef __cplusplus
#define EXPORT extern "C"
#define STDCALL
#else
#define EXPORT 
#define STDCALL
#endif

#ifdef WINDOWS_DLL
#undef EXPORT
#undef STDCALL
#ifdef __cplusplus
#define EXPORT extern "C"  __declspec(dllexport)
#define STDCALL
#else
#define EXPORT  __declspec(dllexport)
#define STDCALL
#endif
#endif



#ifdef MSWINDOWS_VB_DLL
#undef EXPORT
#undef STDCALL
#ifdef __cplusplus
#define EXPORT extern "C"  
#define STDCALL _stdcall
#else
#define EXPORT 
#define STDCALL _stdcall
#endif
#endif


#ifdef CALLDLL
#undef EXPORT
#undef STDCALL
#ifdef __cplusplus
#define EXPORT extern "C"
#define STDCALL
#else
#define EXPORT 
#define STDCALL
#endif
#endif



#ifdef SUNUNIX
#define EXPORT extern "C"
#define STDCALL
#ifndef DEFINED_WINDOWS_TYPE
typedef int HWND,LONG,UINT;
#endif
#endif

EXPORT char *  STDCALL  ISQL_GetIsqlFieldType(KINT64 item,char *fieldname);
EXPORT void  STDCALL  ISQL_FreeAllQueryObjects(KINT64 slot);

 EXPORT int STDCALL ISQL_ExecSql(char *cmdstring);
 EXPORT char *     STDCALL ISQL_GetInstanceStat(KINT64 slot);
EXPORT   KINT64  STDCALL  ISQL_CreateInternetSqlInstance(void);

EXPORT KINT64  STDCALL  ISQL_CurrentQueryRowCount(KINT64 slot);
EXPORT   KINT64   STDCALL  ISQL_GetRunTimeQueryItems(KINT64 slot);
EXPORT   KINT64  STDCALL  ISQL_StartInternetSql(KINT64  instance,char *dbhomedir,char *serverip,char * serverport);
EXPORT KINT64   STDCALL ISQL_StopInternetSql(   KINT64 startid);

EXPORT KINT64 STDCALL  ISQL_LoadSqlScript(KINT64 object ,char *scriptfilename,
				 char *logfilename ,
				 int stopinerror,
				 int stoplog,
				 int stopdisplay,
				 KINT64 displayfunc,
				 KINT64 userfunc);
EXPORT void STDCALL  ISQL_EnableSingleStepSqlScript(KINT64 slot);
EXPORT void STDCALL  ISQL_DisableSingleStepSqlScript(KINT64 slot);
EXPORT void STDCALL  ISQL_StartSqlScript(KINT64 slot);
EXPORT void STDCALL  ISQL_StopSqlScript(KINT64 slot);
EXPORT void STDCALL  ISQL_QuitSqlScript(KINT64 slot);
EXPORT KINT64  STDCALL  ISQL_GetRunTimeQueryCount(KINT64);
EXPORT KINT64   STDCALL ISQL_GetRunTimeQueryRowLength(KINT64);
EXPORT KINT64   STDCALL ISQL_GetQueryItemsCount(  KINT64 itemlist);
 

EXPORT char *  STDCALL  ISQL_AllTrim(char *buf);
EXPORT char *  STDCALL  ISQL_Ltrim(char *buf);
EXPORT char *  STDCALL  ISQL_Rtrim(char *buf);


EXPORT   KINT64  STDCALL  ISQL_GetQueryResultObject(KINT64);

EXPORT KINT64  STDCALL  ISQL_GetQueryResultCount(   KINT64 qry);
EXPORT KINT64 STDCALL   ISQL_GetQueryResultRowLength(  KINT64 qry);
EXPORT   KINT64  STDCALL   ISQL_GetQueryResultRow(  KINT64 qry,KINT64 rowno);
EXPORT   KINT64  STDCALL    ISQL_GetQueryResultItems(  KINT64 qry);

EXPORT void  STDCALL  ISQL_FreeQueryResultObject(KINT64,  KINT64);
EXPORT void  STDCALL  ISQL_FreeCurrentQueryResultObject(KINT64);

EXPORT char   STDCALL   ISQL_CopyItemString(  KINT64 qitemlist,char * fieldname,char *buffer);
EXPORT char     STDCALL ISQL_GetItem(  KINT64 qitemlist,char *fieldname,char  *buffer);
EXPORT char   *  STDCALL  ISQL_GetItemString(  KINT64 qitemlist,char *fieldname);
EXPORT KINT64      STDCALL ISQL_GetItemInt(  KINT64 qitemlist,char *fieldname);
EXPORT double  STDCALL  ISQL_GetItemDouble(  KINT64 qitemlist,char *fieldname);

EXPORT char  STDCALL   ISQL_CopyItemStringByFieldNo(  KINT64 qitemlist,int fieldno,char *buffer);
EXPORT char  STDCALL    ISQL_GetItemByFieldNo(  KINT64 qitemlist,int fieldno,char  *buffer);
EXPORT char   * STDCALL  ISQL_GetItemStringByFieldNo(  KINT64 qitemlist,int fieldno);
EXPORT KINT64    STDCALL  ISQL_GetItemIntByFieldNo(  KINT64 qitemlist,int fieldno);
EXPORT double STDCALL   ISQL_GetItemDoubleByFieldNo(  KINT64 qitemlist,int fieldno);


EXPORT char *  STDCALL ISQL_GetItemNameByFieldNo(  KINT64 rec,int itemno);
EXPORT char   STDCALL  ISQL_GetItemTypeByFieldNo(  KINT64 rec,int itemno);
EXPORT KINT64   STDCALL  ISQL_GetItemLengthByFieldNo(  KINT64 rec,int itemno);
EXPORT KINT64   STDCALL  ISQL_GetItemDecPosByFieldNo(  KINT64 rec,int itemno);

EXPORT char   STDCALL  ISQL_GetItemType(  KINT64 rec,char *fieldname);
EXPORT KINT64  STDCALL   ISQL_GetItemLength(  KINT64 rec,char *fieldname);
EXPORT KINT64   STDCALL  ISQL_GetItemDecPos(  KINT64 rec,char *fieldname);
EXPORT KINT64    STDCALL ISQL_GetItemNo(  KINT64 rec,char *fieldname);
EXPORT  void  STDCALL  ISQL_InstallQueryFunction(KINT64 object,KINT64  queryfunction );


 
EXPORT int  STDCALL  ISQL_ThisYear(void);
EXPORT int  STDCALL  ISQL_ThisDay(void);
EXPORT int  STDCALL  ISQL_ThisWeek(void);
EXPORT int STDCALL   ISQL_ThisCentury(void);
EXPORT int   STDCALL ISQL_ThisMonth(void);
EXPORT int  STDCALL  ISQL_EscapeSingleQuote(char *in,char *out);
EXPORT void  STDCALL  ISQL_NoNetworkMode(KINT64 slot);
EXPORT void  STDCALL  ISQL_NetworkMode(KINT64 slot);
EXPORT void STDCALL ISQL_DisableMessage(KINT64 slot);
EXPORT void STDCALL ISQL_EnableMessage(KINT64 slot);
EXPORT int   STDCALL ISQL_InitNetwork(KINT64 slot);
EXPORT void STDCALL   ISQL_SetServerIP(KINT64 slot,KINT64 ipaddr);
EXPORT void   STDCALL ISQL_SetServerPort(KINT64 slot,int port);
EXPORT KINT64   STDCALL  ISQL_GetServerIP(KINT64 slot);
EXPORT KINT64   STDCALL ISQL_GetServerPort(KINT64 slot);
EXPORT char *   STDCALL ISQL_GetHomeDir(KINT64 slot);
EXPORT int  STDCALL  ISQL_SetHomeDir(KINT64 slot,char *buf);


EXPORT   KINT64  STDCALL ISQL_GetQueryRow(  KINT64 qry,KINT64 rowno);
EXPORT   KINT64  STDCALL ISQL_GetQueryItems(  KINT64 qry);
EXPORT   KINT64 STDCALL  ISQL_GetCursorRow(  KINT64 qry,KINT64 rowno);
EXPORT   KINT64 STDCALL  ISQL_GetCursorItems(  KINT64 qry);
EXPORT int STDCALL ISQL_MoveRow(  KINT64 qry ,KINT64 from,KINT64 to);
EXPORT  int STDCALL ISQL_SwapRow(  KINT64 qry, KINT64 from,KINT64 to);
EXPORT int STDCALL  ISQL_SendDeleteCursorMessageToServer(  KINT64 qryobject);
EXPORT   KINT64  STDCALL ISQL_GetCursorRowFromServer(KINT64 qry,KINT64 i);
EXPORT char *  STDCALL  ISQL_GetIsqlFieldType(KINT64 itemobject, char *fieldname);

EXPORT char *  STDCALL  ISQL_CharToDateUS(char *datestring,char *datenumber);
EXPORT char *  STDCALL  ISQL_CharToDateEnglish(char *datestring,char *datenumber);

EXPORT char *  STDCALL  ISQL_CharToTime(char *timestring,char *cleantime);
EXPORT char *  STDCALL  ISQL_TimeToChar(char *timenumber, char *timeout);

EXPORT KINT64    STDCALL  ISQL_GetQueryCount(KINT64);
EXPORT KINT64   STDCALL  ISQL_GetQueryRowLength(KINT64);
EXPORT KINT64    STDCALL  ISQL_GetNextRow(KINT64);
EXPORT KINT64    STDCALL  ISQL_GetPrevRow(KINT64);
EXPORT KINT64    STDCALL  ISQL_GetBottomRow(KINT64);
EXPORT KINT64    STDCALL  ISQL_GetTopRow(KINT64);
EXPORT char *  STDCALL  ISQL_GetFieldData(KINT64,char *fieldname);
EXPORT KINT64   STDCALL  ISQL_GetNumField(KINT64,char *fieldname);
EXPORT char *  STDCALL  ISQL_GetCharField(KINT64,char *fieldname); 
EXPORT int   STDCALL  ISQL_CopyFieldData(KINT64,char *fieldname,char *databufer);
EXPORT KINT64    STDCALL  ISQL_GetRow(KINT64,KINT64 rowno);
EXPORT int   STDCALL  ISQL_Free(KINT64);
EXPORT double   STDCALL  ISQL_GetDoubleField(KINT64,char *fieldname);
EXPORT char *   STDCALL  ISQL_GetFieldDataByFieldNumber(KINT64,KINT64 fieldno);
EXPORT char *   STDCALL  ISQL_GetFieldName(KINT64,KINT64 fieldno);
EXPORT int   STDCALL  ISQL_GetFieldCount(KINT64);
EXPORT char *  STDCALL  ISQL_GetFieldType(KINT64,char *fieldname);
EXPORT int   STDCALL  ISQL_GetFieldLength(KINT64,char *fieldname);
EXPORT char *  STDCALL  ISQL_GetStatus(KINT64);
EXPORT KINT64    STDCALL  ISQL_GetInsertRowId(KINT64);
EXPORT char *ISQL_GetSystemDateUS(char *);
EXPORT char *ISQL_GetSystemDate(char *);

EXPORT char *ISQL_GetSystemTime(char *);
EXPORT int   STDCALL  ISQL_MinuteDiff(char *t1,char *t2);
EXPORT int   STDCALL  ISQL_DayDiff(char *date1, char *date2);
EXPORT char *  STDCALL  ISQL_AddDay(char *datein,int days,char *dateout);
EXPORT char *  STDCALL  ISQL_SubDay(char *datein,int days,char *dateout);

EXPORT char *  STDCALL  ISQL_GetSystemDateEnglish(char *date);


//for php interface
EXPORT KINT64 STDCALL  NewObject(KINT64 startid);
EXPORT void STDCALL  FreeObject(KINT64 objectid);
EXPORT KINT64 STDCALL  Exec(KINT64 objectid,char *cmd);
EXPORT KINT64 STDCALL  Count(KINT64 objectid);
EXPORT KINT64 STDCALL  RowLength(KINT64 objectid);
EXPORT KINT64 STDCALL  Next(KINT64 objectid);
EXPORT KINT64 STDCALL  Prev(KINT64 objectid);
EXPORT KINT64 STDCALL  Bottom(KINT64 objectid);
EXPORT KINT64 STDCALL  Top(KINT64 objectid);
EXPORT char * STDCALL Data(KINT64 objectid,char *fieldname);
EXPORT KINT64 STDCALL  IntData(KINT64 objectid,char *fieldname);
EXPORT int STDCALL  CopyField(KINT64 objectid,char *fieldname,char *databufer);
EXPORT KINT64 STDCALL  Row(KINT64 objectid,KINT64 rowno);
EXPORT double STDCALL  DoubleData(KINT64 objectid,char *fieldname);
EXPORT char * STDCALL  DataByFno(KINT64 objectid,KINT64 fieldno);
EXPORT char * STDCALL  FieldName(KINT64 objectid,KINT64 fieldno);
EXPORT int STDCALL     FieldCount(KINT64 objectid);
EXPORT char * STDCALL  FieldType(KINT64 objectid,char *fieldname);
EXPORT int STDCALL     FieldLength(KINT64 objectid,char *fieldname);
EXPORT char *STDCALL   Status(KINT64 objectid);
EXPORT KINT64 STDCALL    InsertRowId(KINT64 objectid);
EXPORT KINT64 STDCALL    RowNo(KINT64 objectid);
EXPORT int STDCALL MaxBytesUsed(KINT64 objectid,char *fieldname);





//for C interface
EXPORT KINT64 STDCALL  ISQL_NewObject(KINT64 startid);
EXPORT void STDCALL  ISQL_FreeObject(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_Exec(KINT64 objectid,char *cmd);
EXPORT KINT64 STDCALL  ISQL_SetOwnerAccess(KINT64 objectid); /* embedded owner access (see doc) */
EXPORT KINT64 STDCALL  ISQL_Count(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_RowLength(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_Next(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_Prev(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_Bottom(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_Top(KINT64 objectid);
EXPORT char * STDCALL  ISQL_Data(KINT64 objectid,char *fieldname);
EXPORT KINT64 STDCALL  ISQL_IntData(KINT64 objectid,char *fieldname);
EXPORT int STDCALL  ISQL_CopyField(KINT64 objectid,char *fieldname,char *databufer);
EXPORT KINT64 STDCALL  ISQL_Row(KINT64 objectid,KINT64 rowno);
EXPORT double STDCALL  ISQL_DoubleData(KINT64 objectid,char *fieldname);
EXPORT char * STDCALL  ISQL_DataByFno(KINT64 objectid,KINT64 fieldno);
EXPORT char * STDCALL  ISQL_FieldName(KINT64 objectid,KINT64 fieldno);
EXPORT int STDCALL  ISQL_FieldCount(KINT64 objectid);
EXPORT char * STDCALL  ISQL_FieldType(KINT64 objectid,char *fieldname);
EXPORT int STDCALL  ISQL_FieldLength(KINT64 objectid,char *fieldname);
EXPORT char * STDCALL  ISQL_Status(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_InsertRowId(KINT64 objectid);
EXPORT KINT64 STDCALL  ISQL_RowNo(KINT64 objectid);
EXPORT int STDCALL  ISQL_MaxBytesUsed(KINT64 objectid,char *fieldname);
EXPORT int STDCALL  ISQL_StartKamrangaNetworkAgent(KINT64 startid,char *srvrname);
EXPORT int STDCALL  ISQL_StartKamrangaNetworkAgentConnectQ(KINT64 startid,char *srvrname);

EXPORT void STDCALL  ISQL_SetServerMode(KINT64 slot);
EXPORT void STDCALL  ISQL_SetServerMasterMode(KINT64 slot);
EXPORT char * STDCALL  ISQL_GetInstanceStat(KINT64 slot);
EXPORT void  STDCALL  ISQL_InstallQryFunc(KINT64 object,KINT64  queryfunction);
EXPORT void  STDCALL  ISQL_InstallQryItemFunc(KINT64 object,KINT64  queryfunction);
EXPORT void  STDCALL  ISQL_SetClientMode(KINT64 slot);
EXPORT void  STDCALL  ISQL_InClientMode(KINT64 slot);
EXPORT int  STDCALL  ISQL_ServerStarted(KINT64 object);
EXPORT int  STDCALL  ISQL_StartServer(KINT64 object);
EXPORT int  STDCALL  ISQL_StopServer(KINT64 object);;
EXPORT int  STDCALL  ISQL_ServerStopped(KINT64 object);
EXPORT int  STDCALL  ISQL_ServerDisplayOn(KINT64 object);
EXPORT int  STDCALL  ISQL_ServerDisplayOff(KINT64 object);
EXPORT int  STDCALL  ISQL_CloseServerWindow(KINT64 object);
EXPORT void  STDCALL  ISQL_ShowShellPrompt(KINT64 object);
EXPORT int   STDCALL  ISQL_DisplayMessage(KINT64 object,char *message);
EXPORT int   STDCALL  ISQL_CreateServerDisplayWindow(KINT64 object,HWND hwnd, UINT message,UINT wParam,LONG lParam);
EXPORT int   STDCALL  ISQL_ProcessServerDisplayWindowMessage(HWND hwnd, UINT message,UINT wParam,LONG lParam);
EXPORT int   STDCALL  ISQL_CreateShellWindow(KINT64 object,HWND hwnd, UINT message,UINT wParam,LONG lParam);

EXPORT int  STDCALL  ISQL_SetShellExecFunction(KINT64 obj,KINT64 proc);
EXPORT void  STDCALL  ISQL_SetShellMode(KINT64 obj);

EXPORT int   STDCALL  ISQL_RunSrcFile(KINT64,char *filename);
EXPORT int   STDCALL  ISQL_IsLocalClientMode(KINT64 slot);
EXPORT int   STDCALL  ISQL_SetShellPrompt(KINT64,char *prompt);
EXPORT void   STDCALL  ISQL_DeleteInstance(KINT64 slot);
EXPORT int   STDCALL  ISQL_IsSelectedIntoTable(KINT64 slot);
EXPORT char  STDCALL  ISQL_SetExtendedTableMode(KINT64 slot);
EXPORT char  STDCALL  ISQL_ClearExtendedTableMode(KINT64 slot);
EXPORT char * STDCALL  ISQL_ExtractFileName(char *filename);
EXPORT int STDCALL ISQL_ObjectNotBusy(KINT64 object);
EXPORT char  STDCALL ISQL_GetUserPrivilege(KINT64 objectid);
EXPORT char * STDCALL ISQL_GetUserLoginName(KINT64 objectid,char *namebuf);
EXPORT char  STDCALL ISQL_GetLastLoggersPrivilege(KINT64 instance);
EXPORT char * STDCALL ISQL_GetLastLoginName(KINT64 instance,char *namebuf);
EXPORT char * STDCALL ISQL_GetLastPwd(KINT64 instance,char *namebuf);
EXPORT char * STDCALL ISQL_GetPwd(KINT64 objectid,char *namebuf);



#if 0
CURSOR GetQueryCursor(void);
void ReleaseCursor(CURSOR *cursor);
KINT64 GetCursorRowCount(CURSOR cursor);
KINT64 GetCursorRowLength(CURSOR cursor);
CURSORROW  GetCursorRow(CURSOR cursor,KINT64 rowno);
int GetCursorField(CURSORROW cursor_row,char *fieldname,char *value);
int SetCursorField(CURSORROW cursor_row,char *fieldname,char *value);
void ReleaseCursor(void);
char GetCursorFieldType(CURSORROW cursor_row,char *fieldname);
KINT64 GetCursorFieldLength(CURSORROW cursor_row,char *fieldname);
KINT64 GetCursorFieldDecPos(CURSORROW cursor_row,char *fieldname);
KINT64 GetCursorFieldNumber(CURSORROW cursor_row,char *fieldname);
#endif





 
