
Yuvaraj Athur Raghuvir wrote:
Thanks. I have done as suggested in the referred posting[1].
I see that in the docs [2] there is an Mbedded Example. To start with I would like to make that work. For this I need the matching header files. Where should I pick them from? I could not find them in the installation package. Oh, sorry, I see you refer to my post [1]. I forgot to attach my modified header, Mapi.h, that I made by hand from original Mapi.h and embeddedclient.h. My variant of Mapi.h is "all you need" to include to use monetdb embedded. See attach.
#ifndef _MAPI_H_INCLUDED #define _MAPI_H_INCLUDED #include <stdio.h> /* for FILE * */ #define MAPI_AUTO 0 /* automatic type detection */ #define MAPI_TINY 1 #define MAPI_UTINY 2 #define MAPI_SHORT 3 #define MAPI_USHORT 4 #define MAPI_INT 5 #define MAPI_UINT 6 #define MAPI_LONG 7 #define MAPI_ULONG 8 #define MAPI_LONGLONG 9 #define MAPI_ULONGLONG 10 #define MAPI_CHAR 11 #define MAPI_VARCHAR 12 #define MAPI_FLOAT 13 #define MAPI_DOUBLE 14 #define MAPI_DATE 15 #define MAPI_TIME 16 #define MAPI_DATETIME 17 #define MAPI_NUMERIC 18 #define PLACEHOLDER '?' #define MAPI_SEEK_SET 0 #define MAPI_SEEK_CUR 1 #define MAPI_SEEK_END 2 #define MAPI_TRACE 1 #define MAPI_TRACE_LANG 2 typedef int MapiMsg; #define MOK 0 #define MERROR (-1) #define MTIMEOUT (-2) #define MMORE (-3) #define MSERVER (-4) #define LANG_MAL 0 #define LANG_MIL 1 #define LANG_SQL 2 #define LANG_XQUERY 3 typedef struct MapiStruct *Mapi; /* this definition is a straight copy from sql/include/sql_query.h */ typedef enum sql_query_t { Q_PARSE = 0, Q_TABLE = 1, Q_UPDATE = 2, Q_SCHEMA = 3, Q_TRANS = 4, Q_PREPARE = 5, Q_BLOCK = 6 } sql_query_t; typedef struct MapiStatement *MapiHdl; #ifdef __cplusplus extern "C" { #endif /* avoid using "#ifdef WIN32" so that this file does not need our config.h */ #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) #ifndef LIBMAPI #define mapi_export extern __declspec(dllimport) #else #define mapi_export extern __declspec(dllexport) #endif #else #define mapi_export extern #endif /* three structures used for communicating date/time information */ /* these structs are deliberately compatible with the ODBC versions SQL_DATE_STRUCT, SQL_TIME_STRUCT, and SQL_TIMESTAMP_STRUCT */ typedef struct { /* used by MAPI_DATE */ short year; unsigned short month; unsigned short day; } MapiDate; typedef struct { /* used by MAPI_TIME */ unsigned short hour; unsigned short minute; unsigned short second; } MapiTime; typedef struct { /* used by MAPI_DATETIME */ short year; unsigned short month; unsigned short day; unsigned short hour; unsigned short minute; unsigned short second; unsigned int fraction; /* in 1000 millionths of a second (10e-9) */ } MapiDateTime; /* connection-oriented functions */ mapi_export Mapi mapi_mapi(const char *host, int port, const char *username, const char *password, const char *lang, const char *dbname); mapi_export MapiMsg mapi_destroy(Mapi mid); mapi_export MapiMsg mapi_start_talking(Mapi mid); mapi_export Mapi mapi_connect(const char *host, int port, const char *username, const char *password, const char *lang, const char *dbname); mapi_export Mapi mapi_connect_ssl(const char *host, int port, const char *username, const char *password, const char *lang, const char *dbname); #ifdef ST_READ /* if stream.h was included */ mapi_export stream **mapi_embedded_init(Mapi *midp, char *lang); #endif mapi_export MapiMsg mapi_disconnect(Mapi mid); mapi_export MapiMsg mapi_reconnect(Mapi mid); mapi_export MapiMsg mapi_ping(Mapi mid); mapi_export MapiMsg mapi_error(Mapi mid); mapi_export char *mapi_error_str(Mapi mid); mapi_export void mapi_noexplain(Mapi mid, char *errorprefix); mapi_export MapiMsg mapi_explain(Mapi mid, FILE *fd); mapi_export MapiMsg mapi_explain_query(MapiHdl hdl, FILE *fd); mapi_export MapiMsg mapi_explain_result(MapiHdl hdl, FILE *fd); mapi_export MapiMsg mapi_output(Mapi mid, char *output); mapi_export MapiMsg mapi_stream_into(Mapi mid, char *docname, char *colname, FILE *fp); mapi_export MapiMsg mapi_profile(Mapi mid, int flag); mapi_export MapiMsg mapi_trace(Mapi mid, int flag); mapi_export int mapi_get_trace(Mapi mid); mapi_export MapiMsg mapi_log(Mapi mid, const char *nme); mapi_export MapiMsg mapi_setAutocommit(Mapi mid, int autocommit); mapi_export char *mapi_result_error(MapiHdl hdl); mapi_export MapiMsg mapi_next_result(MapiHdl hdl); mapi_export MapiMsg mapi_needmore(MapiHdl hdl); mapi_export int mapi_more_results(MapiHdl hdl); mapi_export MapiHdl mapi_new_handle(Mapi mid); mapi_export MapiMsg mapi_close_handle(MapiHdl hdl); mapi_export MapiMsg mapi_bind(MapiHdl hdl, int fnr, char **ptr); mapi_export MapiMsg mapi_bind_var(MapiHdl hdl, int fnr, int type, void *ptr); mapi_export MapiMsg mapi_bind_numeric(MapiHdl hdl, int fnr, int scale, int precision, void *ptr); mapi_export MapiMsg mapi_clear_bindings(MapiHdl hdl); mapi_export MapiMsg mapi_param_type(MapiHdl hdl, int fnr, int ctype, int sqltype, void *ptr); mapi_export MapiMsg mapi_param_string(MapiHdl hdl, int fnr, int sqltype, char *ptr, int *sizeptr); mapi_export MapiMsg mapi_param(MapiHdl hdl, int fnr, char **ptr); mapi_export MapiMsg mapi_param_numeric(MapiHdl hdl, int fnr, int scale, int precision, void *ptr); mapi_export MapiMsg mapi_clear_params(MapiHdl hdl); mapi_export MapiHdl mapi_prepare(Mapi mid, const char *cmd); mapi_export MapiMsg mapi_prepare_handle(MapiHdl hdl, const char *cmd); mapi_export MapiMsg mapi_virtual_result(MapiHdl hdl, int columns, const char **columnnames, const char **columntypes, const int *columnlengths, int tuplecount, const char ***tuples); mapi_export MapiMsg mapi_execute(MapiHdl hdl); mapi_export MapiMsg mapi_execute_array(MapiHdl hdl, char **val); mapi_export MapiMsg mapi_fetch_reset(MapiHdl hdl); mapi_export MapiMsg mapi_finish(MapiHdl hdl); mapi_export MapiHdl mapi_prepare_array(Mapi mid, const char *cmd, char **val); mapi_export MapiHdl mapi_query(Mapi mid, const char *cmd); mapi_export MapiMsg mapi_query_handle(MapiHdl hdl, const char *cmd); mapi_export MapiHdl mapi_query_prep(Mapi mid); mapi_export MapiMsg mapi_query_part(MapiHdl hdl, const char *cmd, size_t size); mapi_export MapiMsg mapi_query_done(MapiHdl hdl); mapi_export MapiHdl mapi_quick_query(Mapi mid, const char *cmd, FILE *fd); mapi_export MapiHdl mapi_query_array(Mapi mid, const char *cmd, char **val); mapi_export MapiHdl mapi_quick_query_array(Mapi mid, const char *cmd, char **val, FILE *fd); mapi_export MapiHdl mapi_stream_query(Mapi mid, const char *cmd, int windowsize); mapi_export MapiMsg mapi_cache_limit(Mapi mid, int limit); mapi_export MapiMsg mapi_cache_shuffle(MapiHdl hdl, int percentage); mapi_export MapiMsg mapi_cache_freeup(MapiHdl hdl, int percentage); mapi_export MapiMsg mapi_quick_response(MapiHdl hdl, FILE *fd); mapi_export MapiMsg mapi_seek_row(MapiHdl hdl, int rowne, int whence); mapi_export MapiMsg mapi_timeout(Mapi mid, int time); mapi_export int mapi_fetch_row(MapiHdl hdl); mapi_export int mapi_fetch_all_rows(MapiHdl hdl); mapi_export int mapi_get_field_count(MapiHdl hdl); mapi_export int mapi_get_row_count(MapiHdl hdl); mapi_export int mapi_rows_affected(MapiHdl hdl); mapi_export char *mapi_fetch_field(MapiHdl hdl, int fnr); mapi_export MapiMsg mapi_store_field(MapiHdl hdl, int fnr, int outtype, void *outparam); mapi_export char **mapi_fetch_field_array(MapiHdl hdl); mapi_export char *mapi_fetch_line(MapiHdl hdl); mapi_export int mapi_split_line(MapiHdl hdl); mapi_export char *mapi_get_lang(Mapi mid); mapi_export char *mapi_get_dbname(Mapi mid); mapi_export char *mapi_get_host(Mapi mid); mapi_export char *mapi_get_user(Mapi mid); mapi_export char *mapi_get_mapi_version(Mapi mid); mapi_export char *mapi_get_monet_version(Mapi mid); mapi_export int mapi_get_monet_versionId(Mapi mid); mapi_export char *mapi_get_motd(Mapi mid); mapi_export int mapi_is_connected(Mapi mid); mapi_export char *mapi_get_table(MapiHdl hdl, int fnr); mapi_export char *mapi_get_name(MapiHdl hdl, int fnr); mapi_export char *mapi_get_type(MapiHdl hdl, int fnr); mapi_export int mapi_get_len(MapiHdl hdl, int fnr); mapi_export char *mapi_get_query(MapiHdl hdl); mapi_export int mapi_get_querytype(MapiHdl hdl); mapi_export int mapi_get_tableid(MapiHdl hdl); mapi_export char *mapi_quote(const char *msg, int size); mapi_export char *mapi_unquote(char *msg); mapi_export MapiHdl mapi_get_active(Mapi mid); // GARANT BEGIN from embeddedclient.h typedef enum opt_kind { opt_builtin = 0, opt_config = 1, opt_cmdline = 2 } opt_kind; typedef struct opt { opt_kind kind; char *name; char *value; } opt; mapi_export Mapi monetdb_sql(char *dbfarm, char *dbname); mapi_export Mapi embedded_sql(opt *set, int len); // GARANT BEGIN self mapi_export Mapi embedded_mal(opt *set, int len); // GARANT BEGIN from monet_options.h /* mo_print_options will print the option set on stderr */ mapi_export void mo_print_options(opt *set, int setlen); /* mo_find_option, finds the option with the given name in the option set (set,setlen). */ mapi_export char *mo_find_option(opt *set, int setlen, const char *name); /* the option values can contain ${prefix} and ${exec_prefix}, these will be substituted using the mo_substitute function. The return value is a newly allocated buffer, it is the caller's responsibility to free the buffer. */ #ifdef WIN32 /* on Windows, the option values can also contain %prefix% and %exec_prefix% which will be substituted as well. */ #endif mapi_export char *mo_substitute(opt *set, int setlen, char *name); /* mo_system_config will add the options from the system config file (returns the new setlen) */ mapi_export int mo_system_config(opt **Set, int setlen); /* mo_builtin_settings, will place the builtin settings into a new option set (returns the length of this set). */ mapi_export int mo_builtin_settings(opt **Set); /* mo_add_option will add a single option to the option set (returns new length) */ mapi_export int mo_add_option(opt **Set, int setlen, opt_kind kind, const char *name, const char *value); /* mo_free_options will free the resouces take by the options set */ mapi_export void mo_free_options(opt *set, int setlen); // GARANT END #ifdef __cplusplus } #endif #endif /* _MAPI_H_INCLUDED */