revive removed API's
In order to do proper deprecation of those API's we re-introduce them so they can be removed in the next release. This will then also lead to an ABI bump. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -40,6 +40,7 @@ libstrophe_la_SOURCES = \
|
||||
src/conn.c \
|
||||
src/crypto.c \
|
||||
src/ctx.c \
|
||||
src/deprecated.c \
|
||||
src/event.c \
|
||||
src/handler.c \
|
||||
src/hash.c \
|
||||
|
||||
@@ -113,6 +113,12 @@ void strophe_debug(const xmpp_ctx_t *ctx,
|
||||
void strophe_debug_verbose(
|
||||
int level, const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
|
||||
void strophe_log_internal(const xmpp_ctx_t *ctx,
|
||||
xmpp_log_level_t level,
|
||||
const char *area,
|
||||
const char *fmt,
|
||||
va_list ap);
|
||||
|
||||
/** connection **/
|
||||
|
||||
/* opaque connection object */
|
||||
|
||||
10
src/ctx.c
10
src/ctx.c
@@ -312,6 +312,16 @@ static void _strophe_log(const xmpp_ctx_t *ctx,
|
||||
strophe_free(ctx, buf);
|
||||
}
|
||||
|
||||
/* Dummy trampoline, will be removed when deprecated.c is deleted */
|
||||
void strophe_log_internal(const xmpp_ctx_t *ctx,
|
||||
xmpp_log_level_t level,
|
||||
const char *area,
|
||||
const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
_strophe_log(ctx, level, area, fmt, ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the ERROR level.
|
||||
* This is a convenience function for writing to the log at the
|
||||
* ERROR level. It takes a printf-style format string followed by a
|
||||
|
||||
233
src/deprecated.c
Normal file
233
src/deprecated.c
Normal file
@@ -0,0 +1,233 @@
|
||||
/* deprecated.c
|
||||
** strophe XMPP client library -- File with deprecated API functions.
|
||||
**
|
||||
** Copyright (C) 2022 Steffen Jaeckel
|
||||
**
|
||||
** This software is provided AS-IS with no warranty, either express
|
||||
** or implied.
|
||||
**
|
||||
** This program is dual licensed under the MIT and GPLv3 licenses.
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* File with deprecated API functions.
|
||||
*/
|
||||
|
||||
/** @defgroup Deprecated All deprecated functions
|
||||
* These functions will be removed in the next release.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/** Allocate memory in a Strophe context.
|
||||
* All Strophe functions will use this to allocate memory.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param size the number of bytes to allocate
|
||||
*
|
||||
* @return a pointer to the allocated memory or NULL on an error
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void *xmpp_alloc(const xmpp_ctx_t *ctx, size_t size)
|
||||
{
|
||||
return strophe_alloc(ctx, size);
|
||||
}
|
||||
|
||||
/** Reallocate memory in a Strophe context.
|
||||
* All Strophe functions will use this to reallocate memory.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param p a pointer to previously allocated memory
|
||||
* @param size the new size in bytes to allocate
|
||||
*
|
||||
* @return a pointer to the reallocated memory or NULL on an error
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void *xmpp_realloc(const xmpp_ctx_t *ctx, void *p, size_t size)
|
||||
{
|
||||
return strophe_realloc(ctx, p, size);
|
||||
}
|
||||
|
||||
/** implement our own strdup that uses the ctx allocator */
|
||||
/** Duplicate a string.
|
||||
* This function replaces the standard strdup library call with a version
|
||||
* that uses the Strophe context object's allocator.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param s a string
|
||||
*
|
||||
* @return a newly allocated string with the same data as s or NULL on error
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
char *xmpp_strdup(const xmpp_ctx_t *ctx, const char *s)
|
||||
{
|
||||
return strophe_strdup(ctx, s);
|
||||
}
|
||||
|
||||
/** Duplicate a string with a maximum length.
|
||||
* This function replaces the standard strndup library call with a version
|
||||
* that uses the Strophe context object's allocator.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param s a string
|
||||
* @param len the maximum length of the string to copy
|
||||
*
|
||||
* @return a newly allocated string that contains at most `len` symbols
|
||||
* of the original string or NULL on error
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
char *xmpp_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len)
|
||||
{
|
||||
return strophe_strndup(ctx, s, len);
|
||||
}
|
||||
|
||||
void xmpp_log(const xmpp_ctx_t *ctx,
|
||||
xmpp_log_level_t level,
|
||||
const char *area,
|
||||
const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
strophe_log_internal(ctx, level, area, fmt, ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the ERROR level.
|
||||
* This is a convenience function for writing to the log at the
|
||||
* ERROR level. It takes a printf-style format string followed by a
|
||||
* variable list of arguments for formatting.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param area the area to log for
|
||||
* @param fmt a printf-style format string followed by a variable list of
|
||||
* arguments to format
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void xmpp_error(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
strophe_log_internal(ctx, XMPP_LEVEL_ERROR, area, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the WARN level.
|
||||
* This is a convenience function for writing to the log at the WARN level.
|
||||
* It takes a printf-style format string followed by a variable list of
|
||||
* arguments for formatting.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param area the area to log for
|
||||
* @param fmt a printf-style format string followed by a variable list of
|
||||
* arguments to format
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void xmpp_warn(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
strophe_log_internal(ctx, XMPP_LEVEL_WARN, area, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the INFO level.
|
||||
* This is a convenience function for writing to the log at the INFO level.
|
||||
* It takes a printf-style format string followed by a variable list of
|
||||
* arguments for formatting.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param area the area to log for
|
||||
* @param fmt a printf-style format string followed by a variable list of
|
||||
* arguments to format
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void xmpp_info(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
strophe_log_internal(ctx, XMPP_LEVEL_INFO, area, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the DEBUG level.
|
||||
* This is a convenience function for writing to the log at the DEBUG level.
|
||||
* It takes a printf-style format string followed by a variable list of
|
||||
* arguments for formatting.
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @param area the area to log for
|
||||
* @param fmt a printf-style format string followed by a variable list of
|
||||
* arguments to format
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void xmpp_debug(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
strophe_log_internal(ctx, XMPP_LEVEL_DEBUG, area, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** Write to the log at the DEBUG level if verbosity is enabled.
|
||||
* This is a convenience function for writing to the log at the DEBUG level.
|
||||
* It takes a printf-style format string followed by a variable list of
|
||||
* arguments for formatting.
|
||||
*
|
||||
* @param level the verbosity level
|
||||
* @param ctx a Strophe context object
|
||||
* @param area the area to log for
|
||||
* @param fmt a printf-style format string followed by a variable list of
|
||||
* arguments to format
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
void xmpp_debug_verbose(
|
||||
int level, const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (ctx->verbosity < level)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
strophe_log_internal(ctx, XMPP_LEVEL_DEBUG, area, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** strtok_r(3) implementation.
|
||||
* This function has appeared in POSIX.1-2001, but not in C standard.
|
||||
* For example, visual studio older than 2005 doesn't provide strtok_r()
|
||||
* nor strtok_s().
|
||||
*
|
||||
* @ingroup Deprecated
|
||||
*/
|
||||
char *xmpp_strtok_r(char *s, const char *delim, char **saveptr)
|
||||
{
|
||||
return strophe_strtok_r(s, delim, saveptr);
|
||||
}
|
||||
|
||||
int xmpp_snprintf(char *str, size_t count, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = strophe_vsnprintf(str, count, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xmpp_vsnprintf(char *str, size_t count, const char *fmt, va_list arg)
|
||||
{
|
||||
return strophe_vsnprintf(str, count, fmt, arg);
|
||||
}
|
||||
43
strophe.h
43
strophe.h
@@ -587,6 +587,49 @@ void xmpp_rand_bytes(xmpp_rand_t *rand, unsigned char *output, size_t len);
|
||||
*/
|
||||
void xmpp_rand_nonce(xmpp_rand_t *rand, char *output, size_t len);
|
||||
|
||||
/**
|
||||
* Formerly "private but exported" functions made public for now to announce
|
||||
* deprecation */
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
|
||||
#define XMPP_DEPRECATED \
|
||||
__attribute__((deprecated("Function is internal from next release on")))
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1500
|
||||
#define XMPP_DEPRECATED \
|
||||
__declspec(deprecated("Function is internal from next release on"))
|
||||
#else
|
||||
#define XMPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
XMPP_DEPRECATED void *xmpp_alloc(const xmpp_ctx_t *ctx, size_t size);
|
||||
XMPP_DEPRECATED void *xmpp_realloc(const xmpp_ctx_t *ctx, void *p, size_t size);
|
||||
XMPP_DEPRECATED char *xmpp_strdup(const xmpp_ctx_t *ctx, const char *s);
|
||||
XMPP_DEPRECATED char *
|
||||
xmpp_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len);
|
||||
|
||||
XMPP_DEPRECATED char *xmpp_strtok_r(char *s, const char *delim, char **saveptr);
|
||||
XMPP_DEPRECATED int
|
||||
xmpp_snprintf(char *str, size_t count, const char *fmt, ...);
|
||||
XMPP_DEPRECATED int
|
||||
xmpp_vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
|
||||
|
||||
XMPP_DEPRECATED void xmpp_log(const xmpp_ctx_t *ctx,
|
||||
xmpp_log_level_t level,
|
||||
const char *area,
|
||||
const char *fmt,
|
||||
va_list ap);
|
||||
XMPP_DEPRECATED void
|
||||
xmpp_error(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
XMPP_DEPRECATED void
|
||||
xmpp_warn(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
XMPP_DEPRECATED void
|
||||
xmpp_info(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
XMPP_DEPRECATED void
|
||||
xmpp_debug(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
XMPP_DEPRECATED void xmpp_debug_verbose(
|
||||
int level, const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user