home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsu
/
wld
/
WLD.DOC
< prev
Wrap
Text File
|
1992-05-04
|
7KB
|
287 lines
WORLD DEVICE DRIVER INTERFACE (WLD:)
====================================
Some definitions
----------------
#define WR_FIND_CITY 10
#define WR_FIND_COUNTRY 11
#define WR_FIND_EXACT 12
#define WR_NEXT 13
#define WR_BACK 14
#define WR_GET_HOME 15
#define WR_SET_HOME 16
#define WR_GET_DEFAULT_COUNTRY 17
#define WR_SET_DEFAULT_COUNTRY 18
#define WR_GET_DIAL_STRING 19
#define WR_EXTRA 20
#define WR_SET_EXTRA 21
#define WR_GET_CITY_DATA 22
#define WR_GET_COUNTRY_DATA 23
#define WR_CALC 24
#define WR_NEXT_LOCK 25
#define WR_MAX_NAME 20
#define WR_MAX_DIAL 16
#define WR_MAX_CODE 8
#define WR_MAX_INTRA 4
#define WR_MAX_INTER 4
#define WR_MAX_DIAL_STRING 24
#define WR_MAX_IN_STRING 64
#define WR_UNITS_MILES 0
#define WR_UNITS_KILOMETERS 1
#define WR_UNITS_NAUTICAL 2
#define WR_START_STATE 1
#define WR_END_STATE 0
#define WR_NOT_FOUND E_GEN_FAIL
#define WR_FOUND 0
#define WR_EXTRA_ADD_CITY 0
#define WR_EXTRA_UPDATE_CITY 1
#define WR_EXTRA_DELETE_CITY 2
#define WR_EXTRA_UPDATE_COUNTRY 3
#define WR_EXTRA_ADD_HOME 4
#define WR_DELETED 0
#define WR_REVERTED 1
#define WR_TOO_MANY_ERR -23
#define WR_NOTVALID_ERR -25
#define WR_DELHOME_ERR -26
#define WR_DELCAPITAL_ERR -27
#define WR_DUPLICATE_ERR -28
typedef struct /* Lat long */
{
WORD iLat;
WORD iLong;
} LATL;
typedef struct
{
TEXT city[WR_MAX_NAME+1];
TEXT country[WR_MAX_NAME+1];
} WR_FIND_RES;
typedef struct
{
WR_FIND_RES f;
UBYTE units; /* Also baseGMT */
UBYTE DST;
WORD GMT;
LATL latl;
TEXT dial[WR_MAX_DIAL+1];
TEXT STD[WR_MAX_CODE+1];
P_POINT pos;
} WR_CITY_DATA;
typedef struct
{
TEXT dialIntra[WR_MAX_INTRA+1];
TEXT dialInter[WR_MAX_INTER+1];
TEXT dial[WR_MAX_CODE+1];
UBYTE dummy;
} CO_DIAL;
typedef struct
{
WR_FIND_RES f;
BYTE baseGMT;
UBYTE DST;
WORD GMT;
CO_DIAL dial;
} WR_COUNTRY_DATA;
typedef union
{
WR_CITY_DATA ci;
WR_COUNTRY_DATA co;
} WR_EXTRA_DATA;
typedef struct
{
WORD distance;
WORD sunRise;
WORD sunSet;
WORD always;
} WR_CALC_OUT;
typedef union
{
WR_CITY_DATA in;
WR_CALC_OUT out;
} WR_CALC_DATA;
Some documentation
------------------
The world device driver can be opened with the following call:
INT ret;
VOID *w;
ret=p_open(&w,"wld:",0xffff);
and all i/o functions can be requested using p_ioa(), p_ioc() or
p_iow(). At all times an open channel is always positioned on a valid
city or country.
All other functionality is as described below:
INT WR_FIND_CITY(TEXT *match,WR_FIND_RES *result)
Match is in 'match'. Max size WR_MAX_NAME. Text can be
any case - a fold is automatically done.
Return WR_NOT_FOUND or WR_FOUND.
If not found then previous position is restored.
INT WR_FIND_COUNTRY(TEXT *match,WR_FIND_RES *result)
Match is in 'match'. Max size WR_MAX_NAME. Text can be
any case - a fold is automatically done.
Return WR_NOT_FOUND or WR_FOUND.
If not found then previous position is restored.
INT WR_FIND_EXACT(WR_FIND_RES *match)
Match is in 'match'. Matches to the city. Text can be any
case - a fold is automatically done. If no city string is
given a country search is performed.
Return WR_NOT_FOUND or WR_FOUND.
If not found then previous status is restored. On success the type
(for NEXT etc) is city or country depending on whether the city field
was null.
VOID WR_NEXT(WR_FIND_RES *result)
No input parameters.
VOID WR_BACK(WR_FIND_RES *result)
No input parameters.
VOID WR_GET_HOME(WR_FIND_RES *result)
No input parameters. The type (for NEXT etc) is city.
INT WR_SET_HOME(VOID)
No input parameters. Returns WR_NOTVALID_ERR if item no longer valid.
VOID WR_GET_DEFAULT_COUNTRY(WR_FIND_RES *result)
No input parameters. The type (for NEXT etc) is city.
INT WR_SET_DEFAULT_COUNTRY(VOID)
No input parameters. Returns E_GEN_UNDER if item no longer valid.
INT WR_GET_DIAL_STRING(TEXT *inString,TEXT *outString)
Input in 'inString'. Output in 'outString'. Can fail with
E_GEN_ARG (null string, missing ']' after '[' or country
name not found). Limit of P_FNAMESIZE for the input
string. Output buffer must allow for
WR_MAX_DIAL_STRING+1 bytes, returns E_GEN_OVER if it is
too long. Intelligent handling is done if the there is a
space or '-' embedded in the number.
INT WR_EXTRA(WORD *func,WR_EXTRA_DATA *data)
Function number in 'func' and new data in 'data'. 'data'
is not required for DELETE. Can fail because of p_alloc
errors so can return system errors or the specific errors
listed below. No data checking is performed.
This function requires a file to have been opened with
WR_SET_EXTRA and for there to be enough room on the media
for the operation. The standard default file is
\WLD\WORLD.WLD.
Returns WR_NOTVALID_ERR if item is no longer valid.
WR_EXTRA_ADD_CITY
Returns E_GEN_ARG if it fails to match the country string
to a country. Returns WR_DUPLICATE_ERR if the
city/country matches an existing city/country. Returns
WR_TOO_MANY_ERR if more than 32 items are already
present.
WR_EXTRA_UPDATE_CITY
Returns E_GEN_ARG if it fails to match the country text
to a country. Returns WR_DUPLICATE_ERR if the
city/country matches an existing city/country (which it
is not being updated).
WR_EXTRA_DELETE_CITY
Returns WR_NOT_VALID if current item is not an extra
city, WR_DELHOME_ERR if the item is the current home,
WR_DELCAPITAL_ERR if the item is an added capital city.
Returns either WR_REVERTED or WR_DELETED depending on
whether it was an added on updated item.
WR_EXTRA_UPDATE_COUNTRY
Returns E_GEN_ARG if the capital string does not match an
existing city in the country being updated or if the new
country name conflicts with an existing country. All
city GMTs in extra for that country will be adjusted.
They will also take the new DST.
INT WR_SET_EXTRA(WORD *flag,TEXT *name)
Flag is in 'flag' and name is in 'name'. Returns system
errors and E_GEN_IMAGE if the file is badly formatted or
has a different database version number. The name is
parsed with the extension '.WLD'.
P_FOPEN
Fails if files does not exist or can not be opened. If it
is badly formatted it returns E_GEN_IMAGE. If the
current item is in the extra database it becomes invalid
(though NEXT & BACK will work but any function using the
current position will fail). For example
WR_GET_CITY_DATA will give the error E_GEN_UNDER.
P_FREPLACE
Fails if can not replace/create the file.
INT WR_GET_CITY_DATA(WR_CITY_DATA *result)
No input parameters. Returns WR_NOTVALID_ERR if item no
longer valid.
INT WR_GET_COUNTRY_DATA(WR_COUNTRY_DATA *result)
No input parameters. Returns WR_NOTVALID_ERR if item no longer valid.
INT WR_CALC(WORD *state,WR_CALC_DATA *calc)
Input state in 'wFlag', and when 'state' ==
WR_START_STATE data is in 'calc'. On 'state' ==
WR_END_STATE result is returned to 'calc'. New state
always returned in wFlag. Can return system errors (eg
E_GEN_NOMEMORY).
VOID WR_NEXT_LOCK(WR_FIND_RES *result)
Returns the next city in the current country.