shell.c File Reference

Go to the source code of this file.

Classes

struct  previous_mode_data
struct  callback_data

Defines

#define readline(p)   local_getline(p,stdin)
#define add_history(X)
#define read_history(X)
#define write_history(X)
#define stifle_history(X)
#define BEGIN_TIMER   beginTimer()
#define END_TIMER   endTimer()
#define HAS_TIMER   1
#define MODE_Line   0
#define MODE_Column   1
#define MODE_List   2
#define MODE_Semi   3
#define MODE_Html   4
#define MODE_Insert   5
#define MODE_Tcl   6
#define MODE_Csv   7
#define MODE_Explain   8
#define ArraySize(X)   (sizeof(X)/sizeof(X[0]))

Functions

int isatty ()
static void beginTimer (void)
static double timeDiff (struct timeval *pStart, struct timeval *pEnd)
static void endTimer (void)
static int isNumber (const char *z, int *realnum)
static void shellstaticFunc (sqlite3_context *context, int argc, sqlite3_value **argv)
static char * local_getline (char *zPrompt, FILE *in)
static char * one_input_line (const char *zPrior, FILE *in)
static void output_quoted_string (FILE *out, const char *z)
static void output_c_string (FILE *out, const char *z)
static void output_html_string (FILE *out, const char *z)
static void output_csv (struct callback_data *p, const char *z, int bSep)
static int callback (void *pArg, int nArg, char **azArg, char **azCol)
static void set_table_name (struct callback_data *p, const char *zName)
static char * appendText (char *zIn, char const *zAppend, char quote)
static int run_table_dump_query (FILE *out, sqlite3 *db, const char *zSelect)
static int dump_callback (void *pArg, int nArg, char **azArg, char **azCol)
static int run_schema_dump_query (struct callback_data *p, const char *zQuery, char **pzErrMsg)
static int process_input (struct callback_data *p, FILE *in)
static void open_db (struct callback_data *p)
static void resolve_backslashes (char *z)
static int booleanValue (char *zArg)
static int do_meta_command (char *zLine, struct callback_data *p)
static int _contains_semicolon (const char *z, int N)
static int _all_whitespace (const char *z)
static int _is_command_terminator (const char *zLine)
static char * find_home_dir (void)
static void process_sqliterc (struct callback_data *p, const char *sqliterc_override)
static void usage (int showDetail)
static void main_init (struct callback_data *data)
int main (int argc, char **argv)

Variables

static struct rusage sBegin
static int enableTimer = 0
static int bail_on_error = 0
static int stdin_is_interactive = 1
static sqlite3db = 0
static volatile int seenInterrupt = 0
static char * Argv0
static char mainPrompt [20]
static char continuePrompt [20]
static const char * zShellStatic = 0
static const char * modeDescr []
static const char needCsvQuote []
static char zHelp []
static const char zOptions []

Define Documentation

#define add_history (  ) 

Definition at line 41 of file shell.c.

Referenced by one_input_line().

#define ArraySize (  )     (sizeof(X)/sizeof(X[0]))
#define BEGIN_TIMER   beginTimer()

Definition at line 100 of file shell.c.

Referenced by process_input().

#define END_TIMER   endTimer()

Definition at line 101 of file shell.c.

Referenced by process_input().

#define HAS_TIMER   1

Definition at line 102 of file shell.c.

#define MODE_Column   1

Definition at line 332 of file shell.c.

Referenced by callback(), do_meta_command(), and main().

#define MODE_Csv   7

Definition at line 338 of file shell.c.

Referenced by callback(), do_meta_command(), and main().

#define MODE_Explain   8

Definition at line 339 of file shell.c.

Referenced by callback(), and do_meta_command().

#define MODE_Html   4

Definition at line 335 of file shell.c.

Referenced by callback(), do_meta_command(), and main().

#define MODE_Insert   5

Definition at line 336 of file shell.c.

Referenced by callback(), and do_meta_command().

#define MODE_Line   0

Definition at line 331 of file shell.c.

Referenced by callback(), do_meta_command(), and main().

#define MODE_List   2

Definition at line 333 of file shell.c.

Referenced by callback(), do_meta_command(), main(), and main_init().

#define MODE_Semi   3

Definition at line 334 of file shell.c.

Referenced by callback(), and do_meta_command().

#define MODE_Tcl   6

Definition at line 337 of file shell.c.

Referenced by callback(), and do_meta_command().

#define read_history (  ) 

Definition at line 42 of file shell.c.

Referenced by main().

#define readline (  )     local_getline(p,stdin)

Definition at line 40 of file shell.c.

Referenced by one_input_line().

#define stifle_history (  ) 

Definition at line 44 of file shell.c.

Referenced by main().

#define write_history (  ) 

Definition at line 43 of file shell.c.

Referenced by main().


Function Documentation

static int _all_whitespace ( const char *  z  )  [static]

Definition at line 1623 of file shell.c.

Referenced by _is_command_terminator(), and process_input().

static int _contains_semicolon ( const char *  z,
int  N 
) [static]

Definition at line 1614 of file shell.c.

Referenced by process_input().

static int _is_command_terminator ( const char *  zLine  )  [static]

Definition at line 1649 of file shell.c.

References _all_whitespace().

Referenced by process_input().

static char* appendText ( char *  zIn,
char const *  zAppend,
char  quote 
) [static]

Definition at line 720 of file shell.c.

Referenced by dump_callback().

static void beginTimer ( void   )  [static]

Definition at line 76 of file shell.c.

References enableTimer, and sBegin.

static int booleanValue ( char *  zArg  )  [static]

Definition at line 1013 of file shell.c.

Referenced by do_meta_command().

static int callback ( void *  pArg,
int  nArg,
char **  azArg,
char **  azCol 
) [static]
static int do_meta_command ( char *  zLine,
struct callback_data p 
) [static]
static int dump_callback ( void *  pArg,
int  nArg,
char **  azArg,
char **  azCol 
) [static]
static void endTimer ( void   )  [static]

Definition at line 91 of file shell.c.

References enableTimer, sBegin, and timeDiff().

static char* find_home_dir ( void   )  [static]

Definition at line 1773 of file shell.c.

References sqlite3_snprintf().

Referenced by main(), and process_sqliterc().

int isatty (  ) 

Referenced by main().

static int isNumber ( const char *  z,
int *  realnum 
) [static]

Definition at line 177 of file shell.c.

Referenced by callback().

static char* local_getline ( char *  zPrompt,
FILE *  in 
) [static]

Definition at line 230 of file shell.c.

Referenced by do_meta_command(), and one_input_line().

int main ( int  argc,
char **  argv 
)
static void main_init ( struct callback_data data  )  [static]
static char* one_input_line ( const char *  zPrior,
FILE *  in 
) [static]

Definition at line 277 of file shell.c.

References add_history, continuePrompt, local_getline(), mainPrompt, and readline.

Referenced by process_input().

static void open_db ( struct callback_data p  )  [static]
static void output_c_string ( FILE *  out,
const char *  z 
) [static]

Definition at line 391 of file shell.c.

Referenced by callback(), and do_meta_command().

static void output_csv ( struct callback_data p,
const char *  z,
int  bSep 
) [static]

Definition at line 467 of file shell.c.

References needCsvQuote, callback_data::nullvalue, callback_data::out, and callback_data::separator.

Referenced by callback().

static void output_html_string ( FILE *  out,
const char *  z 
) [static]

Definition at line 420 of file shell.c.

Referenced by callback().

static void output_quoted_string ( FILE *  out,
const char *  z 
) [static]

Definition at line 361 of file shell.c.

Referenced by callback().

static int process_input ( struct callback_data p,
FILE *  in 
) [static]
static void process_sqliterc ( struct callback_data p,
const char *  sqliterc_override 
) [static]

Definition at line 1833 of file shell.c.

References Argv0, find_home_dir(), process_input(), sqlite3_snprintf(), and stdin_is_interactive.

Referenced by main().

static void resolve_backslashes ( char *  z  )  [static]

Definition at line 982 of file shell.c.

Referenced by do_meta_command().

static int run_schema_dump_query ( struct callback_data p,
const char *  zQuery,
char **  pzErrMsg 
) [static]
static int run_table_dump_query ( FILE *  out,
sqlite3 db,
const char *  zSelect 
) [static]
static void set_table_name ( struct callback_data p,
const char *  zName 
) [static]

Definition at line 679 of file shell.c.

References callback_data::zDestTable.

Referenced by do_meta_command(), and main().

static void shellstaticFunc ( sqlite3_context context,
int  argc,
sqlite3_value **  argv 
) [static]

Definition at line 210 of file shell.c.

References sqlite3_result_text(), SQLITE_STATIC, and zShellStatic.

Referenced by open_db().

static double timeDiff ( struct timeval *  pStart,
struct timeval *  pEnd 
) [static]

Definition at line 83 of file shell.c.

Referenced by endTimer().

static void usage ( int  showDetail  )  [static]

Definition at line 1890 of file shell.c.

References Argv0.

Referenced by main().


Variable Documentation

char* Argv0 [static]

Definition at line 138 of file shell.c.

Referenced by main(), process_input(), process_sqliterc(), and usage().

int bail_on_error = 0 [static]

Definition at line 114 of file shell.c.

Referenced by do_meta_command(), main(), and process_input().

char continuePrompt[20] [static]

Definition at line 145 of file shell.c.

Referenced by do_meta_command(), main_init(), and one_input_line().

sqlite3* db = 0 [static]

Definition at line 127 of file shell.c.

Referenced by analyzeDatabase(), attachFunc(), blobReadWrite(), changes(), changeTempStorage(), checkReadLocks(), Cleanup(), codeAlias(), codeAttach(), codeTriggerProgram(), corruptSchema(), create_database(), createIncrblobChannel(), detachFunc(), exprAnalyze(), flagPragma(), flattenSubquery(), freeIndex(), FUNC(), func_callback_wrapper(), generateColumnNames(), groupConcatStep(), icuLoadCollation(), incrblobClose(), invalidateTempStorage(), isLikeOrGlob(), isSortingIndex(), keyInfoFromExprList(), last_insert_rowid(), likeFunc(), loadExt(), lookupName(), multiSelect(), multiSelectOrderBy(), openStatTable(), reindexDatabases(), releaseMemArray(), renameTableFunc(), renameTriggerFunc(), replaceFunc(), resolveAlias(), resolveAsName(), resolveCompoundOrderBy(), resolveSelectStep(), selectAddColumnTypeAndCollation(), selectColumnsFromExprList(), selectExpander(), setDateTimeToCurrent(), sqlite3_step(), sqlite3AddCheckConstraint(), sqlite3AddCollateType(), sqlite3AddColumn(), sqlite3AddColumnType(), sqlite3AddDefaultValue(), sqlite3AlterBeginAddColumn(), sqlite3AlterFinishAddColumn(), sqlite3AlterRenameTable(), sqlite3Analyze(), sqlite3BeginTransaction(), sqlite3BeginTrigger(), sqlite3ChangeCookie(), sqlite3CodeRowTrigger(), sqlite3CodeVerifySchema(), sqlite3CommitTransaction(), sqlite3CreateForeignKey(), sqlite3CreateIndex(), sqlite3CreateView(), sqlite3DeleteFrom(), sqlite3DeleteTable(), sqlite3DropIndex(), sqlite3DropTable(), sqlite3DropTrigger(), sqlite3DropTriggerPtr(), sqlite3EndTable(), sqlite3ErrorMsg(), sqlite3ExprAssignVarNumber(), sqlite3ExprCodeTarget(), sqlite3ExprCollSeq(), sqlite3ExprFunction(), sqlite3ExprListAppend(), sqlite3ExprSetColl(), sqlite3FindInIndex(), sqlite3FinishCoding(), sqlite3FinishTrigger(), sqlite3FixInit(), sqlite3IndexAffinityStr(), sqlite3IndexKeyinfo(), sqlite3InitCallback(), sqlite3Insert(), sqlite3LocateCollSeq(), sqlite3MaterializeView(), sqlite3NestedParse(), sqlite3OpenTempDatabase(), sqlite3Pragma(), sqlite3ReadSchema(), sqlite3RefillIndex(), sqlite3Reindex(), sqlite3Reprepare(), sqlite3ResolveOrderGroupBy(), sqlite3ResultSetOfSelect(), sqlite3RollbackTransaction(), sqlite3RunParser(), sqlite3Select(), sqlite3SelectNew(), sqlite3SelectPrep(), sqlite3SrcListAppendFromTerm(), sqlite3StartTable(), sqlite3Step(), sqlite3TableAffinityStr(), sqlite3TwoPartName(), sqlite3Update(), sqlite3ValueFree(), sqlite3VdbeChangeP4(), sqlite3VdbeChangeToNoop(), sqlite3VdbeExec(), sqlite3VdbeList(), sqlite3VdbeMakeReady(), sqlite3VdbeMemFromBtree(), sqlite3VdbeSetNumCols(), sqlite3VdbeUsesBtree(), sqlite3ViewGetColumnNames(), sqlite3WhereBegin(), sqlite3WhereEnd(), sqliteDefaultBusyCallback(), sqliteResetColumnNames(), strftimeFunc(), targetSrcList(), total_changes(), updateVirtualTable(), whereClauseClear(), whereClauseInsert(), whereTempTriggers(), xauth_callback_wrapper(), xbusy_callback_wrapper(), xcommit_callback_wrapper(), xcompare_callback_wrapper(), xneeded_callback_wrapper(), xprogress_callback_wrapper(), and xtrace_callback_wrapper().

int enableTimer = 0 [static]

Definition at line 71 of file shell.c.

Referenced by beginTimer(), do_meta_command(), and endTimer().

char mainPrompt[20] [static]

Definition at line 144 of file shell.c.

Referenced by do_meta_command(), main_init(), and one_input_line().

const char* modeDescr[] [static]
Initial value:
 {
  "line",
  "column",
  "list",
  "semi",
  "html",
  "insert",
  "tcl",
  "csv",
  "explain",
}

Definition at line 341 of file shell.c.

Referenced by do_meta_command().

const char needCsvQuote[] [static]
Initial value:
 {
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1, 
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
}

Definition at line 442 of file shell.c.

Referenced by output_csv().

struct rusage sBegin [static]

Definition at line 68 of file shell.c.

Referenced by beginTimer(), and endTimer().

volatile int seenInterrupt = 0 [static]

Definition at line 132 of file shell.c.

Referenced by process_input().

int stdin_is_interactive = 1 [static]

Definition at line 120 of file shell.c.

Referenced by main(), process_input(), and process_sqliterc().

char zHelp[] [static]

Definition at line 904 of file shell.c.

const char zOptions[] [static]
Initial value:
 
  "   -init filename       read/process named file\n"
  "   -echo                print commands before execution\n"
  "   -[no]header          turn headers on or off\n"
  "   -bail                stop after hitting an error\n"
  "   -interactive         force interactive I/O\n"
  "   -batch               force batch I/O\n"
  "   -column              set output mode to 'column'\n"
  "   -csv                 set output mode to 'csv'\n"
  "   -html                set output mode to HTML\n"
  "   -line                set output mode to 'line'\n"
  "   -list                set output mode to 'list'\n"
  "   -separator 'x'       set output field separator (|)\n"
  "   -nullvalue 'text'    set text string for NULL values\n"
  "   -version             show SQLite version\n"

Definition at line 1874 of file shell.c.

const char* zShellStatic = 0 [static]

Definition at line 209 of file shell.c.

Referenced by do_meta_command(), and shellstaticFunc().


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:50:01 2011 by Doxygen 1.6.1