fatolong - convert ASCII to LONG value



int fatolong (sptr, format, l, size)
char *sptr;
char *format;
LONG *l;
int size;


Fatolong converts a string pointed to by sptr to an integer value
using format to control the conversion. The result of the
conversion is stored in the LONG value pointed at by l. Size is
the size of the LONG value. Although the name implies only long
integers, fatolong supports both long and short integers. Size
must be the size of a long or short integer.

Fatolong first tries to convert sptr using format. If this fails,
fatolong applies a set of standard input rules. These rules allow
an optional string of tabs and spaces, then an optional minus
sign, then a string of digits. The string may also contain one
or more of the thousands separator character (returned by
getfthou(C-3)) to make the number more readable.

Fatolong returns the number of characters in sptr used to convert
the value. The advantages of calling fatolong over atol(3) or
atolong(C-3) is that fatolong understands special formats and
special characters for any defined country, it accepts a number
containing embedded thousands separator characters (commas for
U.S.A. formats), and it has additional checks for overflow and
edit errors.

The first unrecognized character ends the string. When doing edit
checks, it is left to the calling program to determine if the
remaining unrecognized characters should be considered valid.


fcountry(C-3), getfthou(C-3), atolong(C-3), atol(3)
C/Base Reference Manual Chapter 13, "Formatting Data Values"


If an error occurs, fatolong returns a negative number and the
contents of l are undefined. The following symbolic error codes
are defined in :

FTOOBIG size is not the size of a long or short
integer (use sizeof function) or the result

FFORMAT format is invalid

FIFORMAT sptr does not conform to any of the
formatting rules