Commit 9e155260 authored by Bruce Momjian's avatar Bruce Momjian

pgindent run. Make it all clean.

parent 6cf8707b
......@@ -4,76 +4,81 @@
#include "utils/elog.h"
static char * PARSE_BUFFER;
static char * PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
static char *PARSE_BUFFER;
static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
static unsigned int SCANNER_POS;
void set_parse_buffer( char* s );
void reset_parse_buffer( void );
int read_parse_buffer( void );
char * parse_buffer( void );
char * parse_buffer_ptr( void );
unsigned int parse_buffer_curr_char( void );
unsigned int parse_buffer_size( void );
unsigned int parse_buffer_pos( void );
void set_parse_buffer(char *s);
void reset_parse_buffer(void);
int read_parse_buffer(void);
char *parse_buffer(void);
char *parse_buffer_ptr(void);
unsigned int parse_buffer_curr_char(void);
unsigned int parse_buffer_size(void);
unsigned int parse_buffer_pos(void);
extern void cube_flush_scanner_buffer(void); /* defined in cubescan.l */
extern void cube_flush_scanner_buffer(void); /* defined in cubescan.l */
void set_parse_buffer( char* s )
void
set_parse_buffer(char *s)
{
PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s);
if ( PARSE_BUFFER_SIZE == 0 ) {
elog(ERROR, "cube_in: can't parse an empty string");
}
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s);
if (PARSE_BUFFER_SIZE == 0)
elog(ERROR, "cube_in: can't parse an empty string");
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
}
void reset_parse_buffer( void )
void
reset_parse_buffer(void)
{
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
cube_flush_scanner_buffer();
PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0;
cube_flush_scanner_buffer();
}
int read_parse_buffer( void )
int
read_parse_buffer(void)
{
int c;
/*
c = *PARSE_BUFFER_PTR++;
SCANNER_POS++;
*/
c = PARSE_BUFFER[SCANNER_POS];
if(SCANNER_POS < PARSE_BUFFER_SIZE)
SCANNER_POS++;
return c;
int c;
/*
* c = *PARSE_BUFFER_PTR++; SCANNER_POS++;
*/
c = PARSE_BUFFER[SCANNER_POS];
if (SCANNER_POS < PARSE_BUFFER_SIZE)
SCANNER_POS++;
return c;
}
char * parse_buffer( void )
char *
parse_buffer(void)
{
return PARSE_BUFFER;
return PARSE_BUFFER;
}
unsigned int parse_buffer_curr_char( void )
unsigned int
parse_buffer_curr_char(void)
{
return PARSE_BUFFER[SCANNER_POS];
return PARSE_BUFFER[SCANNER_POS];
}
char * parse_buffer_ptr( void )
char *
parse_buffer_ptr(void)
{
return PARSE_BUFFER_PTR;
return PARSE_BUFFER_PTR;
}
unsigned int parse_buffer_pos( void )
unsigned int
parse_buffer_pos(void)
{
return SCANNER_POS;
return SCANNER_POS;
}
unsigned int parse_buffer_size( void )
unsigned int
parse_buffer_size(void)
{
return PARSE_BUFFER_SIZE;
return PARSE_BUFFER_SIZE;
}
extern void set_parse_buffer( char* s );
extern void reset_parse_buffer( void );
extern int read_parse_buffer( void );
extern char * parse_buffer( void );
extern char * parse_buffer_ptr( void );
extern unsigned int parse_buffer_curr_char( void );
extern unsigned int parse_buffer_pos( void );
extern unsigned int parse_buffer_size( void );
extern void set_parse_buffer(char *s);
extern void reset_parse_buffer(void);
extern int read_parse_buffer(void);
extern char *parse_buffer(void);
extern char *parse_buffer_ptr(void);
extern unsigned int parse_buffer_curr_char(void);
extern unsigned int parse_buffer_pos(void);
extern unsigned int parse_buffer_size(void);
This diff is collapsed.
typedef struct NDBOX {
unsigned int size; /* required to be a Postgres varlena type */
unsigned int dim;
float x[1];
} NDBOX;
typedef struct NDBOX
{
unsigned int size; /* required to be a Postgres varlena type */
unsigned int dim;
float x[1];
} NDBOX;
......@@ -9,7 +9,7 @@
const int EARTH_RADIUS = 3958.747716;
const int TWO_PI = 2.0 * M_PI;
double *geo_distance(Point *pt1, Point *pt2);
double *geo_distance(Point *pt1, Point *pt2);
/******************************************************
......
......@@ -20,7 +20,7 @@ main(int argc, char **argv)
char attname[256];
char typname[256];
int count;
char optstr[256];
char optstr[256];
if (argc != 2)
halt("Usage: %s database\n", argv[0]);
......
......@@ -62,11 +62,11 @@ select p.* from product p, title_fti f1, title_fti f2 where
that can build the final query automatigally?
*/
extern Datum fti(PG_FUNCTION_ARGS);
static char *breakup(char *, char *);
static bool is_stopword(char *);
extern Datum fti(PG_FUNCTION_ARGS);
static char *breakup(char *, char *);
static bool is_stopword(char *);
static bool new_tuple = false;
static bool new_tuple = false;
/* THIS LIST MUST BE IN SORTED ORDER, A BINARY SEARCH IS USED!!!! */
......
/*
* PostgreSQL type definitions for managed LargeObjects.
*
* $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.7 2001/02/10 02:31:25 tgl Exp $
* $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.8 2001/03/22 03:59:09 momjian Exp $
*
*/
......@@ -36,7 +36,7 @@ Blob *lo_in(char *str); /* Create from String */
char *lo_out(Blob * addr);/* Output oid as String */
Oid lo_oid(Blob * addr);/* Return oid as an oid */
Blob *lo(Oid oid); /* Return Blob based on oid */
Datum lo_manage(PG_FUNCTION_ARGS); /* Trigger handler */
Datum lo_manage(PG_FUNCTION_ARGS); /* Trigger handler */
/*
* This creates a large object, and sets its OID to the value in the
......@@ -69,7 +69,7 @@ lo_in(char *str)
* There is no Oid passed, so create a new one
*/
oid = DatumGetObjectId(DirectFunctionCall1(lo_creat,
Int32GetDatum(INV_READ | INV_WRITE)));
Int32GetDatum(INV_READ | INV_WRITE)));
if (oid == InvalidOid)
elog(ERROR, "lo_in: InvalidOid returned from lo_creat");
}
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
* $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.2 2001/03/13 01:17:40 tgl Exp $
* $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.3 2001/03/22 03:59:09 momjian Exp $
*/
#include "postgres.h"
......@@ -24,7 +24,7 @@ dbState(DBState state)
{
switch (state)
{
case DB_STARTUP:
case DB_STARTUP:
return "STARTUP";
case DB_SHUTDOWNED:
return "SHUTDOWNED";
......@@ -43,16 +43,17 @@ int
main()
{
ControlFileData ControlFile;
int fd;
char ControlFilePath[MAXPGPATH];
char *DataDir;
crc64 crc;
char pgctime_str[32];
char ckpttime_str[32];
int fd;
char ControlFilePath[MAXPGPATH];
char *DataDir;
crc64 crc;
char pgctime_str[32];
char ckpttime_str[32];
DataDir = getenv("PGDATA");
if ( DataDir == NULL ) {
fprintf(stderr,"PGDATA is not defined\n");
if (DataDir == NULL)
{
fprintf(stderr, "PGDATA is not defined\n");
exit(1);
}
......@@ -73,8 +74,8 @@ main()
/* Check the CRC. */
INIT_CRC64(crc);
COMP_CRC64(crc,
(char*) &ControlFile + sizeof(crc64),
COMP_CRC64(crc,
(char *) &ControlFile + sizeof(crc64),
sizeof(ControlFileData) - sizeof(crc64));
FIN_CRC64(crc);
......@@ -93,7 +94,7 @@ main()
"Database state: %s\n"
"pg_control last modified: %s\n"
"Current log file id: %u\n"
"Next log file segment: %u\n"
"Next log file segment: %u\n"
"Latest checkpoint location: %X/%X\n"
"Prior checkpoint location: %X/%X\n"
"Latest checkpoint's REDO location: %X/%X\n"
......
/* -------------------------------------------------------------------------
* pg_dumplo
*
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.5 2001/01/24 19:42:44 momjian Exp $
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.6 2001/03/22 03:59:10 momjian Exp $
*
* Karel Zak 1999-2000
* -------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
#include <time.h>
#include <libpq-fe.h>
......@@ -22,17 +22,17 @@
#include "pg_dumplo.h"
extern int errno;
extern int errno;
void
load_lolist( LODumpMaster *pgLO )
void
load_lolist(LODumpMaster * pgLO)
{
LOlist *ll;
int i;
int n;
LOlist *ll;
int i;
int n;
/* ----------
/* ----------
* Now find any candidate tables who have columns of type oid.
*
* NOTE: System tables including pg_largeobject will be ignored.
......@@ -40,8 +40,8 @@ load_lolist( LODumpMaster *pgLO )
*
* NOTE: the system oid column is ignored, as it has attnum < 1.
* This shouldn't matter for correctness, but it saves time.
* ----------
*/
* ----------
*/
pgLO->res = PQexec(pgLO->conn,
"SELECT c.relname, a.attname "
"FROM pg_class c, pg_attribute a, pg_type t "
......@@ -52,43 +52,49 @@ load_lolist( LODumpMaster *pgLO )
" AND c.relkind = 'r' "
" AND c.relname NOT LIKE 'pg_%'");
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK) {
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname,
PQerrorMessage(pgLO->conn));
exit(RE_ERROR);
}
if ((n = PQntuples(pgLO->res)) == 0) {
if ((n = PQntuples(pgLO->res)) == 0)
{
fprintf(stderr, "%s: No OID columns in the database.\n", progname);
exit(RE_ERROR);
}
}
pgLO->lolist = (LOlist *) malloc((n + 1) * sizeof(LOlist));
if (!pgLO->lolist) {
if (!pgLO->lolist)
{
fprintf(stderr, "%s: can't allocate memory\n", progname);
exit(RE_ERROR);
}
for (i = 0, ll = pgLO->lolist; i < n; i++, ll++) {
}
for (i = 0, ll = pgLO->lolist; i < n; i++, ll++)
{
ll->lo_table = strdup(PQgetvalue(pgLO->res, i, 0));
ll->lo_attr = strdup(PQgetvalue(pgLO->res, i, 1));
ll->lo_attr = strdup(PQgetvalue(pgLO->res, i, 1));
}
ll->lo_table = ll->lo_attr = (char *) NULL;
ll->lo_table = ll->lo_attr = (char *) NULL;
PQclear(pgLO->res);
}
void
pglo_export(LODumpMaster *pgLO)
void
pglo_export(LODumpMaster * pgLO)
{
LOlist *ll;
int tuples;
LOlist *ll;
int tuples;
char path[BUFSIZ],
Qbuff[QUERY_BUFSIZ];
if (pgLO->action != ACTION_SHOW) {
time_t t;
Qbuff[QUERY_BUFSIZ];
if (pgLO->action != ACTION_SHOW)
{
time_t t;
time(&t);
fprintf(pgLO->index, "#\n# This is the PostgreSQL large object dump index\n#\n");
fprintf(pgLO->index, "#\tDate: %s", ctime(&t));
......@@ -97,90 +103,102 @@ pglo_export(LODumpMaster *pgLO)
fprintf(pgLO->index, "#\tUser: %s\n", pgLO->user);
fprintf(pgLO->index, "#\n# oid\ttable\tattribut\tinfile\n#\n");
}
pgLO->counter = 0;
for(ll=pgLO->lolist; ll->lo_table != NULL; ll++) {
for (ll = pgLO->lolist; ll->lo_table != NULL; ll++)
{
/* ----------
* Query: find the LOs referenced by this column
* ----------
*/
sprintf(Qbuff, "SELECT DISTINCT l.loid FROM \"%s\" x, pg_largeobject l WHERE x.\"%s\" = l.loid",
ll->lo_table, ll->lo_attr);
/* puts(Qbuff); */
pgLO->res = PQexec(pgLO->conn, Qbuff);
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK) {
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname,
PQerrorMessage(pgLO->conn));
}
else if ((tuples = PQntuples(pgLO->res)) == 0) {
}
else if ((tuples = PQntuples(pgLO->res)) == 0)
{
if (!pgLO->quiet && pgLO->action == ACTION_EXPORT_ATTR)
printf("%s: no large objects in \"%s\".\"%s\"\n",
progname, ll->lo_table, ll->lo_attr);
} else {
int t;
char *val;
progname, ll->lo_table, ll->lo_attr);
}
else
{
int t;
char *val;
/* ----------
* Create DIR/FILE
* ----------
*/
if (pgLO->action != ACTION_SHOW) {
if (pgLO->action != ACTION_SHOW)
{
sprintf(path, "%s/%s/%s", pgLO->space, pgLO->db,
ll->lo_table);
if (mkdir(path, DIR_UMASK) == -1) {
if (errno != EEXIST) {
if (mkdir(path, DIR_UMASK) == -1)
{
if (errno != EEXIST)
{
perror(path);
exit(RE_ERROR);
}
exit(RE_ERROR);
}
}
sprintf(path, "%s/%s/%s/%s", pgLO->space, pgLO->db,
ll->lo_table, ll->lo_attr);
if (mkdir(path, DIR_UMASK) == -1) {
if (errno != EEXIST) {
ll->lo_table, ll->lo_attr);
if (mkdir(path, DIR_UMASK) == -1)
{
if (errno != EEXIST)
{
perror(path);
exit(RE_ERROR);
}
exit(RE_ERROR);
}
}
if (!pgLO->quiet)
printf("dump %s.%s (%d large obj)\n",
ll->lo_table, ll->lo_attr, tuples);
printf("dump %s.%s (%d large obj)\n",
ll->lo_table, ll->lo_attr, tuples);
}
pgLO->counter += tuples;
for(t=0; t<tuples; t++) {
Oid lo;
for (t = 0; t < tuples; t++)
{
Oid lo;
val = PQgetvalue(pgLO->res, t, 0);
lo = atooid(val);
if (pgLO->action == ACTION_SHOW) {
if (pgLO->action == ACTION_SHOW)
{
printf("%s.%s: %u\n", ll->lo_table, ll->lo_attr, lo);
continue;
}
sprintf(path, "%s/%s/%s/%s/%s", pgLO->space,
pgLO->db, ll->lo_table, ll->lo_attr, val);
if (lo_export(pgLO->conn, lo, path) < 0)
sprintf(path, "%s/%s/%s/%s/%s", pgLO->space,
pgLO->db, ll->lo_table, ll->lo_attr, val);
if (lo_export(pgLO->conn, lo, path) < 0)
fprintf(stderr, "%s: lo_export failed:\n%s", progname,
PQerrorMessage(pgLO->conn));
else
fprintf(pgLO->index, "%s\t%s\t%s\t%s/%s/%s/%s\n", val,
ll->lo_table, ll->lo_attr, pgLO->db, ll->lo_table, ll->lo_attr, val);
else
fprintf(pgLO->index, "%s\t%s\t%s\t%s/%s/%s/%s\n", val,
ll->lo_table, ll->lo_attr, pgLO->db, ll->lo_table, ll->lo_attr, val);
}
}
......
/* -------------------------------------------------------------------------
* pg_dumplo
*
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.3 2001/01/24 19:42:45 momjian Exp $
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
*
* Karel Zak 1999-2000
* -------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
#include <time.h>
#include <libpq-fe.h>
......@@ -22,76 +22,82 @@
#include "pg_dumplo.h"
extern int errno;
extern int errno;
void
pglo_import(LODumpMaster *pgLO)
void
pglo_import(LODumpMaster * pgLO)
{
LOlist loa;
Oid new_oid;
char tab[MAX_TABLE_NAME], attr[MAX_ATTR_NAME],
path[BUFSIZ], lo_path[BUFSIZ],
Qbuff[QUERY_BUFSIZ];
while(fgets(Qbuff, QUERY_BUFSIZ, pgLO->index)) {
Oid new_oid;
char tab[MAX_TABLE_NAME],
attr[MAX_ATTR_NAME],
path[BUFSIZ],
lo_path[BUFSIZ],
Qbuff[QUERY_BUFSIZ];
while (fgets(Qbuff, QUERY_BUFSIZ, pgLO->index))
{
if (*Qbuff == '#')
continue;
if (! pgLO->remove && ! pgLO->quiet)
if (!pgLO->remove && !pgLO->quiet)
printf(Qbuff);
sscanf(Qbuff, "%u\t%s\t%s\t%s\n", &loa.lo_oid, tab, attr, path);
sscanf(Qbuff, "%u\t%s\t%s\t%s\n", &loa.lo_oid, tab, attr, path);
loa.lo_table = tab;
loa.lo_attr = attr;
loa.lo_attr = attr;
sprintf(lo_path, "%s/%s", pgLO->space, path);
sprintf(lo_path, "%s/%s", pgLO->space, path);
/* ----------
* Import LO
* ----------
*/
if ((new_oid = lo_import(pgLO->conn, lo_path)) == 0) {
if ((new_oid = lo_import(pgLO->conn, lo_path)) == 0)
{
fprintf(stderr, "%s: %s\n", progname, PQerrorMessage(pgLO->conn));
PQexec(pgLO->conn, "ROLLBACK");
fprintf(stderr, "\n%s: ROLLBACK\n", progname);
exit(RE_ERROR);
}
if (pgLO->remove) {
if (pgLO->remove)
{
notice(pgLO, FALSE);
if (lo_unlink(pgLO->conn, loa.lo_oid) < 0)
fprintf(stderr, "%s: can't remove LO %u:\n%s",
progname, loa.lo_oid, PQerrorMessage(pgLO->conn));
if (lo_unlink(pgLO->conn, loa.lo_oid) < 0)
fprintf(stderr, "%s: can't remove LO %u:\n%s",
progname, loa.lo_oid, PQerrorMessage(pgLO->conn));
else if (!pgLO->quiet)
printf("remove old %u and create new %u\n",
loa.lo_oid, new_oid);
notice(pgLO, TRUE);
printf("remove old %u and create new %u\n",
loa.lo_oid, new_oid);
notice(pgLO, TRUE);
}
pgLO->counter++;
/* ----------
* UPDATE oid in tab
* ----------
*/
sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u",
sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u",
loa.lo_table, loa.lo_attr, new_oid, loa.lo_attr, loa.lo_oid);
/*fprintf(stderr, Qbuff);*/
/* fprintf(stderr, Qbuff); */
pgLO->res = PQexec(pgLO->conn, Qbuff);
if (PQresultStatus(pgLO->res) != PGRES_COMMAND_OK) {
fprintf(stderr, "%s: %s\n",progname, PQerrorMessage(pgLO->conn));
if (PQresultStatus(pgLO->res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "%s: %s\n", progname, PQerrorMessage(pgLO->conn));
PQclear(pgLO->res);
PQexec(pgLO->conn, "ROLLBACK");
fprintf(stderr, "\n%s: ROLLBACK\n", progname);
exit(RE_ERROR);
}
}
PQclear(pgLO->res);
}
}
}
}
This diff is collapsed.
/* -------------------------------------------------------------------------
* pg_dumplo
*
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.3 2001/01/24 19:42:45 momjian Exp $
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.4 2001/03/22 03:59:10 momjian Exp $
*
* Karel Zak 1999-2000
* -------------------------------------------------------------------------
......@@ -17,12 +17,12 @@
/* ----------
* Define
* ----------
*/
*/
#define QUERY_BUFSIZ (8*1024)
#define DIR_UMASK 0755
#define FILE_UMASK 0644
#define TRUE 1
#define TRUE 1
#define FALSE 0
#define RE_OK 0
#define RE_ERROR 1
......@@ -36,44 +36,47 @@
* LO struct
* ----------
*/
typedef struct {
char *lo_table,
*lo_attr;
Oid lo_oid;
} LOlist;
typedef struct
{
char *lo_table,
*lo_attr;
Oid lo_oid;
} LOlist;
typedef struct {
int action;
LOlist *lolist;
char **argv,
*user,
*db,
*host,
*space;
FILE *index;
int counter,
argc,
lolist_start,
remove,
quiet;
PGresult *res;
PGconn *conn;
} LODumpMaster;
typedef struct
{
int action;
LOlist *lolist;
char **argv,
*user,
*db,
*host,
*space;
FILE *index;
int counter,
argc,
lolist_start,
remove,
quiet;
PGresult *res;
PGconn *conn;
} LODumpMaster;
typedef enum {
typedef enum
{
ACTION_NONE,
ACTION_SHOW,
ACTION_EXPORT_ATTR,
ACTION_EXPORT_ALL,
ACTION_EXPORT_ATTR,
ACTION_EXPORT_ALL,
ACTION_IMPORT
} PGLODUMP_ACTIONS;
} PGLODUMP_ACTIONS;
extern char *progname;
extern void notice (LODumpMaster *pgLO, int set);
extern void index_file (LODumpMaster *pgLO);
extern void load_lolist (LODumpMaster *pgLO);
extern void pglo_export (LODumpMaster *pgLO);
extern void pglo_import (LODumpMaster *pgLO);
extern void notice(LODumpMaster * pgLO, int set);
extern void index_file(LODumpMaster * pgLO);
extern void load_lolist(LODumpMaster * pgLO);
extern void pglo_export(LODumpMaster * pgLO);
extern void pglo_import(LODumpMaster * pgLO);
#endif /* PG_DUMPLO_H */
#endif /* PG_DUMPLO_H */
/* -------------------------------------------------------------------------
* pg_dumplo
*
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/utils.c,v 1.3 2001/01/24 19:42:45 momjian Exp $
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/utils.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
*
* Karel Zak 1999-2000
* -------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
#include <time.h>
#include <libpq-fe.h>
......@@ -22,65 +22,76 @@
#include "pg_dumplo.h"
extern int errno;
extern int errno;
static void Dummy_NoticeProcessor(void *arg, const char *message);
static void Default_NoticeProcessor(void *arg, const char *message);
static void Dummy_NoticeProcessor(void * arg, const char * message);
static void Default_NoticeProcessor(void * arg, const char * message);
void
index_file(LODumpMaster *pgLO)
index_file(LODumpMaster * pgLO)
{
char path[BUFSIZ];
char path[BUFSIZ];
if (pgLO->action == ACTION_SHOW)
return;
sprintf(path, "%s/%s", pgLO->space, pgLO->db);
sprintf(path, "%s/%s", pgLO->space, pgLO->db);
if (pgLO->action == ACTION_EXPORT_ATTR ||
pgLO->action == ACTION_EXPORT_ALL) {
if (mkdir(path, DIR_UMASK) == -1) {
if (errno != EEXIST) {
pgLO->action == ACTION_EXPORT_ALL)
{
if (mkdir(path, DIR_UMASK) == -1)
{
if (errno != EEXIST)
{
perror(path);
exit(RE_ERROR);
}
exit(RE_ERROR);
}
}
sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "w")) == NULL) {
sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "w")) == NULL)
{
perror(path);
exit(RE_ERROR);
}
} else if (pgLO->action != ACTION_NONE ) {
sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "r")) == NULL) {
}
else if (pgLO->action != ACTION_NONE)
{
sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "r")) == NULL)
{
perror(path);
exit(RE_ERROR);
}
}
}
static
void Dummy_NoticeProcessor(void * arg, const char * message)
static
void
Dummy_NoticeProcessor(void *arg, const char *message)
{
;
;
}
static
void Default_NoticeProcessor(void * arg, const char * message)
static
void
Default_NoticeProcessor(void *arg, const char *message)
{
fprintf(stderr, "%s", message);
fprintf(stderr, "%s", message);
}
void
notice(LODumpMaster *pgLO, int set)
{
if (set)PQsetNoticeProcessor(pgLO->conn, Default_NoticeProcessor, NULL);
else PQsetNoticeProcessor(pgLO->conn, Dummy_NoticeProcessor, NULL);
void
notice(LODumpMaster * pgLO, int set)
{
if (set)
PQsetNoticeProcessor(pgLO->conn, Default_NoticeProcessor, NULL);
else
PQsetNoticeProcessor(pgLO->conn, Dummy_NoticeProcessor, NULL);
}
......@@ -2,10 +2,10 @@
*
* Copyright 2001 by Nathan Myers <ncm@nospam.cantrip.org>
* This software is distributed free of charge with no warranty of any kind.
* You have permission to make copies for any purpose, provided that (1)
* this copyright notice is retained unchanged, and (2) you agree to
* absolve the author of all responsibility for all consequences arising
* from any use.
* You have permission to make copies for any purpose, provided that (1)
* this copyright notice is retained unchanged, and (2) you agree to
* absolve the author of all responsibility for all consequences arising
* from any use.
*/
#include <stdio.h>
......@@ -13,73 +13,94 @@
#include <syslog.h>
#include <string.h>
struct {
const char *tag;
int size;
int priority;
} tags[] = {
{ "", 0, LOG_NOTICE },
{ "emerg:", sizeof("emerg"), LOG_EMERG },
{ "alert:", sizeof("alert"), LOG_ALERT },
{ "crit:", sizeof("crit"), LOG_CRIT },
{ "err:", sizeof("err"), LOG_ERR },
{ "error:", sizeof("error"), LOG_ERR },
{ "warning:", sizeof("warning"), LOG_WARNING },
{ "notice:", sizeof("notice"), LOG_NOTICE },
{ "info:", sizeof("info"), LOG_INFO },
{ "debug:", sizeof("debug"), LOG_DEBUG }
struct
{
const char *tag;
int size;
int priority;
} tags[] =
{
{
"", 0, LOG_NOTICE
},
{
"emerg:", sizeof("emerg"), LOG_EMERG
},
{
"alert:", sizeof("alert"), LOG_ALERT
},
{
"crit:", sizeof("crit"), LOG_CRIT
},
{
"err:", sizeof("err"), LOG_ERR
},
{
"error:", sizeof("error"), LOG_ERR
},
{
"warning:", sizeof("warning"), LOG_WARNING
},
{
"notice:", sizeof("notice"), LOG_NOTICE
},
{
"info:", sizeof("info"), LOG_INFO
},
{
"debug:", sizeof("debug"), LOG_DEBUG
}
};
int main()
int
main()
{
char buf[301];
int c;
char *pos = buf;
const char *colon = 0;
char buf[301];
int c;
char *pos = buf;
const char *colon = 0;
#ifndef DEBUG
openlog("postgresql", LOG_CONS, LOG_LOCAL1);
openlog("postgresql", LOG_CONS, LOG_LOCAL1);
#endif
while ( (c = getchar()) != EOF) {
if (c == '\r') {
continue;
}
if (c == '\n') {
int level = sizeof(tags)/sizeof(*tags);
char *bol;
while ((c = getchar()) != EOF)
{
if (c == '\r')
continue;
if (c == '\n')
{
int level = sizeof(tags) / sizeof(*tags);
char *bol;
if (colon == 0 || (size_t)(colon - buf) > sizeof("warning")) {
level = 1;
}
*pos = 0;
while (--level) {
if (pos - buf >= tags[level].size
&& strncmp(buf, tags[level].tag, tags[level].size) == 0) {
break;
}
}
bol = buf + tags[level].size;
if (bol > buf && *bol == ' ') {
++bol;
}
if (pos - bol > 0) {
if (colon == 0 || (size_t) (colon - buf) > sizeof("warning"))
level = 1;
*pos = 0;
while (--level)
{
if (pos - buf >= tags[level].size
&& strncmp(buf, tags[level].tag, tags[level].size) == 0)
break;
}
bol = buf + tags[level].size;
if (bol > buf && *bol == ' ')
++bol;
if (pos - bol > 0)
{
#ifndef DEBUG
syslog(tags[level].priority, "%s", bol);
syslog(tags[level].priority, "%s", bol);
#else
printf("%d/%s\n", tags[level].priority, bol);
printf("%d/%s\n", tags[level].priority, bol);
#endif
}
pos = buf;
colon = (char const *)0;
continue;
}
if (c == ':' && !colon) {
colon = pos;
}
if ((size_t)(pos - buf) < sizeof(buf)-1) {
*pos++ = c;
}
}
return 0;
}
pos = buf;
colon = (char const *) 0;
continue;
}
if (c == ':' && !colon)
colon = pos;
if ((size_t) (pos - buf) < sizeof(buf) - 1)
*pos++ = c;
}
return 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* pgcrypto.h
* Header file for pgcrypto.
*
*
* Copyright (c) 2000 Marko Kreen
* All rights reserved.
*
......@@ -9,15 +9,15 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
......@@ -26,25 +26,27 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: pgcrypto.h,v 1.2 2001/01/09 16:07:13 momjian Exp $
* $Id: pgcrypto.h,v 1.3 2001/03/22 03:59:10 momjian Exp $
*/
#ifndef _PG_CRYPTO_H
#define _PG_CRYPTO_H
typedef struct _pg_digest pg_digest;
struct _pg_digest {
char *name;
uint (*length)(pg_digest *h);
uint8 *(*digest)(pg_digest *h, uint8 *data,
uint dlen, uint8 *buf);
struct _pg_digest
{
char *name;
uint (*length) (pg_digest * h);
uint8 *(*digest) (pg_digest * h, uint8 *data,
uint dlen, uint8 *buf);
/* private */
union {
uint code;
union
{
uint code;
const void *ptr;
} misc;
} misc;
};
extern pg_digest *pg_find_digest(pg_digest *hbuf, char *name);
extern pg_digest *pg_find_digest(pg_digest * hbuf, char *name);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,7 +15,7 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com>
#include "executor/spi.h" /* this is what you need to work with SPI */
#include "commands/trigger.h" /* -"- and triggers */
extern Datum moddatetime(PG_FUNCTION_ARGS);
extern Datum moddatetime(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(moddatetime);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment