Home Introduction Advanced Man Page Examples
Argtable is an ANSI C command line parser.
Stewart
Heitmann
sheitmann@users.sourceforge.net
Argtable is an ANSI C library for parsing GNU style command line options with a minimum of fuss. It enables a program's command line syntax to be defined in the source code as an array of argtable structs. The command line is then parsed according to that specification and the resulting values are returned in those same structs where they are accessible to the main program. Both tagged (-v, --verbose, --foo=bar) and untagged arguments are supported, as are multiple instances of each argument. Syntax error handling is automatic and the library also provides the means for generating a textual description of the command line syntax, as in the following example:
myprog [-lRv] [-k <int>] [-D MACRO]... [-o <output>] [--help] [--version] <file> [<file>]...
-l, -L |
list files |
-R |
recurse through subdirectories |
-k, --scalar=<int> |
define scalar value k (default is 3) |
-D, --define=MACRO |
macro definitions |
-o <output> |
output file (default is "-") |
-v, --verbose, --debug |
verbose messages |
--help |
print this help and exit |
--version |
print version information and exit |
<file> |
input file(s) |
The default parsing, validation, and error reporting routines may be replaced by user-defined callbacks if desired, and new argtable data types may be created to parse user-defined argument types. The parsing itself is done using GNU getopt so the parser is 100% GNU compatible, and care has been taken to make the internal command line buffer handling secure against buffer overun attacks, as might be attempted with maliciously long command lines.
It runs on Linux, FreeBSD, NetBSD, OpenBSD, Cygwin, Sun Solaris, Apple Mac OS X and Microsoft Windows platforms. It is known to compile with GCC, DJGPP, Visual C++, Open Watcom, MinGW, Texas Instruments DSP Compiler and should compile on any standard ANSI C compiler.
Argtable is open-source software that is distributed under the terms of the GNU Library General Public License (LGPL). It is available from NetBSD ports (devel/argtable), FreeBSD ports (devel/argtable), OpenBSD ports (devel/argtable), Mac OS X Darwin ports (devel/argtable), Gentoo Linux (dev-libs/argtable), Debian Linux (libdevel/libargtable2-dev), and Ubuntu Linux (libdevel/libargtable2-dev). Precompiled Dev-C++ devpaks are available from http://devpaks.org. Also check below for the latest version.
"Introduction to Argtable-2.x" (html) (postscript) (pdf) (italiano)
A tutorial-style introduction
to command line parsing using argtable-2.x.
"Advanced Argtable-2.x Topics" (html) (postscript) (pdf)
A collection of topics on
advanced argtable-2.x parsing techniques.
"The Argtable-2.x Man Page" (html) (postscript) (pdf)
The argtable-2.x programmer's reference manual.
"Argtable Example Code" (html).
Source code examples showing how to parse the command line of a selection of common GNU utilities (echo, ls, mv, rm, uname) plus some generic examples demonstrating basic argtable features.
Version 2.9 (ChangeLog), released March 26, 2008
This release fixes a makefile bug related to "make dist". In all other respects version 2.9 is identical to version 2.8.
argtable2-9.tar.gz
(source code, 3.3MB)
argtable2-9-1.i386.rpm
(precompiled binary, 2.9MB)
argtable2-9-1.src.rpm
(source code rpm, 3.3MB)
Version 1.4 (DEPRECATED 2003)
The argtable 1.x series has been long deprecated, but is still provided for backward compatibility as the argtable 2.x series does not support legacy code using the argtable 1.x series library. Both argtable 1.x and 2.x series libraries will happily coexist on the same system, so you may install them together if you wish. New users will not need this version at all.
argtable-1.4.tar.gz (source code, 442KB)
Previous releases of both the 1.x and 2.x series are available from the Sourceforge argtable downloads site.
Argtable debuted on sunsite.unc.edu in November 1998 and was relocated to sourceforge.net in December 2001. The argtable-1.x series was replaced by the argtable-2.x series in October 2003.
Nina Clemson for
editing the original argtable-1.0 documentation.
Livio Bertacco for contributing bug fixes and the argtable-2.x Visual
C++ Makefiles.
Justin Dearing for contributing bug fixes and Windows DLL support,
plus code support for the Open Watcom compiler and help with the Mac OS X
configuration.
Asa Packer for contributing bug fixes and upgrades to the Visual C++
Makefiles.
Danilo Cicerone for the Italian translation of "Introduction to
Argtable-2x" and the argtable devpak. Both are available from his site at http://www.digitazero.org.
Uli Fouquet for
configuration patches and documentation related to cross-compiling argtable
from Unix to Windows as well as providing the arg_print_glossary_gnu
function.
Shachar Schemesh for
integrating argtable into Debian Linux and kick-starting the migration to
automake/autoconf.
Jasper Lievisse Adriaanse for
maintaining the argtable package in OpenBSD ports.
Ulrich Mohr for bug fixes relating to Texas Instrument DSP platforms.
John Vickers and Steve O'Neil for bug fixes relating to Solaris/Motorola platforms.
Lori A. Pritchett-Sheats for fixing a makefile bug relating to "make dist".
Paolo Bormida for instructions on building argtable with date and regex support on Windows.