strint, strdouble, strtime, strdate, strlat, strlon, timestr, itimestr, datestr, latstr, lonstr - String conversion routines

SYNOPSIS

#include <uif.h>
#include <terrno.h>

char *strint(str, delim, most, val, nvals)
char *str;
int delim;
int most, *val, *nvals;

char *strdouble(str, delim, most, val, nvals)
char *str;
int delim, most;
double *val;
int *nvals;

int strtime(str, time)
char *str;
double *time;

int strdate(str, date)
char *str;
int *date;

int strlat(str, lat)
char *str;
double *lat;

int strlon(str, lon)
char *str;
double *lon;

char *timestr(time, str)
double time;
char *str;

char *itimestr(time, str)
int time;
char *str;

char *datestr(date, str)
int date;
char *str;

char *latstr(lat, str)
double lat;
char *str;

char *lonstr(lon, str)
double lon;
char *str;

DESCRIPTION

These functions either extract numbers, dates, times, latitudes, and longitudes from strings, or write dates, times, latitudes and longitudes into strings.

Date, time, latitude and longitude each can have several input formats, but for simplicity, each has but one output format (*).

Numeric formats are as follows:

a. date =
integer days since 1/1/1900, inclusive
b. time =
integer or real seconds of the day
c. latitude =
real degrees in [-90., 90.] where north > 0
d. longitude =
real degrees in [-180., 180.] where east > 0

String formats are as follows: ([] means optional)

a. date =
yy/mm/dd (*) yy.ddd (ddd is julian day)
b. time =
hh:mm:ss[.ss] (*) mm:ss[.ss] ss[.ss]
c. latitude =
dd mm ss N/S (or n/s) dd mm[.mm] N/S (or n/s) (*) dd[.dd] N/S (or n/s)
d. longitude =
ddd mm ss N/S (or n/s) ddd mm[.mm] N/S (or n/s) (*) ddd[.dd] N/S (or n/s)

strint converts text data in str to a list of integers, and returns a pointer to the item in str after the last number extracted. An extra delimiter, specified by delim, is allowed in addition to blanks between values. most specifies the maximum number of integers to extract. The output list of numbers is returned in the array val. The number of integers extracted is returned in nvals.

strdouble converts text data in str to a list of reals, and returns a pointer to the item in str after the last number extracted. An extra delimiter, specified by delim, is allowed in addition to blanks between values. most specifies the maximum number of reals to extract. The output list of numbers is returned in the array val. The number of reals extracted is returned in nvals.

strtime converts text data in str to real time. time is returned in seconds.

strdate converts text data in str to integer date. date is returned in number of days since Jan, 1, 1900, inclusive.

strlat converts text data in str to real latitude lat. lat is returned in degrees north.

strlon converts text data in str to real longitude lon. lon is returned in degrees east.

itimestr and timestr converts times to string format. Input is in seconds.

datestr converts date to string format. Input is in days since Jan 1, 1900, inclusive.

latstr converts latitude to string format. Input is in degrees north.

lonstr converts longitude to string format. Input is in degrees east.

RETURN VALUES

Functions that have string input return 0 if successful. Otherwise they return -1 and set terrno to the appropriate conversion error code.

Functions that have string output return pointers to the output strings if successful. Otherwise, they return NULL and set terrno to the appropriate error code.

ERRORS

Error codes for these routines are defined in include/uif.h:

Not an integer

Not a valid real

Conversion over or under flow

Not a valid latitude

Invalid latitude hemisphere

Lat not in [0, 90]

Not a valid longitude

Invalid longitude hemisphere

Lon not in [0, 180]

Invalid time format

Not a valid time

Invalid date format

Not a valid date

FILES

include/uif.a, include/terrno.h, lib/libuif.a

SEE ALSO

dates, prmdate

NOTES

Integer overflows are ignored.


Last Update: $Date: 1999/05/10 20:56:32 $