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

Function process_sqliterc

ThirdParty/sqlite/vtksqlite/shell.c:32364–32402  ·  view source on GitHub ↗

** Read input from the file given by sqliterc_override. Or if that ** parameter is NULL, take input from the first of find_xdg_config() ** or ~/.sqliterc which is found. ** ** Returns the number of errors. */

Source from the content-addressed store, hash-verified

32362** Returns the number of errors.
32363*/
32364static void process_sqliterc(
32365 ShellState *p, /* Configuration data */
32366 const char *sqliterc_override /* Name of config file. NULL to use default */
32367){
32368 char *home_dir = NULL;
32369 const char *sqliterc = sqliterc_override;
32370 char *zBuf = 0;
32371 FILE *inSaved = p->in;
32372 int savedLineno = p->lineno;
32373
32374 if( sqliterc == NULL ){
32375 sqliterc = zBuf = find_xdg_config();
32376 }
32377 if( sqliterc == NULL ){
32378 home_dir = find_home_dir(0);
32379 if( home_dir==0 ){
32380 eputz("-- warning: cannot find home directory;"
32381 " cannot read ~/.sqliterc\n");
32382 return;
32383 }
32384 zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
32385 shell_check_oom(zBuf);
32386 sqliterc = zBuf;
32387 }
32388 p->in = sqlite3_fopen(sqliterc,"rb");
32389 if( p->in ){
32390 if( stdin_is_interactive ){
32391 sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
32392 }
32393 if( process_input(p) && bail_on_error ) exit(1);
32394 fclose(p->in);
32395 }else if( sqliterc_override!=0 ){
32396 sqlite3_fprintf(stderr,"cannot open: \"%s\"\n", sqliterc);
32397 if( bail_on_error ) exit(1);
32398 }
32399 p->in = inSaved;
32400 p->lineno = savedLineno;
32401 sqlite3_free(zBuf);
32402}
32403
32404/*
32405** Show available command line options

Callers 1

wmainFunction · 0.85

Calls 6

find_xdg_configFunction · 0.85
find_home_dirFunction · 0.85
shell_check_oomFunction · 0.85
sqlite3_fopenFunction · 0.85
sqlite3_fprintfFunction · 0.85
process_inputFunction · 0.85

Tested by

no test coverage detected