LCOV - code coverage report
Current view: top level - src - deprecated.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 59 0.0 %
Date: 2023-08-10 00:00:00 Functions: 0 14 0.0 %

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

Generated by: LCOV version 1.14