1 /*************************************************************************
3 * $Id: doc.h,v 1.20 2006/08/18 11:32:08 breese Exp $
5 * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
16 ************************************************************************/
22 @author Daniel Stenberg
24 @section intro Introduction
26 Trio is a fully matured and stable set of printf and string functions
27 designed be used by applications with focus on portability or with the
28 need for additional features that are not supported by standard stdio
31 There are several cases where you may want to consider using trio:
33 @li Portability across heterogeneous platforms.
34 @li Embedded systems without stdio support.
35 @li Extendability of unsupported features.
36 @li Your native version does not do everything you need.
38 When you write applications that must be portable to a wide range of
39 platforms you often have to deal with inadequate implementations of the
40 stdio library functions. Most notably is the lack of secure formatting
41 functions, such as snprintf, or the lack of parameter reordering commonly
42 used for the internationalization of applications, such as the <num>$
43 modifier. Sometimes the feature you need is simply not present in stdio.
44 So you end up spending much effort on determining which platforms supports
45 what, and to write your own versions of various features. This is where
46 trio can help you. Trio is a platform-independent implementation of the
47 stdio printf and scanf functions and the string library functions.
49 The functionality described in the stdio standards is a compromise, and
50 does unfortunately not include a mechanism to extend the functionality for
51 an individual application. Oftentimes an application has the need for an
52 extra feature, and the application code can become much more clear and
53 readable by using an extension mechanism. Trio supports a range of useful
54 extensions such as user-defined specifiers, passing of arguments in arrays,
55 localized string scanning, thousand-separators, and arbitrary integer bases.
57 Trio fully implements the C99 (ISO/IEC 9899:1999) and UNIX98 (the Single
58 Unix Specification, Version 2) standards, as well as many features from
59 other implemenations, e.g. the GNU libc and BSD4.
61 @section examples Examples
63 @subsection ex1 Binary Numbers
64 Output an integer as a binary number using a trio extension.
66 trio_printf("%..2i\n", number);
69 @subsection ex2 Thousand-separator
70 Output a number with thousand-separator using a trio extension.
72 trio_printf("%'f\n", 12345.6);
74 The thousand-separator described by the locale is used.
76 @subsection ex3 Fixed Length Array and Sticky Modifier
77 Output an fixed length array of floating-point numbers.
79 double array[] = {1.0, 2.0, 3.0};
80 printf("%.2f %.2f %.2f\n", array[0], array[1], array[2]);
82 The same with two trio extensions (arguments are passed in an array, and
83 the first formatting specifier sets the sticky option so we do not have
84 to type all the formatting modifiers for the remaining formatting specifiers)
86 trio_printfv("%!.2f %f %f\n", array);
88 Another, and more powerful, application of being able to pass arguments in
89 an array is the creation of the printf/scanf statement at run-time, where
90 the formatting string, and thus the argument list, is based on an external
93 @subsection ex4 Localized scanning
94 Parse a string consisting of one or more upper-case alphabetic characters
95 followed by one or more numeric characters.
97 sscanf(buffer, "%[A-Z]%[0-9]", alphabetic, numeric);
99 The same but with locale using a trio extension.
101 trio_sscanf(buffer, "%[[:upper:]]%[[:digit:]]", alphabetic, numeric);
104 @section legal Legal Issues
105 Trio is distributed under the following license, which allows practically
106 anybody to use it in almost any kind of software, including proprietary
107 software, without difficulty.
109 "Copyright (C) 1998-2001 Bjorn Reese and Daniel Stenberg.
111 Permission to use, copy, modify, and distribute this software for any
112 purpose with or without fee is hereby granted, provided that the above
113 copyright notice and this permission notice appear in all copies.
115 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
116 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
117 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
118 CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER."
120 @section contribution Contribution
122 @subsection contribute Contribute
123 We appreciate any type of contribution, from ideas over improvements to
126 The project space contains references to bug and feature tracking,
127 mailing-list, and the CVS repository. We prefer communication via the
128 mailing-list, but do not require you to be subscribed, because trio is a
131 The project space is located at http://sourceforge.net/projects/ctrio/
133 @subsection contributors Contributors
134 We have received contributions from the following persons (in alphabetic
135 order sorted by surname)
146 @li John Fotheringham
154 @li Rune Enggaard Lausen
156 @li Alexander Lukyanov
170 Please let us know, and accept our apology, if we have omitted anybody.