LCOV - code coverage report
Current view: top level - src - deprecated.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 64 0
Test Date: 2024-08-20 10:03:45 Functions: 0.0 % 15 0

            Line data    Source code
       1              : /* SPDX-License-Identifier: MIT OR GPL-3.0-only */
       2              : /* deprecated.c
       3              : ** strophe XMPP client library -- File with deprecated API functions.
       4              : **
       5              : ** Copyright (C) 2022 Steffen Jaeckel
       6              : **
       7              : **  This software is provided AS-IS with no warranty, either express
       8              : **  or implied.
       9              : **
      10              : **  This program is dual licensed under the MIT or GPLv3 licenses.
      11              : */
      12              : 
      13              : /** @file
      14              :  *  File with deprecated API functions.
      15              :  */
      16              : 
      17              : /** @defgroup Deprecated All deprecated functions
      18              :  *  These functions will be removed in the next release.
      19              :  */
      20              : 
      21              : #include "common.h"
      22              : 
      23              : /** Allocate memory in a Strophe context.
      24              :  *  All Strophe functions will use this to allocate memory.
      25              :  *
      26              :  *  @param ctx a Strophe context object
      27              :  *  @param size the number of bytes to allocate
      28              :  *
      29              :  *  @return a pointer to the allocated memory or NULL on an error
      30              :  *
      31              :  *  @ingroup Deprecated
      32              :  */
      33            0 : void *xmpp_alloc(const xmpp_ctx_t *ctx, size_t size)
      34              : {
      35            0 :     return strophe_alloc(ctx, size);
      36              : }
      37              : 
      38              : /** Reallocate memory in a Strophe context.
      39              :  *  All Strophe functions will use this to reallocate memory.
      40              :  *
      41              :  *  @param ctx a Strophe context object
      42              :  *  @param p a pointer to previously allocated memory
      43              :  *  @param size the new size in bytes to allocate
      44              :  *
      45              :  *  @return a pointer to the reallocated memory or NULL on an error
      46              :  *
      47              :  *  @ingroup Deprecated
      48              :  */
      49            0 : void *xmpp_realloc(const xmpp_ctx_t *ctx, void *p, size_t size)
      50              : {
      51            0 :     return strophe_realloc(ctx, p, size);
      52              : }
      53              : 
      54              : /** implement our own strdup that uses the ctx allocator */
      55              : /** Duplicate a string.
      56              :  *  This function replaces the standard strdup library call with a version
      57              :  *  that uses the Strophe context object's allocator.
      58              :  *
      59              :  *  @param ctx a Strophe context object
      60              :  *  @param s a string
      61              :  *
      62              :  *  @return a newly allocated string with the same data as s or NULL on error
      63              :  *
      64              :  *  @ingroup Deprecated
      65              :  */
      66            0 : char *xmpp_strdup(const xmpp_ctx_t *ctx, const char *s)
      67              : {
      68            0 :     return strophe_strdup(ctx, s);
      69              : }
      70              : 
      71              : /** Duplicate a string with a maximum length.
      72              :  *  This function replaces the standard strndup library call with a version
      73              :  *  that uses the Strophe context object's allocator.
      74              :  *
      75              :  *  @param ctx a Strophe context object
      76              :  *  @param s a string
      77              :  *  @param len the maximum length of the string to copy
      78              :  *
      79              :  *  @return a newly allocated string that contains at most `len` symbols
      80              :  *             of the original string or NULL on error
      81              :  *
      82              :  *  @ingroup Deprecated
      83              :  */
      84            0 : char *xmpp_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len)
      85              : {
      86            0 :     return strophe_strndup(ctx, s, len);
      87              : }
      88              : 
      89            0 : void xmpp_log(const xmpp_ctx_t *ctx,
      90              :               xmpp_log_level_t level,
      91              :               const char *area,
      92              :               const char *fmt,
      93              :               va_list ap)
      94              : {
      95            0 :     strophe_log_internal(ctx, level, area, fmt, ap);
      96            0 : }
      97              : 
      98              : /** Write to the log at the ERROR level.
      99              :  *  This is a convenience function for writing to the log at the
     100              :  *  ERROR level.  It takes a printf-style format string followed by a
     101              :  *  variable list of arguments for formatting.
     102              :  *
     103              :  *  @param ctx a Strophe context object
     104              :  *  @param area the area to log for
     105              :  *  @param fmt a printf-style format string followed by a variable list of
     106              :  *      arguments to format
     107              :  *
     108              :  *  @ingroup Deprecated
     109              :  */
     110            0 : void xmpp_error(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
     111              : {
     112            0 :     va_list ap;
     113              : 
     114            0 :     va_start(ap, fmt);
     115            0 :     strophe_log_internal(ctx, XMPP_LEVEL_ERROR, area, fmt, ap);
     116            0 :     va_end(ap);
     117            0 : }
     118              : 
     119              : /** Write to the log at the WARN level.
     120              :  *  This is a convenience function for writing to the log at the WARN level.
     121              :  *  It takes a printf-style format string followed by a variable list of
     122              :  *  arguments for formatting.
     123              :  *
     124              :  *  @param ctx a Strophe context object
     125              :  *  @param area the area to log for
     126              :  *  @param fmt a printf-style format string followed by a variable list of
     127              :  *      arguments to format
     128              :  *
     129              :  *  @ingroup Deprecated
     130              :  */
     131            0 : void xmpp_warn(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
     132              : {
     133            0 :     va_list ap;
     134              : 
     135            0 :     va_start(ap, fmt);
     136            0 :     strophe_log_internal(ctx, XMPP_LEVEL_WARN, area, fmt, ap);
     137            0 :     va_end(ap);
     138            0 : }
     139              : 
     140              : /** Write to the log at the INFO level.
     141              :  *  This is a convenience function for writing to the log at the INFO level.
     142              :  *  It takes a printf-style format string followed by a variable list of
     143              :  *  arguments for formatting.
     144              :  *
     145              :  *  @param ctx a Strophe context object
     146              :  *  @param area the area to log for
     147              :  *  @param fmt a printf-style format string followed by a variable list of
     148              :  *      arguments to format
     149              :  *
     150              :  *  @ingroup Deprecated
     151              :  */
     152            0 : void xmpp_info(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
     153              : {
     154            0 :     va_list ap;
     155              : 
     156            0 :     va_start(ap, fmt);
     157            0 :     strophe_log_internal(ctx, XMPP_LEVEL_INFO, area, fmt, ap);
     158            0 :     va_end(ap);
     159            0 : }
     160              : 
     161              : /** Write to the log at the DEBUG level.
     162              :  *  This is a convenience function for writing to the log at the DEBUG level.
     163              :  *  It takes a printf-style format string followed by a variable list of
     164              :  *  arguments for formatting.
     165              :  *
     166              :  *  @param ctx a Strophe context object
     167              :  *  @param area the area to log for
     168              :  *  @param fmt a printf-style format string followed by a variable list of
     169              :  *      arguments to format
     170              :  *
     171              :  *  @ingroup Deprecated
     172              :  */
     173            0 : void xmpp_debug(const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
     174              : {
     175            0 :     va_list ap;
     176              : 
     177            0 :     va_start(ap, fmt);
     178            0 :     strophe_log_internal(ctx, XMPP_LEVEL_DEBUG, area, fmt, ap);
     179            0 :     va_end(ap);
     180            0 : }
     181              : 
     182              : /** Write to the log at the DEBUG level if verbosity is enabled.
     183              :  *  This is a convenience function for writing to the log at the DEBUG level.
     184              :  *  It takes a printf-style format string followed by a variable list of
     185              :  *  arguments for formatting.
     186              :  *
     187              :  *  @param level the verbosity level
     188              :  *  @param ctx a Strophe context object
     189              :  *  @param area the area to log for
     190              :  *  @param fmt a printf-style format string followed by a variable list of
     191              :  *      arguments to format
     192              :  *
     193              :  *  @ingroup Deprecated
     194              :  */
     195            0 : void xmpp_debug_verbose(
     196              :     int level, const xmpp_ctx_t *ctx, const char *area, const char *fmt, ...)
     197              : {
     198            0 :     va_list ap;
     199              : 
     200            0 :     if (ctx->verbosity < level)
     201            0 :         return;
     202              : 
     203            0 :     va_start(ap, fmt);
     204            0 :     strophe_log_internal(ctx, XMPP_LEVEL_DEBUG, area, fmt, ap);
     205            0 :     va_end(ap);
     206              : }
     207              : 
     208              : /** strtok_r(3) implementation.
     209              :  *  This function has appeared in POSIX.1-2001, but not in C standard.
     210              :  *  For example, visual studio older than 2005 doesn't provide strtok_r()
     211              :  *  nor strtok_s().
     212              :  *
     213              :  *  @ingroup Deprecated
     214              :  */
     215            0 : char *xmpp_strtok_r(char *s, const char *delim, char **saveptr)
     216              : {
     217            0 :     return strophe_strtok_r(s, delim, saveptr);
     218              : }
     219              : 
     220            0 : int xmpp_snprintf(char *str, size_t count, const char *fmt, ...)
     221              : {
     222            0 :     va_list ap;
     223            0 :     int ret;
     224              : 
     225            0 :     va_start(ap, fmt);
     226            0 :     ret = strophe_vsnprintf(str, count, fmt, ap);
     227            0 :     va_end(ap);
     228            0 :     return ret;
     229              : }
     230              : 
     231            0 : int xmpp_vsnprintf(char *str, size_t count, const char *fmt, va_list arg)
     232              : {
     233            0 :     return strophe_vsnprintf(str, count, fmt, arg);
     234              : }
     235              : 
     236              : /** Set TCP keepalive parameters
     237              :  *  Turn on TCP keepalive and set timeout and interval. Zero timeout
     238              :  *  disables TCP keepalives. The parameters are applied immediately for
     239              :  *  a non disconnected object. Also, they are applied when the connection
     240              :  *  object connects successfully.
     241              :  *
     242              :  *  @param conn a Strophe connection object
     243              :  *  @param timeout TCP keepalive timeout in seconds
     244              :  *  @param interval TCP keepalive interval in seconds
     245              :  *
     246              :  *  @note this function is deprecated
     247              :  *  @see xmpp_conn_set_sockopt_callback()
     248              :  *
     249              :  *  @ingroup Deprecated
     250              :  */
     251            0 : void xmpp_conn_set_keepalive(xmpp_conn_t *conn, int timeout, int interval)
     252              : {
     253            0 :     conn->ka_timeout = timeout;
     254            0 :     conn->ka_interval = interval;
     255            0 :     conn->ka_count = 0;
     256            0 :     xmpp_conn_set_sockopt_callback(conn, xmpp_sockopt_cb_keepalive);
     257            0 : }
     258              : 
     259              : /** Disable TLS for this connection, called by users of the library.
     260              :  *  Occasionally a server will be misconfigured to send the starttls
     261              :  *  feature, but will not support the handshake.
     262              :  *
     263              :  *  @param conn a Strophe connection object
     264              :  *
     265              :  *  @note this function is deprecated
     266              :  *  @see xmpp_conn_set_flags()
     267              :  *
     268              :  *  @ingroup Deprecated
     269              :  */
     270            0 : void xmpp_conn_disable_tls(xmpp_conn_t *conn)
     271              : {
     272            0 :     long flags = xmpp_conn_get_flags(conn);
     273              : 
     274            0 :     flags |= XMPP_CONN_FLAG_DISABLE_TLS;
     275            0 :     (void)xmpp_conn_set_flags(conn, flags);
     276            0 : }
        

Generated by: LCOV version 2.0-1