| 1 | /********************************************************************************************************* |
| 2 | * Software License Agreement (BSD License) * |
| 3 | * Author: Sebastien Decugis <[email protected]> * |
| 4 | * * |
| 5 | * Copyright (c) 2015, WIDE Project and NICT * |
| 6 | * All rights reserved. * |
| 7 | * * |
| 8 | * Redistribution and use of this software in source and binary forms, with or without modification, are * |
| 9 | * permitted provided that the following conditions are met: * |
| 10 | * * |
| 11 | * * Redistributions of source code must retain the above * |
| 12 | * copyright notice, this list of conditions and the * |
| 13 | * following disclaimer. * |
| 14 | * * |
| 15 | * * Redistributions in binary form must reproduce the above * |
| 16 | * copyright notice, this list of conditions and the * |
| 17 | * following disclaimer in the documentation and/or other * |
| 18 | * materials provided with the distribution. * |
| 19 | * * |
| 20 | * * Neither the name of the WIDE Project or NICT nor the * |
| 21 | * names of its contributors may be used to endorse or * |
| 22 | * promote products derived from this software without * |
| 23 | * specific prior written permission of WIDE Project and * |
| 24 | * NICT. * |
| 25 | * * |
| 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
| 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
| 28 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
| 29 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
| 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
| 32 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
| 33 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
| 34 | *********************************************************************************************************/ |
| 35 | |
| 36 | #include "fdproto-internal.h"cxx . . $ `<file>/lib/freeDiameter-1.2.1/libfdproto/fdproto-internal.h`/ |
| 37 | |
| 38 | #include <stdarg.h> |
| 39 | |
| 40 | pthread_mutex_tcxx . . $ pthread_mutex_t# fd_log_lockcxx . . $ fd_log_lock. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!; |
| 41 | pthread_key_tcxx . . $ pthread_key_t# fd_log_thnamecxx . . $ fd_log_thname.; |
| 42 | int fd_g_debug_lvlcxx . . $ fd_g_debug_lvl. = FD_LOG_NOTICEcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:273:9`!; |
| 43 | |
| 44 | static void fd_internal_loggercxx . . $ fd_internal_logger(7aa579bceef62d01).( int, const char *, va_listcxx . . $ va_list# ); |
| 45 | static int use_colorscxx . . $ use_colors. = 0; /* 0: not init, 1: yes, 2: no */ |
| 46 | |
| 47 | /* These may be used to pass specific debug requests via the command-line parameters */ |
| 48 | char * fd_debug_one_functioncxx . . $ fd_debug_one_function. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 49 | char * fd_debug_one_filecxx . . $ fd_debug_one_file. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 50 | |
| 51 | /* Useless function, only to ease setting up a breakpoint in gdb (break fd_breakhere) -- use TRACE_HERE */ |
| 52 | int fd_breakscxx . . $ fd_breaks. = 0; |
| 53 | int fd_breakherecxx . . $ fd_breakhere(b126dc7c1de90089).(void) { return ++fd_breakscxx . . $ fd_breaks.; } |
| 54 | |
| 55 | /* Allow passing of the log and debug information from base stack to extensions */ |
| 56 | void (*fd_loggercxx . . $ fd_logger.)( int loglevel, const char * format, va_listcxx . . $ va_list# args ) = fd_internal_loggercxx . . $ fd_internal_logger(7aa579bceef62d01).; |
| 57 | |
| 58 | /* Register an external call back for tracing and debug */ |
| 59 | int fd_log_handler_registercxx . . $ fd_log_handler_register(a23cad1772eef91e).( void (*logger)(int loglevel, const char * format, va_listcxx . . $ va_list# args) ) |
| 60 | { |
| 61 | CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( logger ); |
| 62 | |
| 63 | if ( fd_loggercxx . . $ fd_logger. != fd_internal_loggercxx . . $ fd_internal_logger(7aa579bceef62d01). ) |
| 64 | { |
| 65 | return EALREADYcxx . . $ `<external>/17922322188510340118/errno.h:98:9`!; /* only one registration allowed */ |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | fd_loggercxx . . $ fd_logger. = logger; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | /* Implement a simple reset function here */ |
| 76 | int fd_log_handler_unregistercxx . . $ fd_log_handler_unregister(b126dc7c1de90089). ( void ) |
| 77 | { |
| 78 | fd_loggercxx . . $ fd_logger. = fd_internal_loggercxx . . $ fd_internal_logger(7aa579bceef62d01).; |
| 79 | return 0; /* Successfull in all cases. */ |
| 80 | } |
| 81 | |
| 82 | static void fd_cleanup_mutex_silentcxx . . $ fd_cleanup_mutex_silent(5d22bdacc48458e8).( void * mutex ) |
| 83 | { |
| 84 | (void)pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).((pthread_mutex_tcxx . . $ pthread_mutex_t# *)mutex); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | static void fd_internal_loggercxx . . $ fd_internal_logger(7aa579bceef62d01).( int printlevel, const char *format, va_listcxx . . $ va_list# ap ) |
| 89 | { |
| 90 | char buf[25]; |
| 91 | |
| 92 | /* Do we need to trace this ? */ |
| 93 | if (printlevel < fd_g_debug_lvlcxx . . $ fd_g_debug_lvl.) |
| 94 | return; |
| 95 | |
| 96 | /* add timestamp */ |
| 97 | printfcxx . . $ printf(581fddd72a8db8fc).("%s ", fd_log_timecxx . . $ fd_log_time(4e26191e5e4138fe).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, buf, sizeof(buf), |
| 98 | #if (defined(DEBUG) && defined(DEBUG_WITH_META)) |
| 99 | 1, 1 |
| 100 | #else /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */ |
| 101 | 0, 0 |
| 102 | #endif /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */ |
| 103 | )); |
| 104 | /* Use colors on stdout ? */ |
| 105 | if (!use_colorscxx . . $ use_colors.) { |
| 106 | if (isattycxx . . $ isatty(7864480464b09eea).(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!)) |
| 107 | use_colorscxx . . $ use_colors. = 1; |
| 108 | else |
| 109 | use_colorscxx . . $ use_colors. = 2; |
| 110 | } |
| 111 | |
| 112 | switch(printlevel) { |
| 113 | case FD_LOG_ANNOYINGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:271:9`!: printfcxx . . $ printf(581fddd72a8db8fc).("%s A ", (use_colorscxx . . $ use_colors. == 1) ? "\e[0;37m" : ""); break; |
| 114 | case FD_LOG_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:272:9`!: printfcxx . . $ printf(581fddd72a8db8fc).("%s DBG ", (use_colorscxx . . $ use_colors. == 1) ? "\e[0;37m" : ""); break; |
| 115 | case FD_LOG_NOTICEcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:273:9`!: printfcxx . . $ printf(581fddd72a8db8fc).("%sNOTI ", (use_colorscxx . . $ use_colors. == 1) ? "\e[1;37m" : ""); break; |
| 116 | case FD_LOG_ERRORcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:274:9`!: printfcxx . . $ printf(581fddd72a8db8fc).("%sERROR ", (use_colorscxx . . $ use_colors. == 1) ? "\e[0;31m" : ""); break; |
| 117 | case FD_LOG_FATALcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:275:9`!: printfcxx . . $ printf(581fddd72a8db8fc).("%sFATAL! ", (use_colorscxx . . $ use_colors. == 1) ? "\e[0;31m" : ""); break; |
| 118 | default: printfcxx . . $ printf(581fddd72a8db8fc).("%s ??? ", (use_colorscxx . . $ use_colors. == 1) ? "\e[0;31m" : ""); |
| 119 | } |
| 120 | vprintfcxx . . $ vprintf(5c80dbd47e6ebfbb).(format, ap); |
| 121 | if (use_colorscxx . . $ use_colors. == 1) |
| 122 | printfcxx . . $ printf(581fddd72a8db8fc).("\e[00m"); |
| 123 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 124 | |
| 125 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 126 | } |
| 127 | |
| 128 | /* Log a debug message */ |
| 129 | void fd_logcxx . . $ fd_log(afcfcee7634adf7d). ( int loglevel, const char * format, ... ) |
| 130 | { |
| 131 | va_listcxx . . $ va_list# ap; |
| 132 | |
| 133 | (void)pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&fd_log_lockcxx . . $ fd_log_lock.); |
| 134 | |
| 135 | pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!(fd_cleanup_mutex_silent, &fd_log_lock); |
| 136 | |
| 137 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, format); |
| 138 | fd_loggercxx . . $ fd_logger.(loglevel, format, ap); |
| 139 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 140 | |
| 141 | pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0); |
| 142 | |
| 143 | (void)pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&fd_log_lockcxx . . $ fd_log_lock.); |
| 144 | } |
| 145 | |
| 146 | /* Log a debug message */ |
| 147 | void fd_log_vacxx . . $ fd_log_va(7aa579bceef62d01). ( int loglevel, const char * format, va_listcxx . . $ va_list# args ) |
| 148 | { |
| 149 | (void)pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&fd_log_lockcxx . . $ fd_log_lock.); |
| 150 | |
| 151 | pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!(fd_cleanup_mutex_silent, &fd_log_lock); |
| 152 | fd_loggercxx . . $ fd_logger.(loglevel, format, args); |
| 153 | pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0); |
| 154 | |
| 155 | (void)pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&fd_log_lockcxx . . $ fd_log_lock.); |
| 156 | } |
| 157 | |
| 158 | /* Function to set the thread's friendly name */ |
| 159 | void fd_log_threadnamecxx . . $ fd_log_threadname(85c52e162fed56f9). ( const char * name ) |
| 160 | { |
| 161 | void * val = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 162 | |
| 163 | TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p(%s)", name, name?:"/"); |
| 164 | |
| 165 | /* First, check if a value is already assigned to the current thread */ |
| 166 | val = pthread_getspecificcxx . . $ pthread_getspecific(52408c21a1e21ff7).(fd_log_thnamecxx . . $ fd_log_thname.); |
| 167 | if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) { |
| 168 | if (val) { |
| 169 | fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!("(Thread '%s' renamed to '%s')", (char *)val, name?:"(nil)"); |
| 170 | } else { |
| 171 | fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!("(Thread %p named '%s')", (void *)pthread_self(), name?:"(nil)"); |
| 172 | } |
| 173 | } |
| 174 | if (val != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 175 | freecxx . . $ free(5d22bdacc48458e8).(val); |
| 176 | } |
| 177 | |
| 178 | /* Now create the new string */ |
| 179 | if (name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 180 | CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_setspecific(fd_log_thname, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!), /* continue */); |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( val = strdup(name), return ); |
| 185 | |
| 186 | CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_setspecific(fd_log_thname, val), /* continue */); |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | /* Write time into a buffer */ |
| 191 | char * fd_log_timecxx . . $ fd_log_time(4e26191e5e4138fe). ( struct timespeccxx . . $ timespec# * ts, char * buf, size_t len, int incl_date, int incl_ms ) |
| 192 | { |
| 193 | int ret; |
| 194 | size_t offset = 0; |
| 195 | struct timespeccxx . . $ timespec# tp; |
| 196 | struct tmcxx . . $ tm# tm; |
| 197 | |
| 198 | /* Get current time */ |
| 199 | if (!ts) { |
| 200 | ret = clock_gettimecxx . . $ clock_gettime(65aaefb2502b4987).(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &tp); |
| 201 | if (ret != 0) { |
| 202 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, len, "%s", strerrorcxx . . $ strerror(ff224f080444ee45).(ret)); |
| 203 | return buf; |
| 204 | } |
| 205 | ts = &tp; |
| 206 | } |
| 207 | |
| 208 | offset += strftimecxx . . $ strftime(98e75925167c4f1b).(buf + offset, len - offset, incl_date?"%D,%T":"%T", localtime_rcxx . . $ localtime_r(92e3d173686db852).( &ts->tv_seccxx . . $ timespec#tv_sec. , &tm )); |
| 209 | if (incl_ms) |
| 210 | offset += snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, len - offset, ".%6.6ld", ts->tv_nseccxx . . $ timespec#tv_nsec. / 1000); |
| 211 | |
| 212 | return buf; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | static size_t sys_mempageszcxx . . $ sys_mempagesz. = 0; |
| 217 | |
| 218 | static size_t get_mempageszcxx . . $ get_mempagesz(f708dce9a8856c70).(void) { |
| 219 | if (!sys_mempageszcxx . . $ sys_mempagesz.) { |
| 220 | sys_mempageszcxx . . $ sys_mempagesz. = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_PAGESIZEcxx . . $ `<external>/6393649343499073842/confname.h:134:9`!); /* We alloc buffer by memory pages for efficiency. This can be readjusted if too memory consuming */ |
| 221 | if (sys_mempageszcxx . . $ sys_mempagesz. <= 0) |
| 222 | sys_mempageszcxx . . $ sys_mempagesz. = 256; /* default size if above call failed */ |
| 223 | } |
| 224 | return sys_mempageszcxx . . $ sys_mempagesz.; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /* Helper function for fd_*_dump. Prints the format string from 'offset' into '*buf', extends if needed. The location of buf can be updated by this function. */ |
| 229 | char * fd_dump_extendcxx . . $ fd_dump_extend(c968a74efae60792).(char ** buf, size_t *len, size_t *offset, const char * format, ... ) |
| 230 | { |
| 231 | va_listcxx . . $ va_list# ap; |
| 232 | int to_write; |
| 233 | size_t o = 0; |
| 234 | size_t mempagesz = get_mempageszcxx . . $ get_mempagesz(f708dce9a8856c70).(); |
| 235 | |
| 236 | /* we do not TRACE_ENTRY this one on purpose */ |
| 237 | |
| 238 | CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!(buf && len, return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 239 | |
| 240 | if (*buf == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 241 | CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(*buf = malloc(mempagesz), return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 242 | *len = mempagesz; |
| 243 | } |
| 244 | |
| 245 | if (offset) |
| 246 | o = *offset; |
| 247 | |
| 248 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, format); |
| 249 | to_write = vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(*buf + o, *len - o, format, ap); |
| 250 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 251 | |
| 252 | if (to_write + o >= *len) { |
| 253 | /* There was no room in the buffer, we extend and redo */ |
| 254 | size_t new_len = (((to_write + o) / mempagesz) + 1) * mempagesz; |
| 255 | CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(*buf = realloc(*buf, new_len), return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 256 | *len = new_len; |
| 257 | |
| 258 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(ap, format); |
| 259 | to_write = vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(*buf + o, *len - o, format, ap); |
| 260 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(ap); |
| 261 | } |
| 262 | |
| 263 | if (offset) |
| 264 | *offset += to_write; |
| 265 | |
| 266 | return *buf; |
| 267 | } |
| 268 | |
| 269 | char * fd_dump_extend_hexdumpcxx . . $ fd_dump_extend_hexdump(7b0e3ff00f196bca).(char ** buf, size_t *len, size_t *offset, uint8_tcxx . . $ uint8_t# *data, size_t datalen, size_t trunc, size_t wrap ) |
| 270 | { |
| 271 | int truncated = 0; |
| 272 | size_t towrite = 0; |
| 273 | size_t o = 0; |
| 274 | int i; |
| 275 | char * p; |
| 276 | size_t mempagesz = get_mempageszcxx . . $ get_mempagesz(f708dce9a8856c70).(); |
| 277 | #define TRUNK_MARKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/log.c:277:9`! "[...]" |
| 278 | |
| 279 | CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!(buf && len && data, return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 280 | |
| 281 | if (trunc && (datalen > trunc)) { |
| 282 | datalen = trunc; |
| 283 | truncated = 1; |
| 284 | } |
| 285 | |
| 286 | towrite = datalen * 2; |
| 287 | |
| 288 | if (wrap) |
| 289 | towrite += datalen / wrap; /* add 1 '\n' every wrap byte */ |
| 290 | |
| 291 | if (truncated) |
| 292 | towrite += CONSTSTRLENcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:737:9`!(TRUNK_MARKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/log.c:277:9`!); |
| 293 | |
| 294 | |
| 295 | if (offset) |
| 296 | o = *offset; |
| 297 | |
| 298 | if (*buf == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 299 | /* Directly allocate the size we need */ |
| 300 | *len = (((towrite + o) / mempagesz) + 1 ) * mempagesz; |
| 301 | CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(*buf = malloc(*len), return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 302 | } else if ((towrite + o) >= *len) { |
| 303 | /* There is no room in the buffer, we extend and redo */ |
| 304 | size_t new_len = (((towrite + o) / mempagesz) + 1) * mempagesz; |
| 305 | CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!(*buf = realloc(*buf, new_len), return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 306 | *len = new_len; |
| 307 | } |
| 308 | |
| 309 | p = *buf + o; |
| 310 | for (i = 0; i < datalen; i++) { |
| 311 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(p, "%02hhX", data[i]); |
| 312 | p+=2; |
| 313 | if ((wrap) && ((i+1) % wrap == 0)) { |
| 314 | *p++='\n'; *p ='\0'; /* we want to ensure the buffer is always 0-terminated */ |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | if (truncated) |
| 319 | memcpycxx . . $ memcpy(cc817cb175f282d).(p, TRUNK_MARKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/log.c:277:9`!, CONSTSTRLENcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:737:9`!(TRUNK_MARKcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/log.c:277:9`!)); |
| 320 | |
| 321 | if (offset) |
| 322 | *offset += towrite; |
| 323 | |
| 324 | return *buf; |
| 325 | } |