Esempio n. 1
0
/*
 * Load .psqlrc file, if found.
 */
static void
process_psqlrc(char *argv0)
{
	char		home[MAXPGPATH];
	char		rc_file[MAXPGPATH];
	char		my_exec_path[MAXPGPATH];
	char		etc_path[MAXPGPATH];
	char       *envrc;

	find_my_exec(argv0, my_exec_path);
	get_etc_path(my_exec_path, etc_path);

	snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
	process_psqlrc_file(rc_file);

	envrc = getenv("PSQLRC");
	
	if (envrc != NULL && strlen(envrc) > 0)
	{
		expand_tilde(&envrc);
		process_psqlrc_file(envrc);
	}
	else if (get_home_path(home))
	{
		snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
		process_psqlrc_file(rc_file);
	}
}
Esempio n. 2
0
/*
 * Load .psqlrc file, if found.
 */
static void
process_psqlrc(char *argv0)
{
    char		home[MAXPGPATH];
    char		rc_file[MAXPGPATH];
    char		my_exec_path[MAXPGPATH];
    char		etc_path[MAXPGPATH];
    char	   *envrc = getenv("PSQLRC");

    if (find_my_exec(argv0, my_exec_path) < 0)
    {
        fprintf(stderr, _("%s: could not find own program executable\n"), argv0);
        exit(EXIT_FAILURE);
    }

    get_etc_path(my_exec_path, etc_path);

    snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
    process_psqlrc_file(rc_file);

    if (envrc != NULL && strlen(envrc) > 0)
    {
        /* might need to free() this */
        char	   *envrc_alloc = pstrdup(envrc);

        expand_tilde(&envrc_alloc);
        process_psqlrc_file(envrc_alloc);
    }
    else if (get_home_path(home))
    {
        snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
        process_psqlrc_file(rc_file);
    }
}
Esempio n. 3
0
/*
 * Load .psqlrc file, if found.
 */
static void process_psqlrc(char *argv0)
{
	char home[MAX_PG_PATH];
	char rc_file[MAX_PG_PATH];
	char my_exec_path[MAX_PG_PATH];
	char etc_path[MAX_PG_PATH];

	find_my_exec(argv0, my_exec_path);
	get_etc_path(my_exec_path, etc_path);

	snprintf(rc_file, MAX_PG_PATH, "%s/%s", etc_path, SYSPSQLRC);
	process_psqlrc_file(rc_file);

	if (get_home_path(home)) {
		snprintf(rc_file, MAX_PG_PATH, "%s/%s", home, PSQLRC);
		process_psqlrc_file(rc_file);
	}
}