MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / process_sqliterc

Function process_sqliterc

modules/dasSQLITE/sqlite/shell.c:26751–26789  ·  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

26749** Returns the number of errors.
26750*/
26751static void process_sqliterc(
26752 ShellState *p, /* Configuration data */
26753 const char *sqliterc_override /* Name of config file. NULL to use default */
26754){
26755 char *home_dir = NULL;
26756 const char *sqliterc = sqliterc_override;
26757 char *zBuf = 0;
26758 FILE *inSaved = p->in;
26759 int savedLineno = p->lineno;
26760
26761 if( sqliterc == NULL ){
26762 sqliterc = find_xdg_config();
26763 }
26764 if( sqliterc == NULL ){
26765 home_dir = find_home_dir(0);
26766 if( home_dir==0 ){
26767 raw_printf(stderr, "-- warning: cannot find home directory;"
26768 " cannot read ~/.sqliterc\n");
26769 return;
26770 }
26771 zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
26772 shell_check_oom(zBuf);
26773 sqliterc = zBuf;
26774 }
26775 p->in = fopen(sqliterc,"rb");
26776 if( p->in ){
26777 if( stdin_is_interactive ){
26778 utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc);
26779 }
26780 if( process_input(p) && bail_on_error ) exit(1);
26781 fclose(p->in);
26782 }else if( sqliterc_override!=0 ){
26783 utf8_printf(stderr,"cannot open: \"%s\"\n", sqliterc);
26784 if( bail_on_error ) exit(1);
26785 }
26786 p->in = inSaved;
26787 p->lineno = savedLineno;
26788 sqlite3_free(zBuf);
26789}
26790
26791/*
26792** Show available command line options

Callers 1

wmainFunction · 0.85

Calls 5

find_xdg_configFunction · 0.85
find_home_dirFunction · 0.85
shell_check_oomFunction · 0.85
utf8_printfFunction · 0.85
process_inputFunction · 0.85

Tested by

no test coverage detected