Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 755a873

Browse files
committed
Run pgindent over ODBC source. We couldn't do this years ago because we
weren't the master source. We are now, and it really needs it.
1 parent 505a828 commit 755a873

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+10952
-9161
lines changed

src/interfaces/odbc/bind.c

Lines changed: 193 additions & 148 deletions
Large diffs are not rendered by default.

src/interfaces/odbc/bind.h

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
/* File: bind.h
2+
/* File: bind.h
33
*
4-
* Description: See "bind.c"
4+
* Description: See "bind.c"
55
*
6-
* Comments: See "notice.txt" for copyright and license information.
6+
* Comments: See "notice.txt" for copyright and license information.
77
*
88
*/
99

@@ -15,33 +15,40 @@
1515
/*
1616
* BindInfoClass -- stores information about a bound column
1717
*/
18-
struct BindInfoClass_ {
19-
Int4 buflen; /* size of buffer */
20-
Int4 data_left; /* amount of data left to read (SQLGetData) */
21-
char *buffer; /* pointer to the buffer */
22-
Int4 *used; /* used space in the buffer (for strings not counting the '\0') */
23-
Int2 returntype; /* kind of conversion to be applied when returning (SQL_C_DEFAULT, SQL_C_CHAR...) */
18+
struct BindInfoClass_
19+
{
20+
Int4 buflen; /* size of buffer */
21+
Int4 data_left; /* amount of data left to read
22+
* (SQLGetData) */
23+
char *buffer; /* pointer to the buffer */
24+
Int4 *used; /* used space in the buffer (for strings
25+
* not counting the '\0') */
26+
Int2 returntype; /* kind of conversion to be applied when
27+
* returning (SQL_C_DEFAULT,
28+
* SQL_C_CHAR...) */
2429
};
2530

2631
/*
2732
* ParameterInfoClass -- stores information about a bound parameter
2833
*/
29-
struct ParameterInfoClass_ {
30-
Int4 buflen;
31-
char *buffer;
32-
Int4 *used;
33-
Int2 paramType;
34-
Int2 CType;
35-
Int2 SQLType;
36-
UInt4 precision;
37-
Int2 scale;
38-
Oid lobj_oid;
39-
Int4 *EXEC_used; /* amount of data OR the oid of the large object */
40-
char *EXEC_buffer; /* the data or the FD of the large object */
41-
char data_at_exec;
34+
struct ParameterInfoClass_
35+
{
36+
Int4 buflen;
37+
char *buffer;
38+
Int4 *used;
39+
Int2 paramType;
40+
Int2 CType;
41+
Int2 SQLType;
42+
UInt4 precision;
43+
Int2 scale;
44+
Oid lobj_oid;
45+
Int4 *EXEC_used; /* amount of data OR the oid of the large
46+
* object */
47+
char *EXEC_buffer; /* the data or the FD of the large object */
48+
char data_at_exec;
4249
};
4350

4451
BindInfoClass *create_empty_bindings(int num_columns);
45-
void extend_bindings(StatementClass *stmt, int num_columns);
52+
void extend_bindings(StatementClass * stmt, int num_columns);
4653

4754
#endif

src/interfaces/odbc/columninfo.c

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
/* Module: columninfo.c
1+
/* Module: columninfo.c
22
*
3-
* Description: This module contains routines related to
4-
* reading and storing the field information from a query.
3+
* Description: This module contains routines related to
4+
* reading and storing the field information from a query.
55
*
6-
* Classes: ColumnInfoClass (Functions prefix: "CI_")
6+
* Classes: ColumnInfoClass (Functions prefix: "CI_")
77
*
8-
* API functions: none
8+
* API functions: none
99
*
10-
* Comments: See "notice.txt" for copyright and license information.
10+
* Comments: See "notice.txt" for copyright and license information.
1111
*
1212
*/
1313

@@ -20,11 +20,12 @@
2020
ColumnInfoClass *
2121
CI_Constructor()
2222
{
23-
ColumnInfoClass *rv;
23+
ColumnInfoClass *rv;
2424

2525
rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass));
2626

27-
if (rv) {
27+
if (rv)
28+
{
2829
rv->num_fields = 0;
2930
rv->name = NULL;
3031
rv->adtid = NULL;
@@ -37,28 +38,28 @@ ColumnInfoClass *rv;
3738
}
3839

3940
void
40-
CI_Destructor(ColumnInfoClass *self)
41+
CI_Destructor(ColumnInfoClass * self)
4142
{
4243
CI_free_memory(self);
4344

4445
free(self);
4546
}
4647

47-
/* Read in field descriptions.
48-
If self is not null, then also store the information.
48+
/* Read in field descriptions.
49+
If self is not null, then also store the information.
4950
If self is null, then just read, don't store.
5051
*/
5152
char
52-
CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
53+
CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn)
5354
{
54-
Int2 lf;
55-
int new_num_fields;
56-
Oid new_adtid;
57-
Int2 new_adtsize;
58-
Int4 new_atttypmod = -1;
59-
char new_field_name[MAX_MESSAGE_LEN+1];
60-
SocketClass *sock;
61-
ConnInfo *ci;
55+
Int2 lf;
56+
int new_num_fields;
57+
Oid new_adtid;
58+
Int2 new_adtsize;
59+
Int4 new_atttypmod = -1;
60+
char new_field_name[MAX_MESSAGE_LEN + 1];
61+
SocketClass *sock;
62+
ConnInfo *ci;
6263

6364
sock = CC_get_socket(conn);
6465
ci = &conn->connInfo;
@@ -68,24 +69,27 @@ ConnInfo *ci;
6869

6970
mylog("num_fields = %d\n", new_num_fields);
7071

71-
if (self) { /* according to that allocate memory */
72+
if (self)
73+
{ /* according to that allocate memory */
7274
CI_set_num_fields(self, new_num_fields);
7375
}
7476

7577
/* now read in the descriptions */
76-
for(lf = 0; lf < new_num_fields; lf++) {
78+
for (lf = 0; lf < new_num_fields; lf++)
79+
{
7780

7881
SOCK_get_string(sock, new_field_name, MAX_MESSAGE_LEN);
7982
new_adtid = (Oid) SOCK_get_int(sock, 4);
8083
new_adtsize = (Int2) SOCK_get_int(sock, 2);
8184

82-
/* If 6.4 protocol, then read the atttypmod field */
83-
if (PG_VERSION_GE(conn, 6.4)) {
85+
/* If 6.4 protocol, then read the atttypmod field */
86+
if (PG_VERSION_GE(conn, 6.4))
87+
{
8488

8589
mylog("READING ATTTYPMOD\n");
8690
new_atttypmod = (Int4) SOCK_get_int(sock, 4);
8791

88-
/* Subtract the header length */
92+
/* Subtract the header length */
8993
new_atttypmod -= 4;
9094
if (new_atttypmod < 0)
9195
new_atttypmod = -1;
@@ -104,17 +108,18 @@ ConnInfo *ci;
104108

105109

106110
void
107-
CI_free_memory(ColumnInfoClass *self)
111+
CI_free_memory(ColumnInfoClass * self)
108112
{
109-
register Int2 lf;
110-
int num_fields = self->num_fields;
113+
register Int2 lf;
114+
int num_fields = self->num_fields;
111115

112-
for (lf = 0; lf < num_fields; lf++) {
113-
if( self->name[lf])
114-
free (self->name[lf]);
116+
for (lf = 0; lf < num_fields; lf++)
117+
{
118+
if (self->name[lf])
119+
free(self->name[lf]);
115120
}
116121

117-
/* Safe to call even if null */
122+
/* Safe to call even if null */
118123
free(self->name);
119124
free(self->adtid);
120125
free(self->adtsize);
@@ -124,35 +129,33 @@ int num_fields = self->num_fields;
124129
}
125130

126131
void
127-
CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
132+
CI_set_num_fields(ColumnInfoClass * self, int new_num_fields)
128133
{
129-
CI_free_memory(self); /* always safe to call */
134+
CI_free_memory(self); /* always safe to call */
130135

131136
self->num_fields = new_num_fields;
132137

133-
self->name = (char **) malloc (sizeof(char *) * self->num_fields);
134-
self->adtid = (Oid *) malloc (sizeof(Oid) * self->num_fields);
135-
self->adtsize = (Int2 *) malloc (sizeof(Int2) * self->num_fields);
138+
self->name = (char **) malloc(sizeof(char *) * self->num_fields);
139+
self->adtid = (Oid *) malloc(sizeof(Oid) * self->num_fields);
140+
self->adtsize = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
136141
self->display_size = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
137142
self->atttypmod = (Int4 *) malloc(sizeof(Int4) * self->num_fields);
138143
}
139144

140145
void
141-
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
142-
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
146+
CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
147+
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
143148
{
144-
149+
145150
/* check bounds */
146-
if((field_num < 0) || (field_num >= self->num_fields)) {
151+
if ((field_num < 0) || (field_num >= self->num_fields))
147152
return;
148-
}
149153

150154
/* store the info */
151-
self->name[field_num] = strdup(new_name);
155+
self->name[field_num] = strdup(new_name);
152156
self->adtid[field_num] = new_adtid;
153157
self->adtsize[field_num] = new_adtsize;
154158
self->atttypmod[field_num] = new_atttypmod;
155159

156160
self->display_size[field_num] = 0;
157161
}
158-

src/interfaces/odbc/columninfo.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
/* File: columninfo.h
2+
/* File: columninfo.h
33
*
4-
* Description: See "columninfo.c"
4+
* Description: See "columninfo.c"
55
*
6-
* Comments: See "notice.txt" for copyright and license information.
6+
* Comments: See "notice.txt" for copyright and license information.
77
*
88
*/
99

@@ -12,13 +12,14 @@
1212

1313
#include "psqlodbc.h"
1414

15-
struct ColumnInfoClass_ {
16-
Int2 num_fields;
17-
char **name; /* list of type names */
18-
Oid *adtid; /* list of type ids */
19-
Int2 *adtsize; /* list type sizes */
20-
Int2 *display_size; /* the display size (longest row) */
21-
Int4 *atttypmod; /* the length of bpchar/varchar */
15+
struct ColumnInfoClass_
16+
{
17+
Int2 num_fields;
18+
char **name; /* list of type names */
19+
Oid *adtid; /* list of type ids */
20+
Int2 *adtsize; /* list type sizes */
21+
Int2 *display_size; /* the display size (longest row) */
22+
Int4 *atttypmod; /* the length of bpchar/varchar */
2223
};
2324

2425
#define CI_get_num_fields(self) (self->num_fields)
@@ -29,15 +30,15 @@ struct ColumnInfoClass_ {
2930
#define CI_get_atttypmod(self, col) (self->atttypmod[col])
3031

3132
ColumnInfoClass *CI_Constructor(void);
32-
void CI_Destructor(ColumnInfoClass *self);
33-
void CI_free_memory(ColumnInfoClass *self);
34-
char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn);
33+
void CI_Destructor(ColumnInfoClass * self);
34+
void CI_free_memory(ColumnInfoClass * self);
35+
char CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn);
3536

3637
/* functions for setting up the fields from within the program, */
3738
/* without reading from a socket */
38-
void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields);
39-
void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
40-
Oid new_adtid, Int2 new_adtsize, Int4 atttypmod);
39+
void CI_set_num_fields(ColumnInfoClass * self, int new_num_fields);
40+
void CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
41+
Oid new_adtid, Int2 new_adtsize, Int4 atttypmod);
4142

4243

4344
#endif

0 commit comments

Comments
 (0)