Sun Java System Portal Server 7 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 SOIF syntax.

Objects in SOIF 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 SOIF contains attribute-value pairs for title, author, and description.


Example 19–1 SOIF 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 SOIF. It also has an rd field, whose value is the SOIF for the resource. Once you get the SOIF for the resource, you can use the functions for working with SOIF that are defined in PortalServer-base/sdk/rdm/include/soif.h file to get more information about the resource. (The file robotapi.h includes soif.h.)

For example, the macro SOIF_Findval(soif, attribute) gets the value of the given attribute in the given SOIF. 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 19–2 SOIF_Findval Macro Example


int my_new_raf(libcs_pblock *pb, CSFilter *csf, CSResource *csr)
    char *metavalue;
    if (metavalue = (char *)SOIF_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 SOIF objects, see Memory Buffer Management.