/// <summary> /// Return an array of string pointers to the individual fields. /// A zero is returned upon encountering end of sequence or error. /// This can be analyzed in using mapi\_error(). /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static string[] MapiFetchFieldArray(MapiHdl hdl) { var pptr = CMapiLib.mapi_fetch_field_array(hdl.Ptr); var ptr = Marshal.ReadIntPtr(pptr); var exploded = new List <string>(); do { exploded.Add(Marshal.PtrToStringAnsi(ptr)); pptr = new IntPtr((int)pptr + IntPtr.Size); ptr = Marshal.ReadIntPtr(pptr); } while (ptr != IntPtr.Zero); return(exploded.ToArray()); }
/// <summary> /// Return a list of accessible tables fields. This can also be obtained by /// inspecting the field descriptor returned by mapi_fetch_field(). /// </summary> /// <param name="mid"></param> /// <returns></returns> public static string[] MapiFields(MapiConnection mid) { var pptr = CMapiLib.mapi_fields(mid.Ptr); var ptr = Marshal.ReadIntPtr(pptr); var exploded = new List <string>(); do { exploded.Add(Marshal.PtrToStringAnsi(ptr)); pptr = new IntPtr((int)pptr + IntPtr.Size); ptr = Marshal.ReadIntPtr(pptr); } while (ptr != IntPtr.Zero); return(exploded.ToArray()); }
/// <summary> /// All rows are cached at the client side first. Subsequent calls to mapi_fetch_row() will take /// the row from the cache. The number or rows cached is returned. /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static long MapiFetchAllRows(MapiHdl hdl) { return(CMapiLib.mapi_fetch_all_rows(hdl.Ptr)); }
/// <summary> /// /// </summary> /// <param name="mid"></param> /// <returns></returns> public static string MapiGetMotd(MapiConnection mid) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_motd(mid.Ptr))); }
/// <summary> /// /// </summary> /// <param name="mid"></param> /// <param name="fnr"></param> /// <returns></returns> public static int MapiGetlen(MapiConnection mid, int fnr) { return(CMapiLib.mapi_get_len(mid.Ptr, fnr)); }
/// <summary> /// Log the interaction between the client and server for offline inspection. /// Beware that the log file overwrites any previous log. It is not intended for recovery. /// </summary> /// <param name="mid"></param> /// <param name="filename"></param> /// <returns></returns> public static MapiMsg MapiTraceLog(MapiConnection mid, string filename) { return(new MapiMsg(CMapiLib.mapi_trace_log(mid.Ptr, filename))); }
/// <summary> /// Set the trace flag to monitor interaction with the server. /// </summary> /// <param name="mid"></param> /// <param name="flag"></param> /// <returns></returns> public static MapiMsg MapiTrace(MapiConnection mid, int flag) { return(new MapiMsg(CMapiLib.mapi_trace(mid.Ptr, flag))); }
/// <summary> /// Escape special characters such as \n, \t in str with backslashes. /// The returned value is a newly allocated string which should be freed by the caller. /// </summary> /// <param name="str"></param> /// <param name="size"></param> /// <returns></returns> public static string MapiQuote(string str, int size) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_quote(str, size))); }
/// <summary> /// Make room in the cache by shuffling percentage tuples out of the cache. /// It is sometimes handy to do so, for example, when your application is stream-based /// and you process each tuple as it arrives and still need a limited look-back. /// This percentage can be set between 0 to 100. Making shuffle= 100% (default) /// leads to paging behavior, while shuffle==1 leads to a sliding window over a /// tuple stream with 1% refreshing. /// </summary> /// <param name="hdl"></param> /// <param name="percentage"></param> /// <returns></returns> public static MapiMsg MapiCacheShuffle(MapiHdl hdl, int percentage) { return(new MapiMsg(CMapiLib.mapi_cache_shuffle(hdl.Ptr, percentage))); }
/// <summary> /// Return the last error code or 0 if there is no error. /// </summary> /// <param name="mid"></param> /// <returns></returns> public static MapiMsg MapiError(MapiConnection mid) { return(new MapiMsg(CMapiLib.mapi_error(mid.Ptr))); }
/// <summary> /// Go to the next result set, discarding the rest of the output of the current result set. /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static MapiMsg MapiNextResult(MapiHdl hdl) { return(new MapiMsg(CMapiLib.mapi_next_result(hdl.Ptr))); }
/// <summary> /// Return a pointer a C-string representation of the value returned. /// A zero is returned upon encountering an error or when the database value is NULL; /// this can be analyzed in using mapi\_error(). /// </summary> /// <param name="hdl"></param> /// <param name="fnr"></param> /// <returns></returns> public static string MapiFetchField(MapiHdl hdl, int fnr) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_fetch_field(hdl.Ptr, fnr))); }
/// <summary> /// Reset the row pointer to the first line in the cache. This need not be a tuple. /// This is mostly used in combination with fetching all tuples at once. /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static MapiMsg MapiFetchReset(MapiHdl hdl) { return(new MapiMsg(CMapiLib.mapi_fetch_reset(hdl.Ptr))); }
/// <summary> /// Reset the row pointer to the requested row number. If whence is MAPI_SEEK_SET (0), /// rownr is the absolute row number (0 being the first row); if whence is /// MAPI_SEEK_CUR (1), rownr is relative to the current row; if whence is /// MAPI\_SEEK\_END (2), rownr is relative to the last row. /// </summary> /// <param name="hdl"></param> /// <param name="rownr"></param> /// <param name="whence"></param> /// <returns></returns> public static MapiMsg MapiSeekRow(MapiHdl hdl, long rownr, int whence) { return(new MapiMsg(CMapiLib.mapi_seek_row(hdl.Ptr, rownr, whence))); }
/// <summary> /// Read the answer to a query and pass the results verbatim to a stream. /// The result is not analyzed or cached. /// </summary> /// <param name="hdl"></param> /// <param name="fs"></param> /// <returns></returns> public static int MapiQuickResponse(MapiHdl hdl, FileStream fs) { return(CMapiLib.mapi_quick_response(hdl.Ptr, fs.SafeFileHandle)); }
/// <summary> /// Set the autocommit flag (default is on). /// This only has an effect when the language is SQL. /// In that case, the server commits after each statement sent to the server. /// </summary> /// <param name="mid"></param> /// <param name="autocommit"></param> /// <returns></returns> public static MapiMsg MapiSetAutocommit(MapiConnection mid, int autocommit) { return(new MapiMsg(CMapiLib.mapi_setAutocommit(mid.Ptr, autocommit))); }
/// <summary> /// A limited number of tuples are pre-fetched after each execute(). /// If maxrows is negative, all rows will be fetched before the application is /// permitted to continue. Once the cache is filled, a number of tuples are shuffled to /// make room for new ones, but taking into account non-read elements. /// Filling the cache quicker than reading leads to an error. /// </summary> /// <param name="mid"></param> /// <param name="maxrows"></param> /// <returns></returns> public static MapiMsg MapiCacheLimit(MapiConnection mid, int maxrows) { return(new MapiMsg(CMapiLib.mapi_cache_limit(mid.Ptr, maxrows))); }
/// <summary> /// Return a pointer to the last error message. /// </summary> /// <param name="mid"></param> /// <returns></returns> public static string MapiErrorString(MapiConnection mid) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_error_str(mid.Ptr))); }
/// <summary> /// Forcefully shuffle the cache making room for new rows. It ignores the read counter, so rows may be lost. /// </summary> /// <param name="hdl"></param> /// <param name="percentage"></param> /// <returns></returns> public static MapiMsg MapiCacheFreeup(MapiHdl hdl, int percentage) { return(new MapiMsg(CMapiLib.mapi_cache_freeup(hdl.Ptr, percentage))); }
/// <summary> /// Return a pointer to the last error message from the server. /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static string MapiResultError(MapiHdl hdl) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_result_error(hdl.Ptr))); }
/// <summary> /// The reverse action of mapi_quote(), turning the database representation into a C-representation. /// The storage space is dynamically created and should be freed after use. /// </summary> /// <param name="str"></param> /// <returns></returns> public static string MapiUnquote(string str) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_unquote(str))); }
/// <summary> /// Write the error message obtained from mserver to a file. /// </summary> /// <param name="mid"></param> /// <param name="fs"></param> /// <returns></returns> public static MapiMsg MapiExplain(MapiConnection mid, FileStream fs) { return(new MapiMsg(CMapiLib.mapi_explain(mid.Ptr, fs.SafeFileHandle))); }
/// <summary> /// Return the current value of the trace flag. /// </summary> /// <param name="mid"></param> /// <returns></returns> public static int MapiGetTrace(MapiConnection mid) { return(CMapiLib.mapi_get_trace(mid.Ptr)); }
/// <summary> /// Write the error message obtained from mserver to a file. /// </summary> /// <param name="hdl"></param> /// <param name="fs"></param> /// <returns></returns> public static MapiMsg MapiExplainResult(MapiHdl hdl, FileStream fs) { return(new MapiMsg(CMapiLib.mapi_explain_result(hdl.Ptr, fs.SafeFileHandle))); }
/// <summary> /// /// </summary> /// <param name="hdl"></param> /// <param name="fnr"></param> /// <returns></returns> public static string MapiGetTable(MapiHdl hdl, int fnr) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_table(hdl.Ptr, fnr))); }
/// <summary> /// Bind a string variable with a field in the return table. /// Upon a successful subsequent mapi_fetch_row() the indicated field /// is stored in the space pointed to by val. Returns an error if /// the field identified does not exist. /// </summary> /// <param name="hdl"></param> /// <param name="fldnr"></param> /// <param name="val"></param> /// <returns></returns> public static MapiMsg MapiBind(MapiHdl hdl, int fldnr, string[] val) { return(new MapiMsg(CMapiLib.mapi_bind(hdl.Ptr, fldnr, val))); }
/// <summary> /// /// </summary> /// <param name="mid"></param> /// <returns></returns> public static string MapiGetDbName(MapiConnection mid) { return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_dbname(mid.Ptr))); }
/// <summary> /// Clear all field bindings. /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static MapiMsg MapiClearBindings(MapiHdl hdl) { return(new MapiMsg(CMapiLib.mapi_clear_bindings(hdl.Ptr))); }
/// <summary> /// /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static MapiMsg MapiClearParams(MapiHdl hdl) { return(new MapiMsg(CMapiLib.mapi_clear_params(hdl.Ptr))); }
/// <summary> /// Retrieve a row from the server. The text retrieved is kept around in a buffer linked with the /// query handle from which selective fields can be extracted. It returns the number of fields /// recognized. A zero is returned upon encountering end of sequence or error. This can be /// analyzed in using mapi_error(). /// </summary> /// <param name="hdl"></param> /// <returns></returns> public static int MapiFetchRow(MapiHdl hdl) { return(CMapiLib.mapi_fetch_row(hdl.Ptr)); }