1 /* 2 * ProFTPD: mod_sql.h -- header file for mod_sql and backends 3 * Time-stamp: <1999-10-04 03:21:21 root> 4 * Copyright (c) 1998-1999 Johnie Ingram. 5 * Copyright (c) 2001 Andrew Houghton 6 * Copyright (c) 2002-2015 The ProFTPD Project 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 21 * 22 * As a special exemption, Andrew Houghton and other respective copyright 23 * holders give permission to link this program with OpenSSL, and distribute 24 * the resulting executable, without including the source code for OpenSSL in 25 * the source distribution. 26 */ 27 28 #ifndef MOD_SQL_H 29 #define MOD_SQL_H 30 31 /* mod_sql helper functions */ 32 int sql_log(int, const char *, ...); 33 cmd_rec *sql_make_cmd(pool *p, int argc, ...); 34 int sql_register_backend(const char *, cmdtable *); 35 int sql_unregister_backend(const char *); 36 37 /* Custom SQLAuthType registration. */ 38 int sql_register_authtype(const char *name, 39 modret_t *(*callback)(cmd_rec *, const char *, const char *)); 40 int sql_unregister_authtype(const char *name); 41 42 /* data passing structure */ 43 struct sql_data_struct { 44 unsigned long rnum; /* number of rows of data */ 45 unsigned long fnum; /* number of fields per row */ 46 char **data; /* data[][] */ 47 }; 48 49 typedef struct sql_data_struct sql_data_t; 50 51 /* on the assumption that logging will turn into a bitmask later */ 52 #define DEBUG_FUNC DEBUG5 53 #define DEBUG_AUTH DEBUG4 54 #define DEBUG_INFO DEBUG3 55 #define DEBUG_WARN DEBUG2 56 57 #define SQL_FREE_CMD(c) destroy_pool((c)->pool) 58 59 /* 60 * These macros are for backends to create basic internal error messages 61 */ 62 63 #define PR_ERR_SQL_REDEF(cmd) mod_create_ret((cmd), 1, _MOD_VERSION, \ 64 "named connection already exists") 65 #define PR_ERR_SQL_UNDEF(cmd) mod_create_ret((cmd), 1, _MOD_VERSION, \ 66 "unknown named connection") 67 #define PR_ERR_SQL_UNKNOWN(cmd) mod_create_ret((cmd), 1, _MOD_VERSION, \ 68 "unknown backend error") 69 #define PR_ERR_SQL_BADCMD(cmd) mod_create_ret((cmd), 1, _MOD_VERSION, \ 70 "badly formed request") 71 72 /* API versions */ 73 74 /* MOD_SQL_API_V1: guarantees to correctly implement cmd_open, cmd_close, 75 * cmd_defineconnection, cmd_select, cmd_insert, cmd_update, cmd_escapestring, 76 * cmd_query, cmd_checkauth, and cmd_identify. Also guarantees to 77 * perform proper registration of the cmdtable. 78 */ 79 #define MOD_SQL_API_V1 "mod_sql_api_v1" 80 81 /* MOD_SQL_API_V2: MOD_SQL_API_V1 && guarantees to correctly implement 82 * cmd_procedure. 83 */ 84 #define MOD_SQL_API_V2 "mod_sql_api_v2" 85 86 /* SQLOption values */ 87 extern unsigned long pr_sql_opts; 88 89 #define SQL_OPT_NO_DISCONNECT_ON_ERROR 0x0001 90 #define SQL_OPT_USE_NORMALIZED_GROUP_SCHEMA 0x0002 91 #define SQL_OPT_NO_RECONNECT 0x0004 92 #define SQL_OPT_IGNORE_CONFIG_FILE 0x0008 93 94 /* SQL connection policy */ 95 extern unsigned int pr_sql_conn_policy; 96 97 #define SQL_CONN_POLICY_PERSESSION 1 98 #define SQL_CONN_POLICY_TIMER 2 99 #define SQL_CONN_POLICY_PERCALL 3 100 #define SQL_CONN_POLICY_PERCONN 4 101 102 #endif /* MOD_SQL_H */ 103