settings.h 1.77 KB
Newer Older
Peter Eisentraut's avatar
Peter Eisentraut committed
1 2 3
/*
 * psql - the PostgreSQL interactive terminal
 *
4
 * Copyright (c) 2000-2005, PostgreSQL Global Development Group
Peter Eisentraut's avatar
Peter Eisentraut committed
5
 *
6
 * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.23 2005/01/01 05:43:08 momjian Exp $
Peter Eisentraut's avatar
Peter Eisentraut committed
7
 */
8 9
#ifndef SETTINGS_H
#define SETTINGS_H
Peter Eisentraut's avatar
Peter Eisentraut committed
10

11
#include "libpq-fe.h"
12 13 14 15 16

#include "variables.h"
#include "print.h"

#define DEFAULT_FIELD_SEP "|"
Peter Eisentraut's avatar
Peter Eisentraut committed
17
#define DEFAULT_RECORD_SEP "\n"
18 19 20 21

#if defined(WIN32) || defined(__CYGWIN__)
#define DEFAULT_EDITOR	"notepad.exe"
#else
22
#define DEFAULT_EDITOR	"vi"
23
#endif
24 25 26 27 28 29 30 31

#define DEFAULT_PROMPT1 "%/%R%# "
#define DEFAULT_PROMPT2 "%/%R%# "
#define DEFAULT_PROMPT3 ">> "


typedef struct _psqlSettings
{
Bruce Momjian's avatar
Bruce Momjian committed
32
	PGconn	   *db;				/* connection to backend */
33
	int			encoding;
Bruce Momjian's avatar
Bruce Momjian committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
	FILE	   *queryFout;		/* where to send the query results */
	bool		queryFoutPipe;	/* queryFout is from a popen() */

	printQueryOpt popt;
	VariableSpace vars;			/* "shell variable" repository */

	char	   *gfname;			/* one-shot file output argument for \g */

	bool		notty;			/* stdin or stdout is not a tty (as
								 * determined on startup) */
	bool		getPassword;	/* prompt the user for a username and
								 * password */
	FILE	   *cur_cmd_source; /* describe the status of the current main
								 * loop */
	bool		cur_cmd_interactive;
Bruce Momjian's avatar
Bruce Momjian committed
49
	int			sversion;		/* backend server version */
50
	const char *progname;		/* in case you renamed psql */
51 52
	char	   *inputfile;		/* for error reporting */
	unsigned	lineno;			/* also for error reporting */
53

54
	bool		timing;			/* enable timing of all queries */
55 56

	PGVerbosity verbosity;		/* current error verbosity level */
57 58
} PsqlSettings;

59 60 61 62
extern PsqlSettings pset;


#define QUIET() (GetVariableBool(pset.vars, "QUIET"))
63 64 65 66 67 68 69 70 71 72 73 74 75


#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

#define EXIT_BADCONN 2

#define EXIT_USER 3
76

77
#endif