Previous | Table of Contents | Next

Page 1042

DESCRIPTION

The strtoul() function converts the string in nptr to an unsigned long integer value according to the given base, which must be between 2 and 36 inclusive, or be the special value 0.

The string must begin with an arbitrary amount of whitespace (as determined by isspace(3)) followed by a single optional + or - sign. If base is zero or 16, the string may then include a 0x prefix, and the number will be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is 0, in which case it is taken as 8 (octal).

The remainder of the string is converted to an unsigned long int value in the obvious manner, stopping at the first character that is not a valid digit in the given base. (In bases above 10, the letter A in either upper- or lowercase represents 10, B represents 11, and so forth, with Z representing 35.)

If endptr is not NULL, strtoul() stores the address of the first invalid character in *endptr. If there were no digits at all, strtoul() stores the original value of nptr in *endptr. (Thus, if *nptr is not \0 but **endptr is \0 on return, the entire string is invalid.)

RETURN VALUE

The strtoul() function returns either the result of the conversion or, if there was a leading minus sign, the negation of the result of the conversion, unless the original (non-negated) value would overflow; in the latter case, strtoul() returns ULONG_MAX and sets the global variable errno to ERANGE.

ERRORS

ERANGE The given string was out of range; the value converted has been clamped.

CONFORMS TO

SVID 3, BSD 4.3, ISO 9899

SEE ALSO

atof(3), atoi(3), atol(3), strtod(3), strtol(3)

BUGS

strtoul ignores the current locale.

GNU, 29 March 1993

strxfrm

strxfrm—String transformation

SYNOPSIS

#include <string.h>
size t strxfrm(char *dest, const char *src, size_t n);

DESCRIPTION

The strxfrm() function transforms the src string into a form such that the result of strcmp() on two strings that have been transformed with strxfrm() is the same as the result of strcoll() on the two strings before their transformation. The first n characters of the transformed string are placed in dest. The transformation is based on the program's current locale for category LC_COLLATE. (See setlocale(3)).

RETURN VALUE

The strxfrm() function returns the number of bytes required to store the transformed string in dest excluding the terminating \0 character. If the value returned is n or more, the contents of dest are indeterminate.

Page 1043

CONFORMS TO

SVID 3, BSD 4.3, ISO 9899

NOTES

The Linux C Library currently hasn't implemented the complete POSIX-collating.

In the POSIX or C locales strxfrm() is equivalent to copying the string with strncpy().

SEE ALSO

bcmp(3), memcmp(3), strcasecmp(3), strcmp(3), strcoll(3), setlocale(3)

GNU, 12 April 1993

swab

swab—Swaps adjacent bytes

SYNOPSIS

#include <string.h>
void swab(const void *from, void*to, size_t n);

DESCRIPTION

The swab() function copies n bytes from the array pointed to by from to the array pointed to by to, exchanging adjacent even and odd bytes. This function is used to exchange data between machines that have different low/high byte ordering.

RETURN VALUE

The swab() function returns no value.

CONFORMS TO

SVID 3, BSD 4.3

SEE ALSO

bstring(3)

GNU, 13 April 1993

sysconf

sysconf—Gets configuration information at runtime

SYNOPSIS

#include <unistd.h>
long sysconf(int name);

DESCRIPTION

sysconf() provides a way for the application to determine values for system limits or options at runtime.

The equivalent macros defined in <unistd.h> can only give conservative values; if an application wants to take advantage of values that may change, a call to sysconf() can be made, which may yield more liberal results.

For getting information about a particular file, see fpathconf() or pathconf().

The following values are supported for name. First, the POSIX.1_compatible values:

Page 1044

_SC_ARG_MAX The maximum length of the arguments to the exec() family of functions; the corresponding macro is ARG_MAX.
_SC_CHILD_MAX The number of simultaneous processes per user ID; the corresponding macro is _POSIX_CHILD_MAX.
_SC_CLK_TCK The number of clock ticks per second; the corresponding macro is CLK_TCK.
_SC_STREAM_MAX The maximum number of streams that a process can have open at any time. The corresponding POSIX macro is STREAM_MAX; the corresponding standard C macro is FOPEN_MAX.
_SC_TZNAME_MAX The maximum number of bytes in a time zone name; the corresponding macro is TZNAME_MAX.
_SC_OPEN_MAX The maximum number of files that a process can have open at any time; the corresponding macro is _POSIX_OPEN_MAX.
_SC_JOB_CONTROL This indicates whether POSIX_style job control is supported, the corresponding macro is _POSIX_JOB_CONTROL.
_SC_SAVED_IDS This indicates whether a process has a saved set-user-ID and a saved set-group-ID; the corresponding macro is _POSIX_SAVED_IDS.
_SC_VERSION Indicates the year and month the POSIX.1 standard was approved in the format YYYYMML; the value 199009L indicates the most recent revision, 1990.

Next, the POSIX.2 values:

_SC_BC_BASE_MAX Indicates the maximum obase value accepted by the bc(1) utility; the corresponding macro is BC_BASE_MAX.
_SC_BC_DIM_MAX Indicates the maximum value of elements permitted in an array by bc(1); the corresponding macro is BC_DIM_MAX.
_SC_BC_SCALE_MAX Indicates the maximum scale value allowed by bc(1); the corresponding macro is BC_SCALE_MAX.
_SC_BC_STRING_MAX Indicates the maximum length of a string accepted by bc(1); the corresponding macro is BC_STRING_MAX.
_SC_COLL_WEIGHTS_MAX Indicates the maximum numbers of weights that can be assigned to an entry of the LC_COLLATE order keyword in the locale definition file; the corresponding macro is COLL_WEIGHTS_MAX.
_SC_EXPR_NEST_MAX Is the maximum number of expressions that can be nested within parentheses by expr(1). The corresponding macro is EXPR_NEST_MAX.
_SC_LINE_MAX The maximum length of a utility's input line length, either from standard input or from a file. This includes length for a trailing newline. The corresponding macro is LINE_MAX.
_SC_RE_DUP_MAX The maximum number of repeated occurrences of a regular expression when the interval notation \{m,n\} is used. The value of the corresponding macro is RE_DUP_MAX.
_SC_2_VERSION Indicates the version of the POSIX.2 standard in the format of YYYYMML. The corresponding macro is POSIX2_VERSION.
_SC_2_DEV Indicates whether the POSIX.2 C language development facilities are supported. The corresponding macro is POSIX2_C_DEV.
_SC_2_FORT_DEV Indicates whether the POSIX.2 FORTRAN development utilities are supported. The corresponding macro is POSIX2_FORT_RUN.
_SC_2_FORT_RUN Indicates whether the POSIX.2 FORTRAN runtime utilities are supported. The corresponding macro is POSIX2_FORT_RUN.

Previous | Table of Contents | Next

1