suricata
util-print.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  */
23 
24 
25 
26 #ifndef __UTIL_PRINT_H__
27 #define __UTIL_PRINT_H__
28 
29 #define PrintBufferData(buf, buf_offset_ptr, buf_size, ...) do { \
30  int cw = snprintf((buf) + *(buf_offset_ptr), \
31  (buf_size) - *(buf_offset_ptr), \
32  __VA_ARGS__); \
33  if (cw >= 0) { \
34  if ( (*(buf_offset_ptr) + cw) >= buf_size) { \
35  SCLogDebug("Truncating data write since it exceeded buffer " \
36  "limit of - %"PRIu32"\n", buf_size); \
37  *(buf_offset_ptr) = buf_size - 1; \
38  } else { \
39  *(buf_offset_ptr) += cw; \
40  } \
41  } \
42  } while (0)
43 
44 void PrintBufferRawLineHex(char *, int *,int, uint8_t *, uint32_t);
45 void PrintRawUriFp(FILE *, uint8_t *, uint32_t);
46 void PrintRawUriBuf(char *, uint32_t *, uint32_t,
47  uint8_t *, uint32_t);
48 void PrintRawJsonFp(FILE *, uint8_t *, uint32_t);
49 void PrintRawDataFp(FILE *, const uint8_t *, uint32_t);
50 void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
51  const uint8_t *src_buf, uint32_t src_buf_len);
52 void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
53  const uint8_t *src_buf, const uint32_t src_buf_len);
54 void PrintRawLineHexBuf(char *, uint32_t, uint8_t *, uint32_t );
55 const char *PrintInet(int , const void *, char *, socklen_t);
56 
57 #endif /* __UTIL_PRINT_H__ */
58 
void PrintRawUriFp(FILE *, uint8_t *, uint32_t)
Definition: util-print.c:93
void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len)
Definition: util-print.c:224
void PrintRawDataFp(FILE *, const uint8_t *, uint32_t)
Definition: util-print.c:141
void PrintRawUriBuf(char *, uint32_t *, uint32_t, uint8_t *, uint32_t)
Definition: util-print.c:118
void PrintRawJsonFp(FILE *, uint8_t *, uint32_t)
Definition: util-print.c:71
void PrintRawLineHexBuf(char *, uint32_t, uint8_t *, uint32_t)
print a buffer as hex on a single line in to retbuf buffer
Definition: util-print.c:61
const char * PrintInet(int, const void *, char *, socklen_t)
Definition: util-print.c:267
void PrintBufferRawLineHex(char *, int *, int, uint8_t *, uint32_t)
print a buffer as hex on a single line
Definition: util-print.c:42
void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, uint32_t src_buf_len)
Definition: util-print.c:175