* lib/quotearg.c: Include <wctype.h> early, before the definition of
[gnulib.git] / doc / gnulib.texi
index b3b09dc..683bc94 100644 (file)
@@ -1,5 +1,5 @@
 \input texinfo   @c -*-texinfo-*-
-@comment $Id: gnulib.texi,v 1.15 2005-07-30 13:47:19 karl Exp $
+@comment $Id: gnulib.texi,v 1.33 2007-03-15 22:58:36 eggert Exp $
 @comment %**start of header
 @setfilename gnulib.info
 @settitle GNU Gnulib
@@ -7,28 +7,21 @@
 @syncodeindex pg cp
 @comment %**end of header
 
-@set UPDATED $Date: 2005-07-30 13:47:19 $
+@set UPDATED $Date: 2007-03-15 22:58:36 $
 
 @copying
 This manual is for GNU Gnulib (updated @value{UPDATED}),
 which is a library of common routines intended to be shared at the
 source level.
 
-Copyright @copyright{} 2004, 2005 Free Software Foundation, Inc.
+Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
-@quotation
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.1 or
 any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
-and with the Back-Cover Texts as in (a) below.  A copy of the
-license is included in the section entitled ``GNU Free Documentation
-License.''
-
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software.  Copies published by the Free
-Software Foundation raise funds for GNU development.''
-@end quotation
+Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+Texts.  A copy of the license is included in the section entitled
+``GNU Free Documentation License.''
 @end copying
 
 @dircategory Software development
@@ -55,21 +48,22 @@ Software Foundation raise funds for GNU development.''
 @end ifnottex
 
 @menu
-* Gnulib::
+* Introduction::
 * Invoking gnulib-tool::
+* Miscellaneous Notes::
+* Particular Modules::          Documentation of Individual Modules
 * Copying This Manual::
 * Index::
 @end menu
 
+@node Introduction
+@chapter Introduction
 
-@node Gnulib
-@chapter Gnulib
+Gnulib is a source code library. It provides basic functionalities to
+programs and libraries.  Currently (as of October 2006) more than 30
+packages make use of Gnulib.
 
-This manual contains some bare-bones documentation, but not much more.
-It's mostly been a place to store notes until someone (you?)@ gets
-around to writing a coherent manual.
-
-Getting started:
+Resources:
 
 @itemize
 @item Gnulib is hosted at Savannah:
@@ -80,14 +74,34 @@ Getting started:
 @end itemize
 
 @menu
+* Library vs. Reusable Code::
+* Portability and Application Code::
+* Modules::
+* Various Kinds of Modules::
+* Collaborative Development::
+* Copyright::
+* Steady Development::
+* Openness::
+@end menu
+
+@include gnulib-intro.texi
+
+
+@include gnulib-tool.texi
+
+
+@node Miscellaneous Notes
+@chapter Miscellaneous Notes
+
+@menu
 * Comments::
 * Header files::
-* Quoting::
-* ctime::
-* inet_ntoa::
 * Out of memory handling::
 * Library version handling::
-* Regular expressions::
+* Windows sockets::
+* Libtool and Windows::
+* License Texinfo sources::
+* Build robot for gnulib::
 @end menu
 
 
@@ -177,81 +191,6 @@ arbitrary order.
 @end itemize
 
 
-@node Quoting
-@section Quoting
-
-@cindex Quoting
-@findex quote
-@findex quotearg
-
-Gnulib provides @samp{quote} and @samp{quotearg} modules to help with
-quoting text, such as file names, in messages to the user.  Here's an
-example of using @samp{quote}:
-
-@example
-#include <quote.h>
- ...
-  error (0, errno, _("cannot change owner of %s"), quote (fname));
-@end example
-
-This differs from
-
-@example
-  error (0, errno, _("cannot change owner of `%s'"), fname);
-@end example
-
-@noindent in that @code{quote} escapes unusual characters in
-@code{fname}, e.g., @samp{'} and control characters like @samp{\n}.
-
-@findex quote_n
-However, a caveat: @code{quote} reuses the storage that it returns.
-Hence if you need more than one thing quoted at the same time, you
-need to use @code{quote_n}.
-
-@findex quotearg_alloc
-Also, the quote module is not suited for multithreaded applications.
-In that case, you have to use @code{quotearg_alloc}, defined in the
-@samp{quotearg} module, which is decidedly less convenient.
-
-
-@node ctime
-@section ctime
-@findex ctime
-
-The @code{ctime} function need not be reentrant, and consequently is
-not required to be thread safe.  Implementations of @code{ctime}
-typically write the time stamp into static buffer.  If two threads
-call @code{ctime} at roughly the same time, you might end up with the
-wrong date in one of the threads, or some undefined string.  There is
-a re-entrant interface @code{ctime_r}, that take a pre-allocated
-buffer and length of the buffer, and return @code{NULL} on errors.
-The input buffer should be at least 26 bytes in size.  The output
-string is locale-independent.  However, years can have more than 4
-digits if @code{time_t} is sufficiently wide, so the length of the
-required output buffer is not easy to determine.  Increasing the
-buffer size when @code{ctime_r} return @code{NULL} is not necessarily
-sufficient. The @code{NULL} return value could mean some other error
-condition, which will not go away by increasing the buffer size.
-
-A more flexible function is @code{strftime}.  However, note that it is
-locale dependent.
-
-
-@node inet_ntoa
-@section inet_ntoa
-@findex inet_ntoa
-
-The @code{inet_ntoa} function need not be reentrant, and consequently
-is not required to be thread safe.  Implementations of
-@code{inet_ntoa} typically write the time stamp into static buffer.
-If two threads call @code{inet_ntoa} at roughly the same time, you
-might end up with the wrong date in one of the threads, or some
-undefined string.  Further, @code{inet_ntoa} is specific for
-@acronym{IPv4} addresses.
-
-A protocol independent function is @code{inet_ntop}.
-
-
 @node Out of memory handling
 @section Out of memory handling
 
@@ -274,7 +213,7 @@ for.  This is how the library behaves by default.
 However, we realize that some applications may not want to have the
 GSS library abort execution in any situation.  The GSS library support
 a hook to let the application regain control and perform its own
-cleanups when an out of memory situation has occured.  The application
+cleanups when an out of memory situation has occurred.  The application
 can define a function (having a @code{void} prototype, i.e., no return
 value and no parameters) and set the library variable
 @code{xalloc_fail_func} to that function.  The variable should be
@@ -312,7 +251,8 @@ To avoid ELF symbol collisions with other libraries that use the
 AC_DEFINE something like:
 
 @example
-AC_DEFINE(check_version, stringprep_check_version, [Rename check_version.])
+AC_DEFINE(check_version, stringprep_check_version,
+          [Rename check_version.])
 @end example
 
 The @code{stringprep_check_version} function will thus be implemented
@@ -347,281 +287,161 @@ Typical uses look like:
 @end example
 
 
-@node Regular expressions
-@section Regular expressions
+@node Windows sockets
+@section Windows sockets
 
-Gnulib supports many different types of regular expressions; although
-the underlying features are the same or identical, the syntax used
-varies.  The descriptions given here for the different types are
-generated automatically.
+There are several issues when building applications that should work
+under Windows.  The most problematic part is for applications that use
+sockets.
 
-@include regexprops-generic.texi
+Hopefully, we can add helpful notes to this section that will help you
+port your application to Windows using gnulib.
 
+@subsection Getaddrinfo and WINVER
 
-@node Invoking gnulib-tool
-@chapter Invoking gnulib-tool
+This was written for the getaddrinfo module, but may be applicable to
+other functions too.
 
-@pindex gnulib-tool
-@cindex invoking @command{gnulib-tool}
+The getaddrinfo function exists in ws2tcpip.h and -lws2_32 on Windows
+XP.  The function declaration is present if @code{WINVER >= 0x0501}.
+Windows 2000 does not have getaddrinfo in its @file{WS2_32.dll}.
 
-Run @samp{gnulib-tool --help}, and use the source.
-@command{gnulib-tool} is the way to import Gnulib modules.
+Thus, if you want to assume Windows XP or later, you can add
+AC_DEFINE(WINVER, 0x0501) to avoid compiling to (partial) getaddrinfo
+implementation.
 
-@menu
-* Initial import::              First import of Gnulib modules.
-* Importing updated files::     Subsequent imports.
-* Finishing touches::           Simplifying imports.
-@end menu
+If you want to support Windows 2000, don't do anything, but be aware
+that gnulib will use its own (partial) getaddrinfo implementation even
+on Windows XP.  Currently the code does not attempt to determine if
+the getaddrinfo function is available during runtime.
 
+Todo: Make getaddrinfo.c open the WS2_32.DLL and check for the
+getaddrinfo symbol and use it if present, otherwise fall back to our
+own implementation.
 
-@node Initial import
-@section Initial import
-@cindex initial import
 
-Gnulib assumes your project uses Autoconf and Automake.  Invoking
-@samp{gnulib-tool --import} will copy source files, create a
-@file{Makefile.am} to build them, and generate a @file{gnulib.m4} with
-Autoconf M4 macro declarations used by @file{configure.ac}.
+@node Libtool and Windows
+@section Libtool and Windows
 
-Our example will be a library that uses Autoconf, Automake and
-Libtool.  It calls @code{strdup}, and you wish to use gnulib to make
-the package portable to C89 (which doesn't have @code{strdup}).
+If you want it to be possible to cross-compile your program to MinGW
+and you use Libtool, you need to put:
 
 @example
-~/src/libfoo$ gnulib-tool --import strdup
-Module list with included dependencies:
-  strdup
-File list:
-  lib/strdup.c
-  lib/strdup.h
-  m4/onceonly_2_57.m4
-  m4/strdup.m4
-Creating ./lib/Makefile.am...
-Creating ./m4/gnulib.m4...
-Finished.
-
-You may need to add #include directives for the following .h files.
-  #include "strdup.h"
-
-Don't forget to add "lib/Makefile"
-to AC_CONFIG_FILES in "./configure.ac" and to mention
-"lib" in SUBDIRS in some Makefile.am.
-~/src/libfoo$
+AC_LIBTOOL_WIN32_DLL
 @end example
 
-By default, the source code is copied into @file{lib/} and the M4
-macros in @file{m4/}.  You can override these paths by using
-@code{--source-base=DIRECTORY} and @code{--m4-base=DIRECTORY}, or by
-adding @samp{gl_SOURCE_BASE(DIRECTORY)} and
-@samp{gl_M4_BASE(DIRECTORY)} to your @file{configure.ac}.
-Some modules also provide other files necessary
-for building. These files are copied into the directory specified
-by @samp{AC_CONFIG_AUX_DIR} in @file{configure.ac} or by the
-@code{--aux-dir=DIRECTORY} option. If neither is specified, the
-current directory is assumed.
-
-@code{gnulib-tool} can make symbolic links instead
-of copying the source files. Use the @code{--symbolic}
-(or @code{-s} for short) option to do this.
-
-@code{gnulib-tool} will overwrite any pre-existing files, in
-particular @file{Makefile.am}.  Unfortunately, separating the
-generated @file{Makefile.am} content (for building the gnulib library)
-into a separate file, say @file{gnulib.mk}, that could be included
-by your handwritten @file{Makefile.am} is not possible, due to how
-variable assignments are handled by Automake.
-
-Consequently, it can be a good idea to chose directories that are not
-already used by your projects, to separate gnulib imported files from
-your own files.  This approach can also be useful if you want to avoid
-conflicts between other tools (e.g., @code{getextize} that also copy
-M4 files into your package.  Simon Josefsson successfully uses a source
-base of @file{gl/}, and a M4 base of @file{gl/m4/}, in several
-packages.
-
-A few manual steps are required to finish the initial import.
-
-First, you need to make sure Autoconf can find the macro definitions
-in @file{gnulib.m4}.  Use the @code{ACLOCAL_AMFLAGS} specifier in your
-top-level @file{Makefile.am} file, as in:
+in your @file{configure.ac}.  This sets the correct names for the
+@code{OBJDUMP}, @code{DLLTOOL}, and @code{AS} tools for the build.
 
-@example
-ACLOCAL_AMFLAGS = -I m4
-@end example
-
-Naturally, replace @file{m4} with the value from @code{--m4-base} or
-@code{gl_M4_BASE}.  If the M4 base is @file{gl/m4} you would use:
+If you are building a library, you will also need to pass
+@code{-no-undefined} to make sure Libtool produces a DLL for your
+library.  From a @file{Makefile.am}:
 
 @example
-ACLOCAL_AMFLAGS = -I gl/m4
+libgsasl_la_LDFLAGS += -no-undefined
 @end example
 
-You are now ready to call the M4 macros in @code{gnulib.m4} from
-@file{configure.ac}.  The macro @code{gl_EARLY} must be called as soon
-as possible after verifying that the C compiler is working.
-Typically, this is immediately after @code{AC_PROG_CC}, as in:
 
-@example
-...
-AC_PROG_CC
-gl_EARLY
-...
-@end example
-
-The core part of the gnulib checks are done by the macro
-@code{gl_INIT}.  Place it further down in the file, typically where
-you normally check for header files or functions.  Or in a separate
-section with other gnulib statements, such as @code{gl_SOURCE_BASE}.
-For example:
+@node License Texinfo sources
+@section License Texinfo sources
 
-@example
-...
-# For gnulib.
-gl_INIT
-...
-@end example
+Gnulib provides copies of the GNU GPL, GNU LGPL, and GNU FDL licenses
+in Texinfo form.  (The master location is
+@url{http://www.gnu.org/licenses/}).  These Texinfo documents have
+various node names and structures built into them; for your manual,
+you might like to change these.  It's ok to do this, and a convenient
+way to do so is to use a context diff and the @option{--local-dir}
+option to @command{gnulib-tool}.
 
-@code{gl_INIT} will in turn call the macros related with the 
-gnulib functions, be it specific gnulib macros, like @code{gl_FUNC_ALLOCA}
-or autoconf or automake macro like @code{AC_FUNC_ALLOCA} or 
-@code{AM_FUNC_GETLINE} so there is no need to call those macros yourself
-when you use the corresponding gnulib modules.
+Of course the license texts themselves should not be changed at all.
 
-You must also make sure that the gnulib library is built.  Add the
-@code{Makefile} in the gnulib source base directory to
-@code{AC_CONFIG_FILES}, as in:
+@node Build robot for gnulib
+@section Build robot for gnulib
 
-@example
-AC_CONFIG_FILES(... lib/Makefile ...)
-@end example
+To simplify testing on a wide set of platforms, gnulib is built on
+many platforms every day and the results are uploaded to:
 
-If your gnulib source base is @file{gl}, you would use:
+@url{http://autobuild.josefsson.org/gnulib/}
 
-@example
-AC_CONFIG_FILES(... gl/Makefile ...)
-@end example
+If you wish to help the gnulib development effort with build logs for
+your favorite platform, you may perform these steps:
 
-You must also make sure that @code{make} work in the gnulib directory.
-Add the gnulib source base directory to a @code{SUBDIRS} Makefile.am
-statement, as in:
+@enumerate
 
-@example
-SUBDIRS = lib
-@end example
+@item Create gnulib directory
 
-or if you, more likely, already have a few entries in @code{SUBDIRS},
-you can add something like:
+On a machine with recent automake, autoconf, m4 installed and with a
+gnulib cvs checkout (typically a Linux machine), use
 
 @example
-SUBDIRS += lib
+gnulib-tool --create-megatestdir --with-tests --dir=..."
 @end example
 
-If you are using a gnulib source base of @code{gl}, you would use:
+Note: The created directory uses ca. 512 MB on disk.
 
-@example
-SUBDIRS += gl
-@end example
+@item Transfer gnulib directory
 
-Finally, you have to add compiler and linker flags in the appropriate
-source directories, so that you can make use of the gnulib library.
-Since some modules (@samp{getopt}, for example) may copy files into
-the build directory, @file{top_builddir/lib} is needed as well
-as @file{top_srcdir/lib}.  For example:
+Transfer this directory to a build machine (HP-UX, Cygwin, or
+whatever).  Often it is easier to transfer one file, and this can be
+achieved by running, inside the directory the following commands:
 
 @example
-...
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_builddir)/lib
-...
-LIBADD = lib/libgnu.a
-...
+./configure
+make dist
 @end example
 
-Don't forget to @code{#include} the various header files.  In this
-example, you would need to make sure that @samp{#include "strdup.h"}
-is evaluated when compiling all source code files, that want to make
-use of @code{strdup}. 
+And then transferring the @file{dummy-0.tar.gz} file.
 
-When an include file is provided by the gnulib
-you shouldn't try to include the corresponding system header files 
-yourself but let the gnulib header file do it as the ordering
-of the definition for some symbols may be significant.
+@item Build modules
 
-For example, to use the @code{time_r} gnulib module you should
-use include header file provided by the gnulib, and so
-@samp{#include "time_r.h"}, but you shouldn't explicitely
-@samp{#include <time.h>} as it is already done in @file{time_r.h}
-before the redefinition of some symbols.
+On the build machine, run ./autobuild (or "nohup ./autobuild").  It
+creates a directory 'logs/' with a log file for each module.
 
-@node Importing updated files
-@section Importing updated files
+@item Submit build logs
 
-From time to time, you may want to invoke @samp{gnulib-tool --import}
-to update the files in your package.  Once you have set up your
-package for gnulib, this step is quite simple.  For example:
+Submit each log file to Simon's site, either through a
 
 @example
-~/src/libfoo$ gnulib-tool --import --source-base gl --m4-base gl/m4 strdup
-Module list with included dependencies:
-  strdup
-File list:
-  lib/strdup.c
-  lib/strdup.h
-  m4/onceonly_2_57.m4
-  m4/strdup.m4
-Creating ./lib/Makefile.am...
-Creating ./m4/gnulib.m4...
-Finished.
-
-Don't forget to add "lib/Makefile"
-to AC_CONFIG_FILES in "./configure.ac" and to mention
-"lib" in SUBDIRS in some Makefile.am.
-~/src/libfoo$
+mail `echo gnulib__at__autobuild.josefsson.org | sed -e s/__at__/@/`
 @end example
 
-If you don't recall how you invoked the tool last time, the commands
-used (and the operations it resulted in) are placed in comments within
-the generated @file{Makefile.am} and @file{gnulib.m4}, as in:
+or through netcat
 
 @example
-...
-# Invoked as: gnulib-tool --import strdup
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --libtool strdup
-...
+autobuild-submit logs/*
 @end example
 
+@end enumerate
 
-@node Finishing touches
-@section Finishing touches
+@node Particular Modules
+@chapter Particular Modules
 
-Invoking @samp{gnulib-tool --import} with the proper parameters (e.g.,
-@samp{--m4-base gl/m4}) and list of modules (e.g., @samp{strdup
-snprintf getline minmax}) can be tedious.  To simplify this procedure,
-you may put the command line parameters in your @file{configure.ac}.
-For example:
+@menu
+* Quoting::
+* ctime::
+* error and progname::
+* gcd::
+* inet_ntoa::
+* Regular expressions::
+* Supporting Relocation::
+@end menu
 
-@example
-...
-AC_PROG_CC
-gl_EARLY
-...
-# For gnulib.
-gl_SOURCE_BASE(gl)
-gl_M4_BASE(gl/m4)
-gl_LIB(libgl)
-gl_MODULES(getopt progname strdup dummy exit error getpass-gnu getaddrinfo)
-gl_INIT
-...
-@end example
+@include quote.texi
+@include error.texi
+@include ctime.texi
+@include gcd.texi
+@include inet_ntoa.texi
+@include relocatable-maint.texi
 
-This illustrate all macros defined in @file{gnulib.m4}.  With the
-above, importing new files are as simple as running @samp{gnulib-tool
---import} with no additional parameters.
+@node Regular expressions
+@section Regular expressions
 
-The macros @code{gl_EARLY}, @code{gl_INIT}, @code{gl_SOURCE_BASE}, and
-@code{gl_M4_BASE} have been discussed earlier.  The @code{gl_LIB}
-macro can be used if you wish to change the library name (by default
-@file{libgnu.a} or @file{libgnu.la} if you use libtool).  The
-@code{gl_MODULES} macro is used to specify which modules to import.
+Gnulib supports many different types of regular expressions; although
+the underlying features are the same or identical, the syntax used
+varies.  The descriptions given here for the different types are
+generated automatically.
+
+@include regexprops-generic.texi
 
 
 @node Copying This Manual