DlpReadResourceByIndex(3)

NAME
DlpReadResourceByIndex, DlpReadResourceByType - read a resource from a PalmOS device

LIBRARY
libpconn

SYNOPSIS
#include <palm.h>
#include <pconn/pconn.h>
int
DlpReadResourceByIndex(PConnection *pconn, const ubyte handle, const uword index, const uword offset, const uword len, struct dlp_resource *value, const ubyte **data);
int
DlpReadResourceByType(PConnection *pconn, const ubyte handle, const udword type, const uword id, const uword offset, const uword len, struct dlp_resource *value, ubyte *data);

DESCRIPTION
These functions read a resource from an open database on the Palm. Palm resources are similar to those in the resource fork of a MacOS file: they are identified by a four-character type, and an integer ID, which identifies different resources of the same type (that is, there may be multiple resource with the ID 1000, but only one CODE resource may have the ID 1000).

DlpReadResourceByIndex reads the indexth resource in the database.

handle specifies the database handle, as returned by DlpOpenDB(3). The database must already be open for reading.

index specifies the index of the resource from the beginning of the database. Resource indices start at 0.

offset specifies the offset at which to start reading the resource: to read the resource from the beginning, use 0; to skip the first 10 bytes, use 10.

len specifies the maximum number of bytes to read.

value will be filled in with the resource header, which is of the following form:

    struct dlp_resource
    {
    	udword type;
    	uword id;
    	uword index;
    	uword size;
    };

data will be filled in with a pointer to the resource data. This pointer is to an internal buffer, and must not be freed. The length of the data will be the smaller of value.size and len.

DlpReadResourceByType is similar to DlpReadResourceByIndex(), except that you specify the resource by type and ID, rather than by index.

type specifies the four-character type of the resource, with the first letter in the most-significant 8 bits.

id specifies the resource identifier.

All other arguments are as for DlpReadResourceByIndex().

RETURN VALUE
These functions return 0 if successful, or a negative value otherwise.

SEE ALSO
libpconn(3), DlpOpenDB(3).