0001 TPLOGDUMPDIFF(3)
0002 ================
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tplogdumpdiff - print the hex-dump differences of two buffers to log file
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <ndebug.h>
0014
0015 void tplogdumpdiff(int 'lev', char *'comment', void *'ptr1', void *'ptr2', int 'len');
0016
0017 or
0018
0019 #define TP_DUMP_DIFF('lev','comment','ptr','ptr2','len')
0020
0021 Link with '-lnstd -lpthread -lrt -lm'
0022
0023 DESCRIPTION
0024 -----------
0025 Function compares two memory areas by given pointers 'ptr' and 'ptr2'. The hex dump is generate and
0026 output is written to current logger (either process based, thread based or request based). The
0027 *tplogdumpdiff()* basically is wrapper for *TP_LOGDUMP_DIFF*. For C/C++ programs it is recommended
0028 to use macro version. 'lev' is debug level from 1 (log_always) .. 5 (log_debug). Comment is title line of
0029 the dump. 'ptr' and 'ptr2' are pointer to memory blocks to compare. 'len' is number of bytes in each array to compare.
0030
0031 Log levels are following (from ndebug.h):
0032
0033 - log_always 1
0034
0035 - log_error 2
0036
0037 - log_warn 3
0038
0039 - log_info 4
0040
0041 - log_debug 5
0042
0043
0044
0045 RETURN VALUE
0046 ------------
0047 N/A
0048
0049 ERRORS
0050 ------
0051 N/A
0052
0053 EXAMPLE
0054 -------
0055
0056 Code dumpdifftest.c
0057
0058 ---------------------------------------------------------------------
0059 #include <ndebug.h>
0060
0061 int main (int argc, char **argv)
0062 {
0063 char arr1[32];
0064 char arr2[32];
0065 int i;
0066
0067 for (i=0; i<sizeof(arr1); i++)
0068 {
0069 arr1[i]=(char)(65+i);
0070 arr2[i]=(char)(66+i);
0071 }
0072
0073 tplogdumpdiff(log_debug, "Compare two arrays", arr1, arr2, sizeof(arr1));
0074
0075 TP_DUMP_DIFF(5, "Compare two arrays (TP_DUMP version)", arr1, arr2, sizeof(arr1));
0076
0077 return 0;
0078 }
0079 ---------------------------------------------------------------------
0080
0081 Sample run:
0082 ---------------------------------------------------------------------
0083 $ cc dumpdifftest.c -lnstd -lpthread -lrt -lm -I /include
0084 $ ./a.out
0085 t:USER:5:10865:000:20160928:095506583:/tplog.c:0437:Compare two arrays
0086 < 0000 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 ABCDEFGHIJKLMNOP
0087 > 0000 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 BCDEFGHIJKLMNOPQ
0088 < 0010 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 QRSTUVWXYZ[\]^_`
0089 > 0010 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 RSTUVWXYZ[\]^_`a
0090 t:USER:5:10865:000:20160928:095506583:mpdiff.c:0017:Compare two arrays (TP_DUMP version)
0091 < 0000 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 ABCDEFGHIJKLMNOP
0092 > 0000 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 BCDEFGHIJKLMNOPQ
0093 < 0010 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 QRSTUVWXYZ[\]^_`
0094 > 0010 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 RSTUVWXYZ[\]^_`a
0095 ---------------------------------------------------------------------
0096
0097 BUGS
0098 ----
0099 Report bugs to support@mavimax.com
0100
0101 SEE ALSO
0102 --------
0103 *tplogdump(3)* *tplog(3)* *tplogprintubf(3)* *tplogconfig(3)* *tplogsetreqfile_direct(3)* *tplogsetreqfile(3)* *ex_devguide(guides)*
0104
0105 COPYING
0106 -------
0107 (C) Mavimax, Ltd
0108