Sun Java System Portal Server 7.1 Developer's Guide

Getting Information on the Processed Resource

As mentioned in RAF Prototype, the prototype for all robot application functions is in the following format:

int (*RobotAPIFn)(pblock *pb, CSFilter *csf, CSResource *csr);

where csr is a data structure that contains information about the resource being processed.

The CSResource structure is defined in the header file robotapi.h. This structure contains information about the resource being processed. Each resource is in Search syntax.

Objects in Search syntax have a schema name, an associated URL, and a set of attribute-value pairs.

In the Getting Information on the Processed Resource, the schema name is @DOCUMENT, the URL is: http://developer.siroe.com/docs/manuals/htmlguid/index.htm, and the Search contains attribute-value pairs for title, author, and description.


Example 22–1 Search Syntax Example


@DOCUMENT{ http://developer.siroe.com/docs/manuals/htmlguid/index.htm
    title{18}: HTML Tag Reference
    author{11}: Preston Day
    description{37}: Reference to HTML tags and attributes
}

A CSResource structure has a url field, which contains the URL for the Search. It also has an rd field, whose value is the Search for the resource. Once you get the Search for the resource, you can use the functions for working with Search that are defined in PortalServer-base/sdk/rdm/include/search.h file to get more information about the resource. (The file robotapi.h includes search.h.)

For example, the macro Search_Findval(search, attribute) gets the value of the given attribute in the given Search. Getting Information on the Processed Resource uses this macro to print the value of the META attribute if it exists for the resource being processed.


Example 22–2 Search_Findval Macro Example


int my_new_raf(libcs_pblock *pb, CSFilter *csf, CSResource *csr)
    char *metavalue;
    if (metavalue = (char *)Search_Findval(csr->rd, “meta”))
    printf(“The value of the META tag in the resource is %s” metavalue);
    /* rest of function ... */
}

It is recommended that you review the CSResource structure in the file robotapi.h for more information on other fields and macros. For more information about the routines to use with Search objects, see Memory Buffer Management.