| 1 |
/* |
| 2 |
* Copyright (C) 2012 William Pitcock <[email protected]> |
| 3 |
* Copyright (C) 2018 Atheme Development Group (https://atheme.github.io/) |
| 4 |
* |
| 5 |
* Permission to use, copy, modify, and/or distribute this software for any |
| 6 |
* purpose with or without fee is hereby granted, provided that the above |
| 7 |
* copyright notice and this permission notice appear in all copies. |
| 8 |
* |
| 9 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 10 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 11 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 12 |
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 13 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 14 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 15 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 16 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 17 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 18 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 19 |
* POSSIBILITY OF SUCH DAMAGE. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef ATHEME_CONTRIB_COMPAT_H |
| 23 |
#define ATHEME_CONTRIB_COMPAT_H 1 |
| 24 |
|
| 25 |
#include "atheme.h" |
| 26 |
|
| 27 |
#undef PACKAGE |
| 28 |
#undef PACKAGE_BUGREPORT |
| 29 |
#undef PACKAGE_NAME |
| 30 |
#undef PACKAGE_STRING |
| 31 |
#undef PACKAGE_TARNAME |
| 32 |
#undef PACKAGE_URL |
| 33 |
#undef PACKAGE_VERSION |
| 34 |
#undef VERSION |
| 35 |
|
| 36 |
#include "contrib-sysconf.h" |
| 37 |
#include "contrib-vendors.h" |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef STR_EMAIL_NOT_VERIFIED |
| 42 |
# define STR_EMAIL_NOT_VERIFIED _("You must verify your e-mail address before you may perform this operation.") |
| 43 |
#endif |
| 44 |
#ifndef STR_INSUFFICIENT_PARAMS |
| 45 |
# define STR_INSUFFICIENT_PARAMS _("Insufficient parameters for \2%s\2.") |
| 46 |
#endif |
| 47 |
#ifndef STR_INVALID_PARAMS |
| 48 |
# define STR_INVALID_PARAMS _("Invalid parameters for \2%s\2.") |
| 49 |
#endif |
| 50 |
#ifndef STR_IS_NOT_REGISTERED |
| 51 |
# define STR_IS_NOT_REGISTERED _("\2%s\2 is not registered.") |
| 52 |
#endif |
| 53 |
#ifndef STR_NO_PRIVILEGE |
| 54 |
# define STR_NO_PRIVILEGE _("You do not have the \2%s\2 privilege.") |
| 55 |
#endif |
| 56 |
#ifndef STR_NOT_AUTHORIZED |
| 57 |
# define STR_NOT_AUTHORIZED _("You are not authorized to perform this operation.") |
| 58 |
#endif |
| 59 |
#ifndef STR_NOT_AUTHORIZED_TARGET |
| 60 |
# define STR_NOT_AUTHORIZED_TARGET _("You are not authorized to use the target argument.") |
| 61 |
#endif |
| 62 |
#ifndef STR_NOT_LOGGED_IN |
| 63 |
# define STR_NOT_LOGGED_IN _("You are not logged in.") |
| 64 |
#endif |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
#if (CURRENT_ABI_REVISION < 710000) |
| 69 |
|
| 70 |
typedef char *stringref; |
| 71 |
|
| 72 |
# define compat_sendemail(user, myuser, type, email, content) \ |
| 73 |
sendemail(user, type, myuser, content) |
| 74 |
|
| 75 |
#else /* (CURRENT_ABI_REVISION < 710000) */ |
| 76 |
# define compat_sendemail sendemail |
| 77 |
#endif /* (CURRENT_ABI_REVISION >= 710000) */ |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
#if (CURRENT_ABI_REVISION < 730000) |
| 82 |
|
| 83 |
/* This function was introduced in the Atheme 7.3 development series, |
| 84 |
* and both crypt_string() and gen_salt() were removed. We want to use |
| 85 |
* the new function, but if we're building against older versions, |
| 86 |
* redefine it in terms of the older functions. |
| 87 |
*/ |
| 88 |
# define crypt_password(pass) crypt_string(pass, gen_salt()) |
| 89 |
|
| 90 |
/* These were renamed in the Atheme 7.3 development series and we want |
| 91 |
* to use the new names. |
| 92 |
*/ |
| 93 |
# define atheme_object(obj) object(obj) |
| 94 |
# define atheme_object_dispose(obj) object_dispose(obj) |
| 95 |
# define atheme_object_init(obj, name, dest) object_init(obj, name, dest) |
| 96 |
# define atheme_object_ref(obj) object_ref(obj) |
| 97 |
# define atheme_object_sink_ref(obj) object_sink_ref(obj) |
| 98 |
# define atheme_object_unref(obj) object_unref(obj) |
| 99 |
# define atheme_random() arc4random() |
| 100 |
# define atheme_random_uniform(bound) arc4random_uniform(bound) |
| 101 |
# define atheme_random_buf(dest, size) arc4random_buf(dest, size) |
| 102 |
|
| 103 |
/* This function was introduced in the Atheme 7.3 development series and |
| 104 |
* we want to make use of it. |
| 105 |
*/ |
| 106 |
# define sfree(ptr) free(ptr) |
| 107 |
|
| 108 |
/* These attribute macros were introduced in the Atheme 7.3 development |
| 109 |
* series, and it would be nice to be able to make use of them. |
| 110 |
*/ |
| 111 |
# if defined(__GNUC__) || defined(__INTEL_COMPILER) |
| 112 |
# define ATHEME_FATTR_DEPRECATED __attribute__((deprecated)) |
| 113 |
# define ATHEME_FATTR_MALLOC __attribute__((malloc)) |
| 114 |
# define ATHEME_FATTR_NORETURN __attribute__((noreturn)) |
| 115 |
# define ATHEME_FATTR_PRINTF(fmt, start) __attribute__((format(__printf__, fmt, start))) |
| 116 |
# define ATHEME_FATTR_SCANF(fmt, start) __attribute__((format(__scanf__, fmt, start))) |
| 117 |
# define ATHEME_FATTR_WUR __attribute__((warn_unused_result)) |
| 118 |
# define ATHEME_SATTR_PACKED __attribute__((packed)) |
| 119 |
# define ATHEME_VATTR_ALIGNED(alignment) __attribute__((aligned(alignment))) |
| 120 |
# define ATHEME_VATTR_UNUSED __attribute__((unused)) |
| 121 |
# else |
| 122 |
# define ATHEME_FATTR_DEPRECATED /* No function attribute support */ |
| 123 |
# define ATHEME_FATTR_MALLOC /* No function attribute support */ |
| 124 |
# define ATHEME_FATTR_NORETURN /* No function attribute support */ |
| 125 |
# define ATHEME_FATTR_PRINTF(fmt, start) /* No function attribute support */ |
| 126 |
# define ATHEME_FATTR_SCANF(fmt, start) /* No function attribute support */ |
| 127 |
# define ATHEME_FATTR_WUR /* No function attribute support */ |
| 128 |
# define ATHEME_SATTR_PACKED /* No structure attribute support */ |
| 129 |
# define ATHEME_VATTR_ALIGNED(alignment) /* No variable attribute support */ |
| 130 |
# define ATHEME_VATTR_UNUSED /* No variable attribute support */ |
| 131 |
# endif |
| 132 |
|
| 133 |
// This new name was introduced in the Atheme 7.3 development series. |
| 134 |
#define MODFLAG_FAIL MODTYPE_FAIL |
| 135 |
|
| 136 |
/* These 2 macros were introduced in the Atheme 7.3 development series and |
| 137 |
* they're much nicer to use. |
| 138 |
*/ |
| 139 |
#define VENDOR_DECLARE_MODULE_V1(name, unloadcap, ven) \ |
| 140 |
DECLARE_MODULE_V1(name, unloadcap, mod_init, mod_deinit, PACKAGE_STRING, ven); |
| 141 |
|
| 142 |
#define SIMPLE_DECLARE_MODULE_V1(name, unloadcap) \ |
| 143 |
VENDOR_DECLARE_MODULE_V1(name, unloadcap, VENDOR_STRING) |
| 144 |
|
| 145 |
/* These were redefined in the Atheme 7.3 development series to not |
| 146 |
* include the space for a NULL terminator in their definition. This |
| 147 |
* repository now assumes this is the case, so when building against |
| 148 |
* 7.2 or earlier we need to subtract 1 or provide our own definition |
| 149 |
* for a macro newly introduced in 7.3 (GROUPLEN). |
| 150 |
*/ |
| 151 |
# define COMPAT_HOSTLEN (HOSTLEN - 1) |
| 152 |
# define COMPAT_NICKLEN (NICKLEN - 1) |
| 153 |
# define COMPAT_PASSLEN (PASSLEN - 1) |
| 154 |
# define COMPAT_IDLEN (IDLEN - 1) |
| 155 |
# define COMPAT_CHANNELLEN (CHANNELLEN - 1) |
| 156 |
# define COMPAT_GROUPLEN (NICKLEN - 1) |
| 157 |
# define COMPAT_USERLEN (USERLEN - 1) |
| 158 |
# define COMPAT_HOSTIPLEN (HOSTIPLEN - 1) |
| 159 |
# define COMPAT_GECOSLEN (GECOSLEN - 1) |
| 160 |
# define COMPAT_KEYLEN (KEYLEN - 1) |
| 161 |
# define COMPAT_EMAILLEN (EMAILLEN - 1) |
| 162 |
# define COMPAT_MEMOLEN (MEMOLEN - 1) |
| 163 |
|
| 164 |
#else /* (CURRENT_ABI_REVISION < 730000) */ |
| 165 |
|
| 166 |
# define COMPAT_HOSTLEN HOSTLEN |
| 167 |
# define COMPAT_NICKLEN NICKLEN |
| 168 |
# define COMPAT_PASSLEN PASSLEN |
| 169 |
# define COMPAT_IDLEN IDLEN |
| 170 |
# define COMPAT_CHANNELLEN CHANNELLEN |
| 171 |
# define COMPAT_GROUPLEN GROUPLEN |
| 172 |
# define COMPAT_USERLEN USERLEN |
| 173 |
# define COMPAT_HOSTIPLEN HOSTIPLEN |
| 174 |
# define COMPAT_GECOSLEN GECOSLEN |
| 175 |
# define COMPAT_KEYLEN KEYLEN |
| 176 |
# define COMPAT_EMAILLEN EMAILLEN |
| 177 |
# define COMPAT_MEMOLEN MEMOLEN |
| 178 |
|
| 179 |
// This definition was removed in the Atheme 7.3 development series. |
| 180 |
# define IRCD_RES_HOSTLEN 255 |
| 181 |
|
| 182 |
// This is a no-op in at least 7.3+ and were removed. |
| 183 |
static inline struct hook *hook_add_event(const char *name) { return NULL; } |
| 184 |
static inline void hook_del_event(struct hook *hook) { } |
| 185 |
|
| 186 |
/* These typedefs were removed in the Atheme 7.3 development series, |
| 187 |
* but we can't use the new names because they consist of structures |
| 188 |
* or enums and we can't make structure aliases to other structures |
| 189 |
* present in the older versions. |
| 190 |
*/ |
| 191 |
typedef enum cmd_faultcode cmd_faultcode_t; |
| 192 |
typedef enum database_transaction database_transaction_t; |
| 193 |
typedef enum db_save_strategy db_save_strategy_t; |
| 194 |
typedef enum log_type log_type_t; |
| 195 |
typedef enum module_unload_capability module_unload_capability_t; |
| 196 |
typedef enum module_unload_intent module_unload_intent_t; |
| 197 |
|
| 198 |
typedef struct hook hook_t; |
| 199 |
typedef struct hook_channel_joinpart hook_channel_joinpart_t; |
| 200 |
typedef struct hook_channel_message hook_cmessage_data_t; |
| 201 |
typedef struct hook_channel_mode hook_channel_mode_t; |
| 202 |
typedef struct hook_channel_mode_change hook_channel_mode_change_t; |
| 203 |
typedef struct hook_channel_topic_check hook_channel_topic_check_t; |
| 204 |
typedef struct hook_server_delete hook_server_delete_t; |
| 205 |
typedef struct hook_user_nick hook_user_nick_t; |
| 206 |
typedef struct hook_user_delete_info hook_user_delete_t; |
| 207 |
|
| 208 |
typedef struct hook_channel_acl_req hook_channel_acl_req_t; |
| 209 |
typedef struct hook_channel_register_check hook_channel_register_check_t; |
| 210 |
typedef struct hook_channel_req hook_channel_req_t; |
| 211 |
typedef struct hook_channel_successtion_req hook_channel_succession_req_t; |
| 212 |
typedef struct hook_expiry_req hook_expiry_req_t; |
| 213 |
typedef struct hook_host_request hook_host_request_t; |
| 214 |
typedef struct hook_info_noexist hook_info_noexist_req_t; |
| 215 |
typedef struct hook_metadata_change hook_metadata_change_t; |
| 216 |
typedef struct hook_module_load hook_module_load_t; |
| 217 |
typedef struct hook_myentity_req hook_myentity_req_t; |
| 218 |
typedef struct hook_nick_enforce hook_nick_enforce_t; |
| 219 |
typedef struct hook_user_needforce hook_user_needforce_t; |
| 220 |
typedef struct hook_user_register_check hook_user_register_check_t; |
| 221 |
typedef struct hook_user_rename hook_user_rename_t; |
| 222 |
typedef struct hook_user_req hook_user_req_t; |
| 223 |
typedef struct hook_user_login_check hook_user_login_check_t; |
| 224 |
typedef struct hook_user_logout_check hook_user_logout_check_t; |
| 225 |
typedef struct hook_user_rename_check hook_user_rename_check_t; |
| 226 |
|
| 227 |
typedef struct atheme_regex atheme_regex_t; |
| 228 |
typedef struct authcookie authcookie_t; |
| 229 |
typedef struct chanacs chanacs_t; |
| 230 |
typedef struct chanban chanban_t; |
| 231 |
typedef struct channel channel_t; |
| 232 |
typedef struct chansvs chansvs_t; |
| 233 |
typedef struct chanuser chanuser_t; |
| 234 |
typedef struct claro_state claro_state_t; |
| 235 |
typedef struct command command_t; |
| 236 |
typedef struct connection connection_t; |
| 237 |
typedef struct crypt_impl crypt_impl_t; |
| 238 |
typedef struct database_handle database_handle_t; |
| 239 |
typedef struct database_module database_module_t; |
| 240 |
typedef struct database_vtable database_vtable_t; |
| 241 |
typedef struct default_template default_template_t; |
| 242 |
typedef struct res_dns_query dns_query_t; |
| 243 |
typedef struct res_dns_reply dns_reply_t; |
| 244 |
typedef struct email_canonicalizer_item email_canonicalizer_item_t; |
| 245 |
typedef struct entity_chanacs_validation_vtable entity_chanacs_validation_vtable_t; |
| 246 |
typedef struct groupacs groupacs_t; |
| 247 |
typedef struct ircd ircd_t; |
| 248 |
typedef struct kline kline_t; |
| 249 |
typedef struct language language_t; |
| 250 |
typedef struct logfile logfile_t; |
| 251 |
typedef struct metadata metadata_t; |
| 252 |
typedef struct module module_t; |
| 253 |
typedef struct mycertfp mycertfp_t; |
| 254 |
typedef struct mychan mychan_t; |
| 255 |
typedef struct myentity myentity_t; |
| 256 |
typedef struct mygroup mygroup_t; |
| 257 |
typedef struct mymemo mymemo_t; |
| 258 |
typedef struct mynick mynick_t; |
| 259 |
typedef struct myuser myuser_t; |
| 260 |
typedef struct myuser_name myuser_name_t; |
| 261 |
typedef struct nicksvs nicksvs_t; |
| 262 |
typedef struct nsaddr nsaddr_t; |
| 263 |
typedef struct atheme_object object_t; |
| 264 |
typedef struct operclass operclass_t; |
| 265 |
typedef struct path_handler path_handler_t; |
| 266 |
typedef struct proto_cmd pcommand_t; |
| 267 |
typedef struct qline qline_t; |
| 268 |
typedef struct sasl_message sasl_message_t; |
| 269 |
typedef struct server server_t; |
| 270 |
typedef struct service service_t; |
| 271 |
typedef struct soper soper_t; |
| 272 |
typedef struct sourceinfo sourceinfo_t; |
| 273 |
typedef struct svsignore svsignore_t; |
| 274 |
typedef struct atheme_table table_t; |
| 275 |
typedef struct atheme_table_cell table_cell_t; |
| 276 |
typedef struct atheme_table_row table_row_t; |
| 277 |
typedef struct taint_reason taint_reason_t; |
| 278 |
typedef struct tld tld_t; |
| 279 |
typedef struct uid_provider uid_provider_t; |
| 280 |
typedef struct uplink uplink_t; |
| 281 |
typedef struct user user_t; |
| 282 |
typedef struct v4_moduleheader v4_moduleheader_t; |
| 283 |
typedef struct xline xline_t; |
| 284 |
|
| 285 |
typedef conf_handler_fn conf_handler_t; |
| 286 |
typedef atheme_object_destructor_fn destructor_t; |
| 287 |
typedef email_canonicalizer_fn email_canonicalizer_t; |
| 288 |
typedef hook_fn hookfn_t; |
| 289 |
typedef log_write_func_fn log_write_func_t; |
| 290 |
typedef void (*module_unload_handler_t)(module_t *, module_unload_intent_t); |
| 291 |
|
| 292 |
#endif /* (CURRENT_ABI_REVISION >= 730000) */ |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
#endif /* !ATHEME_CONTRIB_COMPAT_H */ |