jabberd14: add options for databases
pkgsrc changes: --------------- * Add options.mk to exclusively choose a database engine between MySQL and PostgreSQL. * Add necessary patches to appease g++ and compile with PostgreSQL support.
This commit is contained in:
parent
66c38b0bdc
commit
1bb0852f0f
|
@ -38,6 +38,8 @@ USE_LIBTOOL= yes
|
|||
USE_TOOLS+= aclocal autoconf automake gettext gmake pkg-config
|
||||
USE_LANGUAGES= c c++11
|
||||
|
||||
.include "options.mk"
|
||||
|
||||
BUILD_DEFS+= JABBERD_PIDDIR JABBERD_SPOOLDIR
|
||||
|
||||
PKG_GROUPS= ${JABBERD_GROUP}
|
||||
|
|
|
@ -5,5 +5,8 @@ RMD160 (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = 77
|
|||
SHA512 (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = b62ff5046b6e50491685775fb09d421ec561ad3c64536e80aa29631e9adcdcef23ee9a576ed7621786a3a89abc00bd20b0799041168aca40c7ac9d351969f5d3
|
||||
Size (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = 655198 bytes
|
||||
SHA1 (patch-Makefile.am) = 928cdb5aa77e80f5b698f08b623484d93d3500ab
|
||||
SHA1 (patch-configure.ac) = 0542bf8cebce67fe35d76232110dafc0ff398bbd
|
||||
SHA1 (patch-configure.ac) = 2b33279ad40c2f8857324e48c1d5784fc6cc0bd3
|
||||
SHA1 (patch-jabberd_lib_xmlnode.cc) = 64dbacdb09753e74a05a3873401051339f616133
|
||||
SHA1 (patch-jabberd_lib_xmlnode.hh) = 58a3dc7dafca01e494aa99b28445d6c0157c35ca
|
||||
SHA1 (patch-jsm_sessions.cc) = 051bfddb6bbec1684fd89e0c0c0fbc48fa89a568
|
||||
SHA1 (patch-xdb__sql_xdb__sql.cc) = 5807e42a55803d27f8c39c3a3c613d2b91854bfc
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# $NetBSD: $
|
||||
|
||||
PKG_OPTIONS_VAR= PKG_OPTIONS.jabberd
|
||||
PKG_OPTIONS_OPTIONAL_GROUPS= database
|
||||
PKG_OPTIONS_GROUP.database= mysql pgsql
|
||||
|
||||
.include "../../mk/bsd.options.mk"
|
||||
|
||||
###
|
||||
### MySQL support
|
||||
###
|
||||
.if !empty(PKG_OPTIONS:Mmysql)
|
||||
CONFIGURE_ARGS+= --with-mysql=${BUILDLINK_INCDIRS.mysql}
|
||||
. include "../../mk/mysql.buildlink3.mk"
|
||||
.else
|
||||
CONFIGURE_ARGS+= --with-mysql=no
|
||||
.endif
|
||||
|
||||
###
|
||||
### PostgresSQL support
|
||||
###
|
||||
.if !empty(PKG_OPTIONS:Mpgsql)
|
||||
CONFIGURE_ARGS+= --with-postgresql=${BUILDLINK_INCDIRS.pgsql}
|
||||
. include "../../mk/pgsql.buildlink3.mk"
|
||||
.else
|
||||
CONFIGURE_ARGS+= --with-postgresql=no
|
||||
.endif
|
|
@ -13,3 +13,12 @@ $NetBSD$
|
|||
|
||||
dnl Check for programs
|
||||
AC_PROG_CC
|
||||
@@ -348,7 +348,7 @@ if test "$postgresql" != "no"; then
|
||||
LDFLAGS="${LDFLAGS} -L$postgresql/lib"
|
||||
CPPFLAGS="${CPPFLAGS} -I$postgresql/include"
|
||||
fi
|
||||
- AC_CHECK_HEADER(postgresql/libpq-fe.h,
|
||||
+ AC_CHECK_HEADER(libpq-fe.h,
|
||||
AC_CHECK_LIB(pq, PQconnectdb,
|
||||
[postgresql=yes LIBS="${LIBS} -lpq"], postgresql=no),
|
||||
postgresql=no)
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
$NetBSD$
|
||||
|
||||
* Move struct xmlnode_t from xmlnode.cc to xmlnode.hh to appease g++.
|
||||
|
||||
--- jabberd/lib/xmlnode.cc.orig 2019-09-29 18:37:09.000000000 +0000
|
||||
+++ jabberd/lib/xmlnode.cc
|
||||
@@ -44,34 +44,6 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
-//----[ internal types ]-------------------------------------------------------
|
||||
-
|
||||
-struct xmlnode_t {
|
||||
- char *name; /**< local name of the xmlnode */
|
||||
- char *prefix; /**< namespace prefix for this xmlnode */
|
||||
- char *ns_iri; /**< namespace IRI for this xmlnode */
|
||||
- unsigned short type; /**< type of the xmlnode, one of ::NTYPE_TAG,
|
||||
- ::NTYPE_ATTRIB, ::NTYPE_CDATA, or ::NTYPE_UNDEF */
|
||||
- char *data; /**< data of the xmlnode, for attributes this is the value, for
|
||||
- text nodes this is the text */
|
||||
- int data_sz; /**< length of the data in the xmlnode */
|
||||
- /* int complete; */
|
||||
- pool p; /**< memory pool used by this xmlnode (the same as for all other
|
||||
- xmlnode in a tree) */
|
||||
- struct xmlnode_t
|
||||
- *parent; /**< parent node for this node, or NULL for the root element */
|
||||
- struct xmlnode_t *firstchild; /**< first child element of this node, or NULL
|
||||
- for no child elements */
|
||||
- struct xmlnode_t *lastchild; /**< last child element of this node, or NULL
|
||||
- for no child elements */
|
||||
- struct xmlnode_t *prev; /**< previous sibling */
|
||||
- struct xmlnode_t *next; /**< next sibling */
|
||||
- struct xmlnode_t *firstattrib; /**< first attribute node of this node */
|
||||
- struct xmlnode_t *lastattrib; /**< last attribute node of this node */
|
||||
-};
|
||||
-
|
||||
-//-----------------------------------------------------------------------------
|
||||
-
|
||||
#ifdef POOL_DEBUG
|
||||
std::map<pool, std::list<xmlnode>> existing_xmlnodes;
|
||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||
$NetBSD$
|
||||
|
||||
* Move struct xmlnode_t from xmlnode.cc to xmlnode.hh to appease g++.
|
||||
|
||||
--- jabberd/lib/xmlnode.hh.orig 2019-09-29 18:37:09.000000000 +0000
|
||||
+++ jabberd/lib/xmlnode.hh
|
||||
@@ -48,7 +48,29 @@
|
||||
' ' /**< character used to separate NS IRI from local name in expat \
|
||||
callbacks */
|
||||
|
||||
-typedef struct xmlnode_t _xmlnode, *xmlnode;
|
||||
+typedef struct xmlnode_t {
|
||||
+ char *name; /**< local name of the xmlnode */
|
||||
+ char *prefix; /**< namespace prefix for this xmlnode */
|
||||
+ char *ns_iri; /**< namespace IRI for this xmlnode */
|
||||
+ unsigned short type; /**< type of the xmlnode, one of ::NTYPE_TAG,
|
||||
+ ::NTYPE_ATTRIB, ::NTYPE_CDATA, or ::NTYPE_UNDEF */
|
||||
+ char *data; /**< data of the xmlnode, for attributes this is the value, for
|
||||
+ text nodes this is the text */
|
||||
+ int data_sz; /**< length of the data in the xmlnode */
|
||||
+ /* int complete; */
|
||||
+ pool p; /**< memory pool used by this xmlnode (the same as for all other
|
||||
+ xmlnode in a tree) */
|
||||
+ struct xmlnode_t
|
||||
+ *parent; /**< parent node for this node, or NULL for the root element */
|
||||
+ struct xmlnode_t *firstchild; /**< first child element of this node, or NULL
|
||||
+ for no child elements */
|
||||
+ struct xmlnode_t *lastchild; /**< last child element of this node, or NULL
|
||||
+ for no child elements */
|
||||
+ struct xmlnode_t *prev; /**< previous sibling */
|
||||
+ struct xmlnode_t *next; /**< next sibling */
|
||||
+ struct xmlnode_t *firstattrib; /**< first attribute node of this node */
|
||||
+ struct xmlnode_t *lastattrib; /**< last attribute node of this node */
|
||||
+} _xmlnode, *xmlnode;
|
||||
|
||||
namespace xmppd {
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
$NetBSD$
|
||||
|
||||
* Include missing header for xmlnode_str.
|
||||
* Header files of pkgsrc PostgreSQL are not in postgresql/ directory.
|
||||
* Reorder xdbsql_struct.
|
||||
* Change function signature.
|
||||
* Add missing enumeration values in switch.
|
||||
* Add parentheses for test condition used as boolean value.
|
||||
|
||||
--- xdb_sql/xdb_sql.cc.orig 2019-09-29 18:37:09.000000000 +0000
|
||||
+++ xdb_sql/xdb_sql.cc
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <jabberd.h>
|
||||
|
||||
+#include <expat.hh>
|
||||
#include <namespaces.hh>
|
||||
|
||||
#include <list>
|
||||
@@ -40,7 +41,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
-#include <postgresql/libpq-fe.h>
|
||||
+#include <libpq-fe.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -91,12 +92,6 @@ typedef struct xdbsql_struct {
|
||||
std::map<std::string, _xdbsql_ns_def>
|
||||
namespace_defs; /**< definitions of queries for the different namespaces
|
||||
*/
|
||||
- char *onconnect; /**< SQL query that should be executed after we connected
|
||||
- to the database server */
|
||||
- xht namespace_prefixes; /**< prefixes for the namespaces (key = prefix,
|
||||
- value = ns_iri) */
|
||||
- xht std_namespace_prefixes; /**< prefixes used by the component itself for
|
||||
- the namespaces */
|
||||
#ifdef HAVE_MYSQL
|
||||
int use_mysql; /**< if we want to use the mysql driver */
|
||||
MYSQL *mysql; /**< our database handle */
|
||||
@@ -114,6 +109,12 @@ typedef struct xdbsql_struct {
|
||||
PGconn *postgresql; /**< our postgresql connection handle */
|
||||
char *postgresql_conninfo; /**< settings used to connect to postgresql */
|
||||
#endif
|
||||
+ char *onconnect; /**< SQL query that should be executed after we connected
|
||||
+ to the database server */
|
||||
+ xht namespace_prefixes; /**< prefixes for the namespaces (key = prefix,
|
||||
+ value = ns_iri) */
|
||||
+ xht std_namespace_prefixes; /**< prefixes used by the component itself for
|
||||
+ the namespaces */
|
||||
} * xdbsql, _xdbsql;
|
||||
|
||||
/* forward declaration */
|
||||
@@ -414,7 +415,7 @@ static int xdb_sql_execute_mysql(instanc
|
||||
* @return 0 on success, non zero on failure
|
||||
*/
|
||||
#ifdef HAVE_POSTGRESQL
|
||||
-static int xdb_sql_execute_postgresql(instance i, xdbsql xq, char *query,
|
||||
+static int xdb_sql_execute_postgresql(instance i, xdbsql xq, char const *query,
|
||||
xmlnode xmltemplate, xmlnode result) {
|
||||
PGresult *res = NULL;
|
||||
ExecStatusType status = static_cast<ExecStatusType>(0);
|
||||
@@ -452,6 +453,7 @@ static int xdb_sql_execute_postgresql(in
|
||||
case PGRES_EMPTY_QUERY:
|
||||
case PGRES_BAD_RESPONSE:
|
||||
case PGRES_FATAL_ERROR:
|
||||
+ case PGRES_NONFATAL_ERROR:
|
||||
log_warn(i->id, "%s: %s", PQresStatus(status),
|
||||
PQresultErrorMessage(res));
|
||||
PQclear(res);
|
||||
@@ -459,6 +461,9 @@ static int xdb_sql_execute_postgresql(in
|
||||
case PGRES_COMMAND_OK:
|
||||
case PGRES_COPY_OUT:
|
||||
case PGRES_COPY_IN:
|
||||
+ case PGRES_COPY_BOTH:
|
||||
+ case PGRES_SINGLE_TUPLE:
|
||||
+ case PGRES_TUPLES_OK:
|
||||
PQclear(res);
|
||||
return 0;
|
||||
}
|
||||
@@ -473,8 +478,8 @@ static int xdb_sql_execute_postgresql(in
|
||||
new_instance = xmlnode_dup_pool(result->p, xmltemplate);
|
||||
|
||||
/* find variables in the template and replace them with values */
|
||||
- while (variable = xdb_sql_find_node_recursive(new_instance, "value",
|
||||
- NS_JABBERD_XDBSQL)) {
|
||||
+ while ((variable = xdb_sql_find_node_recursive(new_instance, "value",
|
||||
+ NS_JABBERD_XDBSQL))) {
|
||||
xmlnode parent = xmlnode_get_parent(variable);
|
||||
int value =
|
||||
j_atoi(xmlnode_get_attrib_ns(variable, "value", NULL), 0);
|
Loading…
Reference in New Issue