Browse code

Add db_oracle module and toolses for it

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3997 689a6050-402a-0410-94f2-e92a70836424

Iouri Kharon authored on 09/04/2008 15:46:09
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+#include "orasel.h"
2
+
3
+//-----------------------------------------------------------------------------
4
+static void out_delim(const unsigned* pl, unsigned nc)
5
+{
6
+	unsigned i;
7
+
8
+	for(i = 0; i < nc; i++) {
9
+		unsigned j = pl[i] + 2;
10
+
11
+		putchar('+');
12
+		do putchar('-'); while(--j);
13
+	}
14
+	printf("+\n");
15
+}
16
+
17
+//-----------------------------------------------------------------------------
18
+void out_res(const res_t* _r)
19
+{
20
+	unsigned* pl = NULL;
21
+	unsigned  nc = _r->col_n, nr = _r->row_n, i, j;
22
+	Str**     ps = _r->names;
23
+
24
+	if(!outmode.raw) {
25
+		pl = safe_malloc(nc * sizeof(unsigned));
26
+		for(i = 0; i < nc; i++)
27
+			pl[i] = ps[i]->len;
28
+		for(j = 0; j < nr; j++) {
29
+			ps = _r->rows[j];
30
+			for(i = 0; i < nc; i++) 
31
+				if(pl[i] < ps[i]->len) pl[i] = ps[i]->len;
32
+		}
33
+
34
+		out_delim(pl, nc);
35
+	}
36
+	if(!outmode.hdr) {
37
+		ps = _r->names;
38
+		for(i = 0; i < nc; i++) {
39
+			if(!outmode.raw) {
40
+				printf("| %-*.*s ", pl[i], ps[i]->len, ps[i]->s);
41
+			} else {
42
+				if(i) putchar('\t');
43
+				printf("%.*s", ps[i]->len, ps[i]->s);
44
+			}
45
+		}
46
+		if(outmode.raw) putchar('\n');
47
+		else {
48
+			printf("|\n");
49
+			out_delim(pl, nc);
50
+		}
51
+	}
52
+	for(j = 0; j < nr; j++) {
53
+		ps = _r->rows[j];
54
+		if(!outmode.raw) {
55
+			for(i = 0; i < nc; i++)
56
+				printf(_r->types[i] ? "| %-*.*s " : "| %*.*s ",
57
+					pl[i], ps[i]->len, ps[i]->s);
58
+			printf("|\n");
59
+		} else {
60
+			for(i = 0; i < nc; i++) {
61
+				if(i) putchar('\t');
62
+				printf("%.*s", ps[i]->len, ps[i]->s);
63
+			}
64
+			putchar('\n');
65
+		}
66
+	}
67
+	if(!outmode.raw) out_delim(pl, nc);
68
+}
69
+
70
+//-----------------------------------------------------------------------------