MCPcopy Create free account
hub / github.com/Kitware/VTK / arDotCommand

Function arDotCommand

ThirdParty/sqlite/vtksqlite/shell.c:27680–27786  ·  view source on GitHub ↗

** Implementation of ".ar" dot command. */

Source from the content-addressed store, hash-verified

27678** Implementation of ".ar" dot command.
27679*/
27680static int arDotCommand(
27681 ShellState *pState, /* Current shell tool state */
27682 int fromCmdLine, /* True if -A command-line option, not .ar cmd */
27683 char **azArg, /* Array of arguments passed to dot command */
27684 int nArg /* Number of entries in azArg[] */
27685){
27686 ArCommand cmd;
27687 int rc;
27688 memset(&cmd, 0, sizeof(cmd));
27689 cmd.fromCmdLine = fromCmdLine;
27690 rc = arParseCommand(azArg, nArg, &cmd);
27691 if( rc==SQLITE_OK ){
27692 int eDbType = SHELL_OPEN_UNSPEC;
27693 cmd.p = pState;
27694 cmd.out = pState->out;
27695 cmd.db = pState->db;
27696 if( cmd.zFile ){
27697 eDbType = deduceDatabaseType(cmd.zFile, 1);
27698 }else{
27699 eDbType = pState->openMode;
27700 }
27701 if( eDbType==SHELL_OPEN_ZIPFILE ){
27702 if( cmd.eCmd==AR_CMD_EXTRACT || cmd.eCmd==AR_CMD_LIST ){
27703 if( cmd.zFile==0 ){
27704 cmd.zSrcTable = sqlite3_mprintf("zip");
27705 }else{
27706 cmd.zSrcTable = sqlite3_mprintf("zipfile(%Q)", cmd.zFile);
27707 }
27708 }
27709 cmd.bZip = 1;
27710 }else if( cmd.zFile ){
27711 int flags;
27712 if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS;
27713 if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_INSERT
27714 || cmd.eCmd==AR_CMD_REMOVE || cmd.eCmd==AR_CMD_UPDATE ){
27715 flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
27716 }else{
27717 flags = SQLITE_OPEN_READONLY;
27718 }
27719 cmd.db = 0;
27720 if( cmd.bDryRun ){
27721 sqlite3_fprintf(cmd.out, "-- open database '%s'%s\n", cmd.zFile,
27722 eDbType==SHELL_OPEN_APPENDVFS ? " using 'apndvfs'" : "");
27723 }
27724 rc = sqlite3_open_v2(cmd.zFile, &cmd.db, flags,
27725 eDbType==SHELL_OPEN_APPENDVFS ? "apndvfs" : 0);
27726 if( rc!=SQLITE_OK ){
27727 sqlite3_fprintf(stderr, "cannot open file: %s (%s)\n",
27728 cmd.zFile, sqlite3_errmsg(cmd.db));
27729 goto end_ar_command;
27730 }
27731 sqlite3_fileio_init(cmd.db, 0, 0);
27732 sqlite3_sqlar_init(cmd.db, 0, 0);
27733 sqlite3_create_function(cmd.db, "shell_putsnl", 1, SQLITE_UTF8, cmd.p,
27734 shellPutsFunc, 0, 0);
27735
27736 }
27737 if( cmd.zSrcTable==0 && cmd.bZip==0 && cmd.eCmd!=AR_CMD_HELP ){

Callers 2

do_meta_commandFunction · 0.85
wmainFunction · 0.85

Calls 12

arParseCommandFunction · 0.85
deduceDatabaseTypeFunction · 0.85
sqlite3_fprintfFunction · 0.85
sqlite3_fileio_initFunction · 0.85
sqlite3_sqlar_initFunction · 0.85
arCreateOrUpdateCommandFunction · 0.85
arExtractCommandFunction · 0.85
arListCommandFunction · 0.85
arUsageFunction · 0.85
arRemoveCommandFunction · 0.85
close_dbFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected