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#ifndef SURICATA_UTIL_PRINT_H
25#define SURICATA_UTIL_PRINT_H
26
27#define PrintBufferData(buf, buf_offset_ptr, buf_size, ...) do { \
28 int cw = snprintf((buf) + *(buf_offset_ptr), \
29 (buf_size) - *(buf_offset_ptr), \
30 __VA_ARGS__); \
31 if (cw >= 0) { \
32 if ( (*(buf_offset_ptr) + cw) >= buf_size) { \
33 SCLogDebug("Truncating data write since it exceeded buffer " \
34 "limit of - %"PRIu32"\n", buf_size); \
35 *(buf_offset_ptr) = buf_size - 1; \
36 } else { \
37 *(buf_offset_ptr) += cw; \
38 } \
39 } \
40 } while (0)
41
42void PrintBufferRawLineHex(char *, int *,int, const uint8_t *, uint32_t);
43void PrintRawUriFp(FILE *, const uint8_t *, uint32_t);
44void PrintRawUriBuf(char *, uint32_t *, uint32_t, const uint8_t *, size_t);
45void PrintRawDataFp(FILE *, const uint8_t *, uint32_t);
46void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
47 const uint8_t *src_buf, uint32_t src_buf_len);
48void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
49 const uint8_t *src_buf, const uint32_t src_buf_len);
50void PrintRawLineHexBuf(char *, uint32_t, const uint8_t *, uint32_t );
51const char *PrintInet(int , const void *, char *, socklen_t);
52void PrintHexString(char *str, size_t size, uint8_t *buf, size_t buf_len);
53
54#endif /* SURICATA_UTIL_PRINT_H */
#define str(s)
void PrintRawLineHexBuf(char *, uint32_t, const uint8_t *, uint32_t)
print a buffer as hex on a single line into retbuf buffer
Definition util-print.c:61
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:149
void PrintRawUriBuf(char *, uint32_t *, uint32_t, const uint8_t *, size_t)
Definition util-print.c:93
void PrintRawUriFp(FILE *, const uint8_t *, uint32_t)
Definition util-print.c:69
const char * PrintInet(int, const void *, char *, socklen_t)
Definition util-print.c:231
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:195
void PrintBufferRawLineHex(char *, int *, int, const uint8_t *, uint32_t)
print a buffer as hex on a single line
Definition util-print.c:44
void PrintRawDataFp(FILE *, const uint8_t *, uint32_t)
Definition util-print.c:112
void PrintHexString(char *str, size_t size, uint8_t *buf, size_t buf_len)
Definition util-print.c:255