mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Standard pgindent run for 8.1.
This commit is contained in:
@ -88,10 +88,10 @@ dbf_open(char *file, int flags)
|
||||
dbh->db_nfields = (dbh->db_hlen - sizeof(dbf_header)) / sizeof(dbf_field);
|
||||
|
||||
/*
|
||||
* dbh->db_hlen - sizeof(dbf_header) isn't the correct size, cos
|
||||
* dbh->hlen is in fact a little more cos of the 0x0D (and possibly
|
||||
* another byte, 0x4E, I have seen this somewhere). Because of
|
||||
* rounding everything turns out right :)
|
||||
* dbh->db_hlen - sizeof(dbf_header) isn't the correct size, cos dbh->hlen
|
||||
* is in fact a little more cos of the 0x0D (and possibly another byte,
|
||||
* 0x4E, I have seen this somewhere). Because of rounding everything turns
|
||||
* out right :)
|
||||
*/
|
||||
|
||||
if ((fields = (f_descr *) calloc(dbh->db_nfields, sizeof(f_descr)))
|
||||
@ -155,8 +155,7 @@ dbf_write_head(dbhead * dbh)
|
||||
now = time((time_t *) NULL);
|
||||
dbf_time = localtime(&now);
|
||||
head.dbh_year = dbf_time->tm_year;
|
||||
head.dbh_month = dbf_time->tm_mon + 1; /* Months since January +
|
||||
* 1 */
|
||||
head.dbh_month = dbf_time->tm_mon + 1; /* Months since January + 1 */
|
||||
head.dbh_day = dbf_time->tm_mday;
|
||||
|
||||
put_long(head.dbh_records, dbh->db_records);
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define _DBF_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <gmon.h> /* we need it to define u_char type */
|
||||
#include <gmon.h> /* we need it to define u_char type */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
@ -64,8 +64,7 @@ typedef struct
|
||||
u_char dbf_type; /* field-type */
|
||||
u_char dbf_reserved[4]; /* some reserved stuff */
|
||||
u_char dbf_flen; /* field-length */
|
||||
u_char dbf_dec; /* number of decimal positions if type is
|
||||
* 'N' */
|
||||
u_char dbf_dec; /* number of decimal positions if type is 'N' */
|
||||
u_char dbf_stub[14]; /* stuff we don't need */
|
||||
} dbf_field;
|
||||
|
||||
@ -89,15 +88,14 @@ typedef struct
|
||||
u_char db_year; /* last update as YYMMDD */
|
||||
u_char db_month;
|
||||
u_char db_day;
|
||||
u_long db_hlen; /* length of the diskheader, for
|
||||
* calculating the offsets */
|
||||
u_long db_hlen; /* length of the diskheader, for calculating
|
||||
* the offsets */
|
||||
u_long db_records; /* number of records */
|
||||
u_long db_currec; /* current record-number starting at 0 */
|
||||
u_short db_rlen; /* length of the record */
|
||||
u_char db_nfields; /* number of fields */
|
||||
u_char *db_buff; /* record-buffer to save malloc()'s */
|
||||
f_descr *db_fields; /* pointer to an array of field-
|
||||
* descriptions */
|
||||
f_descr *db_fields; /* pointer to an array of field- descriptions */
|
||||
} dbhead;
|
||||
|
||||
/* structure that contains everything a user wants from a field, including
|
||||
|
@ -169,7 +169,7 @@ usage(void)
|
||||
{
|
||||
printf("dbf2pg\n"
|
||||
"usage: dbf2pg [-u | -l] [-h hostname] [-W] [-U username]\n"
|
||||
" [-B transaction_size] [-F charset_from [-T charset_to]]\n"
|
||||
" [-B transaction_size] [-F charset_from [-T charset_to]]\n"
|
||||
" [-s oldname=[newname][,oldname=[newname][...]]] [-d dbase]\n"
|
||||
" [-t table] [-c | -D] [-f] [-v[v]] dbf-file\n");
|
||||
}
|
||||
@ -251,7 +251,7 @@ do_create(PGconn *conn, char *table, dbhead * dbh)
|
||||
printf("Building CREATE-clause\n");
|
||||
|
||||
if (!(query = (char *) malloc(
|
||||
(dbh->db_nfields * 40) + 29 + strlen(table))))
|
||||
(dbh->db_nfields * 40) + 29 + strlen(table))))
|
||||
{
|
||||
fprintf(stderr, "Memory allocation error in function do_create\n");
|
||||
PQfinish(conn);
|
||||
@ -359,9 +359,8 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
|
||||
}
|
||||
|
||||
/*
|
||||
* make sure we can build the COPY query, note that we don't need to
|
||||
* just add this value, since the COPY query is a separate query (see
|
||||
* below)
|
||||
* make sure we can build the COPY query, note that we don't need to just
|
||||
* add this value, since the COPY query is a separate query (see below)
|
||||
*/
|
||||
if (h < 17 + strlen(table))
|
||||
h = 17 + strlen(table);
|
||||
@ -370,7 +369,7 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
|
||||
{
|
||||
PQfinish(conn);
|
||||
fprintf(stderr,
|
||||
"Memory allocation error in function do_inserts (query)\n");
|
||||
"Memory allocation error in function do_inserts (query)\n");
|
||||
close(dbh->db_fd);
|
||||
free(dbh);
|
||||
exit(1);
|
||||
@ -386,12 +385,10 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (end == 0) /* "end" is a user option, if not
|
||||
* specified, */
|
||||
if (end == 0) /* "end" is a user option, if not specified, */
|
||||
end = dbh->db_records; /* then all records are processed. */
|
||||
|
||||
if (t_block == 0) /* user not specified transaction block
|
||||
* size */
|
||||
if (t_block == 0) /* user not specified transaction block size */
|
||||
t_block = end - begin; /* then we set it to be the full data */
|
||||
|
||||
for (i = begin; i < end; i++)
|
||||
@ -426,9 +423,8 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
|
||||
j = 0; /* counter for fields in the output */
|
||||
for (h = 0; h < dbh->db_nfields; h++)
|
||||
{
|
||||
if (!strlen(fields[h].db_name)) /* When the new fieldname
|
||||
* is empty, the field is
|
||||
* skipped */
|
||||
if (!strlen(fields[h].db_name)) /* When the new fieldname is
|
||||
* empty, the field is skipped */
|
||||
continue;
|
||||
else
|
||||
j++;
|
||||
@ -639,8 +635,8 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
/*
|
||||
* FIXME: Ivan thinks this is bad: printf("unknown
|
||||
* argument: %s\n", argv[0]);
|
||||
* FIXME: Ivan thinks this is bad: printf("unknown argument:
|
||||
* %s\n", argv[0]);
|
||||
*/
|
||||
exit(1);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user