PDA

View Full Version : "An Open Message to Barack Obama"



SA210
04-28-2013, 02:38 AM
.
An open message to Terrorist Obama..for murdering over 4700 men, women and children with his illegal drone program with 98% of the casualties being innocent non-combatants, not to mention the extension of the Afghanistan war and illegal intervention in Libya.


Obama, who exactly do you think you're fooling at this point?...By your definition, you are a terrorist and should be the one rotting in Guantanamo Bay




An Open Message to Barack Obama


https://www.youtube.com/watch?v=V3MuzLezG9s


Props to Storm Clouds Gathering for another excellent video :tu

Woo Bum-kon
04-28-2013, 03:44 AM
:lol still can't explain why Tamerlan would trust the FBI
:lol failing completely the first time you actually post your very own conspiracy theory

SA210
04-28-2013, 04:12 AM
:cry I troll topics bc I'm angry SA210 owned me too :cry

Wrong thread, pussy. You can go troll the other one where I owned you and the others badly. This is about Terrorist Obama and the the fact about his mass murder of almost 5,000 human beings with his illegal war criminal drone program. Thanks :tu

Woo Bum-kon
04-28-2013, 04:50 AM
I can turn threads about school shootings, Boston Bombings, Christmas, etc. into threads about Barack Obama and drones because I'm raising awareness! But when you try to change the subject of a thread, you're a troll!

:lmao failed utterly when you presented your first conspiracy theory

SA210
04-28-2013, 05:24 AM
:madrun I failed utterly when SA210 presented facts about my conspiracy theory :madrun


:lmao I was right, proved you wrong and you're still butthurt about it.

:lol 19 yr old boy was unarmed in an "hour long back and forth shootout with police"

:lol trolling topics out of desperation and butthurt, and lying.

Woo Bum-kon
04-28-2013, 05:48 AM
I didn't present a conspiracy theory, moron.


:lmao I was right, proved you wrong and you're still butthurt about it.

You claimed that the government was behind the bombings. You haven't proven that at all.


:lol 19 yr old boy was unarmed in an "hour long back and forth shootout with police"

:lmao That doesn't make any sense. Even if what you said is 100% true, that doesn't mean he wasn't behind the bombings.

Your conspiracy theories make no sense whatsoever, and the conclusions that you get from your "evidence" aren't logical at all. Maybe it's because you came to your conclusion, then started to looking for evidence supporting it, like you always do.

And... :lmao still can't explain why Tamerlan would trust the FBI.
:lmao still can't explain why the FBI would kill Tamerlan and not his brother.

SA210
04-28-2013, 05:58 AM
:lol excessive emotions and lying to compensate for being a wuss
:lol still trolling topics that have nothing to do with the topic your were owned in
:lol avatar of a mass murderer

Woo Bum-kon
04-28-2013, 06:03 AM
:lol excessive emotions and lying to compensate for being a wuss

lol excessive emotions. You are the one who cries "bitch," "sheep," and "liar" whenever somebody disagrees with you.


:lol still trolling topics that have nothing to do with the topic your were owned in

lol giant hypocrite who turns everything into a discussion about drones doesn't like it when somebody else changes the subject
lol still can't explain how I was owned
lol still dodging questions


:lol avatar of a mass murderer

You know what's funny? If Woo was an American citizen who went on a killing spree in 2013, you'd be taking his side and claiming that the government was responsible. :lol

Next, you'll call me an Obama-supporter, and your entire insult repertoire will be depleted.

SA210
04-28-2013, 06:25 AM
*yawn* more lies from the troll, and butthurt mass murder supporter lol. If you'd like to discuss your lies over a cup of coffee, let me know :tu

For now, back to the topic.. :tu



.
An open message to Terrorist Obama..for murdering over 4700 men, women and children with his illegal drone program with 98% of the casualties being innocent non-combatants, not to mention the extension of the Afghanistan war and illegal intervention in Libya.



An Open Message to Barack Obama


https://www.youtube.com/watch?v=V3MuzLezG9s


Props to Storm Clouds Gathering for another excellent video :tu

Woo Bum-kon
04-28-2013, 06:27 AM
:lmao the guy who defended two people who murdered four people in the span of a week, is calling somebody else a supporter of mass murder

Blake
04-28-2013, 08:14 AM
Because Obama watches YouTube.

And the background of storm clouds + blood splatter = instant credibility

The Reckoning
04-28-2013, 08:36 AM
:danceclub lol didnt watch. no gif needed.
:danceclub

baseline bum
04-28-2013, 12:32 PM
http://i.imgur.com/86CmbL3.png

SA210
04-28-2013, 12:49 PM
:cry Yup, I'm also part of the butthurt crew that SA210 owned. Btw, I know SA210 posted facts about Obama being a mass murderer, so I'll try and change the subject to divert attention from that. I support child murder and state sponsored terrorism like some of my fellow butthurt posters :cry

Avante
04-28-2013, 12:52 PM
Obama a terrorist...hahahaha!!!!!!!!!! Obviously OP doesn't know the meaning of the word.

SA210
04-28-2013, 01:00 PM
Obama a terrorist...hahahaha!!!!!!!!!! Obviously OP doesn't know the meaning of the word.

nah, it's obvious you haven't studied the illegal drone program, or you choose to ignore it. Children and families are being terrorized and murdered. He's a terrorist. He's a war criminal. He's a mass child murderer. It's just a fact.

In before the lie gets spewed about how they are all terrorists over there including kids and terrorists use kids as shields so it isn't our fault even though we are in illegal wars and shouldn't be there to begin with, etc blah blah blah..

Ignorance

baseline bum
04-28-2013, 01:00 PM
/* Hierarchial argument parsing, layered over getopt.
Copyright (C) 1995-1999, 2003, 2004, 2005, 2006, 2007, 2009, 2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _ARGP_H
#define _ARGP_H

#include <stdio.h>
#include <ctype.h>
#include <getopt.h>
#include <limits.h>

#define __need_error_t
#include <errno.h>

#ifndef __THROW
# define __THROW
#endif
#ifndef __NTH
# define __NTH(fct) fct __THROW
#endif

#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
# define __format__ format
# define __printf__ printf
# endif
#endif

/* GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict". */
#ifndef __restrict
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
# if defined restrict || 199901L <= __STDC_VERSION__
# define __restrict restrict
# else
# define __restrict
# endif
# endif
#endif

#ifndef __error_t_defined
typedef int error_t;
# define __error_t_defined
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* A description of a particular option. A pointer to an array of
these is passed in the OPTIONS field of an argp structure. Each option
entry can correspond to one long option and/or one short option; more
names for the same option can be added by following an entry in an option
array with options having the OPTION_ALIAS flag set. */
struct argp_option
{
/* The long option name. For more than one name for the same option, you
can use following options with the OPTION_ALIAS flag set. */
const char *name;

/* What key is returned for this option. If > 0 and printable, then it's
also accepted as a short option. */
int key;

/* If non-NULL, this is the name of the argument associated with this
option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
const char *arg;

/* OPTION_ flags. */
int flags;

/* The doc string for this option. If both NAME and KEY are 0, This string
will be printed outdented from the normal option column, making it
useful as a group header (it will be the first thing printed in its
group); in this usage, it's conventional to end the string with a `:'. */
const char *doc;

/* The group this option is in. In a long help message, options are sorted
alphabetically within each group, and the groups presented in the order
0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
if this field 0 will inherit the group number of the previous entry, or
zero if it's the first one, unless its a group header (NAME and KEY both
0), in which case, the previous entry + 1 is the default. Automagic
options such as --help are put into group -1. */
int group;
};

/* The argument associated with this option is optional. */
#define OPTION_ARG_OPTIONAL 0x1

/* This option isn't displayed in any help messages. */
#define OPTION_HIDDEN 0x2

/* This option is an alias for the closest previous non-alias option. This
means that it will be displayed in the same help entry, and will inherit
fields other than NAME and KEY from the aliased option. */
#define OPTION_ALIAS 0x4

/* This option isn't actually an option (and so should be ignored by the
actual option parser), but rather an arbitrary piece of documentation that
should be displayed in much the same manner as the options. If this flag
is set, then the option NAME field is displayed unmodified (e.g., no `--'
prefix is added) at the left-margin (where a *short* option would normally
be displayed), and the documentation string in the normal place. For
purposes of sorting, any leading whitespace and punctuation is ignored,
except that if the first non-whitespace character is not `-', this entry
is displayed after all options (and OPTION_DOC entries with a leading `-')
in the same group. */
#define OPTION_DOC 0x8

/* This option shouldn't be included in `long' usage messages (but is still
included in help messages). This is mainly intended for options that are
completely documented in an argp's ARGS_DOC field, in which case including
the option in the generic usage list would be redundant. For instance,
if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
distinguish these two cases, -x should probably be marked
OPTION_NO_USAGE. */
#define OPTION_NO_USAGE 0x10

struct argp; /* fwd declare this type */
struct argp_state; /* " */
struct argp_child; /* " */

/* The type of a pointer to an argp parsing function. */
typedef error_t (*argp_parser_t) (int __key, char *__arg,
struct argp_state *__state);

/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
returns will simply be ignored. For user keys, this error will be turned
into EINVAL (if the call to argp_parse is such that errors are propagated
back to the user instead of exiting); returning EINVAL itself would result
in an immediate stop to parsing in *all* cases. */
#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */

/* Special values for the KEY argument to an argument parsing function.
ARGP_ERR_UNKNOWN should be returned if they aren't understood.

The sequence of keys to a parsing function is either (where each
uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):

INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized

The third case is where every parser returned ARGP_KEY_UNKNOWN for an
argument, in which case parsing stops at that argument (returning the
unparsed arguments to the caller of argp_parse if requested, or stopping
with an error message if not).

If an error occurs (either detected by argp, or because the parsing
function returned an error value), then the parser is called with
ARGP_KEY_ERROR, and no further calls are made. */

/* This is not an option at all, but rather a command line argument. If a
parser receiving this key returns success, the fact is recorded, and the
ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
argument, a parser function decrements the NEXT field of the state it's
passed, the option won't be considered processed; this is to allow you to
actually modify the argument (perhaps into an option), and have it
processed again. */
#define ARGP_KEY_ARG 0
/* There are remaining arguments not parsed by any parser, which may be found
starting at (STATE->argv + STATE->next). If success is returned, but
STATE->next left untouched, it's assumed that all arguments were consume,
otherwise, the parser should adjust STATE->next to reflect any arguments
consumed. */
#define ARGP_KEY_ARGS 0x1000006
/* There are no more command line arguments at all. */
#define ARGP_KEY_END 0x1000001
/* Because it's common to want to do some special processing if there aren't
any non-option args, user parsers are called with this key if they didn't
successfully process any non-option arguments. Called just before
ARGP_KEY_END (where more general validity checks on previously parsed
arguments can take place). */
#define ARGP_KEY_NO_ARGS 0x1000002
/* Passed in before any parsing is done. Afterwards, the values of each
element of the CHILD_INPUT field, if any, in the state structure is
copied to each child's state to be the initial value of the INPUT field. */
#define ARGP_KEY_INIT 0x1000003
/* Use after all other keys, including SUCCESS & END. */
#define ARGP_KEY_FINI 0x1000007
/* Passed in when parsing has successfully been completed (even if there are
still arguments remaining). */
#define ARGP_KEY_SUCCESS 0x1000004
/* Passed in if an error occurs. */
#define ARGP_KEY_ERROR 0x1000005

/* An argp structure contains a set of options declarations, a function to
deal with parsing one, documentation string, a possible vector of child
argp's, and perhaps a function to filter help output. When actually
parsing options, getopt is called with the union of all the argp
structures chained together through their CHILD pointers, with conflicts
being resolved in favor of the first occurrence in the chain. */
struct argp
{
/* An array of argp_option structures, terminated by an entry with both
NAME and KEY having a value of 0. */
const struct argp_option *options;

/* What to do with an option from this structure. KEY is the key
associated with the option, and ARG is any associated argument (NULL if
none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
parsing is stopped immediately, and that value is returned from
argp_parse(). For special (non-user-supplied) values of KEY, see the
ARGP_KEY_ definitions below. */
argp_parser_t parser;

/* A string describing what other arguments are wanted by this program. It
is only used by argp_usage to print the `Usage:' message. If it
contains newlines, the strings separated by them are considered
alternative usage patterns, and printed on separate lines (lines after
the first are prefix by ` or: ' instead of `Usage:'). */
const char *args_doc;

/* If non-NULL, a string containing extra text to be printed before and
after the options in a long help message (separated by a vertical tab
`\v' character). */
const char *doc;

/* A vector of argp_children structures, terminated by a member with a 0
argp field, pointing to child argps should be parsed with this one. Any
conflicts are resolved in favor of this argp, or early argps in the
CHILDREN list. This field is useful if you use libraries that supply
their own argp structure, which you want to use in conjunction with your
own. */
const struct argp_child *children;

/* If non-zero, this should be a function to filter the output of help
messages. KEY is either a key from an option, in which case TEXT is
that option's help text, or a special key from the ARGP_KEY_HELP_
defines, below, describing which other help text TEXT is. The function
should return either TEXT, if it should be used as-is, a replacement
string, which should be malloced, and will be freed by argp, or NULL,
meaning `print nothing'. The value for TEXT is *after* any translation
has been done, so if any of the replacement text also needs translation,
that should be done by the filter function. INPUT is either the input
supplied to argp_parse, or NULL, if argp_help was called directly. */
char *(*help_filter) (int __key, const char *__text, void *__input);

/* If non-zero the strings used in the argp library are translated using
the domain described by this string. Otherwise the currently installed
default domain is used. */
const char *argp_domain;
};

/* Possible KEY arguments to a help filter function. */
#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
TEXT is NULL for this key. */
/* Explanatory note emitted when duplicate option arguments have been
suppressed. */
#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */

/* When an argp has a non-zero CHILDREN field, it should point to a vector of
argp_child structures, each of which describes a subsidiary argp. */
struct argp_child
{
/* The child parser. */
const struct argp *argp;

/* Flags for this child. */
int flags;

/* If non-zero, an optional header to be printed in help output before the
child options. As a side-effect, a non-zero value forces the child
options to be grouped together; to achieve this effect without actually
printing a header string, use a value of "". */
const char *header;

/* Where to group the child options relative to the other (`consolidated')
options in the parent argp; the values are the same as the GROUP field
in argp_option structs, but all child-groupings follow parent options at
a particular group level. If both this field and HEADER are zero, then
they aren't grouped at all, but rather merged with the parent options
(merging the child's grouping levels with the parents). */
int group;
};

/* Parsing state. This is provided to parsing functions called by argp,
which may examine and, as noted, modify fields. */
struct argp_state
{
/* The top level ARGP being parsed. */
const struct argp *root_argp;

/* The argument vector being parsed. May be modified. */
int argc;
char **argv;

/* The index in ARGV of the next arg that to be parsed. May be modified. */
int next;

/* The flags supplied to argp_parse. May be modified. */
unsigned flags;

/* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
number of the current arg, starting at zero, and incremented after each
such call returns. At all other times, this is the number of such
arguments that have been processed. */
unsigned arg_num;

/* If non-zero, the index in ARGV of the first argument following a special
`--' argument (which prevents anything following being interpreted as an
option). Only set once argument parsing has proceeded past this point. */
int quoted;

/* An arbitrary pointer passed in from the user. */
void *input;
/* Values to pass to child parsers. This vector will be the same length as
the number of children for the current parser. */
void **child_inputs;

/* For the parser's use. Initialized to 0. */
void *hook;

/* The name used when printing messages. This is initialized to ARGV[0],
or PROGRAM_INVOCATION_NAME if that is unavailable. */
char *name;

/* Streams used when argp prints something. */
FILE *err_stream; /* For errors; initialized to stderr. */
FILE *out_stream; /* For information; initialized to stdout. */

void *pstate; /* Private, for use by argp. */
};

/* Flags for argp_parse (note that the defaults are those that are
convenient for program command line parsing): */

/* Don't ignore the first element of ARGV. Normally (and always unless
ARGP_NO_ERRS is set) the first element of the argument vector is
skipped for option parsing purposes, as it corresponds to the program name
in a command line. */
#define ARGP_PARSE_ARGV0 0x01

/* Don't print error messages for unknown options to stderr; unless this flag
is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
name in the error messages. This flag implies ARGP_NO_EXIT (on the
assumption that silent exiting upon errors is bad behaviour). */
#define ARGP_NO_ERRS 0x02

/* Don't parse any non-option args. Normally non-option args are parsed by
calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
as the value. Since it's impossible to know which parse function wants to
handle it, each one is called in turn, until one returns 0 or an error
other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
argp_parse returns prematurely (but with a return value of 0). If all
args have been parsed without error, all parsing functions are called one
last time with a key of ARGP_KEY_END. This flag needn't normally be set,
as the normal behavior is to stop parsing as soon as some argument can't
be handled. */
#define ARGP_NO_ARGS 0x04

/* Parse options and arguments in the same order they occur on the command
line -- normally they're rearranged so that all options come first. */
#define ARGP_IN_ORDER 0x08

/* Don't provide the standard long option --help, which causes usage and
option help information to be output to stdout, and exit (0) called. */
#define ARGP_NO_HELP 0x10

/* Don't exit on errors (they may still result in error messages). */
#define ARGP_NO_EXIT 0x20

/* Use the gnu getopt `long-only' rules for parsing arguments. */
#define ARGP_LONG_ONLY 0x40

/* Turns off any message-printing/exiting options. */
#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)

/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
index in ARGV of the first unparsed option is returned in it. If an
unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
routine returned a non-zero value, it is returned; otherwise 0 is
returned. This function may also call exit unless the ARGP_NO_HELP flag
is set. INPUT is a pointer to a value to be passed in to the parser. */
extern error_t argp_parse (const struct argp *__restrict __argp,
int __argc, char **__restrict __argv,
unsigned __flags, int *__restrict __arg_index,
void *__restrict __input);
extern error_t __argp_parse (const struct argp *__restrict __argp,
int __argc, char **__restrict __argv,
unsigned __flags, int *__restrict __arg_index,
void *__restrict __input);

/* Global variables. */

/* If defined or set by the user program to a non-zero value, then a default
option --version is added (unless the ARGP_NO_HELP flag is used), which
will print this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
extern const char *argp_program_version;

/* If defined or set by the user program to a non-zero value, then a default
option --version is added (unless the ARGP_NO_HELP flag is used), which
calls this function with a stream to print the version to and a pointer to
the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
extern void (*argp_program_version_hook) (FILE *__restrict __stream,
struct argp_state *__restrict
__state);

/* If defined or set by the user program, it should point to string that is
the bug-reporting address for the program. It will be printed by
argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
standard help messages), embedded in a sentence that says something like
`Report bugs to ADDR.'. */
extern const char *argp_program_bug_address;

/* The exit status that argp will use when exiting due to a parsing error.
If not defined or set by the user program, this defaults to EX_USAGE from
<sysexits.h>. */
extern error_t argp_err_exit_status;

/* Flags for argp_help. */
#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
#define ARGP_HELP_LONG 0x08 /* a long help message. */
#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)

baseline bum
04-28-2013, 01:01 PM
#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
reflect ARGP_LONG_ONLY mode. */

/* These ARGP_HELP flags are only understood by argp_state_help. */
#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */

/* The standard thing to do after a program command line parsing error, if an
error message has already been printed. */
#define ARGP_HELP_STD_ERR \
(ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
/* The standard thing to do after a program command line parsing error, if no
more specific error message has been printed. */
#define ARGP_HELP_STD_USAGE \
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
/* The standard thing to do in response to a --help option. */
#define ARGP_HELP_STD_HELP \
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
| ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)

/* Output a usage message for ARGP to STREAM. FLAGS are from the set
ARGP_HELP_*. */
extern void argp_help (const struct argp *__restrict __argp,
FILE *__restrict __stream,
unsigned __flags, char *__restrict __name);
extern void __argp_help (const struct argp *__restrict __argp,
FILE *__restrict __stream, unsigned __flags,
char *__name);

/* The following routines are intended to be called from within an argp
parsing routine (thus taking an argp_state structure as the first
argument). They may or may not print an error message and exit, depending
on the flags in STATE -- in any case, the caller should be prepared for
them *not* to exit, and should return an appropiate error after calling
them. [argp_usage & argp_error should probably be called argp_state_...,
but they're used often enough that they should be short] */

/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
from the set ARGP_HELP_*. */
extern void argp_state_help (const struct argp_state *__restrict __state,
FILE *__restrict __stream,
unsigned int __flags);
extern void __argp_state_help (const struct argp_state *__restrict __state,
FILE *__restrict __stream,
unsigned int __flags);

/* Possibly output the standard usage message for ARGP to stderr and exit. */
extern void argp_usage (const struct argp_state *__state);
extern void __argp_usage (const struct argp_state *__state);

/* If appropriate, print the printf string FMT and following args, preceded
by the program name and `:', to stderr, and followed by a `Try ... --help'
message, then exit (1). */
extern void argp_error (const struct argp_state *__restrict __state,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern void __argp_error (const struct argp_state *__restrict __state,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));

/* Similar to the standard gnu error-reporting function error(), but will
respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
to STATE->err_stream. This is useful for argument parsing code that is
shared between program startup (when exiting is desired) and runtime
option parsing (when typically an error code is returned instead). The
difference between this function and argp_error is that the latter is for
*parsing errors*, and the former is for other problems that occur during
parsing but don't reflect a (syntactic) problem with the input. */
extern void argp_failure (const struct argp_state *__restrict __state,
int __status, int __errnum,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
extern void __argp_failure (const struct argp_state *__restrict __state,
int __status, int __errnum,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));

/* Returns true if the option OPT is a valid short option. */
extern int _option_is_short (const struct argp_option *__opt) __THROW;
extern int __option_is_short (const struct argp_option *__opt) __THROW;

/* Returns true if the option OPT is in fact the last (unused) entry in an
options array. */
extern int _option_is_end (const struct argp_option *__opt) __THROW;
extern int __option_is_end (const struct argp_option *__opt) __THROW;

/* Return the input field for ARGP in the parser corresponding to STATE; used
by the help routines. */
extern void *_argp_input (const struct argp *__restrict __argp,
const struct argp_state *__restrict __state)
__THROW;
extern void *__argp_input (const struct argp *__restrict __argp,
const struct argp_state *__restrict __state)
__THROW;

#ifdef __USE_EXTERN_INLINES

# if !_LIBC
# define __argp_usage argp_usage
# define __argp_state_help argp_state_help
# define __option_is_short _option_is_short
# define __option_is_end _option_is_end
# endif

# ifndef ARGP_EI
# define ARGP_EI __extern_inline
# endif

ARGP_EI void
__argp_usage (const struct argp_state *__state)
{
__argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
}

ARGP_EI int
__NTH (__option_is_short (const struct argp_option *__opt))
{
if (__opt->flags & OPTION_DOC)
return 0;
else
{
int __key = __opt->key;
return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
}
}

ARGP_EI int
__NTH (__option_is_end (const struct argp_option *__opt))
{
return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
}

# if !_LIBC
# undef __argp_usage
# undef __argp_state_help
# undef __option_is_short
# undef __option_is_end
# endif
#endif /* Use extern inlines. */

#ifdef __cplusplus
}
#endif

#endif /* argp.h */

baseline bum
04-28-2013, 01:01 PM
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* If set by the user program, it should point to string that is the
bug-reporting address for the program. It will be printed by argp_help if
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */
const char *argp_program_bug_address;

baseline bum
04-28-2013, 01:02 PM
/* Default definition for ARGP_ERR_EXIT_STATUS
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <sysexits.h>

#include "argp.h"

/* The exit status that argp will use when exiting due to a parsing error.
If not defined or set by the user program, this defaults to EX_USAGE from
<sysexits.h>. */
error_t argp_err_exit_status = EX_USAGE;

baseline bum
04-28-2013, 01:02 PM
/* Word-wrapping and line-truncating streams
Copyright (C) 1997-1999,2001-2003,2005,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* This package emulates glibc `line_wrap_stream' semantics for systems that
don't have that. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <ctype.h>

#include "argp-fmtstream.h"
#include "argp-namefrob.h"

#ifndef ARGP_FMTSTREAM_USE_LINEWRAP

#ifndef isblank
#define isblank(ch) ((ch)==' ' || (ch)=='\t')
#endif

#ifdef _LIBC
# include <wchar.h>
# include <libio/libioP.h>
# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
#endif

#define INIT_BUF_SIZE 200
#define PRINTF_SIZE_GUESS 150

/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
written on it with LMARGIN spaces and limits them to RMARGIN columns
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
replacing the whitespace before them with a newline and WMARGIN spaces.
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
Returns NULL if there was an error. */
argp_fmtstream_t
__argp_make_fmtstream (FILE *stream,
size_t lmargin, size_t rmargin, ssize_t wmargin)
{
argp_fmtstream_t fs;

fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
if (fs != NULL)
{
fs->stream = stream;

fs->lmargin = lmargin;
fs->rmargin = rmargin;
fs->wmargin = wmargin;
fs->point_col = 0;
fs->point_offs = 0;

fs->buf = (char *) malloc (INIT_BUF_SIZE);
if (! fs->buf)
{
free (fs);
fs = 0;
}
else
{
fs->p = fs->buf;
fs->end = fs->buf + INIT_BUF_SIZE;
}
}

return fs;
}
#if 0
/* Not exported. */
#ifdef weak_alias
weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
#endif
#endif

/* Flush FS to its stream, and free it (but don't close the stream). */
void
__argp_fmtstream_free (argp_fmtstream_t fs)
{
__argp_fmtstream_update (fs);
if (fs->p > fs->buf)
{
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
}
free (fs->buf);
free (fs);
}
#if 0
/* Not exported. */
#ifdef weak_alias
weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
#endif
#endif

/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
void
__argp_fmtstream_update (argp_fmtstream_t fs)
{
char *buf, *nl;
size_t len;

/* Scan the buffer for newlines. */
buf = fs->buf + fs->point_offs;
while (buf < fs->p)
{
size_t r;

if (fs->point_col == 0 && fs->lmargin != 0)
{
/* We are starting a new line. Print spaces to the left margin. */
const size_t pad = fs->lmargin;
if (fs->p + pad < fs->end)
{
/* We can fit in them in the buffer by moving the
buffer text up and filling in the beginning. */
memmove (buf + pad, buf, fs->p - buf);
fs->p += pad; /* Compensate for bigger buffer. */
memset (buf, ' ', pad); /* Fill in the spaces. */
buf += pad; /* Don't bother searching them. */
}
else
{
/* No buffer space for spaces. Must flush. */
size_t i;
for (i = 0; i < pad; i++)
{
if (_IO_fwide (fs->stream, 0) > 0)
putwc_unlocked (L' ', fs->stream);
else
putc_unlocked (' ', fs->stream);
}
}
fs->point_col = pad;
}

len = fs->p - buf;
nl = memchr (buf, '\n', len);

if (fs->point_col < 0)
fs->point_col = 0;

if (!nl)
{
/* The buffer ends in a partial line. */

if (fs->point_col + len < fs->rmargin)
{
/* The remaining buffer text is a partial line and fits
within the maximum line width. Advance point for the
characters to be written and stop scanning. */
fs->point_col += len;
break;
}
else
/* Set the end-of-line pointer for the code below to
the end of the buffer. */
nl = fs->p;
}
else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
{
/* The buffer contains a full line that fits within the maximum
line width. Reset point and scan the next line. */
fs->point_col = 0;
buf = nl + 1;
continue;
}

/* This line is too long. */
r = fs->rmargin - 1;

if (fs->wmargin < 0)
{
/* Truncate the line by overwriting the excess with the
newline and anything after it in the buffer. */
if (nl < fs->p)
{
memmove (buf + (r - fs->point_col), nl, fs->p - nl);
fs->p -= buf + (r - fs->point_col) - nl;
/* Reset point for the next line and start scanning it. */
fs->point_col = 0;
buf += r + 1; /* Skip full line plus \n. */
}
else
{
/* The buffer ends with a partial line that is beyond the
maximum line width. Advance point for the characters
written, and discard those past the max from the buffer. */
fs->point_col += len;
fs->p -= fs->point_col - r;
break;
}
}
else
{
/* Do word wrap. Go to the column just past the maximum line
width and scan back for the beginning of the word there.
Then insert a line break. */

char *p, *nextline;
int i;

p = buf + (r + 1 - fs->point_col);
while (p >= buf && !isblank (*p))
--p;
nextline = p + 1; /* This will begin the next line. */

if (nextline > buf)
{
/* Swallow separating blanks. */
if (p >= buf)
do
--p;
while (p >= buf && isblank (*p));
nl = p + 1; /* The newline will replace the first blank. */
}
else
{
/* A single word that is greater than the maximum line width.
Oh well. Put it on an overlong line by itself. */
p = buf + (r + 1 - fs->point_col);
/* Find the end of the long word. */
do
++p;
while (p < nl && !isblank (*p));
if (p == nl)
{
/* It already ends a line. No fussing required. */
fs->point_col = 0;
buf = nl + 1;
continue;
}
/* We will move the newline to replace the first blank. */
nl = p;
/* Swallow separating blanks. */
do
++p;
while (isblank (*p));
/* The next line will start here. */
nextline = p;
}

/* Note: There are a bunch of tests below for
NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
at the end of the buffer, and NEXTLINE is in fact empty (and so
we need not be careful to maintain its contents). */

if ((nextline == buf + len + 1
? fs->end - nl < fs->wmargin + 1
: nextline - (nl + 1) < fs->wmargin)
&& fs->p > nextline)
{
/* The margin needs more blanks than we removed. */
if (fs->end - fs->p > fs->wmargin + 1)
/* Make some space for them. */
{
size_t mv = fs->p - nextline;
memmove (nl + 1 + fs->wmargin, nextline, mv);
nextline = nl + 1 + fs->wmargin;
len = nextline + mv - buf;
*nl++ = '\n';
}
else
/* Output the first line so we can use the space. */
{
#ifdef _LIBC
__fxprintf (fs->stream, "%.*s\n",
(int) (nl - fs->buf), fs->buf);
#else
if (nl > fs->buf)
fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
putc_unlocked ('\n', fs->stream);
#endif

len += buf - fs->buf;
nl = buf = fs->buf;
}
}
else
/* We can fit the newline and blanks in before
the next word. */
*nl++ = '\n';

if (nextline - nl >= fs->wmargin
|| (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
/* Add blanks up to the wrap margin column. */
for (i = 0; i < fs->wmargin; ++i)
*nl++ = ' ';
else
for (i = 0; i < fs->wmargin; ++i)
if (_IO_fwide (fs->stream, 0) > 0)
putwc_unlocked (L' ', fs->stream);
else
putc_unlocked (' ', fs->stream);

/* Copy the tail of the original buffer into the current buffer
position. */
if (nl < nextline)
memmove (nl, nextline, buf + len - nextline);
len -= nextline - buf;

/* Continue the scan on the remaining lines in the buffer. */
buf = nl;

/* Restore bufp to include all the remaining text. */
fs->p = nl + len;

/* Reset the counter of what has been output this line. If wmargin
is 0, we want to avoid the lmargin getting added, so we set
point_col to a magic value of -1 in that case. */
fs->point_col = fs->wmargin ? fs->wmargin : -1;
}
}

/* Remember that we've scanned as far as the end of the buffer. */
fs->point_offs = fs->p - fs->buf;
}

/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
growing the buffer, or by flushing it. True is returned iff we succeed. */
int
__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
{
if ((size_t) (fs->end - fs->p) < amount)
{
ssize_t wrote;

/* Flush FS's buffer. */
__argp_fmtstream_update (fs);

#ifdef _LIBC
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
wrote = fs->p - fs->buf;
#else
wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
#endif
if (wrote == fs->p - fs->buf)
{
fs->p = fs->buf;
fs->point_offs = 0;
}
else
{
fs->p -= wrote;
fs->point_offs -= wrote;
memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
return 0;
}

if ((size_t) (fs->end - fs->buf) < amount)
/* Gotta grow the buffer. */
{
size_t old_size = fs->end - fs->buf;
size_t new_size = old_size + amount;
char *new_buf;

if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
{
__set_errno (ENOMEM);
return 0;
}

fs->buf = new_buf;
fs->end = new_buf + new_size;
fs->p = fs->buf;
}
}

return 1;
}

ssize_t
__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
{
int out;
size_t avail;
size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */

do
{
va_list args;

if (! __argp_fmtstream_ensure (fs, size_guess))
return -1;

va_start (args, fmt);
avail = fs->end - fs->p;
out = __vsnprintf (fs->p, avail, fmt, args);
va_end (args);
if ((size_t) out >= avail)
size_guess = out + 1;
}
while ((size_t) out >= avail);

fs->p += out;

return out;
}
#if 0
/* Not exported. */
#ifdef weak_alias
weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
#endif
#endif

#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */

baseline bum
04-28-2013, 01:03 PM
/* Word-wrapping and line-truncating streams.
Copyright (C) 1997, 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* This package emulates glibc `line_wrap_stream' semantics for systems that
don't have that. If the system does have it, it is just a wrapper for
that. This header file is only used internally while compiling argp, and
shouldn't be installed. */

#ifndef _ARGP_FMTSTREAM_H
#define _ARGP_FMTSTREAM_H

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
# define __format__ format
# define __printf__ printf
# endif
#endif

#if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)
/* line_wrap_stream is available, so use that. */
#define ARGP_FMTSTREAM_USE_LINEWRAP
#endif

#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
/* Just be a simple wrapper for line_wrap_stream; the semantics are
*slightly* different, as line_wrap_stream doesn't actually make a new
object, it just modifies the given stream (reversibly) to do
line-wrapping. Since we control who uses this code, it doesn't matter. */

#include <linewrap.h>

typedef FILE *argp_fmtstream_t;

#define argp_make_fmtstream line_wrap_stream
#define __argp_make_fmtstream line_wrap_stream
#define argp_fmtstream_free line_unwrap_stream
#define __argp_fmtstream_free line_unwrap_stream

#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
#define argp_fmtstream_puts(fs,str) fputs(str,fs)
#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
#define __argp_fmtstream_printf fprintf
#define argp_fmtstream_printf fprintf

#define __argp_fmtstream_lmargin line_wrap_lmargin
#define argp_fmtstream_lmargin line_wrap_lmargin
#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
#define __argp_fmtstream_rmargin line_wrap_rmargin
#define argp_fmtstream_rmargin line_wrap_rmargin
#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
#define __argp_fmtstream_wmargin line_wrap_wmargin
#define argp_fmtstream_wmargin line_wrap_wmargin
#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
#define __argp_fmtstream_point line_wrap_point
#define argp_fmtstream_point line_wrap_point

#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
/* Guess we have to define our own version. */


struct argp_fmtstream
{
FILE *stream; /* The stream we're outputting to. */

size_t lmargin, rmargin; /* Left and right margins. */
ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */

/* Point in buffer to which we've processed for wrapping, but not output. */
size_t point_offs;
/* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
ssize_t point_col;

char *buf; /* Output buffer. */
char *p; /* Current end of text in BUF. */
char *end; /* Absolute end of BUF. */
};

typedef struct argp_fmtstream *argp_fmtstream_t;

/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
written on it with LMARGIN spaces and limits them to RMARGIN columns
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
replacing the whitespace before them with a newline and WMARGIN spaces.
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
Returns NULL if there was an error. */
extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
size_t __lmargin,
size_t __rmargin,
ssize_t __wmargin);
extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
size_t __lmargin,
size_t __rmargin,
ssize_t __wmargin);

/* Flush __FS to its stream, and free it (but don't close the stream). */
extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
extern void argp_fmtstream_free (argp_fmtstream_t __fs);

extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
const char *__fmt, ...)
__attribute__ ((__format__ (printf, 2, 3)));
extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
const char *__fmt, ...)
__attribute__ ((__format__ (printf, 2, 3)));

extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);

extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);

extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
const char *__str, size_t __len);
extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
const char *__str, size_t __len);

/* Access macros for various bits of state. */
#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin

/* Set __FS's left margin to LMARGIN and return the old value. */
extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
size_t __lmargin);
extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
size_t __lmargin);

/* Set __FS's right margin to __RMARGIN and return the old value. */
extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
size_t __rmargin);
extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
size_t __rmargin);

/* Set __FS's wrap margin to __WMARGIN and return the old value. */
extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
size_t __wmargin);
extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
size_t __wmargin);

/* Return the column number of the current output point in __FS. */
extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);

/* Internal routines. */
extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);

#ifdef __OPTIMIZE__
/* Inline versions of above routines. */

#if !_LIBC
#define __argp_fmtstream_putc argp_fmtstream_putc
#define __argp_fmtstream_puts argp_fmtstream_puts
#define __argp_fmtstream_write argp_fmtstream_write
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
#define __argp_fmtstream_point argp_fmtstream_point
#define __argp_fmtstream_update _argp_fmtstream_update
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
#endif

#ifndef ARGP_FS_EI
#define ARGP_FS_EI extern inline
#endif

ARGP_FS_EI size_t
__argp_fmtstream_write (argp_fmtstream_t __fs, const char *__str, size_t __len)
{
if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
{
memcpy (__fs->p, __str, __len);
__fs->p += __len;
return __len;
}
else
return 0;
}

ARGP_FS_EI int
__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str)
{
size_t __len = strlen (__str);
if (__len)
{
size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
return __wrote == __len ? 0 : -1;
}
else
return 0;
}

ARGP_FS_EI int
__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
{
if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
return *__fs->p++ = __ch;
else
return EOF;
}

/* Set __FS's left margin to __LMARGIN and return the old value. */
ARGP_FS_EI size_t
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->lmargin;
__fs->lmargin = __lmargin;
return __old;
}

/* Set __FS's right margin to __RMARGIN and return the old value. */
ARGP_FS_EI size_t
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->rmargin;
__fs->rmargin = __rmargin;
return __old;
}

/* Set FS's wrap margin to __WMARGIN and return the old value. */
ARGP_FS_EI size_t
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->wmargin;
__fs->wmargin = __wmargin;
return __old;
}

/* Return the column number of the current output point in __FS. */
ARGP_FS_EI size_t
__argp_fmtstream_point (argp_fmtstream_t __fs)
{
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
return __fs->point_col >= 0 ? __fs->point_col : 0;
}

#if !_LIBC
#undef __argp_fmtstream_putc
#undef __argp_fmtstream_puts
#undef __argp_fmtstream_write
#undef __argp_fmtstream_set_lmargin
#undef __argp_fmtstream_set_rmargin
#undef __argp_fmtstream_set_wmargin
#undef __argp_fmtstream_point
#undef __argp_fmtstream_update
#undef __argp_fmtstream_ensure
#endif

#endif /* __OPTIMIZE__ */

#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */

#endif /* argp-fmtstream.h */

baseline bum
04-28-2013, 01:04 PM
/* Real definitions for extern inline functions in argp-fmtstream.h
Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#define ARGP_FS_EI
#undef __OPTIMIZE__
#define __OPTIMIZE__ 1
#include "argp-fmtstream.h"

#if 0
/* Not exported. */
/* Add weak aliases. */
#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias)

weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc)
weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts)
weak_alias (__argp_fmtstream_write, argp_fmtstream_write)
weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin)
weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin)
weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin)
weak_alias (__argp_fmtstream_point, argp_fmtstream_point)

#endif
#endif

baseline bum
04-28-2013, 01:05 PM
/* Hierarchial argument parsing help output
Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# if HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
#endif

#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <ctype.h>
#include <limits.h>
#ifdef _LIBC
# include <../libio/libioP.h>
# include <wchar.h>
#endif

#ifndef _
/* This is for other GNU distributions with internationalized messages. */
# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef dgettext
# define dgettext(domain, msgid) \
__dcgettext (domain, msgid, LC_MESSAGES)
# endif
# else
# define dgettext(domain, msgid) (msgid)
# endif
#endif

#ifndef _LIBC
# if HAVE_STRERROR_R
# if !HAVE_DECL_STRERROR_R
char *strerror_r (int errnum, char *buf, size_t buflen);
# endif
# else
# if !HAVE_DECL_STRERROR
char *strerror (int errnum);
# endif
# endif
#endif

#include "argp.h"
#include "argp-fmtstream.h"
#include "argp-namefrob.h"

#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif

/* User-selectable (using an environment variable) formatting parameters.

These may be specified in an environment variable called `ARGP_HELP_FMT',
with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2
Where VALn must be a positive integer. The list of variables is in the
UPARAM_NAMES vector, below. */

/* Default parameters. */
#define DUP_ARGS 0 /* True if option argument can be duplicated. */
#define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */
#define SHORT_OPT_COL 2 /* column in which short options start */
#define LONG_OPT_COL 6 /* column in which long options start */
#define DOC_OPT_COL 2 /* column in which doc options start */
#define OPT_DOC_COL 29 /* column in which option text starts */
#define HEADER_COL 1 /* column in which group headers are printed */
#define USAGE_INDENT 12 /* indentation of wrapped usage lines */
#define RMARGIN 79 /* right margin used for wrapping */

/* User-selectable (using an environment variable) formatting parameters.
They must all be of type `int' for the parsing code to work. */
struct uparams
{
/* If true, arguments for an option are shown with both short and long
options, even when a given option has both, e.g. `-x ARG, --longx=ARG'.
If false, then if an option has both, the argument is only shown with
the long one, e.g., `-x, --longx=ARG', and a message indicating that
this really means both is printed below the options. */
int dup_args;

/* This is true if when DUP_ARGS is false, and some duplicate arguments have
been suppressed, an explanatory message should be printed. */
int dup_args_note;

/* Various output columns. */
int short_opt_col;
int long_opt_col;
int doc_opt_col;
int opt_doc_col;
int header_col;
int usage_indent;
int rmargin;
};

/* This is a global variable, as user options are only ever read once. */
static struct uparams uparams = {
DUP_ARGS, DUP_ARGS_NOTE,
SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL,
USAGE_INDENT, RMARGIN
};

/* A particular uparam, and what the user name is. */
struct uparam_name
{
const char name[14]; /* User name. */
bool is_bool; /* Whether it's `boolean'. */
uint8_t uparams_offs; /* Location of the (int) field in UPARAMS. */
};

/* The name-field mappings we know about. */
static const struct uparam_name uparam_names[] =
{
{ "dup-args", true, offsetof (struct uparams, dup_args) },
{ "dup-args-note", true, offsetof (struct uparams, dup_args_note) },
{ "short-opt-col", false, offsetof (struct uparams, short_opt_col) },
{ "long-opt-col", false, offsetof (struct uparams, long_opt_col) },
{ "doc-opt-col", false, offsetof (struct uparams, doc_opt_col) },
{ "opt-doc-col", false, offsetof (struct uparams, opt_doc_col) },
{ "header-col", false, offsetof (struct uparams, header_col) },
{ "usage-indent", false, offsetof (struct uparams, usage_indent) },
{ "rmargin", false, offsetof (struct uparams, rmargin) }
};
#define nuparam_names (sizeof (uparam_names) / sizeof (uparam_names[0]))

/* Read user options from the environment, and fill in UPARAMS appropiately. */
static void
fill_in_uparams (const struct argp_state *state)
{
const char *var = getenv ("ARGP_HELP_FMT");

#define SKIPWS(p) do { while (isspace (*p)) p++; } while (0);

if (var)
/* Parse var. */
while (*var)
{
SKIPWS (var);

if (isalpha (*var))
{
size_t var_len;
const struct uparam_name *un;
int unspec = 0, val = 0;
const char *arg = var;

while (isalnum (*arg) || *arg == '-' || *arg == '_')
arg++;
var_len = arg - var;

SKIPWS (arg);

if (*arg == '\0' || *arg == ',')
unspec = 1;
else if (*arg == '=')
{
arg++;
SKIPWS (arg);
}

if (unspec)
{
if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
{
val = 0;
var += 3;
var_len -= 3;
}
else
val = 1;
}
else if (isdigit (*arg))
{
val = atoi (arg);
while (isdigit (*arg))
arg++;
SKIPWS (arg);
}

un = uparam_names;
size_t u;
for (u = 0; u < nuparam_names; ++un, ++u)
if (strlen (un->name) == var_len
&& strncmp (var, un->name, var_len) == 0)
{
if (unspec && !un->is_bool)
__argp_failure (state, 0, 0,
dgettext (state == NULL ? NULL
: state->root_argp->argp_domain,
"\
%.*s: ARGP_HELP_FMT parameter requires a value"),
(int) var_len, var);
else
*(int *)((char *)&uparams + un->uparams_offs) = val;
break;
}
if (u == nuparam_names)
__argp_failure (state, 0, 0,
dgettext (state == NULL ? NULL
: state->root_argp->argp_domain, "\
%.*s: Unknown ARGP_HELP_FMT parameter"),
(int) var_len, var);

var = arg;
if (*var == ',')
var++;
}
else if (*var)
{
__argp_failure (state, 0, 0,
dgettext (state == NULL ? NULL
: state->root_argp->argp_domain,
"Garbage in ARGP_HELP_FMT: %s"), var);
break;
}
}
}

/* Returns true if OPT hasn't been marked invisible. Visibility only affects
whether OPT is displayed or used in sorting, not option shadowing. */
#define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN))

/* Returns true if OPT is an alias for an earlier option. */
#define oalias(opt) ((opt)->flags & OPTION_ALIAS)

/* Returns true if OPT is an documentation-only entry. */
#define odoc(opt) ((opt)->flags & OPTION_DOC)

/* Returns true if OPT is the end-of-list marker for a list of options. */
#define oend(opt) __option_is_end (opt)

/* Returns true if OPT has a short option. */
#define oshort(opt) __option_is_short (opt)

/*
The help format for a particular option is like:

-xARG, -yARG, --long1=ARG, --long2=ARG Documentation...

Where ARG will be omitted if there's no argument, for this option, or
will be surrounded by "[" and "]" appropiately if the argument is
optional. The documentation string is word-wrapped appropiately, and if
the list of options is long enough, it will be started on a separate line.
If there are no short options for a given option, the first long option is
indented slighly in a way that's supposed to make most long options appear
to be in a separate column.

For example, the following output (from ps):

-p PID, --pid=PID List the process PID
--pgrp=PGRP List processes in the process group PGRP
-P, -x, --no-parent Include processes without parents
-Q, --all-fields Don't elide unusable fields (normally if there's
some reason ps can't print a field for any
process, it's removed from the output entirely)
-r, --reverse, --gratuitously-long-reverse-option
Reverse the order of any sort
--session[=SID] Add the processes from the session SID (which
defaults to the sid of the current process)

Here are some more options:
-f ZOT, --foonly=ZOT Glork a foonly
-z, --zaza Snit a zar

-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version

The struct argp_option array for the above could look like:

{
{"pid", 'p', "PID", 0, "List the process PID"},
{"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"},
{"no-parent", 'P', 0, 0, "Include processes without parents"},
{0, 'x', 0, OPTION_ALIAS},
{"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
" if there's some reason ps can't"
" print a field for any process, it's"
" removed from the output entirely)" },
{"reverse", 'r', 0, 0, "Reverse the order of any sort"},
{"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
{"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL,
"Add the processes from the session"
" SID (which defaults to the sid of"
" the current process)" },

{0,0,0,0, "Here are some more options:"},
{"foonly", 'f', "ZOT", 0, "Glork a foonly"},
{"zaza", 'z', 0, 0, "Snit a zar"},

{0}
}

Note that the last three options are automatically supplied by argp_parse,
unless you tell it not to with ARGP_NO_HELP.

*/

/* Returns true if CH occurs between BEG and END. */
static int
find_char (char ch, char *beg, char *end)
{
while (beg < end)
if (*beg == ch)
return 1;
else
beg++;
return 0;
}

struct hol_cluster; /* fwd decl */

struct hol_entry
{
/* First option. */
const struct argp_option *opt;
/* Number of options (including aliases). */
unsigned num;

/* A pointers into the HOL's short_options field, to the first short option
letter for this entry. The order of the characters following this point
corresponds to the order of options pointed to by OPT, and there are at
most NUM. A short option recorded in a option following OPT is only
valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's
probably been shadowed by some other entry). */
char *short_options;

/* Entries are sorted by their group first, in the order:
1, 2, ..., n, 0, -m, ..., -2, -1
and then alphabetically within each group. The default is 0. */
int group;

/* The cluster of options this entry belongs to, or 0 if none. */
struct hol_cluster *cluster;

/* The argp from which this option came. */
const struct argp *argp;
};

/* A cluster of entries to reflect the argp tree structure. */
struct hol_cluster
{
/* A descriptive header printed before options in this cluster. */
const char *header;

/* Used to order clusters within the same group with the same parent,
according to the order in which they occurred in the parent argp's child
list. */
int index;

/* How to sort this cluster with respect to options and other clusters at the
same depth (clusters always follow options in the same group). */
int group;

/* The cluster to which this cluster belongs, or 0 if it's at the base
level. */
struct hol_cluster *parent;

/* The argp from which this cluster is (eventually) derived. */
const struct argp *argp;

/* The distance this cluster is from the root. */
int depth;

/* Clusters in a given hol are kept in a linked list, to make freeing them
possible. */
struct hol_cluster *next;
};

/* A list of options for help. */
struct hol
{
/* An array of hol_entry's. */
struct hol_entry *entries;
/* The number of entries in this hol. If this field is zero, the others
are undefined. */
unsigned num_entries;

/* A string containing all short options in this HOL. Each entry contains
pointers into this string, so the order can't be messed with blindly. */
char *short_options;

/* Clusters of entries in this hol. */
struct hol_cluster *clusters;
};

/* Create a struct hol from the options in ARGP. CLUSTER is the
hol_cluster in which these entries occur, or 0, if at the root. */
static struct hol *
make_hol (const struct argp *argp, struct hol_cluster *cluster)
{
char *so;
const struct argp_option *o;
const struct argp_option *opts = argp->options;
struct hol_entry *entry;
unsigned num_short_options = 0;
struct hol *hol = malloc (sizeof (struct hol));

assert (hol);

hol->num_entries = 0;
hol->clusters = 0;

if (opts)
{
int cur_group = 0;

/* The first option must not be an alias. */
assert (! oalias (opts));

baseline bum
04-28-2013, 01:05 PM
/* Calculate the space needed. */
for (o = opts; ! oend (o); o++)
{
if (! oalias (o))
hol->num_entries++;
if (oshort (o))
num_short_options++; /* This is an upper bound. */
}

hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
hol->short_options = malloc (num_short_options + 1);

assert (hol->entries && hol->short_options);
#if SIZE_MAX <= UINT_MAX
assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
#endif

/* Fill in the entries. */
so = hol->short_options;
for (o = opts, entry = hol->entries; ! oend (o); entry++)
{
entry->opt = o;
entry->num = 0;
entry->short_options = so;
entry->group = cur_group =
o->group
? o->group
: ((!o->name && !o->key)
? cur_group + 1
: cur_group);
entry->cluster = cluster;
entry->argp = argp;

do
{
entry->num++;
if (oshort (o) && ! find_char (o->key, hol->short_options, so))
/* O has a valid short option which hasn't already been used.*/
*so++ = o->key;
o++;
}
while (! oend (o) && oalias (o));
}
*so = '\0'; /* null terminated so we can find the length */
}

return hol;
}

/* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the
associated argp child list entry), INDEX, and PARENT, and return a pointer
to it. ARGP is the argp that this cluster results from. */
static struct hol_cluster *
hol_add_cluster (struct hol *hol, int group, const char *header, int index,
struct hol_cluster *parent, const struct argp *argp)
{
struct hol_cluster *cl = malloc (sizeof (struct hol_cluster));
if (cl)
{
cl->group = group;
cl->header = header;

cl->index = index;
cl->parent = parent;
cl->argp = argp;
cl->depth = parent ? parent->depth + 1 : 0;

cl->next = hol->clusters;
hol->clusters = cl;
}
return cl;
}

/* Free HOL and any resources it uses. */
static void
hol_free (struct hol *hol)
{
struct hol_cluster *cl = hol->clusters;

while (cl)
{
struct hol_cluster *next = cl->next;
free (cl);
cl = next;
}

if (hol->num_entries > 0)
{
free (hol->entries);
free (hol->short_options);
}

free (hol);
}

static int
hol_entry_short_iterate (const struct hol_entry *entry,
int (*func)(const struct argp_option *opt,
const struct argp_option *real,
const char *domain, void *cookie),
const char *domain, void *cookie)
{
unsigned nopts;
int val = 0;
const struct argp_option *opt, *real = entry->opt;
char *so = entry->short_options;

for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
if (oshort (opt) && *so == opt->key)
{
if (!oalias (opt))
real = opt;
if (ovisible (opt))
val = (*func)(opt, real, domain, cookie);
so++;
}

return val;
}

static inline int
__attribute__ ((always_inline))
hol_entry_long_iterate (const struct hol_entry *entry,
int (*func)(const struct argp_option *opt,
const struct argp_option *real,
const char *domain, void *cookie),
const char *domain, void *cookie)
{
unsigned nopts;
int val = 0;
const struct argp_option *opt, *real = entry->opt;

for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
if (opt->name)
{
if (!oalias (opt))
real = opt;
if (ovisible (opt))
val = (*func)(opt, real, domain, cookie);
}

return val;
}

/* Iterator that returns true for the first short option. */
static inline int
until_short (const struct argp_option *opt, const struct argp_option *real,
const char *domain, void *cookie)
{
return oshort (opt) ? opt->key : 0;
}

/* Returns the first valid short option in ENTRY, or 0 if there is none. */
static char
hol_entry_first_short (const struct hol_entry *entry)
{
return hol_entry_short_iterate (entry, until_short,
entry->argp->argp_domain, 0);
}

/* Returns the first valid long option in ENTRY, or 0 if there is none. */
static const char *
hol_entry_first_long (const struct hol_entry *entry)
{
const struct argp_option *opt;
unsigned num;
for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
return opt->name;
return 0;
}

/* Returns the entry in HOL with the long option name NAME, or 0 if there is
none. */
static struct hol_entry *
hol_find_entry (struct hol *hol, const char *name)
{
struct hol_entry *entry = hol->entries;
unsigned num_entries = hol->num_entries;

while (num_entries-- > 0)
{
const struct argp_option *opt = entry->opt;
unsigned num_opts = entry->num;

while (num_opts-- > 0)
if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
return entry;
else
opt++;

entry++;
}

return 0;
}

/* If an entry with the long option NAME occurs in HOL, set it's special
sort position to GROUP. */
static void
hol_set_group (struct hol *hol, const char *name, int group)
{
struct hol_entry *entry = hol_find_entry (hol, name);
if (entry)
entry->group = group;
}

/* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1.
EQ is what to return if GROUP1 and GROUP2 are the same. */
static int
group_cmp (int group1, int group2, int eq)
{
if (group1 == group2)
return eq;
else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0))
return group1 - group2;
else
return group2 - group1;
}

/* Compare clusters CL1 & CL2 by the order that they should appear in
output. */
static int
hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2)
{
/* If one cluster is deeper than the other, use its ancestor at the same
level, so that finding the common ancestor is straightforward. */
while (cl1->depth > cl2->depth)
cl1 = cl1->parent;
while (cl2->depth > cl1->depth)
cl2 = cl2->parent;

/* Now reduce both clusters to their ancestors at the point where both have
a common parent; these can be directly compared. */
while (cl1->parent != cl2->parent)
cl1 = cl1->parent, cl2 = cl2->parent;

return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index);
}

/* Return the ancestor of CL that's just below the root (i.e., has a parent
of 0). */
static struct hol_cluster *
hol_cluster_base (struct hol_cluster *cl)
{
while (cl->parent)
cl = cl->parent;
return cl;
}

/* Return true if CL1 is a child of CL2. */
static int
hol_cluster_is_child (const struct hol_cluster *cl1,
const struct hol_cluster *cl2)
{
while (cl1 && cl1 != cl2)
cl1 = cl1->parent;
return cl1 == cl2;
}

/* Given the name of a OPTION_DOC option, modifies NAME to start at the tail
that should be used for comparisons, and returns true iff it should be
treated as a non-option. */
static int
canon_doc_option (const char **name)
{
int non_opt;
/* Skip initial whitespace. */
while (isspace (**name))
(*name)++;
/* Decide whether this looks like an option (leading `-') or not. */
non_opt = (**name != '-');
/* Skip until part of name used for sorting. */
while (**name && !isalnum (**name))
(*name)++;
return non_opt;
}

/* Order ENTRY1 & ENTRY2 by the order which they should appear in a help
listing. */
static int
hol_entry_cmp (const struct hol_entry *entry1,
const struct hol_entry *entry2)
{
/* The group numbers by which the entries should be ordered; if either is
in a cluster, then this is just the group within the cluster. */
int group1 = entry1->group, group2 = entry2->group;

if (entry1->cluster != entry2->cluster)
{
/* The entries are not within the same cluster, so we can't compare them
directly, we have to use the appropiate clustering level too. */
if (! entry1->cluster)
/* ENTRY1 is at the `base level', not in a cluster, so we have to
compare it's group number with that of the base cluster in which
ENTRY2 resides. Note that if they're in the same group, the
clustered option always comes laster. */
return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1);
else if (! entry2->cluster)
/* Likewise, but ENTRY2's not in a cluster. */
return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1);
else
/* Both entries are in clusters, we can just compare the clusters. */
return hol_cluster_cmp (entry1->cluster, entry2->cluster);
}
else if (group1 == group2)
/* The entries are both in the same cluster and group, so compare them
alphabetically. */
{
int short1 = hol_entry_first_short (entry1);
int short2 = hol_entry_first_short (entry2);
int doc1 = odoc (entry1->opt);
int doc2 = odoc (entry2->opt);
const char *long1 = hol_entry_first_long (entry1);
const char *long2 = hol_entry_first_long (entry2);

if (doc1)
doc1 = long1 != NULL && canon_doc_option (&long1);
if (doc2)
doc2 = long2 != NULL && canon_doc_option (&long2);

if (doc1 != doc2)
/* `documentation' options always follow normal options (or
documentation options that *look* like normal options). */
return doc1 - doc2;
else if (!short1 && !short2 && long1 && long2)
/* Only long options. */
return __strcasecmp (long1, long2);
else
/* Compare short/short, long/short, short/long, using the first
character of long options. Entries without *any* valid
options (such as options with OPTION_HIDDEN set) will be put
first, but as they're not displayed, it doesn't matter where
they are. */
{
char first1 = short1 ? short1 : long1 ? *long1 : 0;
char first2 = short2 ? short2 : long2 ? *long2 : 0;
#ifdef _tolower
int lower_cmp = _tolower (first1) - _tolower (first2);
#else
int lower_cmp = tolower (first1) - tolower (first2);
#endif
/* Compare ignoring case, except when the options are both the
same letter, in which case lower-case always comes first. */
return lower_cmp ? lower_cmp : first2 - first1;
}
}
else
/* Within the same cluster, but not the same group, so just compare
groups. */
return group_cmp (group1, group2, 0);
}

/* Version of hol_entry_cmp with correct signature for qsort. */
static int
hol_entry_qcmp (const void *entry1_v, const void *entry2_v)
{
return hol_entry_cmp (entry1_v, entry2_v);
}

/* Sort HOL by group and alphabetically by option name (with short options
taking precedence over long). Since the sorting is for display purposes
only, the shadowing of options isn't effected. */
static void
hol_sort (struct hol *hol)
{
if (hol->num_entries > 0)
qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry),
hol_entry_qcmp);
}

/* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow
any in MORE with the same name. */
static void
hol_append (struct hol *hol, struct hol *more)
{
struct hol_cluster **cl_end = &hol->clusters;

/* Steal MORE's cluster list, and add it to the end of HOL's. */
while (*cl_end)
cl_end = &(*cl_end)->next;
*cl_end = more->clusters;
more->clusters = 0;

/* Merge entries. */
if (more->num_entries > 0)
{
if (hol->num_entries == 0)
{
hol->num_entries = more->num_entries;
hol->entries = more->entries;
hol->short_options = more->short_options;
more->num_entries = 0; /* Mark MORE's fields as invalid. */
}
else
/* Append the entries in MORE to those in HOL, taking care to only add
non-shadowed SHORT_OPTIONS values. */
{
unsigned left;
char *so, *more_so;
struct hol_entry *e;
unsigned num_entries = hol->num_entries + more->num_entries;
struct hol_entry *entries =
malloc (num_entries * sizeof (struct hol_entry));
unsigned hol_so_len = strlen (hol->short_options);
char *short_options =
malloc (hol_so_len + strlen (more->short_options) + 1);

assert (entries && short_options);
#if SIZE_MAX <= UINT_MAX
assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry));
#endif

__mempcpy (__mempcpy (entries, hol->entries,
hol->num_entries * sizeof (struct hol_entry)),
more->entries,
more->num_entries * sizeof (struct hol_entry));

__mempcpy (short_options, hol->short_options, hol_so_len);

/* Fix up the short options pointers from HOL. */
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
e->short_options += (short_options - hol->short_options);

/* Now add the short options from MORE, fixing up its entries
too. */
so = short_options + hol_so_len;
more_so = more->short_options;
for (left = more->num_entries; left > 0; e++, left--)
{
int opts_left;
const struct argp_option *opt;

e->short_options = so;

for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
{
int ch = *more_so;
if (oshort (opt) && ch == opt->key)
/* The next short option in MORE_SO, CH, is from OPT. */
{
if (! find_char (ch, short_options,
short_options + hol_so_len))
/* The short option CH isn't shadowed by HOL's options,
so add it to the sum. */
*so++ = ch;
more_so++;
}
}
}

*so = '\0';

baseline bum
04-28-2013, 01:06 PM
free (hol->entries);
free (hol->short_options);

hol->entries = entries;
hol->num_entries = num_entries;
hol->short_options = short_options;
}
}

hol_free (more);
}

/* Inserts enough spaces to make sure STREAM is at column COL. */
static void
indent_to (argp_fmtstream_t stream, unsigned col)
{
int needed = col - __argp_fmtstream_point (stream);
while (needed-- > 0)
__argp_fmtstream_putc (stream, ' ');
}

/* Output to STREAM either a space, or a newline if there isn't room for at
least ENSURE characters before the right margin. */
static void
space (argp_fmtstream_t stream, size_t ensure)
{
if (__argp_fmtstream_point (stream) + ensure
>= __argp_fmtstream_rmargin (stream))
__argp_fmtstream_putc (stream, '\n');
else
__argp_fmtstream_putc (stream, ' ');
}

/* If the option REAL has an argument, we print it in using the printf
format REQ_FMT or OPT_FMT depending on whether it's a required or
optional argument. */
static void
arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
const char *domain, argp_fmtstream_t stream)
{
if (real->arg)
{
if (real->flags & OPTION_ARG_OPTIONAL)
__argp_fmtstream_printf (stream, opt_fmt,
dgettext (domain, real->arg));
else
__argp_fmtstream_printf (stream, req_fmt,
dgettext (domain, real->arg));
}
}

/* Helper functions for hol_entry_help. */

/* State used during the execution of hol_help. */
struct hol_help_state
{
/* PREV_ENTRY should contain the previous entry printed, or 0. */
struct hol_entry *prev_entry;

/* If an entry is in a different group from the previous one, and SEP_GROUPS
is true, then a blank line will be printed before any output. */
int sep_groups;

/* True if a duplicate option argument was suppressed (only ever set if
UPARAMS.dup_args is false). */
int suppressed_dup_arg;
};

/* Some state used while printing a help entry (used to communicate with
helper functions). See the doc for hol_entry_help for more info, as most
of the fields are copied from its arguments. */
struct pentry_state
{
const struct hol_entry *entry;
argp_fmtstream_t stream;
struct hol_help_state *hhstate;

/* True if nothing's been printed so far. */
int first;

/* If non-zero, the state that was used to print this help. */
const struct argp_state *state;
};

/* If a user doc filter should be applied to DOC, do so. */
static const char *
filter_doc (const char *doc, int key, const struct argp *argp,
const struct argp_state *state)
{
if (argp && argp->help_filter)
/* We must apply a user filter to this output. */
{
void *input = __argp_input (argp, state);
return (*argp->help_filter) (key, doc, input);
}
else
/* No filter. */
return doc;
}

/* Prints STR as a header line, with the margin lines set appropiately, and
notes the fact that groups should be separated with a blank line. ARGP is
the argp that should dictate any user doc filtering to take place. Note
that the previous wrap margin isn't restored, but the left margin is reset
to 0. */
static void
print_header (const char *str, const struct argp *argp,
struct pentry_state *pest)
{
const char *tstr = dgettext (argp->argp_domain, str);
const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state);

if (fstr)
{
if (*fstr)
{
if (pest->hhstate->prev_entry)
/* Precede with a blank line. */
__argp_fmtstream_putc (pest->stream, '\n');
indent_to (pest->stream, uparams.header_col);
__argp_fmtstream_set_lmargin (pest->stream, uparams.header_col);
__argp_fmtstream_set_wmargin (pest->stream, uparams.header_col);
__argp_fmtstream_puts (pest->stream, fstr);
__argp_fmtstream_set_lmargin (pest->stream, 0);
__argp_fmtstream_putc (pest->stream, '\n');
}

pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */
}

if (fstr != tstr)
free ((char *) fstr);
}

/* Inserts a comma if this isn't the first item on the line, and then makes
sure we're at least to column COL. If this *is* the first item on a line,
prints any pending whitespace/headers that should precede this line. Also
clears FIRST. */
static void
comma (unsigned col, struct pentry_state *pest)
{
if (pest->first)
{
const struct hol_entry *pe = pest->hhstate->prev_entry;
const struct hol_cluster *cl = pest->entry->cluster;

if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group)
__argp_fmtstream_putc (pest->stream, '\n');

if (cl && cl->header && *cl->header
&& (!pe
|| (pe->cluster != cl
&& !hol_cluster_is_child (pe->cluster, cl))))
/* If we're changing clusters, then this must be the start of the
ENTRY's cluster unless that is an ancestor of the previous one
(in which case we had just popped into a sub-cluster for a bit).
If so, then print the cluster's header line. */
{
int old_wm = __argp_fmtstream_wmargin (pest->stream);
print_header (cl->header, cl->argp, pest);
__argp_fmtstream_set_wmargin (pest->stream, old_wm);
}

pest->first = 0;
}
else
__argp_fmtstream_puts (pest->stream, ", ");

indent_to (pest->stream, col);
}

/* Print help for ENTRY to STREAM. */
static void
hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
argp_fmtstream_t stream, struct hol_help_state *hhstate)
{
unsigned num;
const struct argp_option *real = entry->opt, *opt;
char *so = entry->short_options;
int have_long_opt = 0; /* We have any long options. */
/* Saved margins. */
int old_lm = __argp_fmtstream_set_lmargin (stream, 0);
int old_wm = __argp_fmtstream_wmargin (stream);
/* PEST is a state block holding some of our variables that we'd like to
share with helper functions. */
struct pentry_state pest = { entry, stream, hhstate, 1, state };

if (! odoc (real))
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
have_long_opt = 1;
break;
}

/* First emit short options. */
__argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (oshort (opt) && opt->key == *so)
/* OPT has a valid (non shadowed) short option. */
{
if (ovisible (opt))
{
comma (uparams.short_opt_col, &pest);
__argp_fmtstream_putc (stream, '-');
__argp_fmtstream_putc (stream, *so);
if (!have_long_opt || uparams.dup_args)
arg (real, " %s", "[%s]",
state == NULL ? NULL : state->root_argp->argp_domain,
stream);
else if (real->arg)
hhstate->suppressed_dup_arg = 1;
}
so++;
}

/* Now, long options. */
if (odoc (real))
/* A `documentation' option. */
{
__argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
comma (uparams.doc_opt_col, &pest);
/* Calling gettext here isn't quite right, since sorting will
have been done on the original; but documentation options
should be pretty rare anyway... */
__argp_fmtstream_puts (stream,
dgettext (state == NULL ? NULL
: state->root_argp->argp_domain,
opt->name));
}
}
else
/* A real long option. */
{
__argp_fmtstream_set_wmargin (stream, uparams.long_opt_col);
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
comma (uparams.long_opt_col, &pest);
__argp_fmtstream_printf (stream, "--%s", opt->name);
arg (real, "=%s", "[=%s]",
state == NULL ? NULL : state->root_argp->argp_domain, stream);
}
}

/* Next, documentation strings. */
__argp_fmtstream_set_lmargin (stream, 0);

if (pest.first)
{
/* Didn't print any switches, what's up? */
if (!oshort (real) && !real->name)
/* This is a group header, print it nicely. */
print_header (real->doc, entry->argp, &pest);
else
/* Just a totally shadowed option or null header; print nothing. */
goto cleanup; /* Just return, after cleaning up. */
}
else
{
const char *tstr = real->doc ? dgettext (state == NULL ? NULL
: state->root_argp->argp_domain,
real->doc) : 0;
const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
if (fstr && *fstr)
{
unsigned int col = __argp_fmtstream_point (stream);

__argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col);
__argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col);

if (col > (unsigned int) (uparams.opt_doc_col + 3))
__argp_fmtstream_putc (stream, '\n');
else if (col >= (unsigned int) uparams.opt_doc_col)
__argp_fmtstream_puts (stream, " ");
else
indent_to (stream, uparams.opt_doc_col);

__argp_fmtstream_puts (stream, fstr);
}
if (fstr && fstr != tstr)
free ((char *) fstr);

/* Reset the left margin. */
__argp_fmtstream_set_lmargin (stream, 0);
__argp_fmtstream_putc (stream, '\n');
}

hhstate->prev_entry = entry;

cleanup:
__argp_fmtstream_set_lmargin (stream, old_lm);
__argp_fmtstream_set_wmargin (stream, old_wm);
}

/* Output a long help message about the options in HOL to STREAM. */
static void
hol_help (struct hol *hol, const struct argp_state *state,
argp_fmtstream_t stream)
{
unsigned num;
struct hol_entry *entry;
struct hol_help_state hhstate = { 0, 0, 0 };

for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
hol_entry_help (entry, state, stream, &hhstate);

if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
{
const char *tstr = dgettext (state == NULL ? NULL
: state->root_argp->argp_domain, "\
Mandatory or optional arguments to long options are also mandatory or \
optional for any corresponding short options.");
const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
state ? state->root_argp : 0, state);
if (fstr && *fstr)
{
__argp_fmtstream_putc (stream, '\n');
__argp_fmtstream_puts (stream, fstr);
__argp_fmtstream_putc (stream, '\n');
}
if (fstr && fstr != tstr)
free ((char *) fstr);
}
}

/* Helper functions for hol_usage. */

/* If OPT is a short option without an arg, append its key to the string
pointer pointer to by COOKIE, and advance the pointer. */
static int
add_argless_short_opt (const struct argp_option *opt,
const struct argp_option *real,
const char *domain, void *cookie)
{
char **snao_end = cookie;
if (!(opt->arg || real->arg)
&& !((opt->flags | real->flags) & OPTION_NO_USAGE))
*(*snao_end)++ = opt->key;
return 0;
}

/* If OPT is a short option with an arg, output a usage entry for it to the
stream pointed at by COOKIE. */
static int
usage_argful_short_opt (const struct argp_option *opt,
const struct argp_option *real,
const char *domain, void *cookie)
{
argp_fmtstream_t stream = cookie;
const char *arg = opt->arg;
int flags = opt->flags | real->flags;

if (! arg)
arg = real->arg;

if (arg && !(flags & OPTION_NO_USAGE))
{
arg = dgettext (domain, arg);

if (flags & OPTION_ARG_OPTIONAL)
__argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
else
{
/* Manually do line wrapping so that it (probably) won't
get wrapped at the embedded space. */
space (stream, 6 + strlen (arg));
__argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
}
}

return 0;
}

/* Output a usage entry for the long option opt to the stream pointed at by
COOKIE. */
static int
usage_long_opt (const struct argp_option *opt,
const struct argp_option *real,
const char *domain, void *cookie)
{
argp_fmtstream_t stream = cookie;
const char *arg = opt->arg;
int flags = opt->flags | real->flags;

if (! arg)
arg = real->arg;

if (! (flags & OPTION_NO_USAGE))
{
if (arg)
{
arg = dgettext (domain, arg);
if (flags & OPTION_ARG_OPTIONAL)
__argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
else
__argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
}
else
__argp_fmtstream_printf (stream, " [--%s]", opt->name);
}

return 0;
}

/* Print a short usage description for the arguments in HOL to STREAM. */
static void
hol_usage (struct hol *hol, argp_fmtstream_t stream)
{
if (hol->num_entries > 0)
{
unsigned nentries;
struct hol_entry *entry;
char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1);
char *snao_end = short_no_arg_opts;

/* First we put a list of short options without arguments. */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, add_argless_short_opt,
entry->argp->argp_domain, &snao_end);
if (snao_end > short_no_arg_opts)
{
*snao_end++ = 0;
__argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts);
}

/* Now a list of short options *with* arguments. */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, usage_argful_short_opt,
entry->argp->argp_domain, stream);

/* Finally, a list of long options (whew!). */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_long_iterate (entry, usage_long_opt,
entry->argp->argp_domain, stream);
}
}

baseline bum
04-28-2013, 01:07 PM
/* Make a HOL containing all levels of options in ARGP. CLUSTER is the
cluster in which ARGP's entries should be clustered, or 0. */
static struct hol *
argp_hol (const struct argp *argp, struct hol_cluster *cluster)
{
const struct argp_child *child = argp->children;
struct hol *hol = make_hol (argp, cluster);
if (child)
while (child->argp)
{
struct hol_cluster *child_cluster =
((child->group || child->header)
/* Put CHILD->argp within its own cluster. */
? hol_add_cluster (hol, child->group, child->header,
child - argp->children, cluster, argp)
/* Just merge it into the parent's cluster. */
: cluster);
hol_append (hol, argp_hol (child->argp, child_cluster)) ;
child++;
}
return hol;
}


/* Calculate how many different levels with alternative args strings exist in
ARGP. */
static size_t
argp_args_levels (const struct argp *argp)
{
size_t levels = 0;
const struct argp_child *child = argp->children;

if (argp->args_doc && strchr (argp->args_doc, '\n'))
levels++;

if (child)
while (child->argp)
levels += argp_args_levels ((child++)->argp);

return levels;
}

/* Print all the non-option args documented in ARGP to STREAM. Any output is
preceded by a space. LEVELS is a pointer to a byte vector the length
returned by argp_args_levels; it should be initialized to zero, and
updated by this routine for the next call if ADVANCE is true. True is
returned as long as there are more patterns to output. */
static int
argp_args_usage (const struct argp *argp, const struct argp_state *state,
char **levels, int advance, argp_fmtstream_t stream)
{
char *our_level = *levels;
int multiple = 0;
const struct argp_child *child = argp->children;
const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);

if (fdoc)
{
const char *cp = fdoc;
nl = __strchrnul (cp, '\n');
if (*nl != '\0')
/* This is a `multi-level' args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */
{
int i;
multiple = 1;
for (i = 0; i < *our_level; i++)
cp = nl + 1, nl = __strchrnul (cp, '\n');
(*levels)++;
}

/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
space (stream, 1 + nl - cp);

__argp_fmtstream_write (stream, cp, nl - cp);
}
if (fdoc && fdoc != tdoc)
free ((char *)fdoc); /* Free user's modified doc string. */

if (child)
while (child->argp)
advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);

if (advance && multiple)
{
/* Need to increment our level. */
if (*nl)
/* There's more we can do here. */
{
(*our_level)++;
advance = 0; /* Our parent shouldn't advance also. */
}
else if (*our_level > 0)
/* We had multiple levels, but used them up; reset to zero. */
*our_level = 0;
}

return !advance;
}

/* Print the documentation for ARGP to STREAM; if POST is false, then
everything preceeding a `\v' character in the documentation strings (or
the whole string, for those with none) is printed, otherwise, everything
following the `\v' character (nothing for strings without). Each separate
bit of documentation is separated a blank line, and if PRE_BLANK is true,
then the first is as well. If FIRST_ONLY is true, only the first
occurrence is output. Returns true if anything was output. */
static int
argp_doc (const struct argp *argp, const struct argp_state *state,
int post, int pre_blank, int first_only,
argp_fmtstream_t stream)
{
const char *text;
const char *inp_text;
void *input = 0;
int anything = 0;
size_t inp_text_limit = 0;
const char *doc = dgettext (argp->argp_domain, argp->doc);
const struct argp_child *child = argp->children;

if (doc)
{
char *vt = strchr (doc, '\v');
inp_text = post ? (vt ? vt + 1 : 0) : doc;
inp_text_limit = (!post && vt) ? (vt - doc) : 0;
}
else
inp_text = 0;

if (argp->help_filter)
/* We have to filter the doc strings. */
{
if (inp_text_limit)
/* Copy INP_TEXT so that it's nul-terminated. */
inp_text = __strndup (inp_text, inp_text_limit);
input = __argp_input (argp, state);
text =
(*argp->help_filter) (post
? ARGP_KEY_HELP_POST_DOC
: ARGP_KEY_HELP_PRE_DOC,
inp_text, input);
}
else
text = (const char *) inp_text;

if (text)
{
if (pre_blank)
__argp_fmtstream_putc (stream, '\n');

if (text == inp_text && inp_text_limit)
__argp_fmtstream_write (stream, inp_text, inp_text_limit);
else
__argp_fmtstream_puts (stream, text);

if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
__argp_fmtstream_putc (stream, '\n');

anything = 1;
}

if (text && text != inp_text)
free ((char *) text); /* Free TEXT returned from the help filter. */
if (inp_text && inp_text_limit && argp->help_filter)
free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */

if (post && argp->help_filter)
/* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
{
text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
if (text)
{
if (anything || pre_blank)
__argp_fmtstream_putc (stream, '\n');
__argp_fmtstream_puts (stream, text);
free ((char *) text);
if (__argp_fmtstream_point (stream)
> __argp_fmtstream_lmargin (stream))
__argp_fmtstream_putc (stream, '\n');
anything = 1;
}
}

if (child)
while (child->argp && !(first_only && anything))
anything |=
argp_doc ((child++)->argp, state,
post, anything || pre_blank, first_only,
stream);

return anything;
}

/* Output a usage message for ARGP to STREAM. If called from
argp_state_help, STATE is the relevent parsing state. FLAGS are from the
set ARGP_HELP_*. NAME is what to use wherever a `program name' is
needed. */
static void
_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
unsigned flags, char *name)
{
int anything = 0; /* Whether we've output anything. */
struct hol *hol = 0;
argp_fmtstream_t fs;

if (! stream)
return;

#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__flockfile (stream);
#endif

fill_in_uparams (state);

fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
if (! fs)
{
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__funlockfile (stream);
#endif
return;
}

if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
{
hol = argp_hol (argp, 0);

/* If present, these options always come last. */
hol_set_group (hol, "help", -1);
hol_set_group (hol, "version", -1);

hol_sort (hol);
}

if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
/* Print a short `Usage:' message. */
{
int first_pattern = 1, more_patterns;
size_t num_pattern_levels = argp_args_levels (argp);
char *pattern_levels = alloca (num_pattern_levels);

memset (pattern_levels, 0, num_pattern_levels);

do
{
int old_lm;
int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent);
char *levels = pattern_levels;

if (first_pattern)
__argp_fmtstream_printf (fs, "%s %s",
dgettext (argp->argp_domain, "Usage:"),
name);
else
__argp_fmtstream_printf (fs, "%s %s",
dgettext (argp->argp_domain, " or: "),
name);

/* We set the lmargin as well as the wmargin, because hol_usage
manually wraps options with newline to avoid annoying breaks. */
old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent);

if (flags & ARGP_HELP_SHORT_USAGE)
/* Just show where the options go. */
{
if (hol->num_entries > 0)
__argp_fmtstream_puts (fs, dgettext (argp->argp_domain,
" [OPTION...]"));
}
else
/* Actually print the options. */
{
hol_usage (hol, fs);
flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */
}

more_patterns = argp_args_usage (argp, state, &levels, 1, fs);

__argp_fmtstream_set_wmargin (fs, old_wm);
__argp_fmtstream_set_lmargin (fs, old_lm);

__argp_fmtstream_putc (fs, '\n');
anything = 1;

first_pattern = 0;
}
while (more_patterns);
}

if (flags & ARGP_HELP_PRE_DOC)
anything |= argp_doc (argp, state, 0, 0, 1, fs);

if (flags & ARGP_HELP_SEE)
{
__argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\
Try `%s --help' or `%s --usage' for more information.\n"),
name, name);
anything = 1;
}

if (flags & ARGP_HELP_LONG)
/* Print a long, detailed help message. */
{
/* Print info about all the options. */
if (hol->num_entries > 0)
{
if (anything)
__argp_fmtstream_putc (fs, '\n');
hol_help (hol, state, fs);
anything = 1;
}
}

if (flags & ARGP_HELP_POST_DOC)
/* Print any documentation strings at the end. */
anything |= argp_doc (argp, state, 1, anything, 0, fs);

if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address)
{
if (anything)
__argp_fmtstream_putc (fs, '\n');
__argp_fmtstream_printf (fs, dgettext (argp->argp_domain,
"Report bugs to %s.\n"),
argp_program_bug_address);
anything = 1;
}

#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__funlockfile (stream);
#endif

if (hol)
hol_free (hol);

__argp_fmtstream_free (fs);
}

/* Output a usage message for ARGP to STREAM. FLAGS are from the set
ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */
void __argp_help (const struct argp *argp, FILE *stream,
unsigned flags, char *name)
{
_help (argp, 0, stream, flags, name);
}
#ifdef weak_alias
weak_alias (__argp_help, argp_help)
#endif

#ifndef _LIBC
char *__argp_basename (char *name)
{
char *short_name = strrchr (name, '/');
return short_name ? short_name + 1 : name;
}

char *
__argp_short_program_name (void)
{
# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
return program_invocation_short_name;
# elif HAVE_DECL_PROGRAM_INVOCATION_NAME
return __argp_basename (program_invocation_name);
# else
/* FIXME: What now? Miles suggests that it is better to use NULL,
but currently the value is passed on directly to fputs_unlocked,
so that requires more changes. */
# if __GNUC__
# warning No reasonable value to return
# endif /* __GNUC__ */
return "";
# endif
}
#endif

/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
from the set ARGP_HELP_*. */
void
__argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
{
if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream)
{
if (state && (state->flags & ARGP_LONG_ONLY))
flags |= ARGP_HELP_LONG_ONLY;

_help (state ? state->root_argp : 0, state, stream, flags,
state ? state->name : __argp_short_program_name ());

if (!state || ! (state->flags & ARGP_NO_EXIT))
{
if (flags & ARGP_HELP_EXIT_ERR)
exit (argp_err_exit_status);
if (flags & ARGP_HELP_EXIT_OK)
exit (0);
}
}
}
#ifdef weak_alias
weak_alias (__argp_state_help, argp_state_help)
#endif

/* If appropriate, print the printf string FMT and following args, preceded
by the program name and `:', to stderr, and followed by a `Try ... --help'
message, then exit (1). */
void
__argp_error (const struct argp_state *state, const char *fmt, ...)
{
if (!state || !(state->flags & ARGP_NO_ERRS))
{
FILE *stream = state ? state->err_stream : stderr;

if (stream)
{
va_list ap;

#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__flockfile (stream);
#endif

va_start (ap, fmt);

#ifdef _LIBC
char *buf;

if (_IO_vasprintf (&buf, fmt, ap) < 0)
buf = NULL;

__fxprintf (stream, "%s: %s\n",
state ? state->name : __argp_short_program_name (), buf);

free (buf);
#else
fputs_unlocked (state ? state->name : __argp_short_program_name (),
stream);
putc_unlocked (':', stream);
putc_unlocked (' ', stream);

vfprintf (stream, fmt, ap);

putc_unlocked ('\n', stream);
#endif

__argp_state_help (state, stream, ARGP_HELP_STD_ERR);

va_end (ap);

baseline bum
04-28-2013, 01:07 PM
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__funlockfile (stream);
#endif
}
}
}
#ifdef weak_alias
weak_alias (__argp_error, argp_error)
#endif

/* Similar to the standard gnu error-reporting function error(), but will
respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
to STATE->err_stream. This is useful for argument parsing code that is
shared between program startup (when exiting is desired) and runtime
option parsing (when typically an error code is returned instead). The
difference between this function and argp_error is that the latter is for
*parsing errors*, and the former is for other problems that occur during
parsing but don't reflect a (syntactic) problem with the input. */
void
__argp_failure (const struct argp_state *state, int status, int errnum,
const char *fmt, ...)
{
if (!state || !(state->flags & ARGP_NO_ERRS))
{
FILE *stream = state ? state->err_stream : stderr;

if (stream)
{
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__flockfile (stream);
#endif

#ifdef _LIBC
__fxprintf (stream, "%s",
state ? state->name : __argp_short_program_name ());
#else
fputs_unlocked (state ? state->name : __argp_short_program_name (),
stream);
#endif

if (fmt)
{
va_list ap;

va_start (ap, fmt);
#ifdef _LIBC
char *buf;

if (_IO_vasprintf (&buf, fmt, ap) < 0)
buf = NULL;

__fxprintf (stream, ": %s", buf);

free (buf);
#else
putc_unlocked (':', stream);
putc_unlocked (' ', stream);

vfprintf (stream, fmt, ap);
#endif

va_end (ap);
}

if (errnum)
{
char buf[200];

#ifdef _LIBC
__fxprintf (stream, ": %s",
__strerror_r (errnum, buf, sizeof (buf)));
#else
putc_unlocked (':', stream);
putc_unlocked (' ', stream);
# ifdef HAVE_STRERROR_R
fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
# else
fputs (strerror (errnum), stream);
# endif
#endif
}

if (_IO_fwide (stream, 0) > 0)
putwc_unlocked (L'\n', stream);
else
putc_unlocked ('\n', stream);

#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__funlockfile (stream);
#endif

if (status && (!state || !(state->flags & ARGP_NO_EXIT)))
exit (status);
}
}
}
#ifdef weak_alias
weak_alias (__argp_failure, argp_failure)
#endif

baseline bum
04-28-2013, 01:10 PM
/* Name frobnication for compiling argp outside of glibc
Copyright (C) 1997, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !_LIBC
/* This code is written for inclusion in gnu-libc, and uses names in the
namespace reserved for libc. If we're not compiling in libc, define those
names to be the normal ones instead. */

/* argp-parse functions */
#undef __argp_parse
#define __argp_parse argp_parse
#undef __option_is_end
#define __option_is_end _option_is_end
#undef __option_is_short
#define __option_is_short _option_is_short
#undef __argp_input
#define __argp_input _argp_input

/* argp-help functions */
#undef __argp_help
#define __argp_help argp_help
#undef __argp_error
#define __argp_error argp_error
#undef __argp_failure
#define __argp_failure argp_failure
#undef __argp_state_help
#define __argp_state_help argp_state_help
#undef __argp_usage
#define __argp_usage argp_usage

/* argp-fmtstream functions */
#undef __argp_make_fmtstream
#define __argp_make_fmtstream argp_make_fmtstream
#undef __argp_fmtstream_free
#define __argp_fmtstream_free argp_fmtstream_free
#undef __argp_fmtstream_putc
#define __argp_fmtstream_putc argp_fmtstream_putc
#undef __argp_fmtstream_puts
#define __argp_fmtstream_puts argp_fmtstream_puts
#undef __argp_fmtstream_write
#define __argp_fmtstream_write argp_fmtstream_write
#undef __argp_fmtstream_printf
#define __argp_fmtstream_printf argp_fmtstream_printf
#undef __argp_fmtstream_set_lmargin
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
#undef __argp_fmtstream_set_rmargin
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
#undef __argp_fmtstream_set_wmargin
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
#undef __argp_fmtstream_point
#define __argp_fmtstream_point argp_fmtstream_point
#undef __argp_fmtstream_update
#define __argp_fmtstream_update _argp_fmtstream_update
#undef __argp_fmtstream_ensure
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
#undef __argp_fmtstream_lmargin
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
#undef __argp_fmtstream_rmargin
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
#undef __argp_fmtstream_wmargin
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin

#include "mempcpy.h"
#include "strcase.h"
#include "strchrnul.h"
#include "strndup.h"

/* normal libc functions we call */
#undef __flockfile
#define __flockfile flockfile
#undef __funlockfile
#define __funlockfile funlockfile
#undef __mempcpy
#define __mempcpy mempcpy
#undef __sleep
#define __sleep sleep
#undef __strcasecmp
#define __strcasecmp strcasecmp
#undef __strchrnul
#define __strchrnul strchrnul
#undef __strerror_r
#define __strerror_r strerror_r
#undef __strndup
#define __strndup strndup
#undef __vsnprintf
#define __vsnprintf vsnprintf

#if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
# define clearerr_unlocked(x) clearerr (x)
#endif
#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
# define feof_unlocked(x) feof (x)
# endif
#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
# define ferror_unlocked(x) ferror (x)
# endif
#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
# define fflush_unlocked(x) fflush (x)
# endif
#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
# define fgets_unlocked(x,y,z) fgets (x,y,z)
# endif
#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
# define fputc_unlocked(x,y) fputc (x,y)
# endif
#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
# define fputs_unlocked(x,y) fputs (x,y)
# endif
#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
# endif
#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
# endif
#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
# define getc_unlocked(x) getc (x)
# endif
#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
# define getchar_unlocked() getchar ()
# endif
#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
# define putc_unlocked(x,y) putc (x,y)
# endif
#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
# define putchar_unlocked(x) putchar (x)
# endif

extern char *__argp_basename (char *name);

#endif /* !_LIBC */

#ifndef __set_errno
#define __set_errno(e) (errno = (e))
#endif

#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
# define __argp_short_program_name() (program_invocation_short_name)
#else
extern char *__argp_short_program_name (void);
#endif

baseline bum
04-28-2013, 01:11 PM
/* Hierarchial argument parsing, layered over getopt
Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# if HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
#endif

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <getopt.h>
#include <getopt_int.h>

#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef dgettext
# define dgettext(domain, msgid) \
__dcgettext (domain, msgid, LC_MESSAGES)
# endif
# else
# define dgettext(domain, msgid) (msgid)
# define gettext(msgid) (msgid)
# endif
#endif
#ifndef N_
# define N_(msgid) (msgid)
#endif

#include "argp.h"
#include "argp-namefrob.h"

/* Getopt return values. */
#define KEY_END (-1) /* The end of the options. */
#define KEY_ARG 1 /* A non-option argument. */
#define KEY_ERR '?' /* An error parsing the options. */

/* The meta-argument used to prevent any further arguments being interpreted
as options. */
#define QUOTE "--"

/* The number of bits we steal in a long-option value for our own use. */
#define GROUP_BITS CHAR_BIT

/* The number of bits available for the user value. */
#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS)
#define USER_MASK ((1 << USER_BITS) - 1)

/* EZ alias for ARGP_ERR_UNKNOWN. */
#define EBADKEY ARGP_ERR_UNKNOWN

/* Default options. */

/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
you can force the program to continue by attaching a debugger and setting
it to 0 yourself. */
static volatile int _argp_hang;

#define OPT_PROGNAME -2
#define OPT_USAGE -3
#define OPT_HANG -4

static const struct argp_option argp_default_options[] =
{
{"help", '?', 0, 0, N_("Give this help list"), -1},
{"usage", OPT_USAGE, 0, 0, N_("Give a short usage message")},
{"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name")},
{"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
N_("Hang for SECS seconds (default 3600)")},
{0, 0}
};

static error_t
argp_default_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case '?':
__argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
break;
case OPT_USAGE:
__argp_state_help (state, state->out_stream,
ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
break;

case OPT_PROGNAME: /* Set the program name. */
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = arg;
#endif
/* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
__PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
to be that, so we have to be a bit careful here.] */

/* Update what we use for messages. */
state->name = strrchr (arg, '/');
if (state->name)
state->name++;
else
state->name = arg;

#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
program_invocation_short_name = state->name;
#endif

if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
== ARGP_PARSE_ARGV0)
/* Update what getopt uses too. */
state->argv[0] = arg;

break;

case OPT_HANG:
_argp_hang = atoi (arg ? arg : "3600");
while (_argp_hang-- > 0)
__sleep (1);
break;

default:
return EBADKEY;
}
return 0;
}

static const struct argp argp_default_argp =
{argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};


static const struct argp_option argp_version_options[] =
{
{"version", 'V', 0, 0, N_("Print program version"), -1},
{0, 0}
};

static error_t
argp_version_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case 'V':
if (argp_program_version_hook)
(*argp_program_version_hook) (state->out_stream, state);
else if (argp_program_version)
fprintf (state->out_stream, "%s\n", argp_program_version);
else
__argp_error (state, dgettext (state->root_argp->argp_domain,
"(PROGRAM ERROR) No version known!?"));
if (! (state->flags & ARGP_NO_EXIT))
exit (0);
break;
default:
return EBADKEY;
}
return 0;
}

static const struct argp argp_version_argp =
{argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};

/* Returns the offset into the getopt long options array LONG_OPTIONS of a
long option with called NAME, or -1 if none is found. Passing NULL as
NAME will return the number of options. */
static int
find_long_option (struct option *long_options, const char *name)
{
struct option *l = long_options;
while (l->name != NULL)
if (name != NULL && strcmp (l->name, name) == 0)
return l - long_options;
else
l++;
if (name == NULL)
return l - long_options;
else
return -1;
}


/* The state of a `group' during parsing. Each group corresponds to a
particular argp structure from the tree of such descending from the top
level argp passed to argp_parse. */
struct group
{
/* This group's parsing function. */
argp_parser_t parser;

/* Which argp this group is from. */
const struct argp *argp;

/* Points to the point in SHORT_OPTS corresponding to the end of the short
options for this group. We use it to determine from which group a
particular short options is from. */
char *short_end;

/* The number of non-option args sucessfully handled by this parser. */
unsigned args_processed;

/* This group's parser's parent's group. */
struct group *parent;
unsigned parent_index; /* And the our position in the parent. */

/* These fields are swapped into and out of the state structure when
calling this group's parser. */
void *input, **child_inputs;
void *hook;
};

/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
from STATE before calling, and back into state afterwards. If GROUP has
no parser, EBADKEY is returned. */
static error_t
group_parse (struct group *group, struct argp_state *state, int key, char *arg)
{
if (group->parser)
{
error_t err;
state->hook = group->hook;
state->input = group->input;
state->child_inputs = group->child_inputs;
state->arg_num = group->args_processed;
err = (*group->parser)(key, arg, state);
group->hook = state->hook;
return err;
}
else
return EBADKEY;
}

struct parser
{
const struct argp *argp;

/* SHORT_OPTS is the getopt short options string for the union of all the
groups of options. */
char *short_opts;
/* LONG_OPTS is the array of getop long option structures for the union of
all the groups of options. */
struct option *long_opts;
/* OPT_DATA is the getopt data used for the re-entrant getopt. */
struct _getopt_data opt_data;

/* States of the various parsing groups. */
struct group *groups;
/* The end of the GROUPS array. */
struct group *egroup;
/* An vector containing storage for the CHILD_INPUTS field in all groups. */
void **child_inputs;

/* True if we think using getopt is still useful; if false, then
remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is
cleared whenever getopt returns KEY_END, but may be set again if the user
moves the next argument pointer backwards. */
int try_getopt;

/* State block supplied to parsing routines. */
struct argp_state state;

/* Memory used by this parser. */
void *storage;
};

/* The next usable entries in the various parser tables being filled in by
convert_options. */
struct parser_convert_state
{
struct parser *parser;
char *short_end;
struct option *long_end;
void **child_inputs_end;
};

/* Converts all options in ARGP (which is put in GROUP) and ancestors
into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
CVT->LONG_END are the points at which new options are added. Returns the
next unused group entry. CVT holds state used during the conversion. */
static struct group *
convert_options (const struct argp *argp,
struct group *parent, unsigned parent_index,
struct group *group, struct parser_convert_state *cvt)
{
/* REAL is the most recent non-alias value of OPT. */
const struct argp_option *real = argp->options;
const struct argp_child *children = argp->children;

if (real || argp->parser)
{
const struct argp_option *opt;

if (real)
for (opt = real; !__option_is_end (opt); opt++)
{
if (! (opt->flags & OPTION_ALIAS))
/* OPT isn't an alias, so we can use values from it. */
real = opt;

if (! (real->flags & OPTION_DOC))
/* A real option (not just documentation). */
{
if (__option_is_short (opt))
/* OPT can be used as a short option. */
{
*cvt->short_end++ = opt->key;
if (real->arg)
{
*cvt->short_end++ = ':';
if (real->flags & OPTION_ARG_OPTIONAL)
*cvt->short_end++ = ':';
}
*cvt->short_end = '\0'; /* keep 0 terminated */
}

if (opt->name
&& find_long_option (cvt->parser->long_opts, opt->name) < 0)
/* OPT can be used as a long option. */
{
cvt->long_end->name = opt->name;
cvt->long_end->has_arg =
(real->arg
? (real->flags & OPTION_ARG_OPTIONAL
? optional_argument
: required_argument)
: no_argument);
cvt->long_end->flag = 0;
/* we add a disambiguating code to all the user's
values (which is removed before we actually call
the function to parse the value); this means that
the user loses use of the high 8 bits in all his
values (the sign of the lower bits is preserved
however)... */
cvt->long_end->val =
((opt->key ? opt->key : real->key) & USER_MASK)
+ (((group - cvt->parser->groups) + 1) << USER_BITS);

/* Keep the LONG_OPTS list terminated. */
(++cvt->long_end)->name = NULL;
}
}
}

group->parser = argp->parser;
group->argp = argp;
group->short_end = cvt->short_end;
group->args_processed = 0;
group->parent = parent;
group->parent_index = parent_index;
group->input = 0;
group->hook = 0;
group->child_inputs = 0;

if (children)
/* Assign GROUP's CHILD_INPUTS field some space from
CVT->child_inputs_end.*/
{
unsigned num_children = 0;
while (children[num_children].argp)
num_children++;
group->child_inputs = cvt->child_inputs_end;
cvt->child_inputs_end += num_children;
}

parent = group++;
}
else
parent = 0;

if (children)
{
unsigned index = 0;
while (children->argp)
group =
convert_options (children++->argp, parent, index++, group, cvt);
}

return group;
}

/* Find the merged set of getopt options, with keys appropiately prefixed. */
static void
parser_convert (struct parser *parser, const struct argp *argp, int flags)
{
struct parser_convert_state cvt;

cvt.parser = parser;
cvt.short_end = parser->short_opts;
cvt.long_end = parser->long_opts;
cvt.child_inputs_end = parser->child_inputs;

if (flags & ARGP_IN_ORDER)
*cvt.short_end++ = '-';
else if (flags & ARGP_NO_ARGS)
*cvt.short_end++ = '+';
*cvt.short_end = '\0';

cvt.long_end->name = NULL;

parser->argp = argp;

if (argp)
parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
else
parser->egroup = parser->groups; /* No parsers at all! */
}

/* Lengths of various parser fields which we will allocated. */
struct parser_sizes
{
size_t short_len; /* Getopt short options string. */
size_t long_len; /* Getopt long options vector. */
size_t num_groups; /* Group structures we allocate. */
size_t num_child_inputs; /* Child input slots. */
};

baseline bum
04-28-2013, 01:11 PM
/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of
argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by
the maximum lengths of the resulting merged getopt short options string and
long-options array, respectively. */
static void
calc_sizes (const struct argp *argp, struct parser_sizes *szs)
{
const struct argp_child *child = argp->children;
const struct argp_option *opt = argp->options;

if (opt || argp->parser)
{
szs->num_groups++;
if (opt)
{
int num_opts = 0;
while (!__option_is_end (opt++))
num_opts++;
szs->short_len += num_opts * 3; /* opt + up to 2 `:'s */
szs->long_len += num_opts;
}
}

if (child)
while (child->argp)
{
calc_sizes ((child++)->argp, szs);
szs->num_child_inputs++;
}
}

/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
static error_t
parser_init (struct parser *parser, const struct argp *argp,
int argc, char **argv, int flags, void *input)
{
error_t err = 0;
struct group *group;
struct parser_sizes szs;
struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;

szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
szs.long_len = 0;
szs.num_groups = 0;
szs.num_child_inputs = 0;

if (argp)
calc_sizes (argp, &szs);

/* Lengths of the various bits of storage used by PARSER. */
#define GLEN (szs.num_groups + 1) * sizeof (struct group)
#define CLEN (szs.num_child_inputs * sizeof (void *))
#define LLEN ((szs.long_len + 1) * sizeof (struct option))
#define SLEN (szs.short_len + 1)

parser->storage = malloc (GLEN + CLEN + LLEN + SLEN);
if (! parser->storage)
return ENOMEM;

parser->groups = parser->storage;
parser->child_inputs = parser->storage + GLEN;
parser->long_opts = parser->storage + GLEN + CLEN;
parser->short_opts = parser->storage + GLEN + CLEN + LLEN;
parser->opt_data = opt_data;

memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *));
parser_convert (parser, argp, flags);

memset (&parser->state, 0, sizeof (struct argp_state));
parser->state.root_argp = parser->argp;
parser->state.argc = argc;
parser->state.argv = argv;
parser->state.flags = flags;
parser->state.err_stream = stderr;
parser->state.out_stream = stdout;
parser->state.next = 0; /* Tell getopt to initialize. */
parser->state.pstate = parser;

parser->try_getopt = 1;

/* Call each parser for the first time, giving it a chance to propagate
values to child parsers. */
if (parser->groups < parser->egroup)
parser->groups->input = input;
for (group = parser->groups;
group < parser->egroup && (!err || err == EBADKEY);
group++)
{
if (group->parent)
/* If a child parser, get the initial input value from the parent. */
group->input = group->parent->child_inputs[group->parent_index];

if (!group->parser
&& group->argp->children && group->argp->children->argp)
/* For the special case where no parsing function is supplied for an
argp, propagate its input to its first child, if any (this just
makes very simple wrapper argps more convenient). */
group->child_inputs[0] = group->input;

err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
}
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */

if (err)
return err;

if (parser->state.flags & ARGP_NO_ERRS)
{
parser->opt_data.opterr = 0;
if (parser->state.flags & ARGP_PARSE_ARGV0)
/* getopt always skips ARGV[0], so we have to fake it out. As long
as OPTERR is 0, then it shouldn't actually try to access it. */
parser->state.argv--, parser->state.argc++;
}
else
parser->opt_data.opterr = 1; /* Print error messages. */

if (parser->state.argv == argv && argv[0])
/* There's an argv[0]; use it for messages. */
{
char *short_name = strrchr (argv[0], '/');
parser->state.name = short_name ? short_name + 1 : argv[0];
}
else
parser->state.name = __argp_short_program_name ();

return 0;
}

/* Free any storage consumed by PARSER (but not PARSER itself). */
static error_t
parser_finalize (struct parser *parser,
error_t err, int arg_ebadkey, int *end_index)
{
struct group *group;

if (err == EBADKEY && arg_ebadkey)
/* Suppress errors generated by unparsed arguments. */
err = 0;

if (! err)
{
if (parser->state.next == parser->state.argc)
/* We successfully parsed all arguments! Call all the parsers again,
just a few more times... */
{
for (group = parser->groups;
group < parser->egroup && (!err || err==EBADKEY);
group++)
if (group->args_processed == 0)
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
for (group = parser->egroup - 1;
group >= parser->groups && (!err || err==EBADKEY);
group--)
err = group_parse (group, &parser->state, ARGP_KEY_END, 0);

if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */

/* Tell the user that all arguments are parsed. */
if (end_index)
*end_index = parser->state.next;
}
else if (end_index)
/* Return any remaining arguments to the user. */
*end_index = parser->state.next;
else
/* No way to return the remaining arguments, they must be bogus. */
{
if (!(parser->state.flags & ARGP_NO_ERRS)
&& parser->state.err_stream)
fprintf (parser->state.err_stream,
dgettext (parser->argp->argp_domain,
"%s: Too many arguments\n"),
parser->state.name);
err = EBADKEY;
}
}

/* Okay, we're all done, with either an error or success; call the parsers
to indicate which one. */

if (err)
{
/* Maybe print an error message. */
if (err == EBADKEY)
/* An appropriate message describing what the error was should have
been printed earlier. */
__argp_state_help (&parser->state, parser->state.err_stream,
ARGP_HELP_STD_ERR);

/* Since we didn't exit, give each parser an error indication. */
for (group = parser->groups; group < parser->egroup; group++)
group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
}
else
/* Notify parsers of success, and propagate back values from parsers. */
{
/* We pass over the groups in reverse order so that child groups are
given a chance to do there processing before passing back a value to
the parent. */
for (group = parser->egroup - 1
; group >= parser->groups && (!err || err == EBADKEY)
; group--)
err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
}

/* Call parsers once more, to do any final cleanup. Errors are ignored. */
for (group = parser->egroup - 1; group >= parser->groups; group--)
group_parse (group, &parser->state, ARGP_KEY_FINI, 0);

if (err == EBADKEY)
err = EINVAL;

free (parser->storage);

return err;
}

/* Call the user parsers to parse the non-option argument VAL, at the current
position, returning any error. The state NEXT pointer is assumed to have
been adjusted (by getopt) to point after this argument; this function will
adjust it correctly to reflect however many args actually end up being
consumed. */
static error_t
parser_parse_arg (struct parser *parser, char *val)
{
/* Save the starting value of NEXT, first adjusting it so that the arg
we're parsing is again the front of the arg vector. */
int index = --parser->state.next;
error_t err = EBADKEY;
struct group *group;
int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */

/* Try to parse the argument in each parser. */
for (group = parser->groups
; group < parser->egroup && err == EBADKEY
; group++)
{
parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
key = ARGP_KEY_ARG;
err = group_parse (group, &parser->state, key, val);

if (err == EBADKEY)
/* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
{
parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
key = ARGP_KEY_ARGS;
err = group_parse (group, &parser->state, key, 0);
}
}

if (! err)
{
if (key == ARGP_KEY_ARGS)
/* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
changed by the user, *all* arguments should be considered
consumed. */
parser->state.next = parser->state.argc;

if (parser->state.next > index)
/* Remember that we successfully processed a non-option
argument -- but only if the user hasn't gotten tricky and set
the clock back. */
(--group)->args_processed += (parser->state.next - index);
else
/* The user wants to reparse some args, give getopt another try. */
parser->try_getopt = 1;
}

return err;
}

/* Call the user parsers to parse the option OPT, with argument VAL, at the
current position, returning any error. */
static error_t
parser_parse_opt (struct parser *parser, int opt, char *val)
{
/* The group key encoded in the high bits; 0 for short opts or
group_number + 1 for long opts. */
int group_key = opt >> USER_BITS;
error_t err = EBADKEY;

if (group_key == 0)
/* A short option. By comparing OPT's position in SHORT_OPTS to the
various starting positions in each group's SHORT_END field, we can
determine which group OPT came from. */
{
struct group *group;
char *short_index = strchr (parser->short_opts, opt);

if (short_index)
for (group = parser->groups; group < parser->egroup; group++)
if (group->short_end > short_index)
{
err = group_parse (group, &parser->state, opt,
parser->opt_data.optarg);
break;
}
}
else
/* A long option. We use shifts instead of masking for extracting
the user value in order to preserve the sign. */
err =
group_parse (&parser->groups[group_key - 1], &parser->state,
(opt << GROUP_BITS) >> GROUP_BITS,
parser->opt_data.optarg);

if (err == EBADKEY)
/* At least currently, an option not recognized is an error in the
parser, because we pre-compute which parser is supposed to deal
with each option. */
{
static const char bad_key_err[] =
N_("(PROGRAM ERROR) Option should have been recognized!?");
if (group_key == 0)
__argp_error (&parser->state, "-%c: %s", opt,
dgettext (parser->argp->argp_domain, bad_key_err));
else
{
struct option *long_opt = parser->long_opts;
while (long_opt->val != opt && long_opt->name)
long_opt++;
__argp_error (&parser->state, "--%s: %s",
long_opt->name ? long_opt->name : "???",
dgettext (parser->argp->argp_domain, bad_key_err));
}
}

return err;
}

/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
Any error from the parsers is returned, and *ARGP_EBADKEY indicates
whether a value of EBADKEY is due to an unrecognized argument (which is
generally not fatal). */
static error_t
parser_parse_next (struct parser *parser, int *arg_ebadkey)
{
int opt;
error_t err = 0;

if (parser->state.quoted && parser->state.next < parser->state.quoted)
/* The next argument pointer has been moved to before the quoted
region, so pretend we never saw the quoting `--', and give getopt
another chance. If the user hasn't removed it, getopt will just
process it again. */
parser->state.quoted = 0;

if (parser->try_getopt && !parser->state.quoted)
/* Give getopt a chance to parse this. */
{
/* Put it back in OPTIND for getopt. */
parser->opt_data.optind = parser->state.next;
/* Distinguish KEY_ERR from a real option. */
parser->opt_data.optopt = KEY_END;
if (parser->state.flags & ARGP_LONG_ONLY)
opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
parser->short_opts, parser->long_opts, 0,
&parser->opt_data);
else
opt = _getopt_long_r (parser->state.argc, parser->state.argv,
parser->short_opts, parser->long_opts, 0,
&parser->opt_data);
/* And see what getopt did. */
parser->state.next = parser->opt_data.optind;

if (opt == KEY_END)
/* Getopt says there are no more options, so stop using
getopt; we'll continue if necessary on our own. */
{
parser->try_getopt = 0;
if (parser->state.next > 1
&& strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
== 0)
/* Not only is this the end of the options, but it's a
`quoted' region, which may have args that *look* like
options, so we definitely shouldn't try to use getopt past
here, whatever happens. */
parser->state.quoted = parser->state.next;
}
else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END)
/* KEY_ERR can have the same value as a valid user short
option, but in the case of a real error, getopt sets OPTOPT
to the offending character, which can never be KEY_END. */
{
*arg_ebadkey = 0;
return EBADKEY;
}
}
else
opt = KEY_END;

if (opt == KEY_END)
{
/* We're past what getopt considers the options. */
if (parser->state.next >= parser->state.argc
|| (parser->state.flags & ARGP_NO_ARGS))
/* Indicate that we're done. */
{
*arg_ebadkey = 1;
return EBADKEY;
}
else
/* A non-option arg; simulate what getopt might have done. */
{
opt = KEY_ARG;
parser->opt_data.optarg = parser->state.argv[parser->state.next++];
}
}

if (opt == KEY_ARG)
/* A non-option argument; try each parser in turn. */
err = parser_parse_arg (parser, parser->opt_data.optarg);
else
err = parser_parse_opt (parser, opt, parser->opt_data.optarg);

if (err == EBADKEY)
*arg_ebadkey = (opt == KEY_END || opt == KEY_ARG);

return err;
}

baseline bum
04-28-2013, 01:11 PM
/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
index in ARGV of the first unparsed option is returned in it. If an
unknown option is present, EINVAL is returned; if some parser routine
returned a non-zero value, it is returned; otherwise 0 is returned. */
error_t
__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
int *end_index, void *input)
{
error_t err;
struct parser parser;

/* If true, then err == EBADKEY is a result of a non-option argument failing
to be parsed (which in some cases isn't actually an error). */
int arg_ebadkey = 0;

if (! (flags & ARGP_NO_HELP))
/* Add our own options. */
{
struct argp_child *child = alloca (4 * sizeof (struct argp_child));
struct argp *top_argp = alloca (sizeof (struct argp));

/* TOP_ARGP has no options, it just serves to group the user & default
argps. */
memset (top_argp, 0, sizeof (*top_argp));
top_argp->children = child;

memset (child, 0, 4 * sizeof (struct argp_child));

if (argp)
(child++)->argp = argp;
(child++)->argp = &argp_default_argp;
if (argp_program_version || argp_program_version_hook)
(child++)->argp = &argp_version_argp;
child->argp = 0;

argp = top_argp;
}

/* Construct a parser for these arguments. */
err = parser_init (&parser, argp, argc, argv, flags, input);

if (! err)
/* Parse! */
{
while (! err)
err = parser_parse_next (&parser, &arg_ebadkey);
err = parser_finalize (&parser, err, arg_ebadkey, end_index);
}

return err;
}
#ifdef weak_alias
weak_alias (__argp_parse, argp_parse)
#endif

/* Return the input field for ARGP in the parser corresponding to STATE; used
by the help routines. */
void *
__argp_input (const struct argp *argp, const struct argp_state *state)
{
if (state)
{
struct group *group;
struct parser *parser = state->pstate;

for (group = parser->groups; group < parser->egroup; group++)
if (group->argp == argp)
return group->input;
}

return 0;
}
#ifdef weak_alias
weak_alias (__argp_input, _argp_input)
#endif

baseline bum
04-28-2013, 01:11 PM
/* Default definition for ARGP_PROGRAM_VERSION.
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* If set by the user program to a non-zero value, then a default option
--version is added (unless the ARGP_NO_HELP flag is used), which will
print this this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
const char *argp_program_version;

baseline bum
04-28-2013, 01:12 PM
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "argp.h"

/* If set by the user program to a non-zero value, then a default option
--version is added (unless the ARGP_NO_HELP flag is used), which calls
this function with a stream to print the version to and a pointer to the
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state);

baseline bum
04-28-2013, 01:12 PM
/* Test program for argp argument parser
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <argp.h>

const char *argp_program_version = "argp-test 1.0";

struct argp_option sub_options[] =
{
{"subopt1", 's', 0, 0, "Nested option 1"},
{"subopt2", 'S', 0, 0, "Nested option 2"},

{ 0, 0, 0, 0, "Some more nested options:", 10},
{"subopt3", 'p', 0, 0, "Nested option 3"},

{"subopt4", 'q', 0, 0, "Nested option 4", 1},

{0}
};

static const char sub_args_doc[] = "STRING...\n-";
static const char sub_doc[] = "\vThis is the doc string from the sub-arg-parser.";

static error_t
sub_parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARGP_KEY_NO_ARGS:
printf ("NO SUB ARGS\n");
break;
case ARGP_KEY_ARG:
printf ("SUB ARG: %s\n", arg);
break;

case 's' : case 'S': case 'p': case 'q':
printf ("SUB KEY %c\n", key);
break;

default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}

static char *
sub_help_filter (int key, const char *text, void *input)
{
if (key == ARGP_KEY_HELP_EXTRA)
return strdup ("This is some extra text from the sub parser (note that it \
is preceded by a blank line).");
else
return (char *)text;
}

static struct argp sub_argp = {
sub_options, sub_parse_opt, sub_args_doc, sub_doc, 0, sub_help_filter
};

/* Structure used to communicate with the parsing functions. */
struct params
{
unsigned foonly; /* Value parsed for foonly. */
unsigned foonly_default; /* Default value for it. */
};

#define OPT_PGRP 1
#define OPT_SESS 2

struct argp_option options[] =
{
{"pid", 'p', "PID", 0, "List the process PID"},
{"pgrp", OPT_PGRP,"PGRP",0, "List processes in the process group PGRP"},
{"no-parent", 'P', 0, 0, "Include processes without parents"},
{0, 'x', 0, OPTION_ALIAS},
{"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
" if there's some reason ps can't"
" print a field for any process, it's"
" removed from the output entirely)" },
{"reverse", 'r', 0, 0, "Reverse the order of any sort"},
{"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
{"session", OPT_SESS,"SID", OPTION_ARG_OPTIONAL,
"Add the processes from the session"
" SID (which defaults to the sid of"
" the current process)" },

{0,0,0,0, "Here are some more options:"},
{"foonly", 'f', "ZOT", OPTION_ARG_OPTIONAL, "Glork a foonly"},
{"zaza", 'z', 0, 0, "Snit a zar"},

{0}
};

static const char args_doc[] = "STRING";
static const char doc[] = "Test program for argp."
"\vThis doc string comes after the options."
"\nHey! Some manual formatting!"
"\nThe current time is: %s";

static void
popt (int key, char *arg)
{
char buf[10];
if (isprint (key))
sprintf (buf, "%c", key);
else
sprintf (buf, "%d", key);
if (arg)
printf ("KEY %s: %s\n", buf, arg);
else
printf ("KEY %s\n", buf);
}

static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
struct params *params = state->input;

switch (key)
{
case ARGP_KEY_NO_ARGS:
printf ("NO ARGS\n");
break;

case ARGP_KEY_ARG:
if (state->arg_num > 0)
return ARGP_ERR_UNKNOWN; /* Leave it for the sub-arg parser. */
printf ("ARG: %s\n", arg);
break;

case 'f':
if (arg)
params->foonly = atoi (arg);
else
params->foonly = params->foonly_default;
popt (key, arg);
break;

case 'p': case 'P': case OPT_PGRP: case 'x': case 'Q':
case 'r': case OPT_SESS: case 'z':
popt (key, arg);
break;

default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}

static char *
help_filter (int key, const char *text, void *input)
{
char *new_text;
struct params *params = input;

if (key == ARGP_KEY_HELP_POST_DOC && text)
{
time_t now = time (0);
asprintf (&new_text, text, ctime (&now));
}
else if (key == 'f')
/* Show the default for the --foonly option. */
asprintf (&new_text, "%s (ZOT defaults to %x)",
text, params->foonly_default);
else
new_text = (char *)text;

return new_text;
}

static struct argp_child argp_children[] = { { &sub_argp }, { 0 } };
static struct argp argp = {
options, parse_opt, args_doc, doc, argp_children, help_filter
};

int
main (int argc, char **argv)
{
struct params params;
params.foonly = 0;
params.foonly_default = random ();
argp_parse (&argp, argc, argv, 0, 0, &params);
printf ("After parsing: foonly = %x\n", params.foonly);
return 0;
}

baseline bum
04-28-2013, 01:12 PM
/* Real definitions for extern inline functions in argp.h
Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#if defined _LIBC || defined HAVE_FEATURES_H
# include <features.h>
#endif

#ifndef __USE_EXTERN_INLINES
# define __USE_EXTERN_INLINES 1
#endif
#define ARGP_EI
#undef __OPTIMIZE__
#define __OPTIMIZE__ 1
#include "argp.h"

/* Add weak aliases. */
#if _LIBC - 0 && defined (weak_alias)

weak_alias (__argp_usage, argp_usage)
weak_alias (__option_is_short, _option_is_short)
weak_alias (__option_is_end, _option_is_end)

#endif

baseline bum
04-28-2013, 01:12 PM
#include <argp.h>


static const struct argp_option test_options[] =
{
{ NULL, 'a', NULL, OPTION_DOC, NULL },
{ NULL, 'b', NULL, OPTION_DOC, NULL },
{ NULL, 0, NULL, 0, NULL }
};

static struct argp test_argp =
{
test_options
};


static int
do_test (int argc, char *argv[])
{
int i;
argp_parse (&test_argp, argc, argv, 0, &i, NULL);
return 0;
}

#define TEST_FUNCTION do_test (argc, argv)
#include "../test-skeleton.c"

Avante
04-28-2013, 01:12 PM
nah, it's obvious you haven't studied the illegal drone program, or you choose to ignore it. Children and families are being terrorized and murdered. He's a terrorist. He's a war criminal. He's a mass child murderer. It's just a fact.

In before the lie gets spewed about how they are all terrorists over there including kids and terrorists use kids as shields so it isn't our fault even though we are in illegal wars and shouldn't be there to begin with, etc blah blah blah..

Ignorance

Do you even know what a terrorist is? The president of the Uniteed States of America a terrorist, hahahahaha!!!!!!!!!! Dude, yank yor head out of your ass, ok?

baseline bum
04-28-2013, 01:13 PM
#include <argp.h>
#include <stdio.h>
#include <stdlib.h>

static struct argp_option argp_options[] = {
{ "dstaddr", 'd', "ADDR", 0,
"set destination (peer) address to ADDR" },
{ "peer", 'p', "ADDR", OPTION_ALIAS },
{ NULL }
};

static error_t parse_opt (int key, char *arg, struct argp_state *state);

static struct argp argp =
{
argp_options, parse_opt
};

static int cnt;

static int
do_test (int argc, char *argv[])
{
int remaining;
argp_parse (&argp, argc, argv, 0, &remaining, NULL);
return cnt != 4;
}

static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case 'd':
case 'p':
printf ("got '%c' with argument '%s'\n", key, arg);
++cnt;
break;
case 0:
case ARGP_KEY_END:
case ARGP_KEY_NO_ARGS:
case ARGP_KEY_INIT:
case ARGP_KEY_SUCCESS:
case ARGP_KEY_FINI:
// Ignore.
return ARGP_ERR_UNKNOWN;
default:
printf ("invalid key '%x'\n", key);
exit (1);
}
return 0;
}

#define TEST_FUNCTION do_test (argc, argv)
#include "../test-skeleton.c"

baseline bum
04-28-2013, 01:13 PM
# Copyright (C) 1997,2002,2003,2006,2007,2010,2012
# Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.

#
# Makefile for argp.
#
subdir := argp

headers = argp.h
routines = $(addprefix argp-, ba fmtstream fs-xinl help parse pv \
pvh xinl eexst)

tests = argp-test tst-argp1 bug-argp1 tst-argp2 bug-argp2

CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions
CFLAGS-argp-parse.c = $(uses-callbacks)
CFLAGS-argp-fmtstream.c = -fexceptions

bug-argp1-ARGS = -- --help
bug-argp2-ARGS = -- -d 111 --dstaddr 222 -p 333 --peer 444

include ../Rules

baseline bum
04-28-2013, 01:13 PM
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 2002.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <argp.h>




#define OPT_TO_THREAD 300
#define OPT_TO_PROCESS 301
#define OPT_SYNC_SIGNAL 302
#define OPT_SYNC_JOIN 303
#define OPT_TOPLEVEL 304


static const struct argp_option test_options[] =
{
{ NULL, 0, NULL, 0, "\
This is a test for threads so we allow ther user to selection the number of \
threads which are used at any one time. Independently the total number of \
rounds can be selected. This is the total number of threads which will have \
run when the process terminates:" },
{ "threads", 't', "NUMBER", 0, "Number of threads used at once" },
{ "starts", 's', "NUMBER", 0, "Total number of working threads" },
{ "toplevel", OPT_TOPLEVEL, "NUMBER", 0,
"Number of toplevel threads which start the other threads; this \
implies --sync-join" },

{ NULL, 0, NULL, 0, "\
Each thread can do one of two things: sleep or do work. The latter is 100% \
CPU bound. The work load is the probability a thread does work. All values \
from zero to 100 (inclusive) are valid. How often each thread repeats this \
can be determined by the number of rounds. The work cost determines how long \
each work session (not sleeping) takes. If it is zero a thread would \
effectively nothing. By setting the number of rounds to zero the thread \
does no work at all and pure thread creation times can be measured." },
{ "workload", 'w', "PERCENT", 0, "Percentage of time spent working" },
{ "workcost", 'c', "NUMBER", 0,
"Factor in the cost of each round of working" },
{ "rounds", 'r', "NUMBER", 0, "Number of rounds each thread runs" },

{ NULL, 0, NULL, 0, "\
There are a number of different methods how thread creation can be \
synchronized. Synchronization is necessary since the number of concurrently \
running threads is limited." },
{ "sync-signal", OPT_SYNC_SIGNAL, NULL, 0,
"Synchronize using a signal (default)" },
{ "sync-join", OPT_SYNC_JOIN, NULL, 0, "Synchronize using pthread_join" },

{ NULL, 0, NULL, 0, "\
One parameter for each threads execution is the size of the stack. If this \
parameter is not used the system's default stack size is used. If many \
threads are used the stack size should be chosen quite small." },
{ "stacksize", 'S', "BYTES", 0, "Size of threads stack" },
{ "guardsize", 'g', "BYTES", 0,
"Size of stack guard area; must fit into the stack" },

{ NULL, 0, NULL, 0, "Signal options:" },
{ "to-thread", OPT_TO_THREAD, NULL, 0, "Send signal to main thread" },
{ "to-process", OPT_TO_PROCESS, NULL, 0,
"Send signal to process (default)" },

{ NULL, 0, NULL, 0, "Administrative options:" },
{ "progress", 'p', NULL, 0, "Show signs of progress" },
{ "timing", 'T', NULL, 0,
"Measure time from startup to the last thread finishing" },
{ NULL, 0, NULL, 0, NULL }
};

/* Prototype for option handler. */
static error_t parse_opt (int key, char *arg, struct argp_state *state);

/* Data structure to communicate with argp functions. */
static struct argp argp =
{
test_options, parse_opt
};


static int
do_test (void)
{
int argc = 2;
char *argv[3] = { (char *) "tst-argp1", (char *) "--help", NULL };
int remaining;

/* Parse and process arguments. */
argp_parse (&argp, argc, argv, 0, &remaining, NULL);

return 0;
}


/* Handle program arguments. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
return ARGP_ERR_UNKNOWN;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"

baseline bum
04-28-2013, 01:13 PM
/* Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <[email protected]>, 2007.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <argp.h>

static const struct argp_option opt1[] =
{
{ "opt1", '1', "NUMBER", 0, "Option 1" },
{ NULL, 0, NULL, 0, NULL }
};

static const struct argp_option opt2[] =
{
{ "opt2", '2', "NUMBER", 0, "Option 2" },
{ NULL, 0, NULL, 0, NULL }
};

static const struct argp_option opt3[] =
{
{ "opt3", '3', "NUMBER", 0, "Option 3" },
{ NULL, 0, NULL, 0, NULL }
};

static const struct argp_option opt4[] =
{
{ "opt4", '4', "NUMBER", 0, "Option 4" },
{ NULL, 0, NULL, 0, NULL }
};

static const struct argp_option opt5[] =
{
{ "opt5", '5', "NUMBER", 0, "Option 5" },
{ NULL, 0, NULL, 0, NULL }
};

static struct argp argp5 =
{
opt5, NULL, "args doc5", "doc5", NULL, NULL, NULL
};

static struct argp argp4 =
{
opt4, NULL, "args doc4", "doc4", NULL, NULL, NULL
};

static struct argp argp3 =
{
opt3, NULL, "args doc3", "doc3", NULL, NULL, NULL
};

static struct argp_child children2[] =
{
{ &argp4, 0, "child3", 3 },
{ &argp5, 0, "child4", 4 },
{ NULL, 0, NULL, 0 }
};

static struct argp argp2 =
{
opt2, NULL, "args doc2", "doc2", children2, NULL, NULL
};

static struct argp_child children1[] =
{
{ &argp2, 0, "child1", 1 },
{ &argp3, 0, "child2", 2 },
{ NULL, 0, NULL, 0 }
};

static struct argp argp1 =
{
opt1, NULL, "args doc1", "doc1", children1, NULL, NULL
};


static int
do_test (void)
{
argp_help (&argp1, stdout, ARGP_HELP_LONG, (char *) "tst-argp2");
return 0;
}


#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"

baseline bum
04-28-2013, 01:13 PM
libc {
GLIBC_2.1 {
# variables in normal name space
argp_err_exit_status; argp_program_bug_address; argp_program_version;
argp_program_version_hook;

# a*
argp_error; argp_failure; argp_help; argp_parse; argp_state_help;
argp_usage;
}
}

Avante
04-28-2013, 01:17 PM
Mental retardation and the internet, not a good combo.

baseline bum
04-28-2013, 01:20 PM
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <assert.h>
#include <atomic.h>
#include <ldsodefs.h>
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysdep.h>
#include <unistd.h>
#include <sys/mman.h>


extern const char *__progname;

#include <wchar.h>
#include <libio/iolibio.h>
#define fflush(s) _IO_fflush (s)

/* This function, when passed a string containing an asserted
expression, a filename, and a line number, prints a message
on the standard error stream of the form:
a.c:10: foobar: Assertion `a == b' failed.
It then aborts program execution via a call to `abort'. */

#ifdef FATAL_PREPARE_INCLUDE
# include FATAL_PREPARE_INCLUDE
#endif


void
__assert_fail_base (const char *fmt, const char *assertion, const char *file,
unsigned int line, const char *function)
{
char *str;

#ifdef FATAL_PREPARE
FATAL_PREPARE;
#endif

int total;
if (__asprintf (&str, fmt,
__progname, __progname[0] ? ": " : "",
file, line,
function ? function : "", function ? ": " : "",
assertion, &total) >= 0)
{
/* Print the message. */
(void) __fxprintf (NULL, "%s", str);
(void) fflush (stderr);

total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
if (__builtin_expect (buf != MAP_FAILED, 1))
{
buf->size = total;
strcpy (buf->msg, str);

/* We have to free the old buffer since the application might
catch the SIGABRT signal. */
struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, buf);

if (old != NULL)
__munmap (old, old->size);
}

free (str);
}
else
{
/* At least print a minimal message. */
static const char errstr[] = "Unexpected error.\n";
__libc_write (STDERR_FILENO, errstr, sizeof (errstr) - 1);
}

abort ();
}


#undef __assert_fail
void
__assert_fail (const char *assertion, const char *file, unsigned int line,
const char *function)
{
__assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"),
assertion, file, line, function);
}
hidden_def(__assert_fail)

baseline bum
04-28-2013, 01:20 PM
/* Copyright (C) 1991,1992,1994-2001,2003,2004,2007,2011,2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/*
* ISO C99 Standard: 7.2 Diagnostics <assert.h>
*/

#ifdef _ASSERT_H

# undef _ASSERT_H
# undef assert
# undef __ASSERT_VOID_CAST

# ifdef __USE_GNU
# undef assert_perror
# endif

#endif /* assert.h */

#define _ASSERT_H 1
#include <features.h>

#if defined __cplusplus && __GNUC_PREREQ (2,95)
# define __ASSERT_VOID_CAST static_cast<void>
#else
# define __ASSERT_VOID_CAST (void)
#endif

/* void assert (int expression);

If NDEBUG is defined, do nothing.
If not, and EXPRESSION is zero, print an error message and abort. */

#ifdef NDEBUG

# define assert(expr) (__ASSERT_VOID_CAST (0))

/* void assert_perror (int errnum);

If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an
error message with the error text for ERRNUM and abort.
(This is a GNU extension.) */

# ifdef __USE_GNU
# define assert_perror(errnum) (__ASSERT_VOID_CAST (0))
# endif

#else /* Not NDEBUG. */

__BEGIN_DECLS

/* This prints an "Assertion failed" message and aborts. */
extern void __assert_fail (const char *__assertion, const char *__file,
unsigned int __line, const char *__function)
__THROW __attribute__ ((__noreturn__));

/* Likewise, but prints the error text for ERRNUM. */
extern void __assert_perror_fail (int __errnum, const char *__file,
unsigned int __line, const char *__function)
__THROW __attribute__ ((__noreturn__));


/* The following is not at all used here but needed for standard
compliance. */
extern void __assert (const char *__assertion, const char *__file, int __line)
__THROW __attribute__ ((__noreturn__));


__END_DECLS

# define assert(expr) \
((expr) \
? __ASSERT_VOID_CAST (0) \
: __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))

# ifdef __USE_GNU
# define assert_perror(errnum) \
(!(errnum) \
? __ASSERT_VOID_CAST (0) \
: __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
# endif

/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
which contains the name of the function currently being defined.
This is broken in G++ before version 2.6.
C9x has a similar variable called __func__, but prefer the GCC one since
it demangles C++ function names. */
# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
# define __ASSERT_FUNCTION __PRETTY_FUNCTION__
# else
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __ASSERT_FUNCTION __func__
# else
# define __ASSERT_FUNCTION ((const char *) 0)
# endif
# endif

#endif /* NDEBUG. */


#if defined __USE_ISOC11 && !defined __cplusplus
/* Static assertion. Requires support in the compiler. */
# undef static_assert
# define static_assert _Static_assert
#endif

baseline bum
04-28-2013, 01:21 PM
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* We have to see the prototype. */
#undef NDEBUG
#include <assert.h>

void
__assert (const char *assertion, const char *file, int line)
{
__assert_fail (assertion, file, line, (const char *) 0);
}

baseline bum
04-28-2013, 01:21 PM
/* Copyright (C) 1994-1998,2001,2002,2005,2009,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <assert.h>
#include <libintl.h>
#include <string.h>


/* This function, when passed an error number, a filename, and a line
number, prints a message on the standard error stream of the form:
a.c:10: foobar: Unexpected error: Computer bought the farm
It then aborts program execution via a call to `abort'. */
void
__assert_perror_fail (int errnum,
const char *file, unsigned int line,
const char *function)
{
char errbuf[1024];

char *e = __strerror_r (errnum, errbuf, sizeof errbuf);
__assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
e, file, line, function);
}
libc_hidden_def (__assert_perror_fail)

baseline bum
04-28-2013, 01:21 PM
iconvdata
localedata

baseline bum
04-28-2013, 01:21 PM
# Copyright (C) 1991, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.

#
# Sub-makefile for assert portion of the library.
#
subdir := assert
headers := assert.h

routines := assert assert-perr __assert
tests := test-assert test-assert-perr

include ../Rules

test-assert-ENV = LANGUAGE=C
test-assert-perr-ENV = LANGUAGE=C

baseline bum
04-28-2013, 01:21 PM
/* Test assert().
*
* This is hairier than you'd think, involving games with
* stdio and signals.
*
*/

#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>

jmp_buf rec;
char buf[160];

static void
sigabrt (int unused)
{
longjmp (rec, 1); /* recover control */
}

#undef NDEBUG
#include <assert.h>
static void
assert1 (void)
{
assert (1 == 2);
}

static void
assert2 (void)
{
assert (1 == 1);
}


#define NDEBUG
#include <assert.h>
static void
assert3 (void)
{
assert (2 == 3);
}

int
main (void)
{

volatile int failed = 1;

fclose (stderr);
stderr = tmpfile ();
if(!stderr)
abort ();

signal (SIGABRT, sigabrt);

if (!setjmp (rec))
assert1 ();
else
failed = 0; /* should happen */

if (!setjmp (rec))
assert2 ();
else
failed = 1; /* should not happen */

if (!setjmp (rec))
assert3 ();
else
failed = 1; /* should not happen */

rewind (stderr);
fgets (buf, 160, stderr);
if (!strstr (buf, "1 == 2"))
failed = 1;

fgets (buf, 160, stderr);
if (strstr (buf, "1 == 1"))
failed = 1;

fgets (buf, 160, stderr);
if (strstr (buf, "2 == 3"))
failed = 1;

return failed;
}

baseline bum
04-28-2013, 01:22 PM
/* Test assert_perror().
*
* This is hairier than you'd think, involving games with
* stdio and signals.
*
*/

#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>

jmp_buf rec;
char buf[160];

static void
sigabrt (int unused)
{
longjmp (rec, 1); /* recover control */
}

#undef NDEBUG
#include <assert.h>
static void
assert1 (void)
{
assert_perror (1);
}

static void
assert2 (void)
{
assert_perror (0);
}

#define NDEBUG
#include <assert.h>
static void
assert3 (void)
{
assert_perror (2);
}

int
main(void)
{
volatile int failed = 1; /* safety in presence of longjmp() */

fclose (stderr);
stderr = tmpfile ();
if (!stderr)
abort ();

signal (SIGABRT, sigabrt);

if (!setjmp (rec))
assert1 ();
else
failed = 0; /* should happen */

if (!setjmp (rec))
assert2 ();
else
failed = 1; /* should not happen */

if (!setjmp (rec))
assert3 ();
else
failed = 1; /* should not happen */

rewind (stderr);
fgets (buf, 160, stderr);
if (!strstr(buf, strerror (1)))
failed = 1;

fgets (buf, 160, stderr);
if (strstr (buf, strerror (0)))
failed = 1;

fgets (buf, 160, stderr);
if (strstr (buf, strerror (2)))
failed = 1;

return failed;
}

baseline bum
04-28-2013, 01:22 PM
libc {
GLIBC_2.0 {
# functions used in inline functions or macros
__assert_fail; __assert_perror_fail;
}
GLIBC_2.2 {
# just for standard compliance
__assert;
}
}

baseline bum
04-28-2013, 01:23 PM
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 2003.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_ATOMIC_H
#define _BITS_ATOMIC_H 1

/* We have by default no support for atomic operations. So define
them non-atomic. If this is a problem somebody will have to come
up with real definitions. */

/* The only basic operation needed is compare and exchange. */
#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
({ __typeof (mem) __gmemp = (mem); \
__typeof (*mem) __gret = *__gmemp; \
__typeof (*mem) __gnewval = (newval); \
\
if (__gret == (oldval)) \
*__gmemp = __gnewval; \
__gret; })

#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
({ __typeof (mem) __gmemp = (mem); \
__typeof (*mem) __gnewval = (newval); \
\
*__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })

#endif /* bits/atomic.h */

baseline bum
04-28-2013, 01:23 PM
/* Macros to swap the order of bytes in integer values.
Copyright (C) 1997-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif

#ifndef _BITS_BYTESWAP_H
#define _BITS_BYTESWAP_H 1

#include <features.h>
#include <bits/types.h>

/* Swap bytes in 16 bit value. */
#define __bswap_constant_16(x) \
((unsigned short int)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))

/* Get __bswap_16. */
#include <bits/byteswap-16.h>

/* Swap bytes in 32 bit value. */
#define __bswap_constant_32(x) \
((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
(((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))

#ifdef __GNUC__
# if __GNUC_PREREQ (4, 3)
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
return __builtin_bswap32 (__bsx);
}
# else
# define __bswap_32(x) \
(__extension__ \
({ register unsigned int __bsx = (x); __bswap_constant_32 (__bsx); }))
# endif
#else
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
return __bswap_constant_32 (__bsx);
}
#endif

/* Swap bytes in 64 bit value. */
#if __GNUC_PREREQ (2, 0)
# define __bswap_constant_64(x) \
(__extension__ ((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \
| (((x) & 0x0000ff0000000000ull) >> 24) \
| (((x) & 0x000000ff00000000ull) >> 8) \
| (((x) & 0x00000000ff000000ull) << 8) \
| (((x) & 0x0000000000ff0000ull) << 24) \
| (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56)))

# if __GNUC_PREREQ (4, 3)
static __inline __uint64_t
__bswap_64 (__uint64_t __bsx)
{
return __builtin_bswap64 (__bsx);
}
# else
# define __bswap_64(x) \
(__extension__ \
({ union { __extension__ __uint64_t __ll; \
unsigned int __l[2]; } __w, __r; \
if (__builtin_constant_p (x)) \
__r.__ll = __bswap_constant_64 (x); \
else \
{ \
__w.__ll = (x); \
__r.__l[0] = __bswap_32 (__w.__l[1]); \
__r.__l[1] = __bswap_32 (__w.__l[0]); \
} \
__r.__ll; }))
# endif
#elif __GLIBC_HAVE_LONG_LONG
# define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \
| (((x) & 0x0000ff0000000000ull) >> 24) \
| (((x) & 0x000000ff00000000ull) >> 8) \
| (((x) & 0x00000000ff000000ull) << 8) \
| (((x) & 0x0000000000ff0000ull) << 24) \
| (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56))

static __inline __uint64_t
__bswap_64 (__uint64_t __bsx)
{
return __bswap_constant_64 (__bsx);
}
#endif

#endif /* _BITS_BYTESWAP_H */

baseline bum
04-28-2013, 01:23 PM
/* Macros to swap the order of bytes in 16-bit integer values.
Copyright (C) 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_BYTESWAP_H
# error "Never use <bits/byteswap-16.h> directly; include <byteswap.h> instead."
#endif

#ifdef __GNUC__
# define __bswap_16(x) \
(__extension__ \
({ unsigned short int __bsx = (unsigned short int) (x); \
__bswap_constant_16 (__bsx); }))
#else
static __inline unsigned short int
__bswap_16 (unsigned short int __bsx)
{
return __bswap_constant_16 (__bsx);
}
#endif

baseline bum
04-28-2013, 01:23 PM
/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
Copyright (C) 1993,1995-1998,2000,2001,2003,2004,2007,2009,2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _UNISTD_H
# error "Never use <bits/confname.h> directly; include <unistd.h> instead."
#endif

/* Values for the NAME argument to `pathconf' and `fpathconf'. */
enum
{
_PC_LINK_MAX,
#define _PC_LINK_MAX _PC_LINK_MAX
_PC_MAX_CANON,
#define _PC_MAX_CANON _PC_MAX_CANON
_PC_MAX_INPUT,
#define _PC_MAX_INPUT _PC_MAX_INPUT
_PC_NAME_MAX,
#define _PC_NAME_MAX _PC_NAME_MAX
_PC_PATH_MAX,
#define _PC_PATH_MAX _PC_PATH_MAX
_PC_PIPE_BUF,
#define _PC_PIPE_BUF _PC_PIPE_BUF
_PC_CHOWN_RESTRICTED,
#define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED
_PC_NO_TRUNC,
#define _PC_NO_TRUNC _PC_NO_TRUNC
_PC_VDISABLE,
#define _PC_VDISABLE _PC_VDISABLE
_PC_SYNC_IO,
#define _PC_SYNC_IO _PC_SYNC_IO
_PC_ASYNC_IO,
#define _PC_ASYNC_IO _PC_ASYNC_IO
_PC_PRIO_IO,
#define _PC_PRIO_IO _PC_PRIO_IO
_PC_SOCK_MAXBUF,
#define _PC_SOCK_MAXBUF _PC_SOCK_MAXBUF
_PC_FILESIZEBITS,
#define _PC_FILESIZEBITS _PC_FILESIZEBITS
_PC_REC_INCR_XFER_SIZE,
#define _PC_REC_INCR_XFER_SIZE _PC_REC_INCR_XFER_SIZE
_PC_REC_MAX_XFER_SIZE,
#define _PC_REC_MAX_XFER_SIZE _PC_REC_MAX_XFER_SIZE
_PC_REC_MIN_XFER_SIZE,
#define _PC_REC_MIN_XFER_SIZE _PC_REC_MIN_XFER_SIZE
_PC_REC_XFER_ALIGN,
#define _PC_REC_XFER_ALIGN _PC_REC_XFER_ALIGN
_PC_ALLOC_SIZE_MIN,
#define _PC_ALLOC_SIZE_MIN _PC_ALLOC_SIZE_MIN
_PC_SYMLINK_MAX,
#define _PC_SYMLINK_MAX _PC_SYMLINK_MAX
_PC_2_SYMLINKS
#define _PC_2_SYMLINKS _PC_2_SYMLINKS
};

/* Values for the argument to `sysconf'. */
enum
{
_SC_ARG_MAX,
#define _SC_ARG_MAX _SC_ARG_MAX
_SC_CHILD_MAX,
#define _SC_CHILD_MAX _SC_CHILD_MAX
_SC_CLK_TCK,
#define _SC_CLK_TCK _SC_CLK_TCK
_SC_NGROUPS_MAX,
#define _SC_NGROUPS_MAX _SC_NGROUPS_MAX
_SC_OPEN_MAX,
#define _SC_OPEN_MAX _SC_OPEN_MAX
_SC_STREAM_MAX,
#define _SC_STREAM_MAX _SC_STREAM_MAX
_SC_TZNAME_MAX,
#define _SC_TZNAME_MAX _SC_TZNAME_MAX
_SC_JOB_CONTROL,
#define _SC_JOB_CONTROL _SC_JOB_CONTROL
_SC_SAVED_IDS,
#define _SC_SAVED_IDS _SC_SAVED_IDS
_SC_REALTIME_SIGNALS,
#define _SC_REALTIME_SIGNALS _SC_REALTIME_SIGNALS
_SC_PRIORITY_SCHEDULING,
#define _SC_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING
_SC_TIMERS,
#define _SC_TIMERS _SC_TIMERS
_SC_ASYNCHRONOUS_IO,
#define _SC_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO
_SC_PRIORITIZED_IO,
#define _SC_PRIORITIZED_IO _SC_PRIORITIZED_IO
_SC_SYNCHRONIZED_IO,
#define _SC_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO
_SC_FSYNC,
#define _SC_FSYNC _SC_FSYNC
_SC_MAPPED_FILES,
#define _SC_MAPPED_FILES _SC_MAPPED_FILES
_SC_MEMLOCK,
#define _SC_MEMLOCK _SC_MEMLOCK
_SC_MEMLOCK_RANGE,
#define _SC_MEMLOCK_RANGE _SC_MEMLOCK_RANGE
_SC_MEMORY_PROTECTION,
#define _SC_MEMORY_PROTECTION _SC_MEMORY_PROTECTION
_SC_MESSAGE_PASSING,
#define _SC_MESSAGE_PASSING _SC_MESSAGE_PASSING
_SC_SEMAPHORES,
#define _SC_SEMAPHORES _SC_SEMAPHORES
_SC_SHARED_MEMORY_OBJECTS,
#define _SC_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS
_SC_AIO_LISTIO_MAX,
#define _SC_AIO_LISTIO_MAX _SC_AIO_LISTIO_MAX
_SC_AIO_MAX,
#define _SC_AIO_MAX _SC_AIO_MAX
_SC_AIO_PRIO_DELTA_MAX,
#define _SC_AIO_PRIO_DELTA_MAX _SC_AIO_PRIO_DELTA_MAX
_SC_DELAYTIMER_MAX,
#define _SC_DELAYTIMER_MAX _SC_DELAYTIMER_MAX
_SC_MQ_OPEN_MAX,
#define _SC_MQ_OPEN_MAX _SC_MQ_OPEN_MAX
_SC_MQ_PRIO_MAX,
#define _SC_MQ_PRIO_MAX _SC_MQ_PRIO_MAX
_SC_VERSION,
#define _SC_VERSION _SC_VERSION
_SC_PAGESIZE,
#define _SC_PAGESIZE _SC_PAGESIZE
#define _SC_PAGE_SIZE _SC_PAGESIZE
_SC_RTSIG_MAX,
#define _SC_RTSIG_MAX _SC_RTSIG_MAX
_SC_SEM_NSEMS_MAX,
#define _SC_SEM_NSEMS_MAX _SC_SEM_NSEMS_MAX
_SC_SEM_VALUE_MAX,
#define _SC_SEM_VALUE_MAX _SC_SEM_VALUE_MAX
_SC_SIGQUEUE_MAX,
#define _SC_SIGQUEUE_MAX _SC_SIGQUEUE_MAX
_SC_TIMER_MAX,
#define _SC_TIMER_MAX _SC_TIMER_MAX

/* Values for the argument to `sysconf'
corresponding to _POSIX2_* symbols. */
_SC_BC_BASE_MAX,
#define _SC_BC_BASE_MAX _SC_BC_BASE_MAX
_SC_BC_DIM_MAX,
#define _SC_BC_DIM_MAX _SC_BC_DIM_MAX
_SC_BC_SCALE_MAX,
#define _SC_BC_SCALE_MAX _SC_BC_SCALE_MAX
_SC_BC_STRING_MAX,
#define _SC_BC_STRING_MAX _SC_BC_STRING_MAX
_SC_COLL_WEIGHTS_MAX,
#define _SC_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX
_SC_EQUIV_CLASS_MAX,
#define _SC_EQUIV_CLASS_MAX _SC_EQUIV_CLASS_MAX
_SC_EXPR_NEST_MAX,
#define _SC_EXPR_NEST_MAX _SC_EXPR_NEST_MAX
_SC_LINE_MAX,
#define _SC_LINE_MAX _SC_LINE_MAX
_SC_RE_DUP_MAX,
#define _SC_RE_DUP_MAX _SC_RE_DUP_MAX
_SC_CHARCLASS_NAME_MAX,
#define _SC_CHARCLASS_NAME_MAX _SC_CHARCLASS_NAME_MAX

_SC_2_VERSION,
#define _SC_2_VERSION _SC_2_VERSION
_SC_2_C_BIND,
#define _SC_2_C_BIND _SC_2_C_BIND
_SC_2_C_DEV,
#define _SC_2_C_DEV _SC_2_C_DEV
_SC_2_FORT_DEV,
#define _SC_2_FORT_DEV _SC_2_FORT_DEV
_SC_2_FORT_RUN,
#define _SC_2_FORT_RUN _SC_2_FORT_RUN
_SC_2_SW_DEV,
#define _SC_2_SW_DEV _SC_2_SW_DEV
_SC_2_LOCALEDEF,
#define _SC_2_LOCALEDEF _SC_2_LOCALEDEF

_SC_PII,
#define _SC_PII _SC_PII
_SC_PII_XTI,
#define _SC_PII_XTI _SC_PII_XTI
_SC_PII_SOCKET,
#define _SC_PII_SOCKET _SC_PII_SOCKET
_SC_PII_INTERNET,
#define _SC_PII_INTERNET _SC_PII_INTERNET
_SC_PII_OSI,
#define _SC_PII_OSI _SC_PII_OSI
_SC_POLL,
#define _SC_POLL _SC_POLL
_SC_SELECT,
#define _SC_SELECT _SC_SELECT
_SC_UIO_MAXIOV,
#define _SC_UIO_MAXIOV _SC_UIO_MAXIOV
_SC_IOV_MAX = _SC_UIO_MAXIOV,
#define _SC_IOV_MAX _SC_IOV_MAX
_SC_PII_INTERNET_STREAM,
#define _SC_PII_INTERNET_STREAM _SC_PII_INTERNET_STREAM
_SC_PII_INTERNET_DGRAM,
#define _SC_PII_INTERNET_DGRAM _SC_PII_INTERNET_DGRAM
_SC_PII_OSI_COTS,
#define _SC_PII_OSI_COTS _SC_PII_OSI_COTS
_SC_PII_OSI_CLTS,
#define _SC_PII_OSI_CLTS _SC_PII_OSI_CLTS
_SC_PII_OSI_M,
#define _SC_PII_OSI_M _SC_PII_OSI_M
_SC_T_IOV_MAX,
#define _SC_T_IOV_MAX _SC_T_IOV_MAX

/* Values according to POSIX 1003.1c (POSIX threads). */
_SC_THREADS,
#define _SC_THREADS _SC_THREADS
_SC_THREAD_SAFE_FUNCTIONS,
#define _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS
_SC_GETGR_R_SIZE_MAX,
#define _SC_GETGR_R_SIZE_MAX _SC_GETGR_R_SIZE_MAX
_SC_GETPW_R_SIZE_MAX,
#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX
_SC_LOGIN_NAME_MAX,
#define _SC_LOGIN_NAME_MAX _SC_LOGIN_NAME_MAX
_SC_TTY_NAME_MAX,
#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX
_SC_THREAD_DESTRUCTOR_ITERATIONS,
#define _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS
_SC_THREAD_KEYS_MAX,
#define _SC_THREAD_KEYS_MAX _SC_THREAD_KEYS_MAX
_SC_THREAD_STACK_MIN,
#define _SC_THREAD_STACK_MIN _SC_THREAD_STACK_MIN
_SC_THREAD_THREADS_MAX,
#define _SC_THREAD_THREADS_MAX _SC_THREAD_THREADS_MAX
_SC_THREAD_ATTR_STACKADDR,
#define _SC_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR
_SC_THREAD_ATTR_STACKSIZE,
#define _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE
_SC_THREAD_PRIORITY_SCHEDULING,
#define _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING
_SC_THREAD_PRIO_INHERIT,
#define _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT
_SC_THREAD_PRIO_PROTECT,
#define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT
_SC_THREAD_PROCESS_SHARED,
#define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED

_SC_NPROCESSORS_CONF,
#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF
_SC_NPROCESSORS_ONLN,
#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN
_SC_PHYS_PAGES,
#define _SC_PHYS_PAGES _SC_PHYS_PAGES
_SC_AVPHYS_PAGES,
#define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES
_SC_ATEXIT_MAX,
#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX
_SC_PASS_MAX,
#define _SC_PASS_MAX _SC_PASS_MAX

_SC_XOPEN_VERSION,
#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION
_SC_XOPEN_XCU_VERSION,
#define _SC_XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION
_SC_XOPEN_UNIX,
#define _SC_XOPEN_UNIX _SC_XOPEN_UNIX
_SC_XOPEN_CRYPT,
#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
_SC_XOPEN_ENH_I18N,
#define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N
_SC_XOPEN_SHM,
#define _SC_XOPEN_SHM _SC_XOPEN_SHM

_SC_2_CHAR_TERM,
#define _SC_2_CHAR_TERM _SC_2_CHAR_TERM
_SC_2_C_VERSION,
#define _SC_2_C_VERSION _SC_2_C_VERSION
_SC_2_UPE,
#define _SC_2_UPE _SC_2_UPE

_SC_XOPEN_XPG2,
#define _SC_XOPEN_XPG2 _SC_XOPEN_XPG2
_SC_XOPEN_XPG3,
#define _SC_XOPEN_XPG3 _SC_XOPEN_XPG3
_SC_XOPEN_XPG4,
#define _SC_XOPEN_XPG4 _SC_XOPEN_XPG4

_SC_CHAR_BIT,
#define _SC_CHAR_BIT _SC_CHAR_BIT
_SC_CHAR_MAX,
#define _SC_CHAR_MAX _SC_CHAR_MAX
_SC_CHAR_MIN,
#define _SC_CHAR_MIN _SC_CHAR_MIN
_SC_INT_MAX,
#define _SC_INT_MAX _SC_INT_MAX
_SC_INT_MIN,
#define _SC_INT_MIN _SC_INT_MIN
_SC_LONG_BIT,
#define _SC_LONG_BIT _SC_LONG_BIT
_SC_WORD_BIT,
#define _SC_WORD_BIT _SC_WORD_BIT
_SC_MB_LEN_MAX,
#define _SC_MB_LEN_MAX _SC_MB_LEN_MAX
_SC_NZERO,
#define _SC_NZERO _SC_NZERO
_SC_SSIZE_MAX,
#define _SC_SSIZE_MAX _SC_SSIZE_MAX
_SC_SCHAR_MAX,
#define _SC_SCHAR_MAX _SC_SCHAR_MAX
_SC_SCHAR_MIN,
#define _SC_SCHAR_MIN _SC_SCHAR_MIN
_SC_SHRT_MAX,
#define _SC_SHRT_MAX _SC_SHRT_MAX
_SC_SHRT_MIN,
#define _SC_SHRT_MIN _SC_SHRT_MIN
_SC_UCHAR_MAX,
#define _SC_UCHAR_MAX _SC_UCHAR_MAX
_SC_UINT_MAX,
#define _SC_UINT_MAX _SC_UINT_MAX
_SC_ULONG_MAX,
#define _SC_ULONG_MAX _SC_ULONG_MAX
_SC_USHRT_MAX,
#define _SC_USHRT_MAX _SC_USHRT_MAX

_SC_NL_ARGMAX,
#define _SC_NL_ARGMAX _SC_NL_ARGMAX
_SC_NL_LANGMAX,
#define _SC_NL_LANGMAX _SC_NL_LANGMAX
_SC_NL_MSGMAX,
#define _SC_NL_MSGMAX _SC_NL_MSGMAX
_SC_NL_NMAX,
#define _SC_NL_NMAX _SC_NL_NMAX
_SC_NL_SETMAX,
#define _SC_NL_SETMAX _SC_NL_SETMAX
_SC_NL_TEXTMAX,
#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX

_SC_XBS5_ILP32_OFF32,
#define _SC_XBS5_ILP32_OFF32 _SC_XBS5_ILP32_OFF32
_SC_XBS5_ILP32_OFFBIG,
#define _SC_XBS5_ILP32_OFFBIG _SC_XBS5_ILP32_OFFBIG
_SC_XBS5_LP64_OFF64,
#define _SC_XBS5_LP64_OFF64 _SC_XBS5_LP64_OFF64
_SC_XBS5_LPBIG_OFFBIG,
#define _SC_XBS5_LPBIG_OFFBIG _SC_XBS5_LPBIG_OFFBIG

_SC_XOPEN_LEGACY,
#define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY
_SC_XOPEN_REALTIME,
#define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME
_SC_XOPEN_REALTIME_THREADS,
#define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS

_SC_ADVISORY_INFO,
#define _SC_ADVISORY_INFO _SC_ADVISORY_INFO
_SC_BARRIERS,
#define _SC_BARRIERS _SC_BARRIERS
_SC_BASE,
#define _SC_BASE _SC_BASE
_SC_C_LANG_SUPPORT,
#define _SC_C_LANG_SUPPORT _SC_C_LANG_SUPPORT
_SC_C_LANG_SUPPORT_R,
#define _SC_C_LANG_SUPPORT_R _SC_C_LANG_SUPPORT_R
_SC_CLOCK_SELECTION,
#define _SC_CLOCK_SELECTION _SC_CLOCK_SELECTION
_SC_CPUTIME,
#define _SC_CPUTIME _SC_CPUTIME
_SC_THREAD_CPUTIME,
#define _SC_THREAD_CPUTIME _SC_THREAD_CPUTIME
_SC_DEVICE_IO,
#define _SC_DEVICE_IO _SC_DEVICE_IO
_SC_DEVICE_SPECIFIC,
#define _SC_DEVICE_SPECIFIC _SC_DEVICE_SPECIFIC
_SC_DEVICE_SPECIFIC_R,
#define _SC_DEVICE_SPECIFIC_R _SC_DEVICE_SPECIFIC_R
_SC_FD_MGMT,
#define _SC_FD_MGMT _SC_FD_MGMT
_SC_FIFO,
#define _SC_FIFO _SC_FIFO
_SC_PIPE,
#define _SC_PIPE _SC_PIPE
_SC_FILE_ATTRIBUTES,
#define _SC_FILE_ATTRIBUTES _SC_FILE_ATTRIBUTES
_SC_FILE_LOCKING,
#define _SC_FILE_LOCKING _SC_FILE_LOCKING
_SC_FILE_SYSTEM,
#define _SC_FILE_SYSTEM _SC_FILE_SYSTEM
_SC_MONOTONIC_CLOCK,
#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK
_SC_MULTI_PROCESS,
#define _SC_MULTI_PROCESS _SC_MULTI_PROCESS
_SC_SINGLE_PROCESS,
#define _SC_SINGLE_PROCESS _SC_SINGLE_PROCESS
_SC_NETWORKING,
#define _SC_NETWORKING _SC_NETWORKING
_SC_READER_WRITER_LOCKS,
#define _SC_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS
_SC_SPIN_LOCKS,
#define _SC_SPIN_LOCKS _SC_SPIN_LOCKS
_SC_REGEXP,
#define _SC_REGEXP _SC_REGEXP
_SC_REGEX_VERSION,
#define _SC_REGEX_VERSION _SC_REGEX_VERSION
_SC_SHELL,
#define _SC_SHELL _SC_SHELL
_SC_SIGNALS,
#define _SC_SIGNALS _SC_SIGNALS
_SC_SPAWN,
#define _SC_SPAWN _SC_SPAWN
_SC_SPORADIC_SERVER,
#define _SC_SPORADIC_SERVER _SC_SPORADIC_SERVER
_SC_THREAD_SPORADIC_SERVER,
#define _SC_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER
_SC_SYSTEM_DATABASE,
#define _SC_SYSTEM_DATABASE _SC_SYSTEM_DATABASE
_SC_SYSTEM_DATABASE_R,
#define _SC_SYSTEM_DATABASE_R _SC_SYSTEM_DATABASE_R
_SC_TIMEOUTS,
#define _SC_TIMEOUTS _SC_TIMEOUTS
_SC_TYPED_MEMORY_OBJECTS,
#define _SC_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS
_SC_USER_GROUPS,
#define _SC_USER_GROUPS _SC_USER_GROUPS
_SC_USER_GROUPS_R,
#define _SC_USER_GROUPS_R _SC_USER_GROUPS_R
_SC_2_PBS,
#define _SC_2_PBS _SC_2_PBS
_SC_2_PBS_ACCOUNTING,
#define _SC_2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING
_SC_2_PBS_LOCATE,
#define _SC_2_PBS_LOCATE _SC_2_PBS_LOCATE
_SC_2_PBS_MESSAGE,
#define _SC_2_PBS_MESSAGE _SC_2_PBS_MESSAGE
_SC_2_PBS_TRACK,
#define _SC_2_PBS_TRACK _SC_2_PBS_TRACK
_SC_SYMLOOP_MAX,
#define _SC_SYMLOOP_MAX _SC_SYMLOOP_MAX
_SC_STREAMS,
#define _SC_STREAMS _SC_STREAMS
_SC_2_PBS_CHECKPOINT,
#define _SC_2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT

_SC_V6_ILP32_OFF32,
#define _SC_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32
_SC_V6_ILP32_OFFBIG,

baseline bum
04-28-2013, 01:24 PM
#define _SC_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG
_SC_V6_LP64_OFF64,
#define _SC_V6_LP64_OFF64 _SC_V6_LP64_OFF64
_SC_V6_LPBIG_OFFBIG,
#define _SC_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG

_SC_HOST_NAME_MAX,
#define _SC_HOST_NAME_MAX _SC_HOST_NAME_MAX
_SC_TRACE,
#define _SC_TRACE _SC_TRACE
_SC_TRACE_EVENT_FILTER,
#define _SC_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER
_SC_TRACE_INHERIT,
#define _SC_TRACE_INHERIT _SC_TRACE_INHERIT
_SC_TRACE_LOG,
#define _SC_TRACE_LOG _SC_TRACE_LOG

_SC_LEVEL1_ICACHE_SIZE,
#define _SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_SIZE
_SC_LEVEL1_ICACHE_ASSOC,
#define _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_ASSOC
_SC_LEVEL1_ICACHE_LINESIZE,
#define _SC_LEVEL1_ICACHE_LINESIZE _SC_LEVEL1_ICACHE_LINESIZE
_SC_LEVEL1_DCACHE_SIZE,
#define _SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_SIZE
_SC_LEVEL1_DCACHE_ASSOC,
#define _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_ASSOC
_SC_LEVEL1_DCACHE_LINESIZE,
#define _SC_LEVEL1_DCACHE_LINESIZE _SC_LEVEL1_DCACHE_LINESIZE
_SC_LEVEL2_CACHE_SIZE,
#define _SC_LEVEL2_CACHE_SIZE _SC_LEVEL2_CACHE_SIZE
_SC_LEVEL2_CACHE_ASSOC,
#define _SC_LEVEL2_CACHE_ASSOC _SC_LEVEL2_CACHE_ASSOC
_SC_LEVEL2_CACHE_LINESIZE,
#define _SC_LEVEL2_CACHE_LINESIZE _SC_LEVEL2_CACHE_LINESIZE
_SC_LEVEL3_CACHE_SIZE,
#define _SC_LEVEL3_CACHE_SIZE _SC_LEVEL3_CACHE_SIZE
_SC_LEVEL3_CACHE_ASSOC,
#define _SC_LEVEL3_CACHE_ASSOC _SC_LEVEL3_CACHE_ASSOC
_SC_LEVEL3_CACHE_LINESIZE,
#define _SC_LEVEL3_CACHE_LINESIZE _SC_LEVEL3_CACHE_LINESIZE
_SC_LEVEL4_CACHE_SIZE,
#define _SC_LEVEL4_CACHE_SIZE _SC_LEVEL4_CACHE_SIZE
_SC_LEVEL4_CACHE_ASSOC,
#define _SC_LEVEL4_CACHE_ASSOC _SC_LEVEL4_CACHE_ASSOC
_SC_LEVEL4_CACHE_LINESIZE,
#define _SC_LEVEL4_CACHE_LINESIZE _SC_LEVEL4_CACHE_LINESIZE
/* Leave room here, maybe we need a few more cache levels some day. */

_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
#define _SC_IPV6 _SC_IPV6
_SC_RAW_SOCKETS,
#define _SC_RAW_SOCKETS _SC_RAW_SOCKETS

_SC_V7_ILP32_OFF32,
#define _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFF32
_SC_V7_ILP32_OFFBIG,
#define _SC_V7_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
_SC_V7_LP64_OFF64,
#define _SC_V7_LP64_OFF64 _SC_V7_LP64_OFF64
_SC_V7_LPBIG_OFFBIG,
#define _SC_V7_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG

_SC_SS_REPL_MAX,
#define _SC_SS_REPL_MAX _SC_SS_REPL_MAX

_SC_TRACE_EVENT_NAME_MAX,
#define _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_EVENT_NAME_MAX
_SC_TRACE_NAME_MAX,
#define _SC_TRACE_NAME_MAX _SC_TRACE_NAME_MAX
_SC_TRACE_SYS_MAX,
#define _SC_TRACE_SYS_MAX _SC_TRACE_SYS_MAX
_SC_TRACE_USER_EVENT_MAX,
#define _SC_TRACE_USER_EVENT_MAX _SC_TRACE_USER_EVENT_MAX

_SC_XOPEN_STREAMS,
#define _SC_XOPEN_STREAMS _SC_XOPEN_STREAMS

_SC_THREAD_ROBUST_PRIO_INHERIT,
#define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT
_SC_THREAD_ROBUST_PRIO_PROTECT
#define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT
};

/* Values for the NAME argument to `confstr'. */
enum
{
_CS_PATH, /* The default search path. */
#define _CS_PATH _CS_PATH

_CS_V6_WIDTH_RESTRICTED_ENVS,
#define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS

_CS_GNU_LIBC_VERSION,
#define _CS_GNU_LIBC_VERSION _CS_GNU_LIBC_VERSION
_CS_GNU_LIBPTHREAD_VERSION,
#define _CS_GNU_LIBPTHREAD_VERSION _CS_GNU_LIBPTHREAD_VERSION

_CS_V5_WIDTH_RESTRICTED_ENVS,
#define _CS_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS
#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS

_CS_V7_WIDTH_RESTRICTED_ENVS,
#define _CS_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS
#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS

_CS_LFS_CFLAGS = 1000,
#define _CS_LFS_CFLAGS _CS_LFS_CFLAGS
_CS_LFS_LDFLAGS,
#define _CS_LFS_LDFLAGS _CS_LFS_LDFLAGS
_CS_LFS_LIBS,
#define _CS_LFS_LIBS _CS_LFS_LIBS
_CS_LFS_LINTFLAGS,
#define _CS_LFS_LINTFLAGS _CS_LFS_LINTFLAGS
_CS_LFS64_CFLAGS,
#define _CS_LFS64_CFLAGS _CS_LFS64_CFLAGS
_CS_LFS64_LDFLAGS,
#define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS
_CS_LFS64_LIBS,
#define _CS_LFS64_LIBS _CS_LFS64_LIBS
_CS_LFS64_LINTFLAGS,
#define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS

_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS
_CS_XBS5_ILP32_OFF32_LDFLAGS,
#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
_CS_XBS5_ILP32_OFF32_LIBS,
#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS
_CS_XBS5_ILP32_OFF32_LINTFLAGS,
#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS
_CS_XBS5_ILP32_OFFBIG_CFLAGS,
#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS
_CS_XBS5_ILP32_OFFBIG_LDFLAGS,
#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
_CS_XBS5_ILP32_OFFBIG_LIBS,
#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS
_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
_CS_XBS5_LP64_OFF64_CFLAGS,
#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS
_CS_XBS5_LP64_OFF64_LDFLAGS,
#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
_CS_XBS5_LP64_OFF64_LIBS,
#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS
_CS_XBS5_LP64_OFF64_LINTFLAGS,
#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS
_CS_XBS5_LPBIG_OFFBIG_CFLAGS,
#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS
_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
_CS_XBS5_LPBIG_OFFBIG_LIBS,
#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS
_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS

_CS_POSIX_V6_ILP32_OFF32_CFLAGS,
#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS
_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
_CS_POSIX_V6_ILP32_OFF32_LIBS,
#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS
_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
_CS_POSIX_V6_ILP32_OFFBIG_LIBS,
#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS
_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
_CS_POSIX_V6_LP64_OFF64_CFLAGS,
#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS
_CS_POSIX_V6_LP64_OFF64_LDFLAGS,
#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS
_CS_POSIX_V6_LP64_OFF64_LIBS,
#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS
_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS

_CS_POSIX_V7_ILP32_OFF32_CFLAGS,
#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
_CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
_CS_POSIX_V7_ILP32_OFF32_LIBS,
#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
_CS_POSIX_V7_ILP32_OFFBIG_LIBS,
#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
_CS_POSIX_V7_LP64_OFF64_CFLAGS,
#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
_CS_POSIX_V7_LP64_OFF64_LDFLAGS,
#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
_CS_POSIX_V7_LP64_OFF64_LIBS,
#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
_CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
_CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,
#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS

_CS_V6_ENV,
#define _CS_V6_ENV _CS_V6_ENV
_CS_V7_ENV
#define _CS_V7_ENV _CS_V7_ENV
};

baseline bum
04-28-2013, 01:24 PM
/* Directory entry structure `struct dirent'. 4.4BSD/Generic version.
Copyright (C) 1996-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _DIRENT_H
# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
#endif

struct dirent
{
#ifndef __USE_FILE_OFFSET64
__ino_t d_ino; /* File serial number. */
#else
__ino64_t d_ino;
#endif
unsigned short int d_reclen; /* Length of the whole `struct dirent'. */
unsigned char d_type; /* File type, possibly unknown. */
unsigned char d_namlen; /* Length of the file name. */

/* Only this member is in the POSIX standard. */
char d_name[1]; /* File name (actually longer). */
};

#ifdef __USE_LARGEFILE64
struct dirent64
{
__ino64_t d_ino;
unsigned short int d_reclen;
unsigned char d_type;
unsigned char d_namlen;

char d_name[1];
};
#endif

#define d_fileno d_ino /* Backwards compatibility. */

#define _DIRENT_HAVE_D_RECLEN 1
#define _DIRENT_HAVE_D_NAMLEN 1
#define _DIRENT_HAVE_D_TYPE 1

#ifdef __INO_T_MATCHES_INO64_T
/* Inform libc code that these two types are effectively identical. */
# define _DIRENT_MATCHES_DIRENT64 1
#endif

baseline bum
04-28-2013, 01:24 PM
/* System dependent definitions for run-time dynamic loading.
Copyright (C) 1996-2001, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _DLFCN_H
# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
#endif

/* The MODE argument to `dlopen' contains one of the following: */
#define RTLD_LAZY 0x00001 /* Lazy function call binding. */
#define RTLD_NOW 0x00002 /* Immediate function call binding. */
#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
#define RTLD_NOLOAD 0x00004 /* Do not load the object. */
#define RTLD_DEEPBIND 0x00008 /* Use deep binding. */

/* If the following bit is set in the MODE argument to `dlopen',
the symbols of the loaded object and its dependencies are made
visible as if the object were linked directly into the program. */
#define RTLD_GLOBAL 0x00100

/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
The implementation does this by default and so we can define the
value to zero. */
#define RTLD_LOCAL 0

/* Do not delete object when closed. */
#define RTLD_NODELETE 0x01000

#ifdef __USE_GNU
/* To support profiling of shared objects it is a good idea to call
the function found using `dlsym' using the following macro since
these calls do not use the PLT. But this would mean the dynamic
loader has no chance to find out when the function is called. The
macro applies the necessary magic so that profiling is possible.
Rewrite
foo = (*fctp) (arg1, arg2);
into
foo = DL_CALL_FCT (fctp, (arg1, arg2));
*/
# define DL_CALL_FCT(fctp, args) \
(_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)

__BEGIN_DECLS

/* This function calls the profiling functions. */
extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;

__END_DECLS

#endif

baseline bum
04-28-2013, 01:24 PM
/* This file specifies the native word size of the machine, which indicates
the ELF file class used for executables and shared objects on this
machine. */

#ifndef _LINK_H
# error "Never use <bits/elfclass.h> directly; include <link.h> instead."
#endif

#include <bits/wordsize.h>

#define __ELF_NATIVE_CLASS __WORDSIZE

/* The entries in the .hash table always have a size of 32 bits. */
typedef uint32_t Elf_Symndx;

baseline bum
04-28-2013, 01:25 PM
/* This file should define __BYTE_ORDER as appropriate for the machine
in question. See string/endian.h for how to define it.

If only the stub bits/endian.h applies to a particular configuration,
bytesex.h is generated by running a program on the host machine.
So if cross-compiling to a machine with a different byte order,
the bits/endian.h file for that machine must exist. */

#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif

#error Machine byte order unknown.

baseline bum
04-28-2013, 01:25 PM
/* Copyright (C) 1999, 2001, 2004, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _UNISTD_H
# error "Never include this file directly. Use <unistd.h> instead"
#endif

#include <bits/wordsize.h>

/* This header should define the following symbols under the described
situations. A value `1' means that the model is always supported,
`-1' means it is never supported. Undefined means it cannot be
statically decided.

_POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type
_POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type

_POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type
_POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type

The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,
_POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,
_XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were
used in previous versions of the Unix standard and are available
only for compatibility.
*/

#if __WORDSIZE == 64

/* We can never provide environments with 32-bit wide pointers. */
# define _POSIX_V7_ILP32_OFF32 -1
# define _POSIX_V7_ILP32_OFFBIG -1
# define _POSIX_V6_ILP32_OFF32 -1
# define _POSIX_V6_ILP32_OFFBIG -1
# define _XBS5_ILP32_OFF32 -1
# define _XBS5_ILP32_OFFBIG -1
/* We also have no use (for now) for an environment with bigger pointers
and offsets. */
# define _POSIX_V7_LPBIG_OFFBIG -1
# define _POSIX_V6_LPBIG_OFFBIG -1
# define _XBS5_LPBIG_OFFBIG -1

/* By default we have 64-bit wide `long int', pointers and `off_t'. */
# define _POSIX_V7_LP64_OFF64 1
# define _POSIX_V6_LP64_OFF64 1
# define _XBS5_LP64_OFF64 1

#else /* __WORDSIZE == 32 */

/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
and all platforms support LFS. */
# define _POSIX_V7_ILP32_OFF32 1
# define _POSIX_V7_ILP32_OFFBIG 1
# define _POSIX_V6_ILP32_OFF32 1
# define _POSIX_V6_ILP32_OFFBIG 1
# define _XBS5_ILP32_OFF32 1
# define _XBS5_ILP32_OFFBIG 1

/* We optionally provide an environment with the above size but an 64-bit
side `off_t'. Therefore we don't define _POSIX_V7_ILP32_OFFBIG. */

/* We can never provide environments with 64-bit wide pointers. */
# define _POSIX_V7_LP64_OFF64 -1
# define _POSIX_V7_LPBIG_OFFBIG -1
# define _POSIX_V6_LP64_OFF64 -1
# define _POSIX_V6_LPBIG_OFFBIG -1
# define _XBS5_LP64_OFF64 -1
# define _XBS5_LPBIG_OFFBIG -1

/* CFLAGS. */
#define __ILP32_OFFBIG_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

#endif /* __WORDSIZE == 32 */

baseline bum
04-28-2013, 01:25 PM
/* Copyright (C) 1991, 1994, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* This file defines the `errno' constants. */

#if !defined __Emath_defined && (defined _ERRNO_H || defined __need_Emath)
#undef __need_Emath
#define __Emath_defined 1

# define EDOM XXX <--- fill in what is actually needed
# define EILSEQ XXX <--- fill in what is actually needed
# define ERANGE XXX <--- fill in what is actually needed
#endif

#ifdef _ERRNO_H
# error "Define here all the missing error messages for the port. These"
# error "must match the numbers of the kernel."
# define Exxxx XXX
...
#endif

baseline bum
04-28-2013, 01:25 PM
/* O_*, F_*, FD_* bit values. 4.4BSD/Generic version.
Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _FCNTL_H
#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif


/* File access modes for `open' and `fcntl'. */
#define O_RDONLY 0 /* Open read-only. */
#define O_WRONLY 1 /* Open write-only. */
#define O_RDWR 2 /* Open read/write. */


/* Bits OR'd into the second argument to open. */
#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
#define O_EXCL 0x0800 /* Fail if file already exists. */
#define O_TRUNC 0x0400 /* Truncate file to zero length. */
#define O_NOCTTY 0x8000 /* Don't assign a controlling terminal. */
#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
#define O_FSYNC 0x0080 /* Synchronous writes. */
#define O_SYNC O_FSYNC
#ifdef __USE_MISC
#define O_SHLOCK 0x0010 /* Open with shared file lock. */
#define O_EXLOCK 0x0020 /* Open with shared exclusive lock. */
#endif
#ifdef __USE_XOPEN2K8
# define O_DIRECTORY 0x00200000 /* Must be a directory. */
# define O_NOFOLLOW 0x00000100 /* Do not follow links. */
# define O_CLOEXEC 0x00400000 /* Set close_on_exec. */
#endif
#if defined __USE_POSIX199309 || defined __USE_UNIX98
# define O_DSYNC 0x00010000 /* Synchronize data. */
# define O_RSYNC 0x00020000 /* Synchronize read operations. */
#endif

/* All opens support large file sizes, so there is no flag bit for this. */
#ifdef __USE_LARGEFILE64
# define O_LARGEFILE 0
#endif

/* File status flags for `open' and `fcntl'. */
#define O_APPEND 0x0008 /* Writes append to the file. */
#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */

#ifdef __USE_BSD
# define O_NDELAY O_NONBLOCK
#endif

#ifdef __USE_BSD
/* Bits in the file status flags returned by F_GETFL.
These are all the O_* flags, plus FREAD and FWRITE, which are
independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
given to `open'. */
# define FREAD 1
# define FWRITE 2

/* Traditional BSD names the O_* bits. */
# define FASYNC O_ASYNC
# define FFSYNC O_FSYNC
# define FSYNC O_SYNC
# define FAPPEND O_APPEND
# define FNDELAY O_NDELAY
#endif

/* Mask for file access modes. This is system-dependent in case
some system ever wants to define some other flavor of access. */
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)

/* Values for the second argument to `fcntl'. */
#define F_DUPFD 0 /* Duplicate file descriptor. */
#define F_GETFD 1 /* Get file descriptor flags. */
#define F_SETFD 2 /* Set file descriptor flags. */
#define F_GETFL 3 /* Get file status flags. */
#define F_SETFL 4 /* Set file status flags. */
#if defined __USE_BSD || defined __USE_UNIX98 || defined __USE_XOPEN2K8
#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
#endif
#define F_GETLK 7 /* Get record locking info. */
#define F_SETLK 8 /* Set record locking info (non-blocking). */
#define F_SETLKW 9 /* Set record locking info (blocking). */
/* Not necessary, we always have 64-bit offsets. */
#define F_GETLK64 F_GETLK /* Get record locking info. */
#define F_SETLK64 F_SETLK /* Set record locking info (non-blocking). */
#define F_SETLKW64 F_SETLKW/* Set record locking info (blocking). */
#ifdef __USE_XOPEN2K8
# define F_DUPFD_CLOEXEC 12 /* Duplicate file descriptor with
close-on-exit set. */
#endif

/* File descriptor flags used with F_GETFD and F_SETFD. */
#define FD_CLOEXEC 1 /* Close on exec. */


#include <bits/types.h>

/* The structure describing an advisory lock. This is the type of the third
argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
struct flock
{
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until EOF. */
__pid_t l_pid; /* Process holding the lock. */
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
};

#ifdef __USE_LARGEFILE64
/* Note this matches struct flock exactly. */
struct flock64
{
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until EOF. */
__pid_t l_pid; /* Process holding the lock. */
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
};
#endif

/* Values for the `l_type' field of a `struct flock'. */
#define F_RDLCK 1 /* Read lock. */
#define F_WRLCK 2 /* Write lock. */
#define F_UNLCK 3 /* Remove lock. */

/* Advise to `posix_fadvise'. */
#ifdef __USE_XOPEN2K
# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif

baseline bum
04-28-2013, 01:25 PM
/* Copyright (C) 1997-2001, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
#endif


/* Here should be the exception be defined:
FE_INVALID
FE_DIVBYZERO
FE_OVERFLOW
FE_UNDERFLOW
FE_INEXACT
We define no macro which signals no exception is supported. */

#define FE_ALL_EXCEPT 0


/* Here should the rounding modes be defined:
FE_TONEAREST
FE_DOWNWARD
FE_UPWARD
FE_TOWARDZERO
We define no macro which signals no rounding mode is selectable. */


/* Type representing exception flags. */
typedef unsigned int fexcept_t;


/* Type representing floating-point environment. */
typedef struct
{
fexcept_t __excepts;
/* XXX I don't know what else we should save. */
}
fenv_t;

/* If the default argument is used we use this value. */
#define FE_DFL_ENV ((const fenv_t *) -1l)

baseline bum
04-28-2013, 01:25 PM
/* This file provides inline versions of floating-pint environment
handling functions. If there were any. */

#ifndef __NO_MATH_INLINES

/* Here is where the code would go. */

#endif

baseline bum
04-28-2013, 01:26 PM
/* Stub `HUGE_VAL' constant.
Used by <stdlib.h> and <math.h> functions for overflow.
Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
#endif

#if __GNUC_PREREQ(3,3)
# define HUGE_VAL (__builtin_huge_val())
#else
# define HUGE_VAL 1e37
#endif

baseline bum
04-28-2013, 01:26 PM
/* Stub `HUGE_VALF' constant.
Used by <stdlib.h> and <math.h> functions for overflow.
Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _MATH_H
# error "Never use <bits/huge_valf.h> directly; include <math.h> instead."
#endif

#if __GNUC_PREREQ(3,3)
# define HUGE_VALF (__builtin_huge_valf())
#else
# define HUGE_VALF 1e37f
#endif

baseline bum
04-28-2013, 01:26 PM
/* Default `HUGE_VALL' constant.
Used by <stdlib.h> and <math.h> functions for overflow.
Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _MATH_H
# error "Never use <bits/huge_vall.h> directly; include <math.h> instead."
#endif

#if __GNUC_PREREQ(3,3)
# define HUGE_VALL (__builtin_huge_vall())
#else
# define HUGE_VALL ((long double) HUGE_VAL)
#endif

baseline bum
04-28-2013, 01:26 PM
/* Copyright (C) 1997-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* Generic version. */

#ifndef _NETINET_IN_H
# error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
#endif

/* To select the IP level. */
#define SOL_IP 0

/* Options for use with `getsockopt' and `setsockopt' at the IP level.
The first word in the comment at the right is the data type used;
"bool" means a boolean value stored in an `int'. */
#define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */
#define IP_HDRINCL 2 /* int; Header is included with data. */
#define IP_TOS 3 /* int; IP type of service and precedence. */
#define IP_TTL 4 /* int; IP time to live. */
#define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */
#define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */
#define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */
#define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */
#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */
#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
#define IP_MULTICAST_LOOP 11 /* i_char; set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */

/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
The `ip_dst' field is used for the first-hop gateway when using a
source route (this gets put into the header proper). */
struct ip_opts
{
struct in_addr ip_dst; /* First hop; zero without source route. */
char ip_opts[40]; /* Actually variable in size. */
};

/* Socket-level values for IPv6. */
#define SOL_IPV6 41
#define SOL_ICMPV6 58

/* IPV6 socket options. */
#define IPV6_ADDRFORM 1
#define IPV6_PKTINFO 2
#define IPV6_HOPOPTS 3
#define IPV6_DSTOPTS 4
#define IPV6_RTHDR 5
#define IPV6_PKTOPTIONS 6
#define IPV6_CHECKSUM 7
#define IPV6_HOPLIMIT 8

#define IPV6_RXINFO IPV6_PKTINFO
#define IPV6_TXINFO IPV6_PKTINFO
#define SCM_SRCINFO IPV6_PKTINFO
#define SCM_SRCRT IPV6_RXSRCRT

#define IPV6_UNICAST_HOPS 16
#define IPV6_MULTICAST_IF 17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
#define IPV6_JOIN_GROUP 20
#define IPV6_LEAVE_GROUP 21
#define IPV6_ROUTER_ALERT 22
#define IPV6_MTU_DISCOVER 23
#define IPV6_MTU 24
#define IPV6_RECVERR 25
#define IPV6_V6ONLY 26
#define IPV6_JOIN_ANYCAST 27
#define IPV6_LEAVE_ANYCAST 28

/* Obsolete synonyms for the above. */
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
#define IPV6_RXHOPOPTS IPV6_HOPOPTS
#define IPV6_RXDSTOPTS IPV6_DSTOPTS

/* Routing header options for IPv6. */
#define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */
#define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */

#define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */

baseline bum
04-28-2013, 01:26 PM
/* Default `INFINITY' constant.
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _MATH_H
# error "Never use <bits/inf.h> directly; include <math.h> instead."
#endif

/* If we don't have real infinity, then we're supposed to produce a float
value that overflows at translation time, which is required to produce
a diagnostic. GCC's __builtin_inff produces a quite nice diagnostic
that tells the user that the target doesn't support infinities. */

#if __GNUC_PREREQ(3,3)
# define INFINITY (__builtin_inff())
#else
# define INFINITY (1e9999f)
#endif

baseline bum
04-28-2013, 01:26 PM
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
#endif

/* This space intentionally left blank. */

baseline bum
04-28-2013, 01:26 PM
/* Structure types for pre-termios terminal ioctls. Generic Unix version.
Copyright (C) 1996,1997,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
#endif

#if defined TIOCGETC || defined TIOCSETC
/* Type of ARG for TIOCGETC and TIOCSETC requests. */
struct tchars
{
char t_intrc; /* Interrupt character. */
char t_quitc; /* Quit character. */
char t_startc; /* Start-output character. */
char t_stopc; /* Stop-output character. */
char t_eofc; /* End-of-file character. */
char t_brkc; /* Input delimiter character. */
};

#define _IOT_tchars /* Hurd ioctl type field. */ \
_IOT (_IOTS (char), 6, 0, 0, 0, 0)
#endif

#if defined TIOCGLTC || defined TIOCSLTC
/* Type of ARG for TIOCGLTC and TIOCSLTC requests. */
struct ltchars
{
char t_suspc; /* Suspend character. */
char t_dsuspc; /* Delayed suspend character. */
char t_rprntc; /* Reprint-line character. */
char t_flushc; /* Flush-output character. */
char t_werasc; /* Word-erase character. */
char t_lnextc; /* Literal-next character. */
};

#define _IOT_ltchars /* Hurd ioctl type field. */ \
_IOT (_IOTS (char), 6, 0, 0, 0, 0)
#endif

/* Type of ARG for TIOCGETP and TIOCSETP requests (and gtty and stty). */
struct sgttyb
{
char sg_ispeed; /* Input speed. */
char sg_ospeed; /* Output speed. */
char sg_erase; /* Erase character. */
char sg_kill; /* Kill character. */
short int sg_flags; /* Mode flags. */
};

#define _IOT_sgttyb /* Hurd ioctl type field. */ \
_IOT (_IOTS (char), 4, _IOTS (short int), 1, 0, 0)

#if defined TIOCGWINSZ || defined TIOCSWINSZ
/* Type of ARG for TIOCGWINSZ and TIOCSWINSZ requests. */
struct winsize
{
unsigned short int ws_row; /* Rows, in characters. */
unsigned short int ws_col; /* Columns, in characters. */

/* These are not actually used. */
unsigned short int ws_xpixel; /* Horizontal pixels. */
unsigned short int ws_ypixel; /* Vertical pixels. */
};

#define _IOT_winsize /* Hurd ioctl type field. */ \
_IOT (_IOTS (unsigned short int), 4, 0, 0, 0, 0)
#endif

#if defined TIOCGSIZE || defined TIOCSSIZE
/* The BSD-style ioctl constructor macros use `sizeof', which can't be used
in a preprocessor conditional. Since the commands are always unique
regardless of the size bits, we can safely define away `sizeof' for the
purpose of the conditional. */
# define sizeof(type) 0
# if defined TIOCGWINSZ && TIOCGSIZE == TIOCGWINSZ
/* Many systems that have TIOCGWINSZ define TIOCGSIZE for source
compatibility with Sun; they define `struct ttysize' to have identical
layout as `struct winsize' and #define TIOCGSIZE to be TIOCGWINSZ
(likewise TIOCSSIZE and TIOCSWINSZ). */
struct ttysize
{
unsigned short int ts_lines;
unsigned short int ts_cols;
unsigned short int ts_xxx;
unsigned short int ts_yyy;
};
#define _IOT_ttysize _IOT_winsize
# else
/* Suns use a different layout for `struct ttysize', and TIOCGSIZE and
TIOCGWINSZ are separate commands that do the same thing with different
structures (likewise TIOCSSIZE and TIOCSWINSZ). */
struct ttysize
{
int ts_lines, ts_cols; /* Lines and columns, in characters. */
};
# endif
# undef sizeof /* See above. */
#endif

baseline bum
04-28-2013, 01:27 PM
/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
#endif

#include <bits/types.h>

/* Mode bits for `msgget', `semget', and `shmget'. */
#define IPC_CREAT 01000 /* create key if key does not exist */
#define IPC_EXCL 02000 /* fail if key exists */
#define IPC_NOWAIT 04000 /* return error on wait */

/* Control commands for `msgctl', `semctl', and `shmctl'. */
#define IPC_RMID 0 /* remove identifier */
#define IPC_SET 1 /* set `ipc_perm' options */
#define IPC_STAT 2 /* get `ipc_perm' options */

/* Special key values. */
#define IPC_PRIVATE ((key_t) 0) /* private key */


/* Data structure used to pass permission information to IPC operations. */
struct ipc_perm
{
__uid_t uid; /* owner's user ID */
__gid_t gid; /* owner's group ID */
__uid_t cuid; /* creator's user ID */
__gid_t cgid; /* creator's group ID */
__mode_t mode; /* read/write permission */
};

baseline bum
04-28-2013, 01:27 PM
/* bits/ipctypes.h -- Define some types used by SysV IPC/MSG/SHM. Generic.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/*
* Never include <bits/ipctypes.h> directly.
*/

#ifndef _BITS_IPCTYPES_H
#define _BITS_IPCTYPES_H 1

#include <bits/types.h>

/* Used in `struct shmid_ds'. */
# if __WORDSIZE == 32
typedef unsigned short int __ipc_pid_t;
# else
typedef int __ipc_pid_t;
# endif


#endif /* bits/ipctypes.h */

baseline bum
04-28-2013, 01:27 PM
/* libc-internal interface for mutex locks. Stub version.
Copyright (C) 1996-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_LIBC_LOCK_H
#define _BITS_LIBC_LOCK_H 1


/* Define a lock variable NAME with storage class CLASS. The lock must be
initialized with __libc_lock_init before it can be used (or define it
with __libc_lock_define_initialized, below). Use `extern' for CLASS to
declare a lock defined in another module. In public structure
definitions you must use a pointer to the lock structure (i.e., NAME
begins with a `*'), because its storage size will not be known outside
of libc. */
#define __libc_lock_define(CLASS,NAME)
#define __libc_lock_define_recursive(CLASS,NAME)
#define __rtld_lock_define_recursive(CLASS,NAME)
#define __libc_rwlock_define(CLASS,NAME)

/* Define an initialized lock variable NAME with storage class CLASS. */
#define __libc_lock_define_initialized(CLASS,NAME)
#define __libc_rwlock_define_initialized(CLASS,NAME)

/* Define an initialized recursive lock variable NAME with storage
class CLASS. */
#define __libc_lock_define_initialized_recursive(CLASS,NAM E)
#define __rtld_lock_define_initialized_recursive(CLASS,NAM E)

/* Initialize the named lock variable, leaving it in a consistent, unlocked
state. */
#define __libc_lock_init(NAME)
#define __rtld_lock_initialize(NAME)
#define __libc_rwlock_init(NAME)

/* Same as last but this time we initialize a recursive mutex. */
#define __libc_lock_init_recursive(NAME)

/* Finalize the named lock variable, which must be locked. It cannot be
used again until __libc_lock_init is called again on it. This must be
called on a lock variable before the containing storage is reused. */
#define __libc_lock_fini(NAME)
#define __libc_rwlock_fini(NAME)

/* Finalize recursive named lock. */
#define __libc_lock_fini_recursive(NAME)

/* Lock the named lock variable. */
#define __libc_lock_lock(NAME)
#define __libc_rwlock_rdlock(NAME)
#define __libc_rwlock_wrlock(NAME)

/* Lock the recursive named lock variable. */
#define __libc_lock_lock_recursive(NAME)
#define __rtld_lock_lock_recursive(NAME)

/* Try to lock the named lock variable. */
#define __libc_lock_trylock(NAME) 0
#define __libc_rwlock_tryrdlock(NAME) 0
#define __libc_rwlock_trywrlock(NAME) 0

/* Try to lock the recursive named lock variable. */
#define __libc_lock_trylock_recursive(NAME) 0

/* Unlock the named lock variable. */
#define __libc_lock_unlock(NAME)
#define __libc_rwlock_unlock(NAME)

/* Unlock the recursive named lock variable. */
#define __libc_lock_unlock_recursive(NAME)
#define __rtld_lock_unlock_recursive(NAME)


/* Define once control variable. */
#define __libc_once_define(CLASS, NAME) CLASS int NAME = 0

/* Call handler iff the first call. */
#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
do { \
if ((ONCE_CONTROL) == 0) { \
INIT_FUNCTION (); \
(ONCE_CONTROL) = 1; \
} \
} while (0)

/* Get once control variable. */
#define __libc_once_get(ONCE_CONTROL) \
((ONCE_CONTROL) == 1)

/* Start a critical region with a cleanup function */
#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
{ \
typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0; \
typeof (ARG) __save_ARG = ARG; \
/* close brace is in __libc_cleanup_region_end below. */

/* End a critical region started with __libc_cleanup_region_start. */
#define __libc_cleanup_region_end(DOIT) \
if ((DOIT) && __save_FCT != 0) \
(*__save_FCT)(__save_ARG); \
}

/* Sometimes we have to exit the block in the middle. */
#define __libc_cleanup_end(DOIT) \
if ((DOIT) && __save_FCT != 0) \
(*__save_FCT)(__save_ARG); \

#define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
#define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)

/* We need portable names for some of the functions. */
#define __libc_mutex_unlock

/* Type for key of thread specific data. */
typedef int __libc_key_t;

/* Create key for thread specific data. */
#define __libc_key_create(KEY,DEST) ((void) (KEY), (void) (DEST), -1)

/* Set thread-specific data associated with KEY to VAL. */
#define __libc_setspecific(KEY,VAL) ((void) (KEY), (void) (VAL))

/* Get thread-specific data associated with KEY. */
#define __libc_getspecific(KEY) ((void) (KEY), (void *) 0)

#endif /* bits/libc-lock.h */

baseline bum
04-28-2013, 01:27 PM
/* libc-internal interface for thread-specific data. Stub or TLS version.
Copyright (C) 1998,2001,2002,2008,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _GENERIC_BITS_LIBC_TSD_H
#define _GENERIC_BITS_LIBC_TSD_H 1

/* This file defines the following macros for accessing a small fixed
set of thread-specific `void *' data used only internally by libc.

__libc_tsd_define(CLASS, TYPE, KEY) -- Define or declare a datum with TYPE
for KEY. CLASS can be `static' for
keys used in only one source file,
empty for global definitions, or
`extern' for global declarations.
__libc_tsd_address(TYPE, KEY) -- Return the `TYPE *' pointing to
the current thread's datum for KEY.
__libc_tsd_get(TYPE, KEY) -- Return the `TYPE' datum for KEY.
__libc_tsd_set(TYPE, KEY, VALUE) -- Set the datum for KEY to VALUE.

The set of available KEY's will usually be provided as an enum,
and contains (at least):
_LIBC_TSD_KEY_MALLOC
_LIBC_TSD_KEY_DL_ERROR
_LIBC_TSD_KEY_RPC_VARS
All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
Some implementations may not provide any enum at all and instead
using string pasting in the macros. */

#include <tls.h>

/* When full support for __thread variables is available, this interface is
just a trivial wrapper for it. Without TLS, this is the generic/stub
implementation for wholly single-threaded systems.

We don't define an enum for the possible key values, because the KEYs
translate directly into variables by macro magic. */

#define __libc_tsd_define(CLASS, TYPE, KEY) \
CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie;

#define __libc_tsd_address(TYPE, KEY) (&__libc_tsd_##KEY)
#define __libc_tsd_get(TYPE, KEY) (__libc_tsd_##KEY)
#define __libc_tsd_set(TYPE, KEY, VALUE) (__libc_tsd_##KEY = (VALUE))

#endif /* bits/libc-tsd.h */

baseline bum
04-28-2013, 01:27 PM
#error "Architecture-specific definition needed."

baseline bum
04-28-2013, 01:27 PM
struct link_map_machine
{
/* empty by default */
};

baseline bum
04-28-2013, 01:27 PM
/* This file should define the implementation-specific limits described
in posix[12]_lim.h. If there are no useful values to give a limit,
don't define it. */

baseline bum
04-28-2013, 01:28 PM
/* Copyright (C) 1997,1998,1999,2000,2004,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
#endif

#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1

/* Normally, there is no long double type and the `float' and `double'
expressions are evaluated as `double'. */
typedef double float_t; /* `float' expressions are evaluated as
`double'. */
typedef double double_t; /* `double' expressions are evaluated as
`double'. */

/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN 2147483647

/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
builtins are supported. */
#if __FP_FAST_FMA
# define FP_FAST_FMA 1
#endif

#if __FP_FAST_FMAF
# define FP_FAST_FMAF 1
#endif

#if __FP_FAST_FMAL
# define FP_FAST_FMAL 1
#endif

#endif /* ISO C99 */

#ifndef __NO_LONG_DOUBLE_MATH
/* Signal that we do not really have a `long double'. The disables the
declaration of all the `long double' function variants. */
# define __NO_LONG_DOUBLE_MATH 1
#endif

baseline bum
04-28-2013, 01:28 PM
/* This file should provide inline versions of math functions.

Surround GCC-specific parts with #ifdef __GNUC__, and use `__extern_inline'.

This file should define __MATH_INLINES if functions are actually defined as
inlines. */

#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__

/* Here goes the real code. */

#endif

baseline bum
04-28-2013, 01:28 PM
/* Definitions for BSD-style memory management.
Copyright (C) 1994-1998,2000,01,02,05 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/* These are the bits used by 4.4 BSD and its derivatives. On systems
(such as GNU) where these facilities are not system services but can be
emulated in the C library, these are the definitions we emulate. */

#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
#endif

/* Protections are chosen from these bits, OR'd together. The
implementation does not necessarily support PROT_EXEC or PROT_WRITE
without PROT_READ. The only guarantees are that no writing will be
allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */

#define PROT_NONE 0x00 /* No access. */
#define PROT_READ 0x04 /* Pages can be read. */
#define PROT_WRITE 0x02 /* Pages can be written. */
#define PROT_EXEC 0x01 /* Pages can be executed. */

/* Flags contain mapping type, sharing type and options. */

/* Mapping type (must choose one and only one of these). */
#ifdef __USE_BSD
# define MAP_FILE 0x0001 /* Mapped from a file or device. */
# define MAP_ANON 0x0002 /* Allocated from anonymous virtual memory. */
# define MAP_TYPE 0x000f /* Mask for type field. */
# ifdef __USE_MISC
# define MAP_ANONYMOUS MAP_ANON /* Linux name. */
# endif
#endif

/* Sharing types (must choose one and only one of these). */
#ifdef __USE_BSD
# define MAP_COPY 0x0020 /* Virtual copy of region at mapping time. */
#endif
#define MAP_SHARED 0x0010 /* Share changes. */
#define MAP_PRIVATE 0x0000 /* Changes private; copy pages on write. */

/* Other flags. */
#define MAP_FIXED 0x0100 /* Map address must be exactly as requested. */
#ifdef __USE_BSD
# define MAP_NOEXTEND 0x0200 /* For MAP_FILE, don't change file size. */
# define MAP_HASSEMPHORE 0x0400 /* Region may contain semaphores. */
# define MAP_INHERIT 0x0800 /* Region is retained after exec. */
#endif

/* Advice to `madvise'. */
#ifdef __USE_BSD
# define MADV_NORMAL 0 /* No further special treatment. */
# define MADV_RANDOM 1 /* Expect random page references. */
# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
# define MADV_WILLNEED 3 /* Will need these pages. */
# define MADV_DONTNEED 4 /* Don't need these pages. */
#endif

/* The POSIX people had to invent similar names for the same things. */
#ifdef __USE_XOPEN2K
# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
#endif

/* Flags to `msync'. */
#define MS_ASYNC 1 /* Sync memory asynchronously. */
#define MS_SYNC 0 /* Synchronous memory sync. */
#define MS_INVALIDATE 2 /* Invalidate the caches. */

/* Flags for `mremap'. */
#ifdef __USE_GNU
# define MREMAP_MAYMOVE 1 /* Mapping address may change. */
# define MREMAP_FIXED 2 /* Fifth argument sets new address. */
#endif

/* Flags for `mlockall' (can be OR'd together). */
#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
#define MCL_FUTURE 2 /* Lock all additions to address
space. */

baseline bum
04-28-2013, 01:28 PM
/* Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _MQUEUE_H
# error "Never use <bits/mqueue.h> directly; include <mqueue.h> instead."
#endif

typedef int mqd_t;

struct mq_attr
{
long int mq_flags; /* Message queue flags. */
long int mq_maxmsg; /* Maximum number of messages. */
long int mq_msgsize; /* Maximum message size. */
long int mq_curmsgs; /* Number of messages currently queued. */
};

baseline bum
04-28-2013, 01:28 PM
/* Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_MSG_H
#error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
#endif

#include <bits/types.h>

/* Define options for message queue functions. */
#define MSG_NOERROR 010000 /* no error if message is too big */

/* Types used in the structure definition. */
typedef unsigned short int msgqnum_t;
typedef unsigned short int msglen_t;


/* Structure of record for one message inside the kernel.
The type `struct __msg' is opaque. */
struct msqid_ds
{
struct ipc_perm msg_perm; /* structure describing operation permission */
__time_t msg_stime; /* time of last msgsnd command */
__time_t msg_rtime; /* time of last msgrcv command */
__time_t msg_ctime; /* time of last change */
msgqnum_t msg_qnum; /* number of messages currently on queue */
msglen_t msg_qbytes; /* max number of bytes allowed on queue */
__pid_t msg_lspid; /* pid of last msgsnd() */
__pid_t msg_lrpid; /* pid of last msgrcv() */
};

baseline bum
04-28-2013, 01:28 PM
#ifndef _MATH_H
#error "Never use <bits/nan.h> directly; include <math.h> instead."
#endif

/* This file should define `NAN' on machines that have such things. */

baseline bum
04-28-2013, 01:29 PM
/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _NETDB_H
# error "Never include <bits/netdb.h> directly; use <netdb.h> instead."
#endif


/* Description of data base entry for a single network. NOTE: here a
poor assumption is made. The network number is expected to fit
into an unsigned long int variable. */
struct netent
{
char *n_name; /* Official name of network. */
char **n_aliases; /* Alias list. */
int n_addrtype; /* Net address type. */
uint32_t n_net; /* Network number. */
};

baseline bum
04-28-2013, 01:29 PM
/* Old-style Unix parameters and limits. Stub version.
Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif

/* This header is expected to define a few particular macros.

The traditional BSD macros that correspond directly to POSIX <limits.h>
macros don't need to be defined here if <bits/local_lim.h> defines the
POSIX limit macro, as the common <sys/param.h> code will define each
traditional name to its POSIX name if available.

This file should define at least:

EXEC_PAGESIZE
*/

baseline bum
04-28-2013, 01:29 PM
/* Copyright (C) 1997, 2000, 2001, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
#endif

/* Event types that can be polled for. These bits may be set in `events'
to indicate the interesting event types; they will appear in `revents'
to indicate the status of the file descriptor. */
#define POLLIN 01 /* There is data to read. */
#define POLLPRI 02 /* There is urgent data to read. */
#define POLLOUT 04 /* Writing now will not block. */

#if defined __USE_XOPEN || defined __USE_XOPEN2K8
/* These values are defined in XPG4.2 and later. */
# define POLLRDNORM POLLIN /* Normal data may be read. */
# define POLLRDBAND POLLPRI /* Priority data may be read. */
# define POLLWRNORM POLLOUT /* Writing now will not block. */
# define POLLWRBAND POLLOUT /* Priority data may be written. */
#endif

/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
#define POLLERR 010 /* Error condition. */
#define POLLHUP 020 /* Hung up. */
#define POLLNVAL 040 /* Invalid polling request. */

baseline bum
04-28-2013, 01:29 PM
/* This file should define the POSIX options described in <unistd.h>,
or leave them undefined, as appropriate. */

baseline bum
04-28-2013, 01:29 PM
/* No thread support. */

baseline bum
04-28-2013, 01:29 PM
/* Bit values & structures for resource limits. 4.4 BSD/generic GNU version.
Copyright (C) 1994,1996,1997,1998,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
#endif

#include <bits/types.h>

/* These are the values for 4.4 BSD and GNU. Earlier BSD systems have a
subset of these kinds of resource limit. In systems where `getrlimit'
and `setrlimit' are not system calls, these are the values used by the C
library to emulate them. */

/* Kinds of resource limit. */
enum __rlimit_resource
{
/* Per-process CPU limit, in seconds. */
RLIMIT_CPU,
#define RLIMIT_CPU RLIMIT_CPU
/* Largest file that can be created, in bytes. */
RLIMIT_FSIZE,
#define RLIMIT_FSIZE RLIMIT_FSIZE
/* Maximum size of data segment, in bytes. */
RLIMIT_DATA,
#define RLIMIT_DATA RLIMIT_DATA
/* Maximum size of stack segment, in bytes. */
RLIMIT_STACK,
#define RLIMIT_STACK RLIMIT_STACK
/* Largest core file that can be created, in bytes. */
RLIMIT_CORE,
#define RLIMIT_CORE RLIMIT_CORE
/* Largest resident set size, in bytes.
This affects swapping; processes that are exceeding their
resident set size will be more likely to have physical memory
taken from them. */
RLIMIT_RSS,
#define RLIMIT_RSS RLIMIT_RSS
/* Locked-in-memory address space. */
RLIMIT_MEMLOCK,
#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
/* Number of processes. */
RLIMIT_NPROC,
#define RLIMIT_NPROC RLIMIT_NPROC
/* Number of open files. */
RLIMIT_OFILE,
RLIMIT_NOFILE = RLIMIT_OFILE, /* Another name for the same thing. */
#define RLIMIT_OFILE RLIMIT_OFILE
#define RLIMIT_NOFILE RLIMIT_NOFILE
/* Maximum size of all socket buffers. */
RLIMIT_SBSIZE,
#define RLIMIT_SBSIZE RLIMIT_SBSIZE
/* Maximum size in bytes of the process address space. */
RLIMIT_AS,
RLIMIT_VMEM = RLIMIT_AS, /* Another name for the same thing. */
#define RLIMIT_AS RLIMIT_AS
#define RLIMIT_VMEM RLIMIT_AS

RLIMIT_NLIMITS, /* Number of limit flavors. */
RLIM_NLIMITS = RLIMIT_NLIMITS /* Traditional name for same. */
};

/* Value to indicate that there is no limit. */
#ifndef __USE_FILE_OFFSET64
# define RLIM_INFINITY 0x7fffffff
#else
# define RLIM_INFINITY 0x7fffffffffffffffLL
#endif

#ifdef __USE_LARGEFILE64
# define RLIM64_INFINITY 0x7fffffffffffffffLL
#endif


/* Type for resource quantity measurement. */
#ifndef __USE_FILE_OFFSET64
typedef __rlim_t rlim_t;
#else
typedef __rlim64_t rlim_t;
#endif
#ifdef __USE_LARGEFILE64
typedef __rlim64_t rlim64_t;
#endif

struct rlimit
{
/* The current (soft) limit. */
rlim_t rlim_cur;
/* The hard limit. */
rlim_t rlim_max;
};

#ifdef __USE_LARGEFILE64
struct rlimit64
{
/* The current (soft) limit. */
rlim64_t rlim_cur;
/* The hard limit. */
rlim64_t rlim_max;
};
#endif

/* Whose usage statistics do you want? */
enum __rusage_who
/* The macro definitions are necessary because some programs want
to test for operating system features with #ifdef RUSAGE_SELF.
In ISO C the reflexive definition is a no-op. */
{
/* The calling process. */
RUSAGE_SELF = 0,
#define RUSAGE_SELF RUSAGE_SELF
/* All of its terminated child processes. */
RUSAGE_CHILDREN = -1
#define RUSAGE_CHILDREN RUSAGE_CHILDREN
};

#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */

/* Structure which says how much of each resource has been used. */
struct rusage
{
/* Total amount of user time used. */
struct timeval ru_utime;
/* Total amount of system time used. */
struct timeval ru_stime;
/* Maximum resident set size (in kilobytes). */
long int ru_maxrss;
/* Amount of sharing of text segment memory
with other processes (kilobyte-seconds). */
long int ru_ixrss;
/* Amount of data segment memory used (kilobyte-seconds). */
long int ru_idrss;
/* Amount of stack memory used (kilobyte-seconds). */
long int ru_isrss;
/* Number of soft page faults (i.e. those serviced by reclaiming
a page from the list of pages awaiting reallocation. */
long int ru_minflt;
/* Number of hard page faults (i.e. those that required I/O). */
long int ru_majflt;
/* Number of times a process was swapped out of physical memory. */
long int ru_nswap;
/* Number of input operations via the file system. Note: This
and `ru_oublock' do not include operations with the cache. */
long int ru_inblock;
/* Number of output operations via the file system. */
long int ru_oublock;
/* Number of IPC messages sent. */
long int ru_msgsnd;
/* Number of IPC messages received. */
long int ru_msgrcv;
/* Number of signals delivered. */
long int ru_nsignals;
/* Number of voluntary context switches, i.e. because the process
gave up the process before it had to (usually to wait for some
resource to be available). */
long int ru_nvcsw;
/* Number of involuntary context switches, i.e. a higher priority process
became runnable or the current process used up its time slice. */
long int ru_nivcsw;
};

/* Priority limits. */
#define PRIO_MIN -20 /* Minimum priority a process can have. */
#define PRIO_MAX 20 /* Maximum priority a process can have. */

/* The type of the WHICH argument to `getpriority' and `setpriority',
indicating what flavor of entity the WHO argument specifies. */
enum __priority_which
{
PRIO_PROCESS = 0, /* WHO is a process ID. */
#define PRIO_PROCESS PRIO_PROCESS
PRIO_PGRP = 1, /* WHO is a process group ID. */
#define PRIO_PGRP PRIO_PGRP
PRIO_USER = 2 /* WHO is a user ID. */
#define PRIO_USER PRIO_USER
};

baseline bum
04-28-2013, 01:29 PM
/* Definitions of constants and data structure for POSIX 1003.1b-1993
scheduling interface.
Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008,2009,2011,2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef __need_schedparam

#ifndef _SCHED_H
# error "Never include <bits/sched.h> directly; use <sched.h> instead."
#endif


/* Scheduling algorithms. */
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2

/* Data structure to describe a process' schedulability. */
struct sched_param
{
int __sched_priority;
};

#endif /* need schedparam */

#if !defined __defined_schedparam \
&& (defined __need_schedparam || defined _SCHED_H)
# define __defined_schedparam 1
/* Data structure to describe a process' schedulability. */
struct __sched_param
{
int __sched_priority;
};
# undef __need_schedparam
#endif


#if defined _SCHED_H && !defined __cpu_set_t_defined
# define __cpu_set_t_defined
/* Size definition for CPU sets. */
# define __CPU_SETSIZE 1024
# define __NCPUBITS (8 * sizeof (__cpu_mask))

/* Type for array elements in 'cpu_set_t'. */
typedef unsigned long int __cpu_mask;

/* Basic access functions. */
# define __CPUELT(cpu) ((cpu) / __NCPUBITS)
# define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))

/* Data structure to describe CPU mask. */
typedef struct
{
__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
} cpu_set_t;

/* Access functions for CPU masks. */
# if __GNUC_PREREQ (2, 91)
# define __CPU_ZERO_S(setsize, cpusetp) \
do __builtin_memset (cpusetp, '\0', setsize); while (0)
# else
# define __CPU_ZERO_S(setsize, cpusetp) \
do { \
size_t __i; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
__cpu_mask *__bits = (cpusetp)->__bits; \
for (__i = 0; __i < __imax; ++__i) \
__bits[__i] = 0; \
} while (0)
# endif
# define __CPU_SET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|= __CPUMASK (__cpu)) \
: 0; }))
# define __CPU_CLR_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
&= ~__CPUMASK (__cpu)) \
: 0; }))
# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
& __CPUMASK (__cpu))) != 0 \
: 0; }))

# define __CPU_COUNT_S(setsize, cpusetp) \
__sched_cpucount (setsize, cpusetp)

# if __GNUC_PREREQ (2, 91)
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
# else
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__extension__ \
({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
if (__arr1[__i] != __arr2[__i]) \
break; \
__i == __imax; }))
# endif

# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
(__extension__ \
({ cpu_set_t *__dest = (destset); \
const __cpu_mask *__arr1 = (srcset1)->__bits; \
const __cpu_mask *__arr2 = (srcset2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
__dest; }))

# define __CPU_ALLOC_SIZE(count) \
((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
# define __CPU_ALLOC(count) __sched_cpualloc (count)
# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)

__BEGIN_DECLS

extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
__THROW;
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
extern void __sched_cpufree (cpu_set_t *__set) __THROW;

__END_DECLS

#endif

baseline bum
04-28-2013, 01:30 PM
/* Copyright (C) 1997, 1998, 2001, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif


/* We don't use `memset' because this would require a prototype and
the array isn't too big. */
#define __FD_ZERO(s) \
do { \
unsigned int __i; \
fd_set *__arr = (s); \
for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
__FDS_BITS (__arr)[__i] = 0; \
} while (0)
#define __FD_SET(d, s) \
((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
#define __FD_CLR(d, s) \
((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
#define __FD_ISSET(d, s) \
((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)

baseline bum
04-28-2013, 01:30 PM
/* Copyright (C) 1995, 1996, 1997, 1998
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
#endif

#include <sys/types.h>

/* Flags for `semop'. */
#define SEM_UNDO 0x1000 /* undo the operation on exit */

/* Commands for `semctl'. */
#define GETPID 11 /* get sempid */
#define GETVAL 12 /* get semval */
#define GETALL 13 /* get all semval's */
#define GETNCNT 14 /* get semncnt */
#define GETZCNT 15 /* get semzcnt */
#define SETVAL 16 /* set semval */
#define SETALL 17 /* set all semval's */


/* Data structure describing a set of semaphores. */
struct semid_ds
{
struct ipc_perm sem_perm; /* operation permission struct */
__time_t sem_otime; /* last semop() time */
__time_t sem_ctime; /* last time changed by semctl() */
unsigned short int sem_nsems; /* number of semaphores in set */
};

/* The user should define a union like the following to use it for arguments
for `semctl'.

union semun
{
int val; <= value for SETVAL
struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
unsigned short int *array; <= array for GETALL & SETALL
struct seminfo *__buf; <= buffer for IPC_INFO
};

Previous versions of this file used to define this union but this is
incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
one must define the union or not. */
#define _SEM_SEMUN_UNDEFINED 1

baseline bum
04-28-2013, 01:30 PM
/* Define the machine-dependent type `jmp_buf'. Stub version. */

#ifndef _SETJMP_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif

typedef int __jmp_buf[1];

baseline bum
04-28-2013, 01:30 PM
/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
#endif

#include <bits/types.h>

/* Flags for `shmat'. */
#define SHM_RDONLY 010000 /* attach read-only else read-write */
#define SHM_RND 020000 /* round attach address to SHMLBA */
#define SHM_REMAP 040000 /* take-over region on attach */

/* Commands for `shmctl'. */
#define SHM_LOCK 11 /* lock segment (root only) */
#define SHM_UNLOCK 12 /* unlock segment (root only) */

__BEGIN_DECLS

/* Segment low boundary address multiple. */
#define SHMLBA (__getpagesize ())
extern int __getpagesize (void) __THROW __attribute__ ((__const__));


/* Type to count number of attaches. */
typedef unsigned short int shmatt_t;

/* Data structure describing a shared memory segment. */
struct shmid_ds
{
struct ipc_perm shm_perm; /* operation permission struct */
int shm_segsz; /* size of segment in bytes */
__time_t shm_atime; /* time of last shmat() */
__time_t shm_dtime; /* time of last shmdt() */
__time_t shm_ctime; /* time of last change by shmctl() */
__pid_t shm_cpid; /* pid of creator */
__pid_t shm_lpid; /* pid of last shmop */
shmatt_t shm_nattch; /* number of current attaches */
};

__END_DECLS

baseline bum
04-28-2013, 01:30 PM
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif

/* These definitions match those used by the 4.4 BSD kernel.
If the operating system has a `sigaction' system call that correctly
implements the POSIX.1 behavior, there should be a system-dependent
version of this file that defines `struct sigaction' and the `SA_*'
constants appropriately. */

/* Structure describing the action to be taken when a signal arrives. */
struct sigaction
{
/* Signal handler. */
#ifdef __USE_POSIX199309
union
{
/* Used if SA_SIGINFO is not set. */
__sighandler_t sa_handler;
/* Used if SA_SIGINFO is set. */
void (*sa_sigaction) (int, siginfo_t *, void *);
}
__sigaction_handler;
# define sa_handler __sigaction_handler.sa_handler
# define sa_sigaction __sigaction_handler.sa_sigaction
#else
__sighandler_t sa_handler;
#endif

/* Additional set of signals to be blocked. */
__sigset_t sa_mask;

/* Special flags. */
int sa_flags;
};

/* Bits in `sa_flags'. */
#if defined __USE_UNIX98 || defined __USE_MISC
# define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
#endif
#if defined __USE_UNIX98 || defined __USE_MISC || defined __USE_XOPEN2K8
# define SA_RESTART 0x0002 /* Restart syscall on signal return. */
# define SA_NODEFER 0x0010 /* Don't automatically block the signal when
its handler is being executed. */
# define SA_RESETHAND 0x0004 /* Reset to SIG_DFL on entry to handler. */
#endif
#define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */

#ifdef __USE_MISC
# define SA_INTERRUPT 0 /* Historical no-op ("not SA_RESTART"). */

/* Some aliases for the SA_ constants. */
# define SA_NOMASK SA_NODEFER
# define SA_ONESHOT SA_RESETHAND
# define SA_STACK SA_ONSTACK
#endif


/* Values for the HOW argument to `sigprocmask'. */
#define SIG_BLOCK 1 /* Block signals. */
#define SIG_UNBLOCK 2 /* Unblock signals. */
#define SIG_SETMASK 3 /* Set the set of blocked signals. */

baseline bum
04-28-2013, 01:30 PM
/* Structure describing state saved while handling a signal. Stub version.
Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SIGNAL_H
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
#endif

/* State of this thread when the signal was taken. */
struct sigcontext
{
int sc_onstack;
__sigset_t sc_mask;

/* Registers and such. */
};

/* Signal subcodes should be defined here. */

baseline bum
04-28-2013, 01:30 PM
/* siginfo_t, sigevent and constants. Stub version.
Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
# error "Never include this file directly. Use <signal.h> instead"
#endif

#if (!defined __have_sigval_t \
&& (defined _SIGNAL_H || defined __need_siginfo_t \
|| defined __need_sigevent_t))
# define __have_sigval_t 1

/* Type for data associated with a signal. */
typedef union sigval
{
int sival_int;
void *sival_ptr;
} sigval_t;
#endif

#if (!defined __have_siginfo_t \
&& (defined _SIGNAL_H || defined __need_siginfo_t))
# define __have_siginfo_t 1

typedef struct siginfo
{
int si_signo; /* Signal number. */
int si_errno; /* If non-zero, an errno value associated with
this signal, as defined in <errno.h>. */
int si_code; /* Signal code. */
__pid_t si_pid; /* Sending process ID. */
__uid_t si_uid; /* Real user ID of sending process. */
void *si_addr; /* Address of faulting instruction. */
int si_status; /* Exit value or signal. */
long int si_band; /* Band event for SIGPOLL. */
union sigval si_value; /* Signal value. */
} siginfo_t;


/* Values for `si_code'. Positive values are reserved for kernel-generated
signals. */
enum
{
SI_ASYNCIO = -4, /* Sent by AIO completion. */
# define SI_ASYNCIO SI_ASYNCIO
SI_MESGQ, /* Sent by real time mesq state change. */
# define SI_MESGQ SI_MESGQ
SI_TIMER, /* Sent by timer expiration. */
# define SI_TIMER SI_TIMER
SI_QUEUE, /* Sent by sigqueue. */
# define SI_QUEUE SI_QUEUE
SI_USER /* Sent by kill, sigsend, raise. */
# define SI_USER SI_USER
};


/* `si_code' values for SIGILL signal. */
enum
{
ILL_ILLOPC = 1, /* Illegal opcode. */
# define ILL_ILLOPC ILL_ILLOPC
ILL_ILLOPN, /* Illegal operand. */
# define ILL_ILLOPN ILL_ILLOPN
ILL_ILLADR, /* Illegal addressing mode. */
# define ILL_ILLADR ILL_ILLADR
ILL_ILLTRP, /* Illegal trap. */
# define ILL_ILLTRP ILL_ILLTRP
ILL_PRVOPC, /* Privileged opcode. */
# define ILL_PRVOPC ILL_PRVOPC
ILL_PRVREG, /* Privileged register. */
# define ILL_PRVREG ILL_PRVREG
ILL_COPROC, /* Coprocessor error. */
# define ILL_COPROC ILL_COPROC
ILL_BADSTK /* Internal stack error. */
# define ILL_BADSTK ILL_BADSTK
};

/* `si_code' values for SIGFPE signal. */
enum
{
FPE_INTDIV = 1, /* Integer divide by zero. */
# define FPE_INTDIV FPE_INTDIV
FPE_INTOVF, /* Integer overflow. */
# define FPE_INTOVF FPE_INTOVF
FPE_FLTDIV, /* Floating point divide by zero. */
# define FPE_FLTDIV FPE_FLTDIV
FPE_FLTOVF, /* Floating point overflow. */
# define FPE_FLTOVF FPE_FLTOVF
FPE_FLTUND, /* Floating point underflow. */
# define FPE_FLTUND FPE_FLTUND
FPE_FLTRES, /* Floating point inexact result. */
# define FPE_FLTRES FPE_FLTRES
FPE_FLTINV, /* Floating point invalid operation. */
# define FPE_FLTINV FPE_FLTINV
FPE_FLTSUB /* Subscript out of range. */
# define FPE_FLTSUB FPE_FLTSUB
};

/* `si_code' values for SIGSEGV signal. */
enum
{
SEGV_MAPERR = 1, /* Address not mapped to object. */
# define SEGV_MAPERR SEGV_MAPERR
SEGV_ACCERR /* Invalid permissions for mapped object. */
# define SEGV_ACCERR SEGV_ACCERR
};

/* `si_code' values for SIGBUS signal. */
enum
{
BUS_ADRALN = 1, /* Invalid address alignment. */
# define BUS_ADRALN BUS_ADRALN
BUS_ADRERR, /* Non-existant physical address. */
# define BUS_ADRERR BUS_ADRERR
BUS_OBJERR /* Object specific hardware error. */
# define BUS_OBJERR BUS_OBJERR
};

/* `si_code' values for SIGTRAP signal. */
enum
{
TRAP_BRKPT = 1, /* Process breakpoint. */
# define TRAP_BRKPT TRAP_BRKPT
TRAP_TRACE /* Process trace trap. */
# define TRAP_TRACE TRAP_TRACE
};

/* `si_code' values for SIGCHLD signal. */
enum
{
CLD_EXITED = 1, /* Child has exited. */
# define CLD_EXITED CLD_EXITED
CLD_KILLED, /* Child was killed. */
# define CLD_KILLED CLD_KILLED
CLD_DUMPED, /* Child terminated abnormally. */
# define CLD_DUMPED CLD_DUMPED
CLD_TRAPPED, /* Traced child has trapped. */
# define CLD_TRAPPED CLD_TRAPPED
CLD_STOPPED, /* Child has stopped. */
# define CLD_STOPPED CLD_STOPPED
CLD_CONTINUED /* Stopped child has continued. */
# define CLD_CONTINUED CLD_CONTINUED
};

/* `si_code' values for SIGPOLL signal. */
enum
{
POLL_IN = 1, /* Data input available. */
# define POLL_IN POLL_IN
POLL_OUT, /* Output buffers available. */
# define POLL_OUT POLL_OUT
POLL_MSG, /* Input message available. */
# define POLL_MSG POLL_MSG
POLL_ERR, /* I/O error. */
# define POLL_ERR POLL_ERR
POLL_PRI, /* High priority input available. */
# define POLL_PRI POLL_PRI
POLL_HUP /* Device disconnected. */
# define POLL_HUP POLL_HUP
};

# undef __need_siginfo_t
#endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */


#if (defined _SIGNAL_H || defined __need_sigevent_t) \
&& !defined __have_sigevent_t
# define __have_sigevent_t 1

/* Structure to transport application-defined values with signals. */
# define SIGEV_MAX_SIZE 64
# define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE / sizeof (int)) - 3)

typedef struct sigevent
{
sigval_t sigev_value;
int sigev_signo;
int sigev_notify;
void (*sigev_notify_function) (sigval_t); /* Function to start. */
void *sigev_notify_attributes; /* Really pthread_attr_t.*/
} sigevent_t;

/* `sigev_notify' values. */
enum
{
SIGEV_SIGNAL = 0, /* Notify via signal. */
# define SIGEV_SIGNAL SIGEV_SIGNAL
SIGEV_NONE, /* Other notification: meaningless. */
# define SIGEV_NONE SIGEV_NONE
SIGEV_THREAD /* Deliver via thread creation. */
# define SIGEV_THREAD SIGEV_THREAD
};

#endif /* have _SIGNAL_H. */

baseline bum
04-28-2013, 01:31 PM
/* Signal number constants. Generic version.
Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifdef _SIGNAL_H

/* Fake signal functions. */

#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */

#ifdef __USE_UNIX98
# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
#endif

/* We define here all the signal names listed in POSIX (1003.1-2008).
Signals in the 1-15 range are defined with their historical numbers.
For other signals specified by POSIX, we use the BSD numbers. */

/* ISO C99 signals. */
#define SIGINT 2 /* Interactive attention signal. */
#define SIGILL 4 /* Illegal instruction. */
#define SIGABRT 6 /* Abnormal termination. */
#define SIGFPE 8 /* Erroneous arithmetic operation. */
#define SIGSEGV 11 /* Invalid access to storage. */
#define SIGTERM 15 /* Termination request. */

/* Historical signals specified by POSIX. */
#define SIGHUP 1 /* Hangup. */
#define SIGQUIT 3 /* Quit. */
#define SIGTRAP 5 /* Trace/breakpoint trap. */
#define SIGKILL 9 /* Killed. */
#define SIGBUS 10 /* Bus error. */
#define SIGSYS 12 /* Bad system call. */
#define SIGPIPE 13 /* Broken pipe. */
#define SIGALRM 14 /* Alarm clock. */

/* New(er) POSIX signals (1003.1-2008). */
#define SIGURG 16 /* High bandwidth data is available at a socket. */
#define SIGSTOP 17 /* Stopped (signal). */
#define SIGTSTP 18 /* Stopped. */
#define SIGCONT 19 /* Continued. */
#define SIGCHLD 20 /* Child terminated or stopped. */
#define SIGTTIN 21 /* Background read from control terminal. */
#define SIGTTOU 22 /* Background write to control terminal. */
#define SIGPOLL 23 /* Pollable event occurred (System V). */
#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
#define SIGXCPU 24 /* CPU time limit exceeded. */
#define SIGXFSZ 25 /* File size limit exceeded. */
#define SIGVTALRM 26 /* Virtual timer expired. */
#define SIGPROF 27 /* Profiling timer expired. */
#define SIGUSR1 30 /* User-defined signal 1. */
#define SIGUSR2 31 /* User-defined signal 2. */

#define _NSIG 32

/* Archaic names for compatibility. */
#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP11 */
#define SIGCLD SIGCHLD /* Old System V name */

#endif /* <signal.h> included. */

baseline bum
04-28-2013, 01:31 PM
/* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version.
Copyright (C) 1991, 1992, 1994, 1996, 1997, 2007, 2012
Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SIGSET_H_types
#define _SIGSET_H_types 1

typedef int __sig_atomic_t;

/* A `sigset_t' has a bit for each signal. */
typedef unsigned long int __sigset_t;

#endif


/* We only want to define these functions if <signal.h> was actually
included; otherwise we were included just to define the types. Since we
are namespace-clean, it wouldn't hurt to define extra macros. But
trouble can be caused by functions being defined (e.g., any global
register vars declared later will cause compilation errors). */

#if !defined _SIGSET_H_fns && defined _SIGNAL_H
#define _SIGSET_H_fns 1

#ifndef _EXTERN_INLINE
# define _EXTERN_INLINE __extern_inline
#endif

/* Return a mask that includes SIG only. The cast to `sigset_t' avoids
overflow if `sigset_t' is wider than `int'. */
#define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1))

#define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0)
#define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0)

#ifdef _GNU_SOURCE
# define __sigisemptyset(set) (*(set) == (__sigset_t) 0)
# define __sigandset(dest, left, right) \
((*(dest) = (*(left) & *(right))), 0)
# define __sigorset(dest, left, right) \
((*(dest) = (*(left) | *(right))), 0)
#endif

/* These functions needn't check for a bogus signal number -- error
checking is done in the non __ versions. */

extern int __sigismember (const __sigset_t *, int);
extern int __sigaddset (__sigset_t *, int);
extern int __sigdelset (__sigset_t *, int);

#ifdef __USE_EXTERN_INLINES
# define __SIGSETFN(NAME, BODY, CONST) \
_EXTERN_INLINE int \
NAME (CONST __sigset_t *__set, int __sig) \
{ \
__sigset_t __mask = __sigmask (__sig); \
return BODY; \
}

__SIGSETFN (__sigismember, (*__set & __mask) ? 1 : 0, const)
__SIGSETFN (__sigaddset, ((*__set |= __mask), 0), )
__SIGSETFN (__sigdelset, ((*__set &= ~__mask), 0), )

# undef __SIGSETFN
#endif


#endif /* ! _SIGSET_H_fns. */

baseline bum
04-28-2013, 01:31 PM
/* sigstack, sigaltstack definitions.
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
#endif


/* Structure describing a signal stack (obsolete). */
struct sigstack
{
__ptr_t ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};


/* Alternate, preferred interface. */
typedef struct sigaltstack
{
__ptr_t ss_sp;
size_t ss_size;
int ss_flags;
} stack_t;


/* Possible values for `ss_flags.'. */
enum
{
SS_ONSTACK = 0x0001,
#define SS_ONSTACK SS_ONSTACK
SS_DISABLE = 0x0004
#define SS_DISABLE SS_DISABLE
};

/* Minumum stack size for a signal handler. */
#define MINSIGSTKSZ 8192

/* System default stack size. */
#define SIGSTKSZ (MINSIGSTKSZ + 32768)

baseline bum
04-28-2013, 01:31 PM
/* Signal handling function for threaded programs. Generic version.
Copyright (C) 2000, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_SIGTHREAD_H
#define _BITS_SIGTHREAD_H 1

#if !defined _SIGNAL_H && !defined _PTHREAD_H
# error "Never include this file directly. Use <pthread.h> instead"
#endif

/* Modify the signal mask for the calling thread. The arguments have the
same meaning as for sigprocmask; in fact, this and sigprocmask might be
the same function. We declare this the same on all platforms, since it
doesn't use any thread-related types. */
extern int pthread_sigmask (int __how, const __sigset_t *__newmask,
__sigset_t *__oldmask) __THROW;


#endif /* bits/sigthread.h */

baseline bum
04-28-2013, 01:31 PM
/* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version.
Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/*
* Never include this file directly; use <sys/socket.h> instead.
*/

#ifndef _BITS_SOCKADDR_H
#define _BITS_SOCKADDR_H 1


/* POSIX.1g specifies this type name for the `sa_family' member. */
typedef unsigned short int sa_family_t;

/* This macro is used to declare the initial common members
of the data types used for socket addresses, `struct sockaddr',
`struct sockaddr_in', `struct sockaddr_un', etc. */

#define __SOCKADDR_COMMON(sa_prefix) \
sa_family_t sa_prefix##family

#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))

#endif /* bits/sockaddr.h */

ChumpDumper
04-28-2013, 01:53 PM
SA210 owned by Avante.

SBM stuck in a love triangle.

SA210
04-28-2013, 02:21 PM
:madrun hey look, I'm still lying, and following SA210 around, I can NOT quit him. Why am I so angry!! I hate that he knows Obama is a terrorist! Why am I so obese?!!! :cry

Thanks for being a stalker and bumping my thread guys. Feel free to keep bumping :tu

:lol 74,610

baseline bum
04-28-2013, 02:24 PM
/* System-specific socket constants and types. Generic/4.3 BSD version.
Copyright (C) 1991,92,1994-1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef __BITS_SOCKET_H
#define __BITS_SOCKET_H 1

#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif

#include <limits.h>
#include <bits/types.h>

#define __need_size_t
#include <stddef.h>

/* Type for length arguments in socket calls. */
#ifndef __socklen_t_defined
typedef __socklen_t socklen_t;
# define __socklen_t_defined
#endif


/* Types of sockets. */
enum __socket_type
{
SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
byte streams. */
#define SOCK_STREAM SOCK_STREAM
SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
of fixed maximum length. */
#define SOCK_DGRAM SOCK_DGRAM
SOCK_RAW = 3, /* Raw protocol interface. */
#define SOCK_RAW SOCK_RAW
SOCK_RDM = 4, /* Reliably-delivered messages. */
#define SOCK_RDM SOCK_RDM
SOCK_SEQPACKET = 5 /* Sequenced, reliable, connection-based,
datagrams of fixed maximum length. */
#define SOCK_SEQPACKET SOCK_SEQPACKET
};

/* Protocol families. */
#define PF_UNSPEC 0 /* Unspecified. */
#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
#define PF_FILE PF_LOCAL /* POSIX name for PF_LOCAL. */
#define PF_INET 2 /* IP protocol family. */
#define PF_IMPLINK 3 /* ARPAnet IMP protocol. */
#define PF_PUP 4 /* PUP protocols. */
#define PF_CHAOS 5 /* MIT Chaos protocols. */
#define PF_NS 6 /* Xerox NS protocols. */
#define PF_ISO 7 /* ISO protocols. */
#define PF_OSI PF_ISO
#define PF_ECMA 8 /* ECMA protocols. */
#define PF_DATAKIT 9 /* AT&T Datakit protocols. */
#define PF_CCITT 10 /* CCITT protocols (X.25 et al). */
#define PF_SNA 11 /* IBM SNA protocol. */
#define PF_DECnet 12 /* DECnet protocols. */
#define PF_DLI 13 /* Direct data link interface. */
#define PF_LAT 14 /* DEC Local Area Transport protocol. */
#define PF_HYLINK 15 /* NSC Hyperchannel protocol. */
#define PF_APPLETALK 16 /* Don't use this. */
#define PF_ROUTE 17 /* Internal Routing Protocol. */
#define PF_LINK 18 /* Link layer interface. */
#define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */
#define PF_COIP 20 /* Connection-oriented IP, aka ST II. */
#define PF_CNT 21 /* Computer Network Technology. */
#define PF_RTIP 22 /* Help Identify RTIP packets. **/
#define PF_IPX 23 /* Novell Internet Protocol. */
#define PF_SIP 24 /* Simple Internet Protocol. */
#define PF_PIP 25 /* Help Identify PIP packets. */
#define PF_INET6 26 /* IP version 6. */
#define PF_MAX 27

/* Address families. */
#define AF_UNSPEC PF_UNSPEC
#define AF_LOCAL PF_LOCAL
#define AF_UNIX PF_UNIX
#define AF_FILE PF_FILE
#define AF_INET PF_INET
#define AF_IMPLINK PF_IMPLINK
#define AF_PUP PF_PUP
#define AF_CHAOS PF_CHAOS
#define AF_NS PF_NS
#define AF_ISO PF_ISO
#define AF_OSI PF_OSI
#define AF_ECMA PF_ECMA
#define AF_DATAKIT PF_DATAKIT
#define AF_CCITT PF_CCITT
#define AF_SNA PF_SNA
#define AF_DECnet PF_DECnet
#define AF_DLI PF_DLI
#define AF_LAT PF_LAT
#define AF_HYLINK PF_HYLINK
#define AF_APPLETALK PF_APPLETALK
#define AF_ROUTE PF_ROUTE
#define AF_LINK PF_LINK
#define pseudo_AF_XTP PF_XTP
#define AF_COIP PF_COIP
#define AF_CNT PF_CNT
#define pseudo_AF_RTIP PF_RTIP
#define AF_IPX PF_IPX
#define AF_SIP PF_SIP
#define pseudo_AF_PIP PF_PIP
#define AF_INET6 PF_INET6
#define AF_MAX PF_MAX


/* Get the definition of the macro to define the common sockaddr members. */
#include <bits/sockaddr.h>

/* Structure describing a generic socket address. */
struct sockaddr
{
__SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
char sa_data[14]; /* Address data. */
};


/* Structure large enough to hold any socket address (with the historical
exception of AF_UNIX). We reserve 128 bytes. */
#if ULONG_MAX > 0xffffffff
# define __ss_aligntype __uint64_t
#else
# define __ss_aligntype __uint32_t
#endif
#define _SS_SIZE 128
#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))

struct sockaddr_storage
{
__SOCKADDR_COMMON (ss_); /* Address family, etc. */
__ss_aligntype __ss_align; /* Force desired alignment. */
char __ss_padding[_SS_PADSIZE];
};


/* Bits in the FLAGS argument to `send', `recv', et al. */
enum
{
MSG_OOB = 0x01, /* Process out-of-band data. */
#define MSG_OOB MSG_OOB
MSG_PEEK = 0x02, /* Peek at incoming messages. */
#define MSG_PEEK MSG_PEEK
MSG_DONTROUTE = 0x04, /* Don't use local routing. */
#define MSG_DONTROUTE MSG_DONTROUTE
MSG_EOR = 0x08, /* Data completes record. */
#define MSG_EOR MSG_EOR
MSG_TRUNC = 0x10, /* Data discarded before delivery. */
#define MSG_TRUNC MSG_TRUNC
MSG_CTRUNC = 0x20, /* Control data lost before delivery. */
#define MSG_CTRUNC MSG_CTRUNC
MSG_WAITALL = 0x40, /* Wait for full request or error. */
#define MSG_WAITALL MSG_WAITALL
MSG_DONTWAIT = 0x80 /* This message should be nonblocking. */
#define MSG_DONTWAIT MSG_DONTWAIT
};


/* Structure describing messages sent by
`sendmsg' and received by `recvmsg'. */
struct msghdr
{
__ptr_t msg_name; /* Address to send to/receive from. */
socklen_t msg_namelen; /* Length of address data. */

struct iovec *msg_iov; /* Vector of data to send/receive into. */
int msg_iovlen; /* Number of elements in the vector. */

__ptr_t msg_accrights; /* Access rights information. */
socklen_t msg_accrightslen; /* Length of access rights information. */

int msg_flags; /* Flags in received message. */
};


/* Protocol number used to manipulate socket-level options
with `getsockopt' and `setsockopt'. */
#define SOL_SOCKET 0xffff

/* Socket-level options for `getsockopt' and `setsockopt'. */
enum
{
SO_DEBUG = 0x0001, /* Record debugging information. */
#define SO_DEBUG SO_DEBUG
SO_ACCEPTCONN = 0x0002, /* Accept connections on socket. */
#define SO_ACCEPTCONN SO_ACCEPTCONN
SO_REUSEADDR = 0x0004, /* Allow reuse of local addresses. */
#define SO_REUSEADDR SO_REUSEADDR
SO_KEEPALIVE = 0x0008, /* Keep connections alive and send
SIGPIPE when they die. */
#define SO_KEEPALIVE SO_KEEPALIVE
SO_DONTROUTE = 0x0010, /* Don't do local routing. */
#define SO_DONTROUTE SO_DONTROUTE
SO_BROADCAST = 0x0020, /* Allow transmission of
broadcast messages. */
#define SO_BROADCAST SO_BROADCAST
SO_USELOOPBACK = 0x0040, /* Use the software loopback to avoid
hardware use when possible. */
#define SO_USELOOPBACK SO_USELOOPBACK
SO_LINGER = 0x0080, /* Block on close of a reliable
socket to transmit pending data. */
#define SO_LINGER SO_LINGER
SO_OOBINLINE = 0x0100, /* Receive out-of-band data in-band. */
#define SO_OOBINLINE SO_OOBINLINE
SO_REUSEPORT = 0x0200, /* Allow local address and port reuse. */
#define SO_REUSEPORT SO_REUSEPORT
SO_SNDBUF = 0x1001, /* Send buffer size. */
#define SO_SNDBUF SO_SNDBUF
SO_RCVBUF = 0x1002, /* Receive buffer. */
#define SO_RCVBUF SO_RCVBUF
SO_SNDLOWAT = 0x1003, /* Send low-water mark. */
#define SO_SNDLOWAT SO_SNDLOWAT
SO_RCVLOWAT = 0x1004, /* Receive low-water mark. */
#define SO_RCVLOWAT SO_RCVLOWAT
SO_SNDTIMEO = 0x1005, /* Send timeout. */
#define SO_SNDTIMEO SO_SNDTIMEO
SO_RCVTIMEO = 0x1006, /* Receive timeout. */
#define SO_RCVTIMEO SO_RCVTIMEO
SO_ERROR = 0x1007, /* Get and clear error status. */
#define SO_ERROR SO_ERROR
SO_STYLE = 0x1008, /* Get socket connection style. */
#define SO_STYLE SO_STYLE
SO_TYPE = SO_STYLE /* Compatible name for SO_STYLE. */
#define SO_TYPE SO_TYPE
};

/* Structure used to manipulate the SO_LINGER option. */
struct linger
{
int l_onoff; /* Nonzero to linger on close. */
int l_linger; /* Time to linger. */
};

#endif /* bits/socket.h */

baseline bum
04-28-2013, 02:24 PM
/* Copyright (C) 1992-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _SYS_STAT_H && !defined _FCNTL_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
#endif

#ifndef _BITS_STAT_H
#define _BITS_STAT_H 1

/* This structure needs to be defined in accordance with the
implementation of __stat, __fstat, and __lstat. */

#include <bits/types.h>

/* Structure describing file characteristics. */
struct stat
{
/* These are the members that POSIX.1 requires. */

__mode_t st_mode; /* File mode. */
#ifndef __USE_FILE_OFFSET64
__ino_t st_ino; /* File serial number. */
#else
__ino64_t st_ino; /* File serial number. */
#endif
__dev_t st_dev; /* Device containing the file. */
__nlink_t st_nlink; /* Link count. */

__uid_t st_uid; /* User ID of the file's owner. */
__gid_t st_gid; /* Group ID of the file's group. */
#ifndef __USE_FILE_OFFSET64
__off_t st_size; /* Size of file, in bytes. */
#else
__off64_t st_size; /* Size of file, in bytes. */
#endif

__time_t st_atime; /* Time of last access. */
__time_t st_mtime; /* Time of last modification. */
__time_t st_ctime; /* Time of last status change. */

/* This should be defined if there is a `st_blksize' member. */
#undef _STATBUF_ST_BLKSIZE
};

/* Encoding of the file mode. These are the standard Unix values,
but POSIX.1 does not specify what values should be used. */

#define __S_IFMT 0170000 /* These bits determine file type. */

/* File types. */
#define __S_IFDIR 0040000 /* Directory. */
#define __S_IFCHR 0020000 /* Character device. */
#define __S_IFBLK 0060000 /* Block device. */
#define __S_IFREG 0100000 /* Regular file. */
#define __S_IFIFO 0010000 /* FIFO. */

/* POSIX.1b objects. */
#define __S_TYPEISMQ(buf) 0
#define __S_TYPEISSEM(buf) 0
#define __S_TYPEISSHM(buf) 0

/* Protection bits. */

#define __S_ISUID 04000 /* Set user ID on execution. */
#define __S_ISGID 02000 /* Set group ID on execution. */
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */

#ifdef __USE_LARGEFILE64
struct stat64
{
__mode_t st_mode; /* File mode. */
__ino64_t st_ino; /* File serial number. */
__dev_t st_dev; /* Device. */
__nlink_t st_nlink; /* Link count. */

__uid_t st_uid; /* User ID of the file's owner. */
__gid_t st_gid; /* Group ID of the file's group.*/
__off64_t st_size; /* Size of file, in bytes. */

__time_t st_atime; /* Time of last access. */
__time_t st_mtime; /* Time of last modification. */
__time_t st_ctime; /* Time of last status change. */
};
#endif

#endif /* bits/stat.h */

baseline bum
04-28-2013, 02:25 PM
/* Definition of `struct statfs', information about a filesystem.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_STATFS_H
# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
#endif

#include <bits/types.h>

/* GNU Hurd NOTE: The size of this structure (16 ints) is known in
<hurd/hurd_types.defs>, since it is used in the `file_statfs' RPC. MiG
does not cope at all well with the passed C structure not being of the
expected size. There are some filler words at the end to allow for
future expansion. To increase the size of the structure used in the RPC
and retain binary compatibility, we would need to assign a new message
number. */

struct statfs
{
unsigned int f_type;
unsigned int f_bsize;
#ifndef __USE_FILE_OFFSET64
__fsblkcnt_t f_blocks;
__fsblkcnt_t f_bfree;
__fsblkcnt_t f_bavail;
__fsblkcnt_t f_files;
__fsblkcnt_t f_ffree;
#else
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsblkcnt64_t f_files;
__fsblkcnt64_t f_ffree;
#endif
__fsid_t f_fsid;
unsigned int f_namelen;
unsigned int f_spare[6];
};

#ifdef __USE_LARGEFILE64
struct statfs64
{
unsigned int f_type;
unsigned int f_bsize;
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsblkcnt64_t f_files;
__fsblkcnt64_t f_ffree;
__fsid_t f_fsid;
unsigned int f_namelen;
unsigned int f_spare[6];
};
#endif

baseline bum
04-28-2013, 02:25 PM
/* Definition of `struct statvfs', information about a filesystem.
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_STATVFS_H
# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
#endif

#include <bits/types.h>

/* GNU Hurd NOTE: The size of this structure (16 ints) is known in
<hurd/hurd_types.defs>, since it is used in the `file_statfs' RPC. MiG
does not cope at all well with the passed C structure not being of the
expected size. There are some filler words at the end to allow for
future expansion. To increase the size of the structure used in the RPC
and retain binary compatibility, we would need to assign a new message
number. */

struct statvfs
{
unsigned long int f_bsize;
unsigned long int f_frsize;
#ifndef __USE_FILE_OFFSET64
__fsblkcnt_t f_blocks;
__fsblkcnt_t f_bfree;
__fsblkcnt_t f_bavail;
__fsfilcnt_t f_files;
__fsfilcnt_t f_ffree;
__fsfilcnt_t f_favail;
#else
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsfilcnt64_t f_files;
__fsfilcnt64_t f_ffree;
__fsfilcnt64_t f_favail;
#endif
__fsid_t f_fsid;
unsigned long int f_flag;
unsigned long int f_namemax;
unsigned int f_spare[6];
};

#ifdef __USE_LARGEFILE64
struct statvfs64
{
unsigned long int f_bsize;
unsigned long int f_frsize;
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsfilcnt64_t f_files;
__fsfilcnt64_t f_ffree;
__fsfilcnt64_t f_favail;
__fsid_t f_fsid;
unsigned long int f_flag;
unsigned long int f_namemax;
unsigned int f_spare[6];
};
#endif

/* Definitions for the flag in `f_flag'. */
enum
{
ST_RDONLY = 1,
#define ST_RDONLY ST_RDONLY
ST_NOSUID = 2
#define ST_NOSUID ST_NOSUID
};

baseline bum
04-28-2013, 02:25 PM
/* Thread package specific definitions of stream lock type. Generic version.
Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_STDIO_LOCK_H
#define _BITS_STDIO_LOCK_H 1

#include <bits/libc-lock.h>

__libc_lock_define_recursive (typedef, _IO_lock_t)

/* We need recursive (counting) mutexes. */
#ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
# define _IO_lock_initializer _LIBC_LOCK_RECURSIVE_INITIALIZER
#elif _IO_MTSAFE_IO
#error libio needs recursive mutexes for _IO_MTSAFE_IO
#endif

#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
#define _IO_lock_trylock(_name) __libc_lock_trylock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)


#define _IO_cleanup_region_start(_fct, _fp) \
__libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp)
#define _IO_cleanup_region_start_noarg(_fct) \
__libc_cleanup_region_start (1, _fct, NULL)
#define _IO_cleanup_region_end(_doit) \
__libc_cleanup_region_end (_doit)

#if defined _LIBC && !defined NOT_IN_libc
# define _IO_acquire_lock(_fp) \
_IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, (_fp)); \
_IO_flockfile (_fp)

# define _IO_release_lock(_fp) \
_IO_funlockfile (_fp); \
_IO_cleanup_region_end (0)
#endif

#endif /* bits/stdio-lock.h */

baseline bum
04-28-2013, 02:25 PM
/* This file should provide inline versions of string functions.

Surround GCC-specific parts with #ifdef __GNUC__, and use `__extern_inline'.

This file should define __STRING_INLINES if functions are actually defined
as inlines. */

#ifndef _BITS_STRING_H
#define _BITS_STRING_H 1


#endif /* bits/string.h */

baseline bum
04-28-2013, 02:25 PM
/* Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _STROPTS_H
# error "Never include <bits/stropts.h> directly; use <stropts.h> instead."
#endif

#ifndef _BITS_STROPTS_H
#define _BITS_STROPTS_H 1

#include <bits/types.h>

/* Macros used as `request' argument to `ioctl'. */
#define __SID ('S' << 8)

#define I_NREAD (__SID | 1) /* Counts the number of data bytes in the data
block in the first message. */
#define I_PUSH (__SID | 2) /* Push STREAMS module onto top of the current
STREAM, just below the STREAM head. */
#define I_POP (__SID | 3) /* Remove STREAMS module from just below the
STREAM head. */
#define I_LOOK (__SID | 4) /* Retrieve the name of the module just below
the STREAM head and place it in a character
string. */
#define I_FLUSH (__SID | 5) /* Flush all input and/or output. */
#define I_SRDOPT (__SID | 6) /* Sets the read mode. */
#define I_GRDOPT (__SID | 7) /* Returns the current read mode setting. */
#define I_STR (__SID | 8) /* Construct an internal STREAMS `ioctl'
message and send that message downstream. */
#define I_SETSIG (__SID | 9) /* Inform the STREAM head that the process
wants the SIGPOLL signal issued. */
#define I_GETSIG (__SID |10) /* Return the events for which the calling
process is currently registered to be sent
a SIGPOLL signal. */
#define I_FIND (__SID |11) /* Compares the names of all modules currently
present in the STREAM to the name pointed to
by `arg'. */
#define I_LINK (__SID |12) /* Connect two STREAMs. */
#define I_UNLINK (__SID |13) /* Disconnects the two STREAMs. */
#define I_PEEK (__SID |15) /* Allows a process to retrieve the information
in the first message on the STREAM head read
queue without taking the message off the
queue. */
#define I_FDINSERT (__SID |16) /* Create a message from the specified
buffer(s), adds information about another
STREAM, and send the message downstream. */
#define I_SENDFD (__SID |17) /* Requests the STREAM associated with `fildes'
to send a message, containing a file
pointer, to the STREAM head at the other end
of a STREAMS pipe. */
#define I_RECVFD (__SID |14) /* Non-EFT definition. */
#define I_SWROPT (__SID |19) /* Set the write mode. */
#define I_GWROPT (__SID |20) /* Return the current write mode setting. */
#define I_LIST (__SID |21) /* List all the module names on the STREAM, up
to and including the topmost driver name. */
#define I_PLINK (__SID |22) /* Connect two STREAMs with a persistent
link. */
#define I_PUNLINK (__SID |23) /* Disconnect the two STREAMs that were
connected with a persistent link. */
#define I_FLUSHBAND (__SID |28) /* Flush only band specified. */
#define I_CKBAND (__SID |29) /* Check if the message of a given priority
band exists on the STREAM head read
queue. */
#define I_GETBAND (__SID |30) /* Return the priority band of the first
message on the STREAM head read queue. */
#define I_ATMARK (__SID |31) /* See if the current message on the STREAM
head read queue is "marked" by some module
downstream. */
#define I_SETCLTIME (__SID |32) /* Set the time the STREAM head will delay when
a STREAM is closing and there is data on
the write queues. */
#define I_GETCLTIME (__SID |33) /* Get current value for closing timeout. */
#define I_CANPUT (__SID |34) /* Check if a certain band is writable. */


/* Used in `I_LOOK' request. */
#define FMNAMESZ 8 /* compatibility w/UnixWare/Solaris. */

/* Flush options. */
#define FLUSHR 0x01 /* Flush read queues. */
#define FLUSHW 0x02 /* Flush write queues. */
#define FLUSHRW 0x03 /* Flush read and write queues. */
#ifdef __USE_GNU
# define FLUSHBAND 0x04 /* Flush only specified band. */
#endif

/* Possible arguments for `I_SETSIG'. */
#define S_INPUT 0x0001 /* A message, other than a high-priority
message, has arrived. */
#define S_HIPRI 0x0002 /* A high-priority message is present. */
#define S_OUTPUT 0x0004 /* The write queue for normal data is no longer
full. */
#define S_MSG 0x0008 /* A STREAMS signal message that contains the
SIGPOLL signal reaches the front of the
STREAM head read queue. */
#define S_ERROR 0x0010 /* Notification of an error condition. */
#define S_HANGUP 0x0020 /* Notification of a hangup. */
#define S_RDNORM 0x0040 /* A normal message has arrived. */
#define S_WRNORM S_OUTPUT
#define S_RDBAND 0x0080 /* A message with a non-zero priority has
arrived. */
#define S_WRBAND 0x0100 /* The write queue for a non-zero priority
band is no longer full. */
#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND,
SIGURG is generated instead of SIGPOLL when
a priority message reaches the front of the
STREAM head read queue. */

/* Option for `I_PEEK'. */
#define RS_HIPRI 0x01 /* Only look for high-priority messages. */

/* Options for `I_SRDOPT'. */
#define RNORM 0x0000 /* Byte-STREAM mode, the default. */
#define RMSGD 0x0001 /* Message-discard mode. */
#define RMSGN 0x0002 /* Message-nondiscard mode. */
#define RPROTDAT 0x0004 /* Deliver the control part of a message as
data. */
#define RPROTDIS 0x0008 /* Discard the control part of a message,
delivering any data part. */
#define RPROTNORM 0x0010 /* Fail `read' with EBADMSG if a message
containing a control part is at the front
of the STREAM head read queue. */
#ifdef __USE_GNU
# define RPROTMASK 0x001C /* The RPROT bits */
#endif

/* Possible mode for `I_SWROPT'. */
#define SNDZERO 0x001 /* Send a zero-length message downstream when a
`write' of 0 bytes occurs. */
#ifdef __USE_GNU
# define SNDPIPE 0x002 /* Send SIGPIPE on write and putmsg if
sd_werror is set. */
#endif

/* Arguments for `I_ATMARK'. */
#define ANYMARK 0x01 /* Check if the message is marked. */
#define LASTMARK 0x02 /* Check if the message is the last one marked
on the queue. */

/* Argument for `I_UNLINK'. */
#ifdef __USE_GNU
# define MUXID_ALL (-1) /* Unlink all STREAMs linked to the STREAM
associated with `fildes'. */
#endif


/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */
#define MSG_HIPRI 0x01 /* Send/receive high priority message. */
#define MSG_ANY 0x02 /* Receive any message. */
#define MSG_BAND 0x04 /* Receive message from specified band. */

/* Values returned by getmsg and getpmsg */
#define MORECTL 1 /* More control information is left in
message. */
#define MOREDATA 2 /* More data is left in message. */


/* Structure used for the I_FLUSHBAND ioctl on streams. */
struct bandinfo
{
unsigned char bi_pri;
int bi_flag;
};

struct strbuf
{
int maxlen; /* Maximum buffer length. */
int len; /* Length of data. */
char *buf; /* Pointer to buffer. */
};

struct strpeek
{
struct strbuf ctlbuf;
struct strbuf databuf;
t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
};

struct strfdinsert
{
struct strbuf ctlbuf;
struct strbuf databuf;
t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
int fildes;
int offset;
};

struct strioctl
{
int ic_cmd;
int ic_timout;
int ic_len;
char *ic_dp;
};

struct strrecvfd
{
int fd;
uid_t uid;
gid_t gid;
char __fill[8]; /* UnixWare/Solaris compatibility */
};


struct str_mlist
{
char l_name[FMNAMESZ + 1];
};

struct str_list
{
int sl_nmods;
struct str_mlist *sl_modlist;
};

#endif /* bits/stropts.h */

baseline bum
04-28-2013, 02:25 PM
/* Declare sys_errlist and sys_nerr, or don't. Don't version.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _STDIO_H
# error "Never include <bits/sys_errlist.h> directly; use <stdio.h> instead."
#endif

/* sys_errlist and sys_nerr are deprecated. Use strerror instead. */

baseline bum
04-28-2013, 02:26 PM
/* <bits/syslog-path.h> -- _PATH_LOG definition
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_SYSLOG_H
# error "Never include this file directly. Use <sys/syslog.h> instead"
#endif

#ifndef _BITS_SYSLOG_PATH_H
#define _BITS_SYSLOG_PATH_H 1

#define _PATH_LOG "/dev/log"

#endif /* bits/syslog-path.h */

baseline bum
04-28-2013, 02:26 PM
/* termios type and macro definitions. 4.4 BSD/generic GNU version.
Copyright (C) 1993,94,96,97,99,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
#endif

/* These macros are also defined in some <bits/ioctls.h> files (with
numerically identical values), but this serves to shut up cpp's
complaining. */
#if defined __USE_MISC || defined __USE_XOPEN

# ifdef NL0
# undef NL0
# endif
# ifdef NL1
# undef NL1
# endif
# ifdef TAB0
# undef TAB0
# endif
# ifdef TAB1
# undef TAB1
# endif
# ifdef TAB2
# undef TAB2
# endif
# ifdef CR0
# undef CR0
# endif
# ifdef CR1
# undef CR1
# endif
# ifdef CR2
# undef CR2
# endif
# ifdef CR3
# undef CR3
# endif
# ifdef FF0
# undef FF0
# endif
# ifdef FF1
# undef FF1
# endif
# ifdef BS0
# undef BS0
# endif
# ifdef BS1
# undef BS1
# endif

#endif /* __USE_MISC || __USE_XOPEN */

#ifdef __USE_BSD

# ifdef MDMBUF
# undef MDMBUF
# endif
# ifdef FLUSHO
# undef FLUSHO
# endif
# ifdef PENDIN
# undef PENDIN
# endif

#endif /* __USE_BSD */

#ifdef ECHO
# undef ECHO
#endif
#ifdef TOSTOP
# undef TOSTOP
#endif
#ifdef NOFLSH
# undef NOFLSH
#endif


/* These definitions match those used by the 4.4 BSD kernel.
If the operating system has termios system calls or ioctls that
correctly implement the POSIX.1 behavior, there should be a
system-dependent version of this file that defines `struct termios',
`tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately. */

/* Type of terminal control flag masks. */
typedef unsigned long int tcflag_t;

/* Type of control characters. */
typedef unsigned char cc_t;

/* Type of baud rate specifiers. */
typedef long int speed_t;

/* Terminal control structure. */
struct termios
{
/* Input modes. */
tcflag_t c_iflag;
#define IGNBRK (1 << 0) /* Ignore break condition. */
#define BRKINT (1 << 1) /* Signal interrupt on break. */
#define IGNPAR (1 << 2) /* Ignore characters with parity errors. */
#define PARMRK (1 << 3) /* Mark parity and framing errors. */
#define INPCK (1 << 4) /* Enable input parity check. */
#define ISTRIP (1 << 5) /* Strip 8th bit off characters. */
#define INLCR (1 << 6) /* Map NL to CR on input. */
#define IGNCR (1 << 7) /* Ignore CR. */
#define ICRNL (1 << 8) /* Map CR to NL on input. */
#define IXON (1 << 9) /* Enable start/stop output control. */
#define IXOFF (1 << 10) /* Enable start/stop input control. */
#if defined __USE_BSD || defined __USE_UNIX98
# define IXANY (1 << 11) /* Any character will restart after stop. */
#endif
#ifdef __USE_BSD
# define IMAXBEL (1 << 13) /* Ring bell when input queue is full. */
#endif
#ifdef __USE_GNU
# define IUCLC (1 << 14) /* Translate upper case input to lower case. */
#endif

/* Output modes. */
tcflag_t c_oflag;
#define OPOST (1 << 0) /* Perform output processing. */
#if defined __USE_BSD || defined __USE_XOPEN
# define ONLCR (1 << 1) /* Map NL to CR-NL on output. */
#endif
#ifdef __USE_BSD
# define OXTABS TAB3 /* Expand tabs to spaces. */
# define ONOEOT (1 << 3) /* Discard EOT (^D) on output. */
#endif
#if defined __USE_BSD || defined __USE_XOPEN
# define OCRNL (1 << 4) /* Map CR to NL. */
# define ONOCR (1 << 5) /* Discard CR's when on column 0. */
# define ONLRET (1 << 6) /* Move to column 0 on NL. */
#endif
#if defined __USE_MISC || defined __USE_XOPEN
# define NLDLY (3 << 8) /* NL delay. */
# define NL0 (0 << 8) /* NL type 0. */
# define NL1 (1 << 8) /* NL type 1. */
# define TABDLY (3 << 10) /* TAB delay. */
# define TAB0 (0 << 10) /* TAB delay type 0. */
# define TAB1 (1 << 10) /* TAB delay type 1. */
# define TAB2 (2 << 10) /* TAB delay type 2. */
# define TAB3 (1 << 2) /* Expand tabs to spaces. */
# define CRDLY (3 << 12) /* CR delay. */
# define CR0 (0 << 12) /* CR delay type 0. */
# define CR1 (1 << 12) /* CR delay type 1. */
# define CR2 (2 << 12) /* CR delay type 2. */
# define CR3 (3 << 12) /* CR delay type 3. */
# define FFDLY (1 << 14) /* FF delay. */
# define FF0 (0 << 14) /* FF delay type 0. */
# define FF1 (1 << 14) /* FF delay type 1. */
# define BSDLY (1 << 15) /* BS delay. */
# define BS0 (0 << 15) /* BS delay type 0. */
# define BS1 (1 << 15) /* BS delay type 1. */
# define VTDLY (1 << 16) /* VT delay. */
# define VT0 (0 << 16) /* VT delay type 0. */
# define VT1 (1 << 16) /* VT delay type 1. */
#endif /* __USE_MISC || __USE_XOPEN */
#ifdef __USE_GNU
# define OLCUC (1 << 17) /* Translate lower case output to upper case */
#endif
#ifdef __USE_XOPEN
# define OFILL (1 << 18) /* Send fill characters for delays. */
#endif

/* Control modes. */
tcflag_t c_cflag;
#ifdef __USE_BSD
# define CIGNORE (1 << 0) /* Ignore these control flags. */
#endif
#define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
#define CS5 0 /* 5 bits per byte. */
#define CS6 (1 << 8) /* 6 bits per byte. */
#define CS7 (1 << 9) /* 7 bits per byte. */
#define CS8 (CS6|CS7) /* 8 bits per byte. */
#define CSTOPB (1 << 10) /* Two stop bits instead of one. */
#define CREAD (1 << 11) /* Enable receiver. */
#define PARENB (1 << 12) /* Parity enable. */
#define PARODD (1 << 13) /* Odd parity instead of even. */
#define HUPCL (1 << 14) /* Hang up on last close. */
#define CLOCAL (1 << 15) /* Ignore modem status lines. */
#ifdef __USE_BSD
# define CRTSCTS (1 << 16) /* RTS/CTS flow control. */
# define CRTS_IFLOW CRTSCTS /* Compatibility. */
# define CCTS_OFLOW CRTSCTS /* Compatibility. */
# define CDTRCTS (1 << 17) /* DTR/CTS flow control. */
# define MDMBUF (1 << 20) /* DTR/DCD flow control. */
# define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control. */
#endif

/* Local modes. */
tcflag_t c_lflag;
#ifdef __USE_BSD
# define ECHOKE (1 << 0) /* Visual erase for KILL. */
#endif
#define _ECHOE (1 << 1) /* Visual erase for ERASE. */
#define ECHOE _ECHOE
#define _ECHOK (1 << 2) /* Echo NL after KILL. */
#define ECHOK _ECHOK
#define _ECHO (1 << 3) /* Enable echo. */
#define ECHO _ECHO
#define _ECHONL (1 << 4) /* Echo NL even if ECHO is off. */
#define ECHONL _ECHONL
#ifdef __USE_BSD
# define ECHOPRT (1 << 5) /* Hardcopy visual erase. */
# define ECHOCTL (1 << 6) /* Echo control characters as ^X. */
#endif
#define _ISIG (1 << 7) /* Enable signals. */
#define ISIG _ISIG
#define _ICANON (1 << 8) /* Do erase and kill processing. */
#define ICANON _ICANON
#ifdef __USE_BSD
# define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */
#endif
#define _IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */
#define IEXTEN _IEXTEN
#define EXTPROC (1 << 11) /* External processing. */
#define _TOSTOP (1 << 22) /* Send SIGTTOU for background output. */
#define TOSTOP _TOSTOP
#ifdef __USE_BSD
# define FLUSHO (1 << 23) /* Output being flushed (state). */
# define NOKERNINFO (1 << 25) /* Disable VSTATUS. */
# define PENDIN (1 << 29) /* Retype pending input (state). */
#endif
#define _NOFLSH (1 << 31) /* Disable flush after interrupt. */
#define NOFLSH _NOFLSH

/* Control characters. */
#define VEOF 0 /* End-of-file character [ICANON]. */
#define VEOL 1 /* End-of-line character [ICANON]. */
#ifdef __USE_BSD
# define VEOL2 2 /* Second EOL character [ICANON]. */
#endif
#define VERASE 3 /* Erase character [ICANON]. */
#ifdef __USE_BSD
# define VWERASE 4 /* Word-erase character [ICANON]. */
#endif
#define VKILL 5 /* Kill-line character [ICANON]. */
#ifdef __USE_BSD
# define VREPRINT 6 /* Reprint-line character [ICANON]. */
#endif
#define VINTR 8 /* Interrupt character [ISIG]. */
#define VQUIT 9 /* Quit character [ISIG]. */
#define VSUSP 10 /* Suspend character [ISIG]. */
#ifdef __USE_BSD
# define VDSUSP 11 /* Delayed suspend character [ISIG]. */
#endif
#define VSTART 12 /* Start (X-ON) character [IXON, IXOFF]. */
#define VSTOP 13 /* Stop (X-OFF) character [IXON, IXOFF]. */
#ifdef __USE_BSD
# define VLNEXT 14 /* Literal-next character [IEXTEN]. */
# define VDISCARD 15 /* Discard character [IEXTEN]. */
#endif
#define VMIN 16 /* Minimum number of bytes read at once [!ICANON]. */
#define VTIME 17 /* Time-out value (tenths of a second) [!ICANON]. */
#ifdef __USE_BSD
# define VSTATUS 18 /* Status character [ICANON]. */
#endif
#define NCCS 20 /* Value duplicated in <hurd/tioctl.defs>. */
cc_t c_cc[NCCS];

/* Input and output baud rates. */
speed_t __ispeed, __ospeed;
#define B0 0 /* Hang up. */
#define B50 50 /* 50 baud. */
#define B75 75 /* 75 baud. */
#define B110 110 /* 110 baud. */
#define B134 134 /* 134.5 baud. */
#define B150 150 /* 150 baud. */
#define B200 200 /* 200 baud. */
#define B300 300 /* 300 baud. */
#define B600 600 /* 600 baud. */
#define B1200 1200 /* 1200 baud. */
#define B1800 1800 /* 1800 baud. */
#define B2400 2400 /* 2400 baud. */
#define B4800 4800 /* 4800 baud. */
#define B9600 9600 /* 9600 baud. */
#define B7200 7200 /* 7200 baud. */
#define B14400 14400 /* 14400 baud. */
#define B19200 19200 /* 19200 baud. */
#define B28800 28800 /* 28800 baud. */
#define B38400 38400 /* 38400 baud. */
#ifdef __USE_MISC
# define EXTA 19200
# define EXTB 38400
#endif
#define B57600 57600
#define B76800 76800
#define B115200 115200
#define B230400 230400
#define B460800 460800
#define B500000 500000
#define B576000 576000
#define B921600 921600
#define B1000000 1000000
#define B1152000 1152000
#define B1500000 1500000
#define B2000000 2000000
#define B2500000 2500000
#define B3000000 3000000
#define B3500000 3500000
#define B4000000 4000000
};

#define _IOT_termios /* Hurd ioctl type field. */ \
_IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)

/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
#define TCSANOW 0 /* Change immediately. */
#define TCSADRAIN 1 /* Change when pending output is written. */
#define TCSAFLUSH 2 /* Flush pending input before changing. */
#ifdef __USE_BSD
# define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */
#endif

/* Values for the QUEUE_SELECTOR argument to `tcflush'. */
#define TCIFLUSH 1 /* Discard data received but not yet read. */
#define TCOFLUSH 2 /* Discard data written but not yet sent. */
#define TCIOFLUSH 3 /* Discard all pending data. */

/* Values for the ACTION argument to `tcflow'. */
#define TCOOFF 1 /* Suspend output. */
#define TCOON 2 /* Restart suspended output. */
#define TCIOFF 3 /* Send a STOP character. */
#define TCION 4 /* Send a START character. */

baseline bum
04-28-2013, 02:26 PM
/* System-dependent timing definitions. Generic version.
Copyright (C) 1996,1997,1999-2002,2003,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/*
* Never include this file directly; use <time.h> instead.
*/

#ifndef __need_timeval
# ifndef _BITS_TIME_H
# define _BITS_TIME_H 1

/* ISO/IEC 9899:1990 7.12.1: <time.h>
The macro `CLOCKS_PER_SEC' is the number per second of the value
returned by the `clock' function. */
/* CAE XSH, Issue 4, Version 2: <time.h>
The value of CLOCKS_PER_SEC is required to be 1 million on all
XSI-conformant systems. */
# define CLOCKS_PER_SEC 1000000l

# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
# include <bits/types.h>
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
# endif

# ifdef __USE_POSIX199309
/* Identifier for system-wide realtime clock. */
# define CLOCK_REALTIME 0
/* Monotonic system-wide clock. */
# define CLOCK_MONOTONIC 1
/* High-resolution timer from the CPU. */
# define CLOCK_PROCESS_CPUTIME_ID 2
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 3
/* Monotonic system-wide clock, not adjusted for frequency scaling. */
# define CLOCK_MONOTONIC_RAW 4
/* Identifier for system-wide realtime clock, updated only on ticks. */
# define CLOCK_REALTIME_COARSE 5
/* Monotonic system-wide clock, updated only on ticks. */
# define CLOCK_MONOTONIC_COARSE 6

/* Flag to indicate time is absolute. */
# define TIMER_ABSTIME 1
# endif

# endif /* bits/time.h */
#endif

#ifdef __need_timeval
# undef __need_timeval
# ifndef _STRUCT_TIMEVAL
# define _STRUCT_TIMEVAL 1
# include <bits/types.h>

/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
# endif /* struct timeval */
#endif /* need timeval */

baseline bum
04-28-2013, 02:26 PM
/* bits/types.h -- definitions of __*_t types underlying *_t types.
Copyright (C) 2002-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

/*
* Never include this file directly; use <sys/types.h> instead.
*/

#ifndef _BITS_TYPES_H
#define _BITS_TYPES_H 1

#include <features.h>
#include <bits/wordsize.h>

/* Convenience types. */
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;

/* Fixed-size types, underlying types depend on word size and compiler. */
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
#if __WORDSIZE == 64
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
#elif defined __GLIBC_HAVE_LONG_LONG
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
#endif

/* quad_t is also 64 bits. */
#if __WORDSIZE == 64
typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
#elif defined __GLIBC_HAVE_LONG_LONG
__extension__ typedef long long int __quad_t;
__extension__ typedef unsigned long long int __u_quad_t;
#else
typedef struct
{
long __val[2];
} __quad_t;
typedef struct
{
__u_long __val[2];
} __u_quad_t;
#endif


/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
macros for each of the OS types we define below. The definitions
of those macros must use the following macros for underlying types.
We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
variants of each of the following integer types on this machine.

16 -- "natural" 16-bit type (always short)
32 -- "natural" 32-bit type (always int)
64 -- "natural" 64-bit type (long or long long)
LONG32 -- 32-bit type, traditionally long
QUAD -- 64-bit type, always long long
WORD -- natural type of __WORDSIZE bits (int or long)
LONGWORD -- type of __WORDSIZE bits, traditionally long

We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
conventional uses of `long' or `long long' type modifiers match the
types we define, even when a less-adorned type would be the same size.
This matters for (somewhat) portably writing printf/scanf formats for
these types, where using the appropriate l or ll format modifiers can
make the typedefs and the formats match up across all GNU platforms. If
we used `long' when it's 64 bits where `long long' is expected, then the
compiler would warn about the formats not matching the argument types,
and the programmer changing them to shut up the compiler would break the
program's portability.

Here we assume what is presently the case in all the GCC configurations
we support: long long is always 64 bits, long is always word/address size,
and int is always 32 bits. */

#define __S16_TYPE short int
#define __U16_TYPE unsigned short int
#define __S32_TYPE int
#define __U32_TYPE unsigned int
#define __SLONGWORD_TYPE long int
#define __ULONGWORD_TYPE unsigned long int
#if __WORDSIZE == 32
# define __SQUAD_TYPE __quad_t
# define __UQUAD_TYPE __u_quad_t
# define __SWORD_TYPE int
# define __UWORD_TYPE unsigned int
# define __SLONG32_TYPE long int
# define __ULONG32_TYPE unsigned long int
# define __S64_TYPE __quad_t
# define __U64_TYPE __u_quad_t
/* We want __extension__ before typedef's that use nonstandard base types
such as `long long' in C89 mode. */
# define __STD_TYPE __extension__ typedef
#elif __WORDSIZE == 64
# define __SQUAD_TYPE long int
# define __UQUAD_TYPE unsigned long int
# define __SWORD_TYPE long int
# define __UWORD_TYPE unsigned long int
# define __SLONG32_TYPE int
# define __ULONG32_TYPE unsigned int
# define __S64_TYPE long int
# define __U64_TYPE unsigned long int
/* No need to mark the typedef with __extension__. */
# define __STD_TYPE typedef
#else
# error
#endif
#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */


__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */
__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */
__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/
__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */
__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */
__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */
__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */
__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */
__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */
__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */

__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */

/* Clock ID used in clock and timer functions. */
__STD_TYPE __CLOCKID_T_TYPE __clockid_t;

/* Timer ID returned by `timer_create'. */
__STD_TYPE __TIMER_T_TYPE __timer_t;

/* Type to represent block size. */
__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;

/* Types from the Large File Support interface. */

/* Type to count number of disk blocks. */
__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;

/* Type to count file system blocks. */
__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;

/* Type to count file system nodes. */
__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;

/* Type of miscellaneous file system fields. */
__STD_TYPE __FSWORD_T_TYPE __fsword_t;

__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */

/* Signed long type used in system calls. */
__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;
/* Unsigned long type used in system calls. */
__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;

/* These few don't really vary by system, they always correspond
to one of the other defined types. */
typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;

/* Duplicates info from stdint.h but this is used in unistd.h. */
__STD_TYPE __SWORD_TYPE __intptr_t;

/* Duplicate info from sys/socket.h. */
__STD_TYPE __U32_TYPE __socklen_t;


#undef __STD_TYPE

#endif /* bits/types.h */

baseline bum
04-28-2013, 02:26 PM
/* bits/typesizes.h -- underlying types for *_t. Generic version.
Copyright (C) 2002-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_TYPES_H
# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
#endif

#ifndef _BITS_TYPESIZES_H
#define _BITS_TYPESIZES_H 1

/* See <bits/types.h> for the meaning of these macros. This file exists so
that <bits/types.h> need not vary across different GNU platforms. */

#define __DEV_T_TYPE __UQUAD_TYPE
#define __UID_T_TYPE __U32_TYPE
#define __GID_T_TYPE __U32_TYPE
#define __INO_T_TYPE __ULONGWORD_TYPE
#define __INO64_T_TYPE __UQUAD_TYPE
#define __MODE_T_TYPE __U32_TYPE
#define __NLINK_T_TYPE __UWORD_TYPE
#define __OFF_T_TYPE __SLONGWORD_TYPE
#define __OFF64_T_TYPE __SQUAD_TYPE
#define __PID_T_TYPE __S32_TYPE
#define __RLIM_T_TYPE __ULONGWORD_TYPE
#define __RLIM64_T_TYPE __UQUAD_TYPE
#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
#define __BLKCNT64_T_TYPE __SQUAD_TYPE
#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
#define __FSWORD_T_TYPE __SWORD_TYPE
#define __ID_T_TYPE __U32_TYPE
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
#define __TIME_T_TYPE __SLONGWORD_TYPE
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __S32_TYPE
#define __KEY_T_TYPE __S32_TYPE
#define __CLOCKID_T_TYPE __S32_TYPE
#define __TIMER_T_TYPE void *
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define __FSID_T_TYPE struct { int __val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE

#ifdef __LP64__
/* Tell the libc code that off_t and off64_t are actually the same type
for all ABI purposes, even if possibly expressed as different base types
for C type-checking purposes. */
# define __OFF_T_MATCHES_OFF64_T 1

/* Same for ino_t and ino64_t. */
# define __INO_T_MATCHES_INO64_T 1
#endif

/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024


#endif /* bits/typesizes.h */

baseline bum
04-28-2013, 02:26 PM
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_UIO_H
# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
#endif


/* `struct iovec' -- Structure describing a section of memory. */

struct iovec
{
/* Starting address. */
__ptr_t iov_base;
/* Length in bytes. */
size_t iov_len;
};

baseline bum
04-28-2013, 02:27 PM
/* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_USTAT_H
# error "Never include <bits/ustat.h> directly; use <sys/ustat.h> instead."
#endif

#include <sys/types.h>

struct ustat
{
__daddr_t f_tfree; /* Number of free blocks. */
__ino_t f_tinode; /* Number of free inodes. */
char f_fname[6];
char f_fpack[6];
};

baseline bum
04-28-2013, 02:27 PM
/* The `struct utmp' type, describing entries in the utmp file. Generic/BSDish
Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _UTMP_H
# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
#endif

#include <paths.h>
#include <time.h>


#define UT_NAMESIZE 8
#define UT_LINESIZE 8
#define UT_HOSTSIZE 16


struct lastlog
{
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};

struct utmp
{
char ut_line[UT_LINESIZE];
char ut_user[UT_NAMESIZE];
#define ut_name ut_user
char ut_host[UT_HOSTSIZE];
long int ut_time;
};


#define _HAVE_UT_HOST 1 /* We have the ut_host field. */

baseline bum
04-28-2013, 02:27 PM
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_UTSNAME_H
# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
#endif

/* The size of the character arrays used to hold the information
in a `struct utsname'. Enlarge this as necessary. */
#define _UTSNAME_LENGTH 1024

baseline bum
04-28-2013, 02:27 PM
/* Definitions of flag bits for `waitpid' et al.
Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _SYS_WAIT_H && !defined _STDLIB_H
# error "Never include <bits/waitflags.h> directly; use <sys/wait.h> instead."
#endif


/* Bits in the third argument to `waitpid'. */
#define WNOHANG 1 /* Don't block waiting. */
#define WUNTRACED 2 /* Report status of stopped children. */

baseline bum
04-28-2013, 02:27 PM
/* Definitions of status bits for `wait' et al.
Copyright (C) 1992,1994,1996,1997,2000,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined _SYS_WAIT_H && !defined _STDLIB_H
# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
#endif


/* Everything extant so far uses these same bits. */


/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)

/* If WIFSIGNALED(STATUS), the terminating signal. */
#define __WTERMSIG(status) ((status) & 0x7f)

/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
#define __WSTOPSIG(status) __WEXITSTATUS(status)

/* Nonzero if STATUS indicates normal termination. */
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)

/* Nonzero if STATUS indicates termination by a signal. */
#define __WIFSIGNALED(status) \
(((signed char) (((status) & 0x7f) + 1) >> 1) > 0)

/* Nonzero if STATUS indicates the child is stopped. */
#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)

/* Nonzero if STATUS indicates the child continued after a stop. We only
define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */
#ifdef WCONTINUED
# define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
#endif

/* Nonzero if STATUS indicates the child dumped core. */
#define __WCOREDUMP(status) ((status) & __WCOREFLAG)

/* Macros for constructing status values. */
#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#define __W_CONTINUED 0xffff
#define __WCOREFLAG 0x80


#ifdef __USE_BSD

# include <endian.h>

union wait
{
int w_status;
struct
{
# if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int __w_termsig:7; /* Terminating signal. */
unsigned int __w_coredump:1; /* Set if dumped core. */
unsigned int __w_retcode:8; /* Return code if exited normally. */
unsigned int:16;
# endif /* Little endian. */
# if __BYTE_ORDER == __BIG_ENDIAN
unsigned int:16;
unsigned int __w_retcode:8;
unsigned int __w_coredump:1;
unsigned int __w_termsig:7;
# endif /* Big endian. */
} __wait_terminated;
struct
{
# if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int __w_stopval:8; /* W_STOPPED if stopped. */
unsigned int __w_stopsig:8; /* Stopping signal. */
unsigned int:16;
# endif /* Little endian. */
# if __BYTE_ORDER == __BIG_ENDIAN
unsigned int:16;
unsigned int __w_stopsig:8; /* Stopping signal. */
unsigned int __w_stopval:8; /* W_STOPPED if stopped. */
# endif /* Big endian. */
} __wait_stopped;
};

# define w_termsig __wait_terminated.__w_termsig
# define w_coredump __wait_terminated.__w_coredump
# define w_retcode __wait_terminated.__w_retcode
# define w_stopsig __wait_stopped.__w_stopsig
# define w_stopval __wait_stopped.__w_stopval

#endif /* Use BSD. */

baseline bum
04-28-2013, 02:27 PM
/* wchar_t type related definitions.
Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H 1

#define __WCHAR_MIN (-2147483647 - 1)
#define __WCHAR_MAX (2147483647)

#endif /* bits/wchar.h */

baseline bum
04-28-2013, 02:27 PM
#error "This file must be written based on the data type sizes of the target"

baseline bum
04-28-2013, 02:28 PM
/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. Generic.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _STROPTS_H
# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
#endif

#ifndef _BITS_XTITYPES_H
#define _BITS_XTITYPES_H 1

#include <bits/types.h>

/* This type is used by some structs in <bits/stropts.h>. */
typedef __SLONGWORD_TYPE __t_scalar_t;
typedef __ULONGWORD_TYPE __t_uscalar_t;


#endif /* bits/xtitypes.h */

baseline bum
04-28-2013, 02:28 PM
/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <alloca.h>
#include <errno.h>
#include <locale.h>
#include <nl_types.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>

#include "catgetsinfo.h"


/* Open the catalog and return a descriptor for the catalog. */
nl_catd
catopen (const char *cat_name, int flag)
{
__nl_catd result;
const char *env_var = NULL;
const char *nlspath = NULL;

if (strchr (cat_name, '/') == NULL)
{
if (flag == NL_CAT_LOCALE)
/* Use the current locale setting for LC_MESSAGES. */
env_var = setlocale (LC_MESSAGES, NULL);
else
/* Use the LANG environment variable. */
env_var = getenv ("LANG");

if (env_var == NULL || *env_var == '\0'
|| (__libc_enable_secure && strchr (env_var, '/') != NULL))
env_var = "C";

nlspath = getenv ("NLSPATH");
if (nlspath != NULL && *nlspath != '\0')
{
/* Append the system dependent directory. */
size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
char *tmp = alloca (len);

__stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
nlspath = tmp;
}
else
nlspath = NLSPATH;
}

result = (__nl_catd) malloc (sizeof (*result));
if (result == NULL)
/* We cannot get enough memory. */
return (nl_catd) -1;

if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
{
/* Couldn't open the file. */
free ((void *) result);
return (nl_catd) -1;
}

return (nl_catd) result;
}


/* Return message from message catalog. */
char *
catgets (nl_catd catalog_desc, int set, int message, const char *string)
{
__nl_catd catalog;
size_t idx;
size_t cnt;

/* Be generous if catalog which failed to be open is used. */
if (catalog_desc == (nl_catd) -1 || ++set <= 0 || message < 0)
return (char *) string;

catalog = (__nl_catd) catalog_desc;

idx = ((set * message) % catalog->plane_size) * 3;
cnt = 0;
do
{
if (catalog->name_ptr[idx + 0] == (u_int32_t) set
&& catalog->name_ptr[idx + 1] == (u_int32_t) message)
return (char *) &catalog->strings[catalog->name_ptr[idx + 2]];

idx += catalog->plane_size * 3;
}
while (++cnt < catalog->plane_depth);

__set_errno (ENOMSG);
return (char *) string;
}


/* Return resources used for loaded message catalog. */
int
catclose (nl_catd catalog_desc)
{
__nl_catd catalog;

/* Be generous if catalog which failed to be open is used. */
if (catalog_desc == (nl_catd) -1)
{
__set_errno (EBADF);
return -1;
}

catalog = (__nl_catd) catalog_desc;

#ifdef _POSIX_MAPPED_FILES
if (catalog->status == mmapped)
__munmap ((void *) catalog->file_ptr, catalog->file_size);
else
#endif /* _POSIX_MAPPED_FILES */
if (catalog->status == malloced)
free ((void *) catalog->file_ptr);
else
{
__set_errno (EBADF);
return -1;
}

free ((void *) catalog);

return 0;
}

baseline bum
04-28-2013, 02:29 PM
/* Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <sys/types.h>


struct catalog_obj
{
u_int32_t magic;
u_int32_t plane_size;
u_int32_t plane_depth;
/* This is in fact two arrays in one: always a pair of name and
pointer into the data area. */
u_int32_t name_ptr[0];
};


/* This structure will be filled after loading the catalog. */
typedef struct catalog_info
{
enum { mmapped, malloced } status;

size_t plane_size;
size_t plane_depth;
u_int32_t *name_ptr;
const char *strings;

struct catalog_obj *file_ptr;
size_t file_size;
} *__nl_catd;



/* The magic number to signal we really have a catalog file. */
#define CATGETS_MAGIC 0x960408deU


/* Prototypes for helper functions. */
extern int __open_catalog (const char *cat_name, const char *nlspath,
const char *env_var, __nl_catd __catalog);
libc_hidden_proto (__open_catalog)

baseline bum
04-28-2013, 02:29 PM
#ifndef _CG_CONFIG_H
#define _CG_CONFIG_H

/* Use the internal textdomain used for libc messages. */
#define PACKAGE _libc_intl_domainname
#ifndef VERSION
/* Get libc version number. */
#include "../version.h"
#endif


#include_next <config.h>

#endif

baseline bum
04-28-2013, 02:29 PM
intl

baseline bum
04-28-2013, 02:30 PM
/* Copyright (C) 1996-2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <[email protected]>, 1996.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <argp.h>
#include <assert.h>
#include <ctype.h>
#include <endian.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <iconv.h>
#include <langinfo.h>
#include <locale.h>
#include <libintl.h>
#include <limits.h>
#include <nl_types.h>
#include <obstack.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>

#include "version.h"

#include "catgetsinfo.h"


#define SWAPU32(w) \
(((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))

struct message_list
{
int number;
const char *message;

const char *fname;
size_t line;
const char *symbol;

struct message_list *next;
};


struct set_list
{
int number;
int deleted;
struct message_list *messages;
int last_message;

const char *fname;
size_t line;
const char *symbol;

struct set_list *next;
};


struct catalog
{
struct set_list *all_sets;
struct set_list *current_set;
size_t total_messages;
wint_t quote_char;
int last_set;

struct obstack mem_pool;
};


/* If non-zero force creation of new file, not using existing one. */
static int force_new;

/* Name of output file. */
static const char *output_name;

/* Name of generated C header file. */
static const char *header_name;

/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;

#define OPT_NEW 1

/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
{
{ "header", 'H', N_("NAME"), 0,
N_("Create C header file NAME containing symbol definitions") },
{ "new", OPT_NEW, NULL, 0,
N_("Do not use existing catalog, force new output file") },
{ "output", 'o', N_("NAME"), 0, N_("Write output to file NAME") },
{ NULL, 0, NULL, 0, NULL }
};

/* Short description of program. */
static const char doc[] = N_("Generate message catalog.\
\vIf INPUT-FILE is -, input is read from standard input. If OUTPUT-FILE\n\
is -, output is written to standard output.\n");

/* Strings for arguments in help texts. */
static const char args_doc[] = N_("\
-o OUTPUT-FILE [INPUT-FILE]...\n[OUTPUT-FILE [INPUT-FILE]...]");

/* Prototype for option handler. */
static error_t parse_opt (int key, char *arg, struct argp_state *state);

/* Function to print some extra text in the help message. */
static char *more_help (int key, const char *text, void *input);

/* Data structure to communicate with argp functions. */
static struct argp argp =
{
options, parse_opt, args_doc, doc, NULL, more_help
};


/* Wrapper functions with error checking for standard functions. */
extern void *xmalloc (size_t n)
__attribute_malloc__ __attribute_alloc_size (1);
extern void *xcalloc (size_t n, size_t s)
__attribute_malloc__ __attribute_alloc_size (1, 2);
extern void *xrealloc (void *o, size_t n)
__attribute_malloc__ __attribute_alloc_size (2);
extern char *xstrdup (const char *) __attribute_malloc__;

/* Prototypes for local functions. */
static void error_print (void);
static struct catalog *read_input_file (struct catalog *current,
const char *fname);
static void write_out (struct catalog *result, const char *output_name,
const char *header_name);
static struct set_list *find_set (struct catalog *current, int number);
static void normalize_line (const char *fname, size_t line, iconv_t cd,
wchar_t *string, wchar_t quote_char,
wchar_t escape_char);
static void read_old (struct catalog *catalog, const char *file_name);
static int open_conversion (const char *codesetp, iconv_t *cd_towcp,
iconv_t *cd_tombp, wchar_t *escape_charp);


int
main (int argc, char *argv[])
{
struct catalog *result;
int remaining;

/* Set program name for messages. */
error_print_progname = error_print;

/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");

/* Set the text message domain. */
textdomain (PACKAGE);

/* Initialize local variables. */
result = NULL;

/* Parse and process arguments. */
argp_parse (&argp, argc, argv, 0, &remaining, NULL);

/* Determine output file. */
if (output_name == NULL)
output_name = remaining < argc ? argv[remaining++] : "-";

/* Process all input files. */
setlocale (LC_CTYPE, "C");
if (remaining < argc)
do
result = read_input_file (result, argv[remaining]);
while (++remaining < argc);
else
result = read_input_file (NULL, "-");

/* Write out the result. */
if (result != NULL)
write_out (result, output_name, header_name);

return error_message_count != 0;
}


/* Handle program arguments. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case 'H':
header_name = arg;
break;
case OPT_NEW:
force_new = 1;
break;
case 'o':
output_name = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}


static char *
more_help (int key, const char *text, void *input)
{
char *tp = NULL;
switch (key)
{
case ARGP_KEY_HELP_EXTRA:
/* We print some extra information. */
if (asprintf (&tp, gettext ("\
For bug reporting instructions, please see:\n\
%s.\n"), REPORT_BUGS_TO) < 0)
return NULL;
return tp;
default:
break;
}
return (char *) text;
}

/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
{
fprintf (stream, "gencat %s%s\n", PKGVERSION, VERSION);
fprintf (stream, gettext ("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "2012");
fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
}


/* The address of this function will be assigned to the hook in the
error functions. */
static void
error_print ()
{
/* We don't want the program name to be printed in messages. Emacs'
compile.el does not like this. */
}


static struct catalog *
read_input_file (struct catalog *current, const char *fname)
{
FILE *fp;
char *buf;
size_t len;
size_t line_number;
wchar_t *wbuf;
size_t wbufsize;
iconv_t cd_towc = (iconv_t) -1;
iconv_t cd_tomb = (iconv_t) -1;
wchar_t escape_char = L'\\';
char *codeset = NULL;

if (strcmp (fname, "-") == 0 || strcmp (fname, "/dev/stdin") == 0)
{
fp = stdin;
fname = gettext ("*standard input*");
}
else
fp = fopen (fname, "r");
if (fp == NULL)
{
error (0, errno, gettext ("cannot open input file `%s'"), fname);
return current;
}

/* If we haven't seen anything yet, allocate result structure. */
if (current == NULL)
{
current = (struct catalog *) xcalloc (1, sizeof (*current));

#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
obstack_init (&current->mem_pool);

current->current_set = find_set (current, NL_SETD);
}

buf = NULL;
len = 0;
line_number = 0;

wbufsize = 1024;
wbuf = (wchar_t *) xmalloc (wbufsize);

while (!feof (fp))
{
int continued;
int used;
size_t start_line = line_number + 1;
char *this_line;

do
{
int act_len;

act_len = getline (&buf, &len, fp);
if (act_len <= 0)
break;
++line_number;

/* It the line continued? */
continued = 0;
if (buf[act_len - 1] == '\n')
{
--act_len;

/* There might be more than one backslash at the end of
the line. Only if there is an odd number of them is
the line continued. */
if (act_len > 0 && buf[act_len - 1] == '\\')
{
int temp_act_len = act_len;

do
{
--temp_act_len;
continued = !continued;
}
while (temp_act_len > 0 && buf[temp_act_len - 1] == '\\');

if (continued)
--act_len;
}
}

/* Append to currently selected line. */
obstack_grow (&current->mem_pool, buf, act_len);
}
while (continued);

obstack_1grow (&current->mem_pool, '\0');
this_line = (char *) obstack_finish (&current->mem_pool);

used = 0;
if (this_line[0] == '$')
{
if (isblank (this_line[1]))
{
int cnt = 1;
while (isblank (this_line[cnt]))
++cnt;
if (strncmp (&this_line[cnt], "codeset=", 8) != 0)
/* This is a comment line. Do nothing. */;
else if (codeset != NULL)
/* Ignore multiple codeset. */;
else
{
int start = cnt + 8;
cnt = start;
while (this_line[cnt] != '\0' && !isspace (this_line[cnt]))
++cnt;
if (cnt != start)
{
int len = cnt - start;
codeset = xmalloc (len + 1);
*((char *) mempcpy (codeset, &this_line[start], len))
= '\0';
}
}
}
else if (strncmp (&this_line[1], "set", 3) == 0)
{
int cnt = sizeof ("set");
int set_number;
const char *symbol = NULL;
while (isspace (this_line[cnt]))
++cnt;

if (isdigit (this_line[cnt]))
{
set_number = atol (&this_line[cnt]);

/* If the given number for the character set is
higher than any we used for symbolic set names
avoid clashing by using only higher numbers for
the following symbolic definitions. */
if (set_number > current->last_set)
current->last_set = set_number;
}
else
{
/* See whether it is a reasonable identifier. */
int start = cnt;
while (isalnum (this_line[cnt]) || this_line[cnt] == '_')
++cnt;

if (cnt == start)
{
/* No correct character found. */
error_at_line (0, 0, fname, start_line,
gettext ("illegal set number"));
set_number = 0;
}
else
{
/* We have found seomthing that looks like a
correct identifier. */
struct set_list *runp;

this_line[cnt] = '\0';
used = 1;
symbol = &this_line[start];

/* Test whether the identifier was already used. */
runp = current->all_sets;
while (runp != 0)
if (runp->symbol != NULL
&& strcmp (runp->symbol, symbol) == 0)
break;
else
runp = runp->next;

if (runp != NULL)
{
/* We cannot allow duplicate identifiers for
message sets. */
error_at_line (0, 0, fname, start_line,
gettext ("duplicate set definition"));
error_at_line (0, 0, runp->fname, runp->line,
gettext ("\
this is the first definition"));
set_number = 0;
}
else
/* Allocate next free message set for identifier. */
set_number = ++current->last_set;
}
}

baseline bum
04-28-2013, 02:31 PM
if (set_number != 0)
{
/* We found a legal set number. */
current->current_set = find_set (current, set_number);
if (symbol != NULL)
used = 1;
current->current_set->symbol = symbol;
current->current_set->fname = fname;
current->current_set->line = start_line;
}
}
else if (strncmp (&this_line[1], "delset", 6) == 0)
{
int cnt = sizeof ("delset");
while (isspace (this_line[cnt]))
++cnt;

if (isdigit (this_line[cnt]))
{
size_t set_number = atol (&this_line[cnt]);
struct set_list *set;

/* Mark the message set with the given number as
deleted. */
set = find_set (current, set_number);
set->deleted = 1;
}
else
{
/* See whether it is a reasonable identifier. */
int start = cnt;
while (isalnum (this_line[cnt]) || this_line[cnt] == '_')
++cnt;

if (cnt == start)
error_at_line (0, 0, fname, start_line,
gettext ("illegal set number"));
else
{
const char *symbol;
struct set_list *runp;

this_line[cnt] = '\0';
used = 1;
symbol = &this_line[start];

/* We have a symbolic set name. This name must
appear somewhere else in the catalogs read so
far. */
for (runp = current->all_sets; runp != NULL;
runp = runp->next)
{
if (strcmp (runp->symbol, symbol) == 0)
{
runp->deleted = 1;
break;
}
}
if (runp == NULL)
/* Name does not exist before. */
error_at_line (0, 0, fname, start_line,
gettext ("unknown set `%s'"), symbol);
}
}
}
else if (strncmp (&this_line[1], "quote", 5) == 0)
{
char buf[2];
char *bufptr;
size_t buflen;
char *wbufptr;
size_t wbuflen;
int cnt;

cnt = sizeof ("quote");
while (isspace (this_line[cnt]))
++cnt;

/* We need the conversion. */
if (cd_towc == (iconv_t) -1
&& open_conversion (codeset, &cd_towc, &cd_tomb,
&escape_char) != 0)
/* Something is wrong. */
goto out;

/* Yes, the quote char can be '\0'; this means no quote
char. The function using the information works on
wide characters so we have to convert it here. */
buf[0] = this_line[cnt];
buf[1] = '\0';
bufptr = buf;
buflen = 2;

wbufptr = (char *) wbuf;
wbuflen = wbufsize;

/* Flush the state. */
iconv (cd_towc, NULL, NULL, NULL, NULL);

iconv (cd_towc, &bufptr, &buflen, &wbufptr, &wbuflen);
if (buflen != 0 || (wchar_t *) wbufptr != &wbuf[2])
error_at_line (0, 0, fname, start_line,
gettext ("invalid quote character"));
else
/* Use the converted wide character. */
current->quote_char = wbuf[0];
}
else
{
int cnt;
cnt = 2;
while (this_line[cnt] != '\0' && !isspace (this_line[cnt]))
++cnt;
this_line[cnt] = '\0';
error_at_line (0, 0, fname, start_line,
gettext ("unknown directive `%s': line ignored"),
&this_line[1]);
}
}
else if (isalnum (this_line[0]) || this_line[0] == '_')
{
const char *ident = this_line;
char *line = this_line;
int message_number;

do
++line;
while (line[0] != '\0' && !isspace (line[0]));
if (line[0] != '\0')
*line++ = '\0'; /* Terminate the identifier. */

/* Now we found the beginning of the message itself. */

if (isdigit (ident[0]))
{
struct message_list *runp;
struct message_list *lastp;

message_number = atoi (ident);

/* Find location to insert the new message. */
runp = current->current_set->messages;
lastp = NULL;
while (runp != NULL)
if (runp->number == message_number)
break;
else
{
lastp = runp;
runp = runp->next;
}
if (runp != NULL)
{
/* Oh, oh. There is already a message with this
number in the message set. */
if (runp->symbol == NULL)
{
/* The existing message had its number specified
by the user. Fatal collision type uh, oh. */
error_at_line (0, 0, fname, start_line,
gettext ("duplicated message number"));
error_at_line (0, 0, runp->fname, runp->line,
gettext ("this is the first definition"));
message_number = 0;
}
else
{
/* Collision was with number auto-assigned to a
symbolic. Change existing symbolic number
and move to end the list (if not already there). */
runp->number = ++current->current_set->last_message;

if (runp->next != NULL)
{
struct message_list *endp;

if (lastp == NULL)
current->current_set->messages=runp->next;
else
lastp->next=runp->next;

endp = runp->next;
while (endp->next != NULL)
endp = endp->next;

endp->next = runp;
runp->next = NULL;
}
}
}
ident = NULL; /* We don't have a symbol. */

if (message_number != 0
&& message_number > current->current_set->last_message)
current->current_set->last_message = message_number;
}
else if (ident[0] != '\0')
{
struct message_list *runp;

/* Test whether the symbolic name was not used for
another message in this message set. */
runp = current->current_set->messages;
while (runp != NULL)
if (runp->symbol != NULL && strcmp (ident, runp->symbol) == 0)
break;
else
runp = runp->next;
if (runp != NULL)
{
/* The name is already used. */
error_at_line (0, 0, fname, start_line, gettext ("\
duplicated message identifier"));
error_at_line (0, 0, runp->fname, runp->line,
gettext ("this is the first definition"));
message_number = 0;
}
else
/* Give the message the next unused number. */
message_number = ++current->current_set->last_message;
}
else
message_number = 0;

if (message_number != 0)
{
char *inbuf;
size_t inlen;
char *outbuf;
size_t outlen;
struct message_list *newp;
size_t line_len = strlen (line) + 1;
size_t ident_len = 0;

/* We need the conversion. */
if (cd_towc == (iconv_t) -1
&& open_conversion (codeset, &cd_towc, &cd_tomb,
&escape_char) != 0)
/* Something is wrong. */
goto out;

/* Convert to a wide character string. We have to
interpret escape sequences which will be impossible
without doing the conversion if the codeset of the
message is stateful. */
while (1)
{
inbuf = line;
inlen = line_len;
outbuf = (char *) wbuf;
outlen = wbufsize;

/* Flush the state. */
iconv (cd_towc, NULL, NULL, NULL, NULL);

iconv (cd_towc, &inbuf, &inlen, &outbuf, &outlen);
if (inlen == 0)
{
/* The string is converted. */
assert (outlen < wbufsize);
assert (wbuf[(wbufsize - outlen) / sizeof (wchar_t) - 1]
== L'\0');
break;
}

if (outlen != 0)
{
/* Something is wrong with this string, we ignore it. */
error_at_line (0, 0, fname, start_line, gettext ("\
invalid character: message ignored"));
goto ignore;
}

/* The output buffer is too small. */
wbufsize *= 2;
wbuf = (wchar_t *) xrealloc (wbuf, wbufsize);
}

/* Strip quote characters, change escape sequences into
correct characters etc. */
normalize_line (fname, start_line, cd_towc, wbuf,
current->quote_char, escape_char);

if (ident)
ident_len = line - this_line;

/* Now the string is free of escape sequences. Convert it
back into a multibyte character string. First free the
memory allocated for the original string. */
obstack_free (&current->mem_pool, this_line);

used = 1; /* Yes, we use the line. */

/* Now fill in the new string. It should never happen that
the replaced string is longer than the original. */
inbuf = (char *) wbuf;
inlen = (wcslen (wbuf) + 1) * sizeof (wchar_t);

outlen = obstack_room (&current->mem_pool);
obstack_blank (&current->mem_pool, outlen);
this_line = (char *) obstack_base (&current->mem_pool);
outbuf = this_line + ident_len;
outlen -= ident_len;

/* Flush the state. */
iconv (cd_tomb, NULL, NULL, NULL, NULL);

iconv (cd_tomb, &inbuf, &inlen, &outbuf, &outlen);
if (inlen != 0)
{
error_at_line (0, 0, fname, start_line,
gettext ("invalid line"));
goto ignore;
}
assert (outbuf[-1] == '\0');

/* Free the memory in the obstack we don't use. */
obstack_blank (&current->mem_pool, -(int) outlen);
line = obstack_finish (&current->mem_pool);

newp = (struct message_list *) xmalloc (sizeof (*newp));
newp->number = message_number;
newp->message = line + ident_len;
/* Remember symbolic name; is NULL if no is given. */
newp->symbol = ident ? line : NULL;
/* Remember where we found the character. */
newp->fname = fname;
newp->line = start_line;

/* Find place to insert to message. We keep them in a
sorted single linked list. */
if (current->current_set->messages == NULL
|| current->current_set->messages->number > message_number)
{
newp->next = current->current_set->messages;
current->current_set->messages = newp;
}
else
{
struct message_list *runp;
runp = current->current_set->messages;
while (runp->next != NULL)
if (runp->next->number > message_number)
break;
else
runp = runp->next;
newp->next = runp->next;
runp->next = newp;
}
}
++current->total_messages;
}
else
{
size_t cnt;

cnt = 0;
/* See whether we have any non-white space character in this
line. */
while (this_line[cnt] != '\0' && isspace (this_line[cnt]))
++cnt;

if (this_line[cnt] != '\0')
/* Yes, some unknown characters found. */
error_at_line (0, 0, fname, start_line,
gettext ("malformed line ignored"));
}

ignore:
/* We can save the memory for the line if it was not used. */
if (!used)
obstack_free (&current->mem_pool, this_line);
}

/* Close the conversion modules. */
iconv_close (cd_towc);
iconv_close (cd_tomb);
free (codeset);

out:
free (wbuf);

if (fp != stdin)
fclose (fp);
return current;
}


static void
write_out (struct catalog *catalog, const char *output_name,
const char *header_name)
{
/* Computing the "optimal" size. */
struct set_list *set_run;
size_t best_total, best_size, best_depth;
size_t act_size, act_depth;
struct catalog_obj obj;
struct obstack string_pool;
const char *strings;
size_t strings_size;
uint32_t *array1, *array2;
size_t cnt;
int fd;

/* If not otherwise told try to read file with existing
translations. */
if (!force_new)
read_old (catalog, output_name);

/* Initialize best_size with a very high value. */
best_total = best_size = best_depth = UINT_MAX;

/* We need some start size for testing. Let's start with
TOTAL_MESSAGES / 5, which theoretically provides a mean depth of
5. */
act_size = 1 + catalog->total_messages / 5;

/* We determine the size of a hash table here. Because the message
numbers can be chosen arbitrary by the programmer we cannot use
the simple method of accessing the array using the message
number. The algorithm is based on the trivial hash function
NUMBER % TABLE_SIZE, where collisions are stored in a second
dimension up to TABLE_DEPTH. We here compute TABLE_SIZE so that
the needed space (= TABLE_SIZE * TABLE_DEPTH) is minimal. */
while (act_size <= best_total)
{
size_t deep[act_size];

act_depth = 1;
memset (deep, '\0', act_size * sizeof (size_t));
set_run = catalog->all_sets;
while (set_run != NULL)
{
struct message_list *message_run;

message_run = set_run->messages;
while (message_run != NULL)
{
size_t idx = (message_run->number * set_run->number) % act_size;

++deep[idx];
if (deep[idx] > act_depth)
{
act_depth = deep[idx];
if (act_depth * act_size > best_total)
break;
}
message_run = message_run->next;
}
set_run = set_run->next;
}

if (act_depth * act_size <= best_total)
{
/* We have found a better solution. */
best_total = act_depth * act_size;
best_size = act_size;
best_depth = act_depth;
}

++act_size;
}

baseline bum
04-28-2013, 02:31 PM
/* let's be prepared for an empty message file. */
if (best_size == UINT_MAX)
{
best_size = 1;
best_depth = 1;
}

/* OK, now we have the size we will use. Fill in the header, build
the table and the second one with swapped byte order. */
obj.magic = CATGETS_MAGIC;
obj.plane_size = best_size;
obj.plane_depth = best_depth;

/* Allocate room for all needed arrays. */
array1 =
(uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3);
memset (array1, '\0', best_size * best_depth * sizeof (uint32_t) * 3);
array2
= (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3);
obstack_init (&string_pool);

set_run = catalog->all_sets;
while (set_run != NULL)
{
struct message_list *message_run;

message_run = set_run->messages;
while (message_run != NULL)
{
size_t idx = (((message_run->number * set_run->number) % best_size)
* 3);
/* Determine collision depth. */
while (array1[idx] != 0)
idx += best_size * 3;

/* Store set number, message number and pointer into string
space, relative to the first string. */
array1[idx + 0] = set_run->number;
array1[idx + 1] = message_run->number;
array1[idx + 2] = obstack_object_size (&string_pool);

/* Add current string to the continuous space containing all
strings. */
obstack_grow0 (&string_pool, message_run->message,
strlen (message_run->message));

message_run = message_run->next;
}

set_run = set_run->next;
}
strings_size = obstack_object_size (&string_pool);
strings = obstack_finish (&string_pool);

/* Compute ARRAY2 by changing the byte order. */
for (cnt = 0; cnt < best_size * best_depth * 3; ++cnt)
array2[cnt] = SWAPU32 (array1[cnt]);

/* Now we can write out the whole data. */
if (strcmp (output_name, "-") == 0
|| strcmp (output_name, "/dev/stdout") == 0)
fd = STDOUT_FILENO;
else
{
fd = creat (output_name, 0666);
if (fd < 0)
error (EXIT_FAILURE, errno, gettext ("cannot open output file `%s'"),
output_name);
}

/* Write out header. */
write (fd, &obj, sizeof (obj));

/* We always write out the little endian version of the index
arrays. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3);
write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3);
#elif __BYTE_ORDER == __BIG_ENDIAN
write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3);
write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3);
#else
# error Cannot handle __BYTE_ORDER byte order
#endif

/* Finally write the strings. */
write (fd, strings, strings_size);

if (fd != STDOUT_FILENO)
close (fd);

/* If requested now write out the header file. */
if (header_name != NULL)
{
int first = 1;
FILE *fp;

/* Open output file. "-" or "/dev/stdout" means write to
standard output. */
if (strcmp (header_name, "-") == 0
|| strcmp (header_name, "/dev/stdout") == 0)
fp = stdout;
else
{
fp = fopen (header_name, "w");
if (fp == NULL)
error (EXIT_FAILURE, errno,
gettext ("cannot open output file `%s'"), header_name);
}

/* Iterate over all sets and all messages. */
set_run = catalog->all_sets;
while (set_run != NULL)
{
struct message_list *message_run;

/* If the current message set has a symbolic name write this
out first. */
if (set_run->symbol != NULL)
fprintf (fp, "%s#define %sSet %#x\t/* %s:%Zu */\n",
first ? "" : "\n", set_run->symbol, set_run->number - 1,
set_run->fname, set_run->line);
first = 0;

message_run = set_run->messages;
while (message_run != NULL)
{
/* If the current message has a symbolic name write
#define out. But we have to take care for the set
not having a symbolic name. */
if (message_run->symbol != NULL)
{
if (set_run->symbol == NULL)
fprintf (fp, "#define AutomaticSet%d%s %#x\t/* %s:%Zu */\n",
set_run->number, message_run->symbol,
message_run->number, message_run->fname,
message_run->line);
else
fprintf (fp, "#define %s%s %#x\t/* %s:%Zu */\n",
set_run->symbol, message_run->symbol,
message_run->number, message_run->fname,
message_run->line);
}

message_run = message_run->next;
}

set_run = set_run->next;
}

if (fp != stdout)
fclose (fp);
}
}


static struct set_list *
find_set (struct catalog *current, int number)
{
struct set_list *result = current->all_sets;

/* We must avoid set number 0 because a set of this number signals
in the tables that the entry is not occupied. */
++number;

while (result != NULL)
if (result->number == number)
return result;
else
result = result->next;

/* Prepare new message set. */
result = (struct set_list *) xcalloc (1, sizeof (*result));
result->number = number;
result->next = current->all_sets;
current->all_sets = result;

return result;
}


/* Normalize given string *in*place* by processing escape sequences
and quote characters. */
static void
normalize_line (const char *fname, size_t line, iconv_t cd, wchar_t *string,
wchar_t quote_char, wchar_t escape_char)
{
int is_quoted;
wchar_t *rp = string;
wchar_t *wp = string;

if (quote_char != L'\0' && *rp == quote_char)
{
is_quoted = 1;
++rp;
}
else
is_quoted = 0;

while (*rp != L'\0')
if (*rp == quote_char)
/* We simply end the string when we find the first time an
not-escaped quote character. */
break;
else if (*rp == escape_char)
{
++rp;
if (quote_char != L'\0' && *rp == quote_char)
/* This is an extension to XPG. */
*wp++ = *rp++;
else
/* Recognize escape sequences. */
switch (*rp)
{
case L'n':
*wp++ = L'\n';
++rp;
break;
case L't':
*wp++ = L'\t';
++rp;
break;
case L'v':
*wp++ = L'\v';
++rp;
break;
case L'b':
*wp++ = L'\b';
++rp;
break;
case L'r':
*wp++ = L'\r';
++rp;
break;
case L'f':
*wp++ = L'\f';
++rp;
break;
case L'0' ... L'7':
{
int number;
char cbuf[2];
char *cbufptr;
size_t cbufin;
wchar_t wcbuf[2];
char *wcbufptr;
size_t wcbufin;

number = *rp++ - L'0';
while (number <= (255 / 8) && *rp >= L'0' && *rp <= L'7')
{
number *= 8;
number += *rp++ - L'0';
}

cbuf[0] = (char) number;
cbuf[1] = '\0';
cbufptr = cbuf;
cbufin = 2;

wcbufptr = (char *) wcbuf;
wcbufin = sizeof (wcbuf);

/* Flush the state. */
iconv (cd, NULL, NULL, NULL, NULL);

iconv (cd, &cbufptr, &cbufin, &wcbufptr, &wcbufin);
if (cbufptr != &cbuf[2] || (wchar_t *) wcbufptr != &wcbuf[2])
error_at_line (0, 0, fname, line,
gettext ("invalid escape sequence"));
else
*wp++ = wcbuf[0];
}
break;
default:
if (*rp == escape_char)
{
*wp++ = escape_char;
++rp;
}
else
/* Simply ignore the backslash character. */;
break;
}
}
else
*wp++ = *rp++;

/* If we saw a quote character at the beginning we expect another
one at the end. */
if (is_quoted && *rp != quote_char)
error_at_line (0, 0, fname, line, gettext ("unterminated message"));

/* Terminate string. */
*wp = L'\0';
return;
}


static void
read_old (struct catalog *catalog, const char *file_name)
{
struct catalog_info old_cat_obj;
struct set_list *set = NULL;
int last_set = -1;
size_t cnt;

/* Try to open catalog, but don't look through the NLSPATH. */
if (__open_catalog (file_name, NULL, NULL, &old_cat_obj) != 0)
{
if (errno == ENOENT)
/* No problem, the catalog simply does not exist. */
return;
else
error (EXIT_FAILURE, errno,
gettext ("while opening old catalog file"));
}

/* OK, we have the catalog loaded. Now read all messages and merge
them. When set and message number clash for any message the new
one is used. If the new one is empty it indicates that the
message should be deleted. */
for (cnt = 0; cnt < old_cat_obj.plane_size * old_cat_obj.plane_depth; ++cnt)
{
struct message_list *message, *last;

if (old_cat_obj.name_ptr[cnt * 3 + 0] == 0)
/* No message in this slot. */
continue;

if (old_cat_obj.name_ptr[cnt * 3 + 0] - 1 != (uint32_t) last_set)
{
last_set = old_cat_obj.name_ptr[cnt * 3 + 0] - 1;
set = find_set (catalog, old_cat_obj.name_ptr[cnt * 3 + 0] - 1);
}

last = NULL;
message = set->messages;
while (message != NULL)
{
if ((uint32_t) message->number >= old_cat_obj.name_ptr[cnt * 3 + 1])
break;
last = message;
message = message->next;
}

if (message == NULL
|| (uint32_t) message->number > old_cat_obj.name_ptr[cnt * 3 + 1])
{
/* We have found a message which is not yet in the catalog.
Insert it at the right position. */
struct message_list *newp;

newp = (struct message_list *) xmalloc (sizeof(*newp));
newp->number = old_cat_obj.name_ptr[cnt * 3 + 1];
newp->message =
&old_cat_obj.strings[old_cat_obj.name_ptr[cnt * 3 + 2]];
newp->fname = NULL;
newp->line = 0;
newp->symbol = NULL;
newp->next = message;

if (last == NULL)
set->messages = newp;
else
last->next = newp;

++catalog->total_messages;
}
else if (*message->message == '\0')
{
/* The new empty message has overridden the old one thus
"deleting" it as required. Now remove the empty remains. */
if (last == NULL)
set->messages = message->next;
else
last->next = message->next;
}
}
}


static int
open_conversion (const char *codeset, iconv_t *cd_towcp, iconv_t *cd_tombp,
wchar_t *escape_charp)
{
char buf[2];
char *bufptr;
size_t bufsize;
wchar_t wbuf[2];
char *wbufptr;
size_t wbufsize;

/* If the input file does not specify the codeset use the locale's. */
if (codeset == NULL)
{
setlocale (LC_ALL, "");
codeset = nl_langinfo (CODESET);
setlocale (LC_ALL, "C");
}

/* Get the conversion modules. */
*cd_towcp = iconv_open ("WCHAR_T", codeset);
*cd_tombp = iconv_open (codeset, "WCHAR_T");
if (*cd_towcp == (iconv_t) -1 || *cd_tombp == (iconv_t) -1)
{
error (0, 0, gettext ("conversion modules not available"));
if (*cd_towcp != (iconv_t) -1)
iconv_close (*cd_towcp);

return 1;
}

/* One special case for historical reasons is the backslash
character. In some codesets the byte value 0x5c is not mapped to
U005c in Unicode. These charsets then don't have a backslash
character at all. Therefore we have to live with whatever the
codeset provides and recognize, instead of the U005c, the character
the byte value 0x5c is mapped to. */
buf[0] = '\\';
buf[1] = '\0';
bufptr = buf;
bufsize = 2;

wbufptr = (char *) wbuf;
wbufsize = sizeof (wbuf);

iconv (*cd_towcp, &bufptr, &bufsize, &wbufptr, &wbufsize);
if (bufsize != 0 || wbufsize != 0)
{
/* Something went wrong, we couldn't convert the byte 0x5c. Go
on with using U005c. */
error (0, 0, gettext ("cannot determine escape character"));
*escape_charp = L'\\';
}
else
*escape_charp = wbuf[0];

return 0;
}

baseline bum
04-28-2013, 02:32 PM
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.

#
# Makefile for catgets.
#
subdir := catgets

headers = nl_types.h
routines = catgets open_catalog
others = gencat
install-bin = gencat
extra-objs = $(gencat-modules:=.o)

tests = tst-catgets
test-srcs = test-gencat

gencat-modules = xmalloc

# To find xmalloc.c
vpath %.c ../locale/programs


include ../Rules

$(objpfx)gencat: $(gencat-modules:%=$(objpfx)%.o)

catgets-CPPFLAGS := -DNLSPATH='"$(msgcatdir)/%L/%N:$(msgcatdir)/%L/LC_MESSAGES/%N:$(msgcatdir)/%l/%N:$(msgcatdir)/%l/LC_MESSAGES/%N:"' \
-DHAVE_CONFIG_H

CPPFLAGS-gencat = -DNOT_IN_libc

generated = de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
test-gencat.h
generated-dirs = de

tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de

ifeq ($(run-built-tests),yes)
tests: $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
$(objpfx)test-gencat.out
# This test just checks whether the program produces any error or not.
# The result is not tested.
$(objpfx)test1.cat: test1.msg $(objpfx)gencat
LC_ALL=hr_HR.ISO-8859-2 LOCPATH=$(common-objpfx)localedata \
GCONV_PATH=$(common-objpfx)iconvdata \
$(built-program-cmd) -H $(objpfx)test1.h $@ $<
$(objpfx)test2.cat: test2.msg $(objpfx)gencat
LOCPATH=$(common-objpfx)localedata \
GCONV_PATH=$(common-objpfx)iconvdata \
$(built-program-cmd) -H $(objpfx)test2.h $@ $<
$(objpfx)de/libc.cat: $(objpfx)de.msg $(objpfx)gencat
$(make-target-directory)
LC_ALL=de_DE.ISO-8859-1 LOCPATH=$(common-objpfx)localedata \
GCONV_PATH=$(common-objpfx)iconvdata $(built-program-cmd) $@ $<
$(objpfx)tst-catgets.out: $(objpfx)de/libc.cat

# Generate a non-simple input file.
$(objpfx)de.msg: xopen-msg.awk $(..)po/de.po
LC_ALL=C $(AWK) -f $^ $< > $@

$(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
$(objpfx)sample.SJIS.cat
$(SHELL) $< $(common-objpfx) '$(built-program-cmd)'

$(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
$(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@
endif

baseline bum
04-28-2013, 02:32 PM
/* Copyright (C) 1996,1997,1999,2003,2004,2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _NL_TYPES_H
#define _NL_TYPES_H 1

#include <features.h>

/* The default message set used by the gencat program. */
#define NL_SETD 1

/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */
#define NL_CAT_LOCALE 1


__BEGIN_DECLS

/* Message catalog descriptor type. */
typedef void *nl_catd;

/* Type used by `nl_langinfo'. */
typedef int nl_item;

/* Open message catalog for later use, returning descriptor.

This function is a possible cancellation point and therefore not
marked with __THROW. */
extern nl_catd catopen (const char *__cat_name, int __flag) __nonnull ((1));

/* Return translation with NUMBER in SET of CATALOG; if not found
return STRING. */
extern char *catgets (nl_catd __catalog, int __set, int __number,
const char *__string) __THROW __nonnull ((1));

/* Close message CATALOG. */
extern int catclose (nl_catd __catalog) __THROW __nonnull ((1));

__END_DECLS

#endif /* nl_types.h */

baseline bum
04-28-2013, 02:34 PM
/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <[email protected]>.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <byteswap.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef _POSIX_MAPPED_FILES
# include <sys/mman.h>
#endif
#include <sys/stat.h>

#include "catgetsinfo.h"
#include <not-cancel.h>


#define SWAPU32(w) bswap_32 (w)


int
__open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
__nl_catd catalog)
{
int fd = -1;
struct stat64 st;
int swapping;
size_t cnt;
size_t max_offset;
size_t tab_size;
const char *lastp;
int result = -1;

if (strchr (cat_name, '/') != NULL || nlspath == NULL)
fd = open_not_cancel_2 (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
#define ENOUGH(n) \
if (__builtin_expect (bufact + (n) >= bufmax, 0)) \
{ \
char *old_buf = buf; \
bufmax += 256 + (n); \
buf = (char *) alloca (bufmax); \
memcpy (buf, old_buf, bufact); \
}

/* The RUN_NLSPATH variable contains a colon separated list of
descriptions where we expect to find catalogs. We have to
recognize certain % substitutions and stop when we found the
first existing file. */
char *buf;
size_t bufact;
size_t bufmax;
size_t len;

buf = NULL;
bufmax = 0;

fd = -1;
while (*run_nlspath != '\0')
{
bufact = 0;

if (*run_nlspath == ':')
{
/* Leading colon or adjacent colons - treat same as %N. */
len = strlen (cat_name);
ENOUGH (len);
memcpy (&buf[bufact], cat_name, len);
bufact += len;
}
else
while (*run_nlspath != ':' && *run_nlspath != '\0')
if (*run_nlspath == '%')
{
const char *tmp;

++run_nlspath; /* We have seen the `%'. */
switch (*run_nlspath++)
{
case 'N':
/* Use the catalog name. */
len = strlen (cat_name);
ENOUGH (len);
memcpy (&buf[bufact], cat_name, len);
bufact += len;
break;
case 'L':
/* Use the current locale category value. */
len = strlen (env_var);
ENOUGH (len);
memcpy (&buf[bufact], env_var, len);
bufact += len;
break;
case 'l':
/* Use language element of locale category value. */
tmp = env_var;
do
{
ENOUGH (1);
buf[bufact++] = *tmp++;
}
while (*tmp != '\0' && *tmp != '_' && *tmp != '.');
break;
case 't':
/* Use territory element of locale category value. */
tmp = env_var;
do
++tmp;
while (*tmp != '\0' && *tmp != '_' && *tmp != '.');
if (*tmp == '_')
{
++tmp;
do
{
ENOUGH (1);
buf[bufact++] = *tmp++;
}
while (*tmp != '\0' && *tmp != '.');
}
break;
case 'c':
/* Use code set element of locale category value. */
tmp = env_var;
do
++tmp;
while (*tmp != '\0' && *tmp != '.');
if (*tmp == '.')
{
++tmp;
do
{
ENOUGH (1);
buf[bufact++] = *tmp++;
}
while (*tmp != '\0');
}
break;
case '%':
ENOUGH (1);
buf[bufact++] = '%';
break;
default:
/* Unknown variable: ignore this path element. */
bufact = 0;
while (*run_nlspath != '\0' && *run_nlspath != ':')
++run_nlspath;
break;
}
}
else
{
ENOUGH (1);
buf[bufact++] = *run_nlspath++;
}

ENOUGH (1);
buf[bufact] = '\0';

if (bufact != 0)
{
fd = open_not_cancel_2 (buf, O_RDONLY);
if (fd >= 0)
break;
}

++run_nlspath;
}
}

/* Avoid dealing with directories and block devices */
if (__builtin_expect (fd, 0) < 0)
return -1;

if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
goto close_unlock_return;

if (__builtin_expect (!S_ISREG (st.st_mode), 0)
|| (size_t) st.st_size < sizeof (struct catalog_obj))
{
/* `errno' is not set correctly but the file is not usable.
Use an reasonable error value. */
__set_errno (EINVAL);
goto close_unlock_return;
}

catalog->file_size = st.st_size;
#ifdef _POSIX_MAPPED_FILES
# ifndef MAP_COPY
/* Linux seems to lack read-only copy-on-write. */
# define MAP_COPY MAP_PRIVATE
# endif
# ifndef MAP_FILE
/* Some systems do not have this flag; it is superfluous. */
# define MAP_FILE 0
# endif
catalog->file_ptr =
(struct catalog_obj *) __mmap (NULL, st.st_size, PROT_READ,
MAP_FILE|MAP_COPY, fd, 0);
if (__builtin_expect (catalog->file_ptr != (struct catalog_obj *) MAP_FAILED,
1))
/* Tell the world we managed to mmap the file. */
catalog->status = mmapped;
else
#endif /* _POSIX_MAPPED_FILES */
{
/* mmap failed perhaps because the system call is not
implemented. Try to load the file. */
size_t todo;
catalog->file_ptr = malloc (st.st_size);
if (catalog->file_ptr == NULL)
goto close_unlock_return;

todo = st.st_size;
/* Save read, handle partial reads. */
do
{
size_t now = read_not_cancel (fd, (((char *) catalog->file_ptr)
+ (st.st_size - todo)), todo);
if (now == 0 || now == (size_t) -1)
{
#ifdef EINTR
if (now == (size_t) -1 && errno == EINTR)
continue;
#endif
free ((void *) catalog->file_ptr);
goto close_unlock_return;
}
todo -= now;
}
while (todo > 0);
catalog->status = malloced;
}

/* Determine whether the file is a catalog file and if yes whether
it is written using the correct byte order. Else we have to swap
the values. */
if (__builtin_expect (catalog->file_ptr->magic == CATGETS_MAGIC, 1))
swapping = 0;
else if (catalog->file_ptr->magic == SWAPU32 (CATGETS_MAGIC))
swapping = 1;
else
{
invalid_file:
/* Invalid file. Free the resources and mark catalog as not
usable. */
#ifdef _POSIX_MAPPED_FILES
if (catalog->status == mmapped)
__munmap ((void *) catalog->file_ptr, catalog->file_size);
else
#endif /* _POSIX_MAPPED_FILES */
free (catalog->file_ptr);
goto close_unlock_return;
}

#define SWAP(x) (swapping ? SWAPU32 (x) : (x))

/* Get dimensions of the used hashing table. */
catalog->plane_size = SWAP (catalog->file_ptr->plane_size);
catalog->plane_depth = SWAP (catalog->file_ptr->plane_depth);

/* The file contains two versions of the pointer tables. Pick the
right one for the local byte order. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
catalog->name_ptr = &catalog->file_ptr->name_ptr[0];
#elif __BYTE_ORDER == __BIG_ENDIAN
catalog->name_ptr = &catalog->file_ptr->name_ptr[catalog->plane_size
* catalog->plane_depth
* 3];
#else
# error Cannot handle __BYTE_ORDER byte order
#endif

/* The rest of the file contains all the strings. They are
addressed relative to the position of the first string. */
catalog->strings =
(const char *) &catalog->file_ptr->name_ptr[catalog->plane_size
* catalog->plane_depth * 3 * 2];

/* Determine the largest string offset mentioned in the table. */
max_offset = 0;
tab_size = 3 * catalog->plane_size * catalog->plane_depth;
for (cnt = 2; cnt < tab_size; cnt += 3)
if (catalog->name_ptr[cnt] > max_offset)
max_offset = catalog->name_ptr[cnt];

/* Now we can check whether the file is large enough to contain the
tables it says it contains. */
if ((size_t) st.st_size
<= (sizeof (struct catalog_obj) + 2 * tab_size + max_offset))
/* The last string is not contained in the file. */
goto invalid_file;

lastp = catalog->strings + max_offset;
max_offset = (st.st_size
- sizeof (struct catalog_obj) + 2 * tab_size + max_offset);
while (*lastp != '\0')
{
if (--max_offset == 0)
goto invalid_file;
++lastp;
}

/* We succeeded. */
result = 0;

/* Release the lock again. */
close_unlock_return:
close_not_cancel_no_status (fd);

return result;
}
libc_hidden_def (__open_catalog)

baseline bum
04-28-2013, 02:34 PM
$ test message catalog

$ codeset=sjis
$quote "
$set 1
1 sample1:ABCDEF:
2 sample2:日本語:
3 sample3:予定表:
4 sample4:TEST\tTAB:
5 sample5:機能\t十種類:
6 double slash\\
7 "another line"
$set Another
FOO "message foo"

baseline bum
04-28-2013, 02:34 PM
$set 10
$quote "
$ Pozn疥ka
Welcome Vtejte v testovacm programu
Author Autor: Vladimir Michl

baseline bum
04-28-2013, 02:35 PM
$set 42
$ Two messages with auto-assigned numbers.
Number1 Auto-assigned #1
Number2 Auto-assigned #2
$ Three messages with explicitly assigned numbers.
0 Explicitly assigned #1
1 Explicitly assigned #2
2 Explicitly assigned #3

baseline bum
04-28-2013, 02:35 PM
#include <locale.h>
#include <nl_types.h>
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
nl_catd catalog;
setlocale (LC_ALL, "");

printf ("LC_MESSAGES = %s\n", setlocale (LC_MESSAGES, NULL));

catalog = catopen ("sample", NL_CAT_LOCALE);
if (catalog == (nl_catd) -1)
{
printf ("no catalog: %m\n");
exit (1);
}

printf ("%s\n", catgets(catalog, 1, 1, "sample 1"));
printf ("%s\n", catgets(catalog, 1, 2, "sample 2"));
printf ("%s\n", catgets(catalog, 1, 3, "sample 3"));
printf ("%s\n", catgets(catalog, 1, 4, "sample 4"));
printf ("%s\n", catgets(catalog, 1, 5, "sample 5"));
printf ("%s\n", catgets(catalog, 1, 6, "sample 6"));
printf ("%s\n", catgets(catalog, 1, 7, "sample 7"));
catclose (catalog);

return 0;
}

baseline bum
04-28-2013, 02:35 PM
#! /bin/sh
# Test escape character handling in gencat.
# Copyright (C) 2000-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.

set -e

common_objpfx=$1
run_program_cmd=$2

# Run the test program.
LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
NLSPATH=${common_objpfx}catgets/%N.%c.cat LC_ALL=ja_JP.SJIS \
${run_program_cmd} \
> ${common_objpfx}catgets/test-gencat.out

# Compare with the expected result.
cmp - ${common_objpfx}catgets/test-gencat.out <<"EOF"
LC_MESSAGES = ja_JP.SJIS
sample1:ABCDEF:
sample2:日本語:
sample3:予定表:
sample4:TEST TAB:
sample5:機能 十種類:
double slash\
another line
EOF
res=$?

cat <<EOF |
#define AnotherSet 0x2 /* *standard input*:13 */
#define AnotherFOO 0x1 /* *standard input*:14 */
EOF
cmp ${common_objpfx}catgets/test-gencat.h - || res=1

exit $res

baseline bum
04-28-2013, 02:35 PM
#include <mcheck.h>
#include <nl_types.h>
#include <stdio.h>
#include <string.h>


static const char *msgs[] =
{
#define INPUT(str)
#define OUTPUT(str) str,
#include <intl/msgs.h>
};
#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))

#define ROUNDS 5

int
main (void)
{
int rnd;
int result = 0;

mtrace ();

/* We do this a few times to stress the memory handling. */
for (rnd = 0; rnd < ROUNDS; ++rnd)
{
nl_catd cd = catopen ("libc", 0);
size_t cnt;

if (cd == (nl_catd) -1)
{
printf ("cannot load catalog: %m\n");
result = 1;
break;
}

/* Go through all the messages and compare the result. */
for (cnt = 0; cnt < nmsgs; ++cnt)
{
char *trans;

trans = catgets (cd, 1, 1 + cnt,
"+#+# if this comes backs it's an error");

if (trans == NULL)
{
printf ("catgets return NULL for %zd\n", cnt);
result = 1;
}
else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
{
printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
result = 1;
}
}

if (catclose (cd) != 0)
{
printf ("catclose failed: %m\n");
result = 1;
}
}

return result;
}

baseline bum
04-28-2013, 02:35 PM
libc {
GLIBC_2.0 {
# c*
catclose; catgets; catopen;
}
GLIBC_PRIVATE {
# functions with required interface outside normal name space
__open_catalog;
}
}

baseline bum
04-28-2013, 02:35 PM
# xopen-msg.awk - Convert Uniforum style .po file to X/Open style .msg file
# Copyright (C) 2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
# The first directive in the .msg should be the definition of the
# message set number. We use always set number 1.
#
BEGIN {
print "$set 1 # Automatically created by xopen-msg.awk"
num = 0
}

#
# The .msg file contains, other then the .po file, only the translations
# but each given a unique ID. Starting from 1 and incrementing by 1 for
# each message we assign them to the messages.
# It is important that the .po file used to generate the ../intl/msg.h file
# (with po2test.awk) is the same as the one used here. (At least the order
# of declarations must not be changed.)
#
function output_message() {
# Ignore messages containing <PRI.*> which would have to be replaced
# by the correct format depending on the word size
if (msg && msg !~ /<PRI.*>/) {
if (msgtype == "msgid") {
# We copy the original message as a comment into the .msg file.
gsub(/\n/, "\n$ ", msg)
printf "$ Original Message: %s\n", msg
} else {
gsub(/\n/, "\\\n", msg)
printf "%d %s\n", ++num, msg
}
}
msg = 0
}

$1 ~ "msg(id|str)" {
# Output collected message
output_message()
# Collect next message
msgtype = $1
sub(/^msg(id|str)[ \t]*"/, "", $0)
sub(/"$/, "", $0)
msg = $0
next
}

/^".*"/ {
# Append to current message
sub(/^"/, "", $0)
sub(/"$/, "", $0)
msg = msg "\n" $0
next
}

END {
# Output last collected message
output_message()
}

CubanMustGo
04-28-2013, 05:24 PM
I think 210 is a rube and a charlatan, BB, but you left out #include <butthurt.h>.

BobaFett1
04-29-2013, 09:15 AM
.
An open message to Terrorist Obama..for murdering over 4700 men, women and children with his illegal drone program with 98% of the casualties being innocent non-combatants, not to mention the extension of the Afghanistan war and illegal intervention in Libya.



An Open Message to Barack Obama


https://www.youtube.com/watch?v=V3MuzLezG9s


Props to Storm Clouds Gathering for another excellent video :tu


It is war. Folks had nothing to do with it die all time. We cannot become soft. If the terrorist are there kill them. Props to Obama.