1 /*
2  * Header file for string appending functions.
3  *
4  * Copyright 2020 by Gray Watson
5  *
6  * This file is part of the dmalloc package.
7  *
8  * Permission to use, copy, modify, and distribute this software for
9  * any purpose and without fee is hereby granted, provided that the
10  * above copyright notice and this permission notice appear in all
11  * copies, and that the name of Gray Watson not be used in advertising
12  * or publicity pertaining to distribution of the document or software
13  * without specific, written prior permission.
14  *
15  * Gray Watson makes no representations about the suitability of the
16  * software described herein for any purpose.  It is provided "as is"
17  * without express or implied warranty.
18  *
19  * The author may be contacted via http://dmalloc.com/
20  */
21 
22 #ifndef __APPENDER_H__
23 #define __APPENDER_H__
24 
25 #if HAVE_STDARG_H
26 # include <stdarg.h>				/* for ... */
27 #endif
28 #if HAVE_STDIO_H
29 # include <stdio.h>				/* for FILE */
30 #endif
31 
32 #include "conf.h"
33 
34 /*<<<<<<<<<<  The below prototypes are auto-generated by fillproto */
35 
36 /*
37  * Append string argument to destination up to limit pointer.  Pointer
38  * to the end of the characters added will be returned.  No \0
39  * character will be added.
40  */
41 extern
42 char	*append_string(char *dest, const char *limit, const char *value);
43 
44 /*
45  * Append long value argument to destination up to limit pointer.
46  * Pointer to the end of the added characters will be returned.  No \0
47  * character will be added.  Variant of itoa() written by Lukas
48  * Chmela which is released under GPLv3.
49  */
50 extern
51 char	*append_long(char *dest, char *limit, long value, int base);
52 
53 /*
54  * Append unsigned long value argument to destination up to limit
55  * pointer.  Pointer to the end of the added characters will be
56  * returned.  No \0 character will be added.  Variant of itoa()
57  * written by Lukas Chmela. Released under GPLv3.
58  */
59 extern
60 char	*append_ulong(char *dest, char *limit, unsigned long value, int base);
61 
62 /*
63  * Append pointer value argument to destination up to limit pointer.
64  * Pointer to the end of the added characters will be returned.  No \0
65  * character will be added.  Variant of itoa() written by Lukas
66  * Chmela which is released under GPLv3.
67  */
68 extern
69 char	*append_pointer(char *dest, char *limit, PNT_ARITH_TYPE value, int base);
70 
71 /*
72  * Append a varargs format to destination.  Pointer to the end of the
73  * characters added will be returned.  No \0 character will be added.
74  */
75 extern
76 char	*append_vformat(char *dest, char *limit, const char *format,
77 			va_list args);
78 
79 /*
80  * Append a varargs format to destination.  Pointer to the end of the
81  * added characters will be returned.  No \0 character will be added.
82  */
83 extern
84 char	*append_format(char *dest, char *limit, const char *format, ...);
85 
86 /*
87  * Append \0 character to destination.  If dest is => limit then \0
88  * will be written one character before the limit.  Pointer past the
89  * end of the \0 character will be returned.
90  */
91 extern
92 char    *append_null(char *dest, char *limit);
93 
94 /*
95  * Local implementation of snprintf.  We are doing this trying to not
96  * use the system version which often can allocate memory itself
97  * causing the library to go recursive.
98  */
99 extern
100 int	loc_vsnprintf(char *buf, const int size, const char *format,
101 		      va_list args);
102 
103 /*
104  * Local implementation of snprintf.  We are doing this trying to not
105  * use the system version which often can allocate memory itself
106  * causing the library to go recursive.
107  */
108 extern
109 int	loc_snprintf(char *buf, const int size, const char *format, ...);
110 
111 /*
112  * Local implementation of printf so we can use %p and other non-standard formats.
113  */
114 extern
115 void	loc_printf(const char *format, ...);
116 
117 /*
118  * Local implementation of fprintf so we can use %p and other non-standard formats.
119  */
120 extern
121 void	loc_fprintf(FILE *file, const char *format, ...);
122 
123 /*
124  * Local implementation of vfprintf so we can use %p and other non-standard formats.
125  */
126 extern
127 void	loc_vfprintf(FILE *file, const char *format, va_list args);
128 
129 /*<<<<<<<<<<   This is end of the auto-generated output from fillproto. */
130 
131 #endif /* ! __APPENDER_H__ */
132