~ubuntu-branches/ubuntu/gutsy/libpgjava/gutsy

« back to all changes in this revision

Viewing changes to src/interfaces/libpgtcl/pgtcl.c

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-04-21 14:25:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050421142511-wibh5vc31fkrorx7
Tags: 7.4.7-3
Built with sources...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * pgtcl.c
 
4
 *
 
5
 *      libpgtcl is a tcl package for front-ends to interface with PostgreSQL.
 
6
 *      It's a Tcl wrapper for libpq.
 
7
 *
 
8
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 
9
 * Portions Copyright (c) 1994, Regents of the University of California
 
10
 *
 
11
 *
 
12
 * IDENTIFICATION
 
13
 *        $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.28.4.1 2004/02/02 01:00:58 neilc Exp $
 
14
 *
 
15
 *-------------------------------------------------------------------------
 
16
 */
 
17
 
 
18
#include "postgres_fe.h"
 
19
#include "libpgtcl.h"
 
20
#include "pgtclCmds.h"
 
21
#include "pgtclId.h"
 
22
 
 
23
/*
 
24
 * Pgtcl_Init
 
25
 *        initialization package for the PGTCL Tcl package
 
26
 *
 
27
 */
 
28
 
 
29
int
 
30
Pgtcl_Init(Tcl_Interp *interp)
 
31
{
 
32
        double          tclversion;
 
33
 
 
34
        /*
 
35
         * finish off the ChannelType struct.  Much easier to do it here then
 
36
         * to guess where it might be by position in the struct.  This is
 
37
         * needed for Tcl7.6 *only*, which has the getfileproc.
 
38
         */
 
39
#if HAVE_TCL_GETFILEPROC
 
40
        Pg_ConnType.getFileProc = PgGetFileProc;
 
41
#endif
 
42
 
 
43
        /*
 
44
         * Tcl versions >= 8.1 use UTF-8 for their internal string
 
45
         * representation. Therefore PGCLIENTENCODING must be set to UNICODE
 
46
         * for these versions.
 
47
         */
 
48
        Tcl_GetDouble(interp, Tcl_GetVar(interp, "tcl_version", TCL_GLOBAL_ONLY), &tclversion);
 
49
        if (tclversion >= 8.1)
 
50
                Tcl_PutEnv("PGCLIENTENCODING=UNICODE");
 
51
 
 
52
        /* register all pgtcl commands */
 
53
        Tcl_CreateCommand(interp,
 
54
                                          "pg_conndefaults",
 
55
                                          Pg_conndefaults,
 
56
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
57
 
 
58
        Tcl_CreateCommand(interp,
 
59
                                          "pg_connect",
 
60
                                          Pg_connect,
 
61
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
62
 
 
63
        Tcl_CreateCommand(interp,
 
64
                                          "pg_disconnect",
 
65
                                          Pg_disconnect,
 
66
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
67
 
 
68
        Tcl_CreateCommand(interp,
 
69
                                          "pg_exec",
 
70
                                          Pg_exec,
 
71
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
72
 
 
73
        Tcl_CreateCommand(interp,
 
74
                                          "pg_select",
 
75
                                          Pg_select,
 
76
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
77
 
 
78
        Tcl_CreateCommand(interp,
 
79
                                          "pg_result",
 
80
                                          Pg_result,
 
81
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
82
 
 
83
        Tcl_CreateCommand(interp,
 
84
                                          "pg_execute",
 
85
                                          Pg_execute,
 
86
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
87
 
 
88
        Tcl_CreateCommand(interp,
 
89
                                          "pg_lo_open",
 
90
                                          Pg_lo_open,
 
91
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
92
 
 
93
        Tcl_CreateCommand(interp,
 
94
                                          "pg_lo_close",
 
95
                                          Pg_lo_close,
 
96
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
97
 
 
98
#ifdef PGTCL_USE_TCLOBJ
 
99
        Tcl_CreateObjCommand(interp,
 
100
                                                 "pg_lo_read",
 
101
                                                 Pg_lo_read,
 
102
                                                 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
103
 
 
104
        Tcl_CreateObjCommand(interp,
 
105
                                                 "pg_lo_write",
 
106
                                                 Pg_lo_write,
 
107
                                                 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
108
#else
 
109
        Tcl_CreateCommand(interp,
 
110
                                          "pg_lo_read",
 
111
                                          Pg_lo_read,
 
112
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
113
 
 
114
        Tcl_CreateCommand(interp,
 
115
                                          "pg_lo_write",
 
116
                                          Pg_lo_write,
 
117
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
118
#endif
 
119
 
 
120
        Tcl_CreateCommand(interp,
 
121
                                          "pg_lo_lseek",
 
122
                                          Pg_lo_lseek,
 
123
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
124
 
 
125
        Tcl_CreateCommand(interp,
 
126
                                          "pg_lo_creat",
 
127
                                          Pg_lo_creat,
 
128
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
129
 
 
130
        Tcl_CreateCommand(interp,
 
131
                                          "pg_lo_tell",
 
132
                                          Pg_lo_tell,
 
133
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
134
 
 
135
        Tcl_CreateCommand(interp,
 
136
                                          "pg_lo_unlink",
 
137
                                          Pg_lo_unlink,
 
138
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
139
 
 
140
        Tcl_CreateCommand(interp,
 
141
                                          "pg_lo_import",
 
142
                                          Pg_lo_import,
 
143
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
144
 
 
145
        Tcl_CreateCommand(interp,
 
146
                                          "pg_lo_export",
 
147
                                          Pg_lo_export,
 
148
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
149
 
 
150
        Tcl_CreateCommand(interp,
 
151
                                          "pg_listen",
 
152
                                          Pg_listen,
 
153
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
154
 
 
155
        Tcl_CreateCommand(interp,
 
156
                                          "pg_on_connection_loss",
 
157
                                          Pg_on_connection_loss,
 
158
                                          (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 
159
 
 
160
        Tcl_PkgProvide(interp, "Pgtcl", "1.4");
 
161
 
 
162
        return TCL_OK;
 
163
}
 
164
 
 
165
 
 
166
int
 
167
Pgtcl_SafeInit(Tcl_Interp *interp)
 
168
{
 
169
        return Pgtcl_Init(interp);
 
170
}