1 /* @include ajfmt *************************************************************
2 **
3 ** AJAX format functions
4 **
5 ** String formatting routines. Similar to printf, fprintf, vprintf
6 ** etc but the set of conversion specifiers is not fixed, and cannot
7 ** store more characters than it can hold.
8 ** There is also ajFmtScanS / ajFmtScanC which is an extended sscanf.
9 **
10 ** Special formatting provided here:
11 **   %B : AJAX boolean
12 **   %D : AJAX date
13 **   %S : AJAX string
14 **   %z : Dynamic char* allocation in ajFmtScanS
15 **
16 ** Other differences are:
17 **   %s : accepts null strings and prints null in angle brackets
18 **
19 ** @author Copyright (C) 1998 Ian Longden
20 ** @author Copyright (C) 1998 Peter Rice
21 ** @author Copyright (C) 1999 Alan Bleasby
22 ** @version $Revision: 1.22 $
23 ** @modified Copyright (C) 2001 Alan Bleasby. Added ajFmtScanS functions
24 ** @modified Copyright (C) 2003 Jon Ison. Added ajFmtScanC functions
25 ** @modified $Date: 2012/03/22 21:19:08 $ by $Author: mks $
26 ** @@
27 **
28 ** This library is free software; you can redistribute it and/or
29 ** modify it under the terms of the GNU Lesser General Public
30 ** License as published by the Free Software Foundation; either
31 ** version 2.1 of the License, or (at your option) any later version.
32 **
33 ** This library is distributed in the hope that it will be useful,
34 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36 ** Lesser General Public License for more details.
37 **
38 ** You should have received a copy of the GNU Lesser General Public
39 ** License along with this library; if not, write to the Free Software
40 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
41 ** MA  02110-1301,  USA.
42 **
43 ******************************************************************************/
44 
45 #ifndef AJFMT_H
46 #define AJFMT_H
47 
48 /* ========================================================================= */
49 /* ============================= include files ============================= */
50 /* ========================================================================= */
51 
52 #include "ajdefine.h"
53 #include "ajfile.h"
54 #include "ajstr.h"
55 
56 #include <stdarg.h>
57 
58 AJ_BEGIN_DECLS
59 
60 
61 
62 
63 /* ========================================================================= */
64 /* =============================== constants =============================== */
65 /* ========================================================================= */
66 
67 
68 
69 
70 /* ========================================================================= */
71 /* ============================== public data ============================== */
72 /* ========================================================================= */
73 
74 
75 
76 
77 /* ========================================================================= */
78 /* =========================== public functions ============================ */
79 /* ========================================================================= */
80 
81 
82 
83 
84 /*
85 ** Prototype definitions
86 */
87 
88 void   ajFmtFmt(int (*put) (int c, void *cl), void *cl,
89                 const char *fmt, ...);
90 void   ajFmtVfmt(int (*put) (int c, void *cl), void *cl,
91                  const char *fmt, va_list ap);
92 void   ajFmtError(const char *fmt, ...);
93 void   ajFmtVError(const char *fmt, va_list ap);
94 void   ajFmtPrint(const char *fmt, ...);
95 void   ajFmtVPrint(const char *fmt, va_list ap);
96 void   ajFmtPrintFp(FILE *stream,
97                     const char *fmt, ...);
98 void   ajFmtVPrintFp(FILE *stream,
99                      const char *fmt, va_list ap);
100 void   ajFmtPrintF(AjPFile file,
101                    const char *fmt, ...);
102 void   ajFmtVPrintF(AjPFile file,
103                     const char *fmt, va_list ap);
104 ajint  ajFmtPrintCL(char *buf, ajint size,
105                     const char *fmt, ...);
106 ajint  ajFmtVPrintCL(char *buf, ajint size,
107                      const char *fmt, va_list ap);
108 void   ajFmtPrintSplit(AjPFile outf, const AjPStr str,
109                        const char *prefix, ajint len,
110                        const char *delim);
111 char*  ajFmtString(const char *fmt, ...);
112 char*  ajFmtVString(const char *fmt, va_list ap);
113 void   ajFmtPutd(const char *str, ajint len,
114                  int (*put) (int c, void *cl), void *cl,
115                  const ajuint *flags, ajint width, ajint precision);
116 void   ajFmtPuts(const char *str, ajint len,
117                  int (*put) (int c, void *cl), void *cl,
118                  const ajuint *flags, ajint width, ajint precision);
119 AjPStr ajFmtStr(const char *fmt, ...);
120 AjPStr ajFmtPrintS(AjPStr *pthis, const char *fmt, ...);
121 AjPStr ajFmtVPrintS(AjPStr *pthis, const char *fmt, va_list ap);
122 AjPStr ajFmtPrintAppS(AjPStr *pthis, const char *fmt, ...);
123 ajint  ajFmtVfmtCL(char *buf, ajint size, const char *fmt,
124                    va_list ap);
125 ajint  ajFmtVfmtStrCL(char **buf, ajint pos, size_t *size,
126                       const char *fmt, va_list ap);
127 
128 ajint  ajFmtScanS(const AjPStr thys, const char *fmt, ...);
129 ajint  ajFmtScanC(const char *thys, const char *fmt, ...);
130 ajint  ajFmtScanF(AjPFile thys, const char *fmt, ...);
131 
132 /*
133 ** End of prototype definitions
134 */
135 
136 
137 
138 
139 AJ_END_DECLS
140 
141 #endif /* !AJFMT_H */
142