Upx_Doxygen
https://github.com/upx/upx
All Classes
snprintf.h
1 /* snprintf.h --
2 
3  This file is part of the UPX executable compressor.
4 
5  Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer
6  Copyright (C) 1996-2016 Laszlo Molnar
7  All Rights Reserved.
8 
9  UPX and the UCL library are free software; you can redistribute them
10  and/or modify them under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of
12  the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING.
21  If not, write to the Free Software Foundation, Inc.,
22  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24  Markus F.X.J. Oberhumer Laszlo Molnar
25  <markus@oberhumer.com> <ezerotven+github@gmail.com>
26  */
27 
28 #ifndef __UPX_SNPRINTF_H
29 #define __UPX_SNPRINTF_H 1
30 
31 /*************************************************************************
32 //
33 **************************************************************************/
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 // info: snprintf() returns length and NOT size, but max_size is indeed size (incl NUL)
40 int upx_vsnprintf(char *str, upx_rsize_t max_size, const char *format, va_list ap);
41 int __acc_cdecl_va upx_snprintf (char *str, upx_rsize_t max_size, const char *format, ...);
42 int upx_vasprintf(char **ptr, const char *format, va_list ap);
43 int __acc_cdecl_va upx_asprintf (char **ptr, const char *format, ...);
44 
45 upx_rsize_t upx_strlen(const char *);
46 
47 #ifdef __cplusplus
48 }
49 #endif
50 
51 // globally redirect some functions
52 #undef sprintf
53 #define sprintf error_sprintf_is_dangerous_use_snprintf
54 #undef strlen
55 #define strlen upx_strlen
56 
57 /*************************************************************************
58 // some unsigned char string support functions
59 **************************************************************************/
60 
61 inline unsigned char *strcpy(unsigned char *s1, const unsigned char *s2) {
62  return (unsigned char *) strcpy((char *) s1, (const char *) s2);
63 }
64 
65 inline int strcmp(const unsigned char *s1, const unsigned char *s2) {
66  return strcmp((const char *) s1, (const char *) s2);
67 }
68 
69 inline int strcasecmp(const unsigned char *s1, const unsigned char *s2) {
70  return strcasecmp((const char *) s1, (const char *) s2);
71 }
72 
73 inline size_t strlen(const unsigned char *s) { return strlen((const char *) s); }
74 
75 #endif /* already included */
76 
77 /* vim:set ts=4 sw=4 et: */