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

Function do_meta_command

ThirdParty/sqlite/vtksqlite/shell.c:28193–31820  ·  view source on GitHub ↗

** If an input line begins with "." then invoke this routine to ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */

Source from the content-addressed store, hash-verified

28191** Return 1 on error, 2 to exit, and 0 otherwise.
28192*/
28193static int do_meta_command(char *zLine, ShellState *p){
28194 int h = 1;
28195 int nArg = 0;
28196 int n, c;
28197 int rc = 0;
28198 char *azArg[52];
28199
28200#ifndef SQLITE_OMIT_VIRTUALTABLE
28201 if( p->expert.pExpert ){
28202 expertFinish(p, 1, 0);
28203 }
28204#endif
28205
28206 /* Parse the input line into tokens.
28207 */
28208 while( zLine[h] && nArg<ArraySize(azArg)-1 ){
28209 while( IsSpace(zLine[h]) ){ h++; }
28210 if( zLine[h]==0 ) break;
28211 if( zLine[h]=='\'' || zLine[h]=='"' ){
28212 int delim = zLine[h++];
28213 azArg[nArg++] = &zLine[h];
28214 while( zLine[h] && zLine[h]!=delim ){
28215 if( zLine[h]=='\\' && delim=='"' && zLine[h+1]!=0 ) h++;
28216 h++;
28217 }
28218 if( zLine[h]==delim ){
28219 zLine[h++] = 0;
28220 }
28221 if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
28222 }else{
28223 azArg[nArg++] = &zLine[h];
28224 while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
28225 if( zLine[h] ) zLine[h++] = 0;
28226 }
28227 }
28228 azArg[nArg] = 0;
28229
28230 /* Process the input line.
28231 */
28232 if( nArg==0 ) return 0; /* no tokens, no error */
28233 n = strlen30(azArg[0]);
28234 c = azArg[0][0];
28235 clearTempFile(p);
28236
28237#ifndef SQLITE_OMIT_AUTHORIZATION
28238 if( c=='a' && cli_strncmp(azArg[0], "auth", n)==0 ){
28239 if( nArg!=2 ){
28240 sqlite3_fprintf(stderr, "Usage: .auth ON|OFF\n");
28241 rc = 1;
28242 goto meta_command_exit;
28243 }
28244 open_db(p, 0);
28245 if( booleanValue(azArg[1]) ){
28246 sqlite3_set_authorizer(p->db, shellAuth, p);
28247 }else if( p->bSafeModePersist ){
28248 sqlite3_set_authorizer(p->db, safeModeAuth, p);
28249 }else{
28250 sqlite3_set_authorizer(p->db, 0, 0);

Callers 2

process_inputFunction · 0.85
wmainFunction · 0.85

Calls 15

expertFinishFunction · 0.85
resolve_backslashesFunction · 0.85
strlen30Function · 0.85
clearTempFileFunction · 0.85
cli_strncmpFunction · 0.85
sqlite3_fprintfFunction · 0.85
open_dbFunction · 0.85
booleanValueFunction · 0.85
failIfSafeModeFunction · 0.85
arDotCommandFunction · 0.85
cli_strcmpFunction · 0.85
close_dbFunction · 0.85

Tested by

no test coverage detected