-C Make\sshell\sbuildable,\sfix\sa\spotential\sleak-to-be
-D 2021-12-02T20:30:35.512
+C Extension\sinterface\stweaks\sin\ssupport\sof\splanned\susage
+D 2021-12-03T19:27:06.906
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c a7a3d9f54eb24821ec5f67f2e5589b68a5d42d46fc5849d7376886777d93a85a
F src/shell.c.in d44df00f8353ade83160cf1f4229e7c9f5dbc0270d6221b8a8435fe3ba2d0d97
-F src/shext_linkage.h 4bb604b09f051571d55002713d86bddc7593af302190371eb7e7171a09472d5c
+F src/shext_linkage.h 1f95d182a0c2526be1b3566567ccfe7847cf13eedf039355a329be08282b2a8b
F src/sqlite.h.in 5cd209ac7dc4180f0e19292846f40440b8488015849ca0110c70b906b57d68f0
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8ff2fd2c166150b2e48639f5e506fb44e29f1a3f65031710b9e89d1c126ac839
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 98cf18611d4c0ddc7ee38ba2565265ad5bc1c9ceec545f9f8f63987015e64117
-R 584282e346a057ab6e193ad4c9e6025d
+P eab1e1af5b51eb267e9bceaf6412d2be12b8f3deb435631e55291211099720ff
+R d47b4cfbdf90e9b5dfc09603b7ee76a8
U larrybr
-Z 5ff8908b0ba1aa560ce65e0890a0d874
+Z 1371e2d598bc40c6fc66804e5df68b0c
#define SQLITE3SHX_H
#include "sqlite3ext.h"
-typedef struct ShellState ShellState;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Convey data to, from and/or between I/O handlers and meta-commands. */
+typedef struct {
+ /* A semi-transient holder of arbitrary data used during operations
+ * not interrupted by meta-command invocations. Any not-null pointer
+ * left after a meta-command has completed is, by contract, to be
+ * freeable using sqlite3_free(). It is otherwise unconstrained.
+ */
+ void *pvHandlerData;
+ /* The output stream to which meta-command output is to be written */
+ FILE *pCurrentOutputStream;
+ /* The number of lines written during a query result output */
+ int resultCount;
+ /* Whether to show column names for certain output modes */
+ int showHeader;
+ /* Column separator character for some modes */
+ char *zFieldSeparator;
+ /* Row separator character for some modes (MODE_Ascii) */
+ char *zRecordSeparator;
+ /* Row set prefix for some modes */
+ char *zRecordLead;
+ /* Row set suffix for some modes */
+ char *zRecordTrail;
+ /* Text to represent a NULL value in external formats */
+ char *zNullValue;
+ /* The number of column widths presently desired or tracked */
+ int numWidths;
+ /* The column widths last specified via .width */
+ int *pWantWidths;
+ /* The column widths last observed in results */
+ int *pHaveWidths;
+} FormatXfrInfo;
+
+/* The shell's state, shared among meta-command implementations.
+ * The ShellState object includes a private partition whose content
+ * and usage are opaque to shell extensions compiled separately
+ * from the shell.c core. (As defined here, it is wholly opaque.)
+ */
+typedef struct ShellStateX {
+ FormatXfrInfo fxi;
+ struct ShellState * pSS;
+} ShellStateX;
/* This function pointer has the same signature as the sqlite3_X_init()
* function that is called as SQLite3 completes loading an extension.
void (*destruct_free)(MetaCommand *);
const char * (*name)(MetaCommand *);
const char * (*help)(MetaCommand *, int more);
- void (*argsRange)(MetaCommand *, int * pMinArgs, int * pMaxArgs);
+ struct {unsigned minArgs; unsigned maxArgs;} (*argsRange)(MetaCommand *);
int (*execute)
- (MetaCommand *, ShellState *, char **pzErrMsg, char *azArgs[], int nArgs);
+ (MetaCommand *, ShellStateX *, char **pzErrMsg, int nArgs, char *azArgs[]);
} MetaCommandVtable;
-/* See "Shell Extensions, Programming" for purposes and usage of the following
- * structs supporting extended meta-commands and import and output modes.
+/* Define an error code to be returned either by a meta-command during its
+ * own argument checking or by the dispatcher for bad argument counts.
*/
+#define SHELL_INVALID_ARGS SQLITE_MISUSE
-/* Convey data to, from and/or between I/O handlers. */
-typedef struct {
- char *zFieldSeparator;
- char *zRecordSeparator;
- char *zRecordLead;
- char *zRecordTrail;
- char *zNullValue;
- char *zSQL;
- int numWidths;
- int *pWantWidths;
- int *pHaveWidths;
- void *pvHandlerData; /* Lifetime is from mid-openX() to mid-closeX(). */
-} FormatInfo;
+/*****************
+ * See "Shell Extensions, Programming" for purposes and usage of the following
+ * structs supporting extended meta-commands and import and output modes.
+ */
/* An instance of below struct, possibly extended/subclassed, is registered
* with the shell to make new or altered output modes available to it.
const char * (*name)(OutModeHandler *);
const char * (*help)(OutModeHandler *, int more);
int (*openResultsOutStream)
- (OutModeHandler * pROS, FormatInfo *pFI, char **pzErr,
- const char * zLocus, const char * zName);
+ (OutModeHandler * pROS, FormatXfrInfo *pFI, char **pzErr,
+ int numArgs, char *azArgs[], const char * zName);
int (*prependResultsOut)
- (OutModeHandler * pROS, FormatInfo *pFI, char **pzErr,
+ (OutModeHandler * pROS, FormatXfrInfo *pFI, char **pzErr,
sqlite3_stmt * pStmt);
int (*rowResultsOut)
- (OutModeHandler * pROS, FormatInfo *pFI, char **pzErr,
+ (OutModeHandler * pROS, FormatXfrInfo *pFI, char **pzErr,
sqlite3_stmt * pStmt);
int (*appendResultsOut)
- (OutModeHandler * pROS, FormatInfo *pFI, char **pzErr,
+ (OutModeHandler * pROS, FormatXfrInfo *pFI, char **pzErr,
sqlite3_stmt * pStmt);
- int (*closeResultsOutStream)
- (OutModeHandler * pROS, FormatInfo *pFI, char **pzErr);
+ void (*closeResultsOutStream)
+ (OutModeHandler * pROS, FormatXfrInfo *pFI, char **pzErr);
} OutModeHandlerVtable;
/* An instance of below struct, possibly extended/subclassed, is registered
const char * (*name)(ImportHandler *);
const char * (*help)(ImportHandler *, int more);
int (*openDataInStream)
- (ImportHandler *pIH, FormatInfo *pFI, char **pzErr,
- const char * zLocus, const char * zName);
+ (ImportHandler *pIH, FormatXfrInfo *pFI, char **pzErr,
+ int numArgs, char *azArgs[], const char * zName);
int (*prepareDataInput)
- (ImportHandler *pIH, FormatInfo *pFI, char **pzErr, sqlite3_stmt * pStmt);
+ (ImportHandler *pIH, FormatXfrInfo *pFI, char **pzErr,
+ sqlite3_stmt * *ppStmt);
int (*rowDataInput)
- (ImportHandler *pIH, FormatInfo *pFI, char **pzErr, sqlite3_stmt * pStmt);
+ (ImportHandler *pIH, FormatXfrInfo *pFI, char **pzErr,
+ sqlite3_stmt *pStmt);
int (*finishDataInput)
- (ImportHandler *pIH, FormatInfo *pFI, char **pzErr, sqlite3_stmt * pStmt);
- int (*closeDataInStream)
- (ImportHandler *pIH, FormatInfo *pFI, char **pzErr);
+ (ImportHandler *pIH, FormatXfrInfo *pFI, char **pzErr,
+ sqlite3_stmt *pStmt);
+ void (*closeDataInStream)
+ (ImportHandler *pIH, FormatXfrInfo *pFI, char **pzErr);
} ImportHandlerVtable;
#define SHELLEXT_VALIDITY_MARK "ExtensibleShell"
/* Test whether a char ** references a ShellExtensionLink instance's
* validityMark, and if so return the instance's address, else return 0.
- * This macro may be used from a shell extension's sqlite3_X_init() function
+ * This macro may be used by a shell extension's sqlite3_X_init() function
* to obtain a pointer to the ShellExtensionLink struct, derived from the
* error message pointer (pzErrMsg) passed as the 2nd argument. This enables
* the extension to incorporate its features into a running shell process.
sqlite3_finalize(pStmt); return rv; \
}
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif /* !defined(SQLITE3SHX_H) */