1 \input texinfo @c -*-texinfo-*-
2 @comment $Id: gnulib.texi,v 1.1 2004-09-19 13:17:06 karl Exp $
3 @comment %**start of header
4 @setfilename gnulib.info
8 @comment %**end of header
10 @set UPDATED $Date: 2004-09-19 13:17:06 $
13 This manual is for GNU Gnulib (updated @value{UPDATED}),
14 which is a library of common routines intended to be shared at the
17 Copyright @copyright{} 2004 Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.1 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
24 and with the Back-Cover Texts as in (a) below. A copy of the
25 license is included in the section entitled ``GNU Free Documentation
28 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
29 this GNU Manual, like GNU software. Copies published by the Free
30 Software Foundation raise funds for GNU development.''
34 @dircategory Software development
36 * gnulib: (gnulib). Source files to share among distributions.
41 @subtitle updated @value{UPDATED}
42 @author @email{bug-gnulib@@gnu.org}
44 @vskip 0pt plus 1filll
59 * Invoking gnulib-tool::
60 * Copying This Manual::
68 This is not a real manual. It's just a place to store random notes
69 until someone (you?) gets around to actually writing a manual.
74 @item Gnulib is hosted at Savannah:
75 @url{http://savannah.gnu.org/projects/gnulib}. Get the sources
76 through CVS from there.
77 @item The Gnulib home page:
78 @url{http://www.gnu.org/software/gnulib/}.
85 * Out of memory handling::
91 @cindex comments describing functions
92 @cindex describing functions, locating
93 Where to put comments describing functions: Because of risk of
94 divergence, we prefer to keep most function describing comments in
95 only one place: just above the actual function definition. Some
96 people prefer to put that documentation in the .h file. In any case,
97 it should appear in just one place unless you can ensure that the
98 multiple copies will always remain identical.
105 The @code{ctime} function need not be reentrant, and consequently is
106 not required to be thread safe. Implementations of @code{ctime}
107 typically write the time stamp into static buffer. If two threads
108 call @code{ctime} at roughly the same time, you might end up with the
109 wrong date in one of the threads, or some undefined string. There is
110 a re-entrant interface @code{ctime_r}, that take a pre-allocated
111 buffer and length of the buffer, and return @code{NULL} on errors.
112 The input buffer should be at least 26 bytes in size. The output
113 string is locale-independent. However, years can have more than 4
114 digits if @code{time_t} is sufficiently wide, so the length of the
115 required output buffer is not easy to determine. Increasing the
116 buffer size when @code{ctime_r} return @code{NULL} is not necessarily
117 sufficient. The @code{NULL} return value could mean some other error
118 condition, which will not go away by increasing the buffer size.
120 A more flexible function is @code{strftime}. However, note that it is
128 The @code{inet_ntoa} function need not be reentrant, and consequently
129 is not required to be thread safe. Implementations of
130 @code{inet_ntoa} typically write the time stamp into static buffer.
131 If two threads call @code{inet_ntoa} at roughly the same time, you
132 might end up with the wrong date in one of the threads, or some
133 undefined string. Further, @code{inet_ntoa} is specific for
134 @acronym{IPv4} addresses.
136 A protocol independent function is @code{inet_ntop}.
139 @node Out of memory handling
140 @section Out of memory handling
142 @cindex Out of Memory handling
143 @cindex Memory allocation failure
144 The GSS API does not have a standard error code for the out of memory
145 error condition. Instead of adding a non-standard error code, this
146 library has chosen to adopt a different strategy. Out of memory
147 handling happens in rare situations, but performing the out of memory
148 error handling after almost all API function invocations pollute your
149 source code and might make it harder to spot more serious problems.
150 The strategy chosen improve code readability and robustness.
152 @cindex Aborting execution
153 For most applications, aborting the application with an error message
154 when the out of memory situation occur is the best that can be wished
155 for. This is how the library behaves by default.
157 @vindex xalloc_fail_func
158 However, we realize that some applications may not want to have the
159 GSS library abort execution in any situation. The GSS library support
160 a hook to let the application regain control and perform its own
161 cleanups when an out of memory situation has occured. The application
162 can define a function (having a @code{void} prototype, i.e., no return
163 value and no parameters) and set the library variable
164 @code{xalloc_fail_func} to that function. The variable should be
168 extern void (*xalloc_fail_func) (void);
171 The GSS library will invoke this function if an out of memory error
172 occurs. Note that after this the GSS library is in an undefined
173 state, so you must unload or restart the application to continue call
174 GSS library functions. The hook is only intended to allow the
175 application to log the situation in a special way. Of course, care
176 must be taken to not allocate more memory, as that will likely also
180 @node Invoking gnulib-tool
181 @chapter Invoking gnulib-tool
184 @cindex invoking @command{gnulib-tool}
186 Run @samp{gnulib-tool --help}, and use the source.
187 @command{gnulib-tool} is the way to import Gnulib modules.
190 @node Copying This Manual
191 @appendix Copying This Manual
194 * GNU Free Documentation License:: License for copying this manual.