pg_repack/bin/pgut/pgut.h

107 lines
2.5 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
2009-04-22 07:26:12 +00:00
* pgut.h
*
* Copyright (c) 2009, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
*
*-------------------------------------------------------------------------
2009-04-22 07:26:12 +00:00
*/
#ifndef PGUT_H
#define PGUT_H
#include "libpq-fe.h"
#include "pqexpbuffer.h"
2009-04-22 07:26:12 +00:00
#include <getopt.h>
#if !defined(C_H) && !defined(__cplusplus)
#ifndef bool
typedef char bool;
#endif
#ifndef true
#define true ((bool) 1)
#endif
#ifndef false
#define false ((bool) 0)
#endif
#endif
2009-04-22 07:26:12 +00:00
/*
* pgut client variables and functions
*/
extern const char *pgut_optstring;
extern const struct option pgut_longopts[];
extern bool pgut_argument(int c, const char *arg);
extern void pgut_help(void);
extern void pgut_cleanup(bool fatal);
2009-04-22 07:26:12 +00:00
/*
* pgut framework variables and functions
*/
extern const char *PROGRAM_NAME;
extern const char *PROGRAM_VERSION;
extern const char *PROGRAM_URL;
extern const char *PROGRAM_EMAIL;
2009-04-22 07:26:12 +00:00
extern const char *dbname;
extern const char *host;
extern const char *port;
extern const char *username;
extern bool password;
extern PGconn *connection;
2009-04-22 07:26:12 +00:00
extern void parse_options(int argc, char **argv);
extern bool assign_option(const char **value, int c, const char *arg);
2009-04-22 07:26:12 +00:00
extern void reconnect(void);
extern void disconnect(void);
extern PGresult *execute_nothrow(const char *query, int nParams, const char **params);
extern PGresult *execute(const char *query, int nParams, const char **params);
extern void command(const char *query, int nParams, const char **params);
#ifdef WIN32
extern unsigned int sleep(unsigned int seconds);
#endif
/*
* elog
*/
#define LOG (-4)
#define INFO (-3)
#define NOTICE (-2)
#define WARNING (-1)
#define ERROR 1
#define HELP 2
#define FATAL 3
#define PANIC 4
#undef elog
extern void
elog(int elevel, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
/*
* StringInfo
*/
#define StringInfoData PQExpBufferData
#define StringInfo PQExpBuffer
#define makeStringInfo createPQExpBuffer
#define initStringInfo initPQExpBuffer
#define freeStringInfo destroyPQExpBuffer
#define termStringInfo termPQExpBuffer
#define resetStringInfo resetPQExpBuffer
#define enlargeStringInfo enlargePQExpBuffer
/*
#define printfPQExpBuffer = resetStringInfo + appendStringInfo
*/
#define appendStringInfo appendPQExpBuffer
#define appendStringInfoString appendPQExpBufferStr
#define appendStringInfoChar appendPQExpBufferChar
#define appendBinaryStringInfo appendBinaryPQExpBuffer
2009-04-22 07:26:12 +00:00
#endif /* PGUT_H */