00001 00002 /* 00003 ** Copyright (C) 2002 Russell Leighton 00004 ** 00005 ** This program is free software; you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation; either version 2 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program; if not, write to the Free Software 00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 00021 00022 00023 #ifndef __AW_PGSQL__ 00024 #define __AW_PGSQL__ 00025 00026 #include "awdb.h" 00027 00028 #include "libpq-fe.h" 00029 00030 #include "monitor.h" 00031 00032 #include "wire.h" 00033 00034 #include "regexmatch.h" 00035 00036 00041 /* 00042 00043 Changes: 00044 00045 */ 00046 00050 typedef struct { 00051 00052 00053 const byte_t 00054 *conninfo; /* connection string per postgres specs */ 00055 00056 } aw_pgsql_cinfo_t ; 00057 00058 00062 typedef struct { 00063 00064 int32_t 00065 prev_connected, /* value for previous attempt */ 00066 connected; /* 1 for connected, -1 for not connected */ 00067 00068 u_int32_t 00069 connection_attempts; 00070 00071 PGconn 00072 *conn; 00073 00074 /* array 1-1 with the watchers, each val marks 00075 if a match occured during the probe, could be a bitmap, but I am being lazy */ 00076 u_int32_t 00077 *match_markers; 00078 00079 } aw_pgsql_state_t ; 00080 00081 00085 void aw_pgsql_init(void); 00086 00090 int32_t aw_pgsql_initialized(void); 00091 00099 void aw_pgsql_disconnect(aw_pgsql_cinfo_t *cinfo, aw_pgsql_state_t *state, aw_logger_t *logger, int32_t close); 00100 00107 void aw_pgsql_disconnect_all(aw_pgsql_cinfo_t *cinfo, aw_pgsql_state_t *state, aw_logger_t *logger); 00108 00115 void aw_pgsql_connect(aw_pgsql_cinfo_t *cinfo, aw_pgsql_state_t *state, aw_logger_t *logger); 00116 00117 #endif 00118