Sun Java System Portal Server 7 Developer's Guide

Chapter 18 Overview of the Robot Application Functions

This chapter contains the following sections:

Introduction to Robot Application Functions

Typically, you might modify the behavior of a search engine robot filter by using the search engine administration interface or the predefined robot application functions (RAFs).

When you want to modify the behavior of the search engine robot filters in a way that is not accommodated by the standard filter functions, you will need to create your own robot application functions (RAFs). Robot filters are defined in the file filter.conf. Filter definitions consist of filter directives, which each specify a robot application function.

Robot Plug-in API Overview

The robot plug-in API is a set of functions and header files that help you create your own robot application functions to use with the directives in robot configuration files. Use this API to create the built-in functions for the directives used in filter.conf (the robot filter configuration file).

When you become familiar with this API, you will be able to override, add, or customize robot functionality. For example, you will be able to create functions that use a custom database for access control, or you can create functions that create custom log files with special entries.

In general, most developers will write RAF functions in C. However, you can define the functions in any language as long as it can build a shared library. If you use C++, you will need to modify the provided C header files to be used by C++ files.

ProcedureTo Create Custom Plug-In Functions

The following steps are a brief overview of the process for creating your own plug-in functions.

Steps
  1. Compile your code to create a shared object (.so) file.

  2. In the Setup directives at the top of filter.conf, you tell the robot to load your shared object file or dynamic-link library.

  3. Write directives that use your plug-in functions in the robot configuration file (filter.conf).

    The PortalServer-base/sdk/robot/include directory contains all the header files you need to include when writing your plug-in functions.

    The PortalServer-base/sdk/robot/examples directory contains sample code, the header files, and a makefile. You should familiarize yourself with the code and samples.

The Robot Application Function Header Files

This section discusses the header files needed for creating robot application functions. The following topics are described:

Header File Hierarchy

The hierarchy of robot plug-in API header files is (directories are shown in bold):


robot
    include
        cscinfo.h
        csmem.h
        filterrules.h
        robotapi.h
        base
            systems.h
        libcs
            adt.h
            cs.h
            csidcf.h
            getopt.h
            log.h
            pblock.h

The robot and its header files are written in ANSI C.

Header File Contents

This section describes the header files you can include when writing your plug-in functions. This section is intended as a starting point for learning the functions included in the header files.

Most of the header files are stored in the following directories:

PortalServer-base/sdk/robot/include

Contains header files that define general purpose data structures and function prototypes. Header files in this directory include:

csinfo.h

Contains functions for object typing, specifically for mapping files to MIME types.

csmem.h

Contains memory-related definitions.

robotapi.h

Contains the type definitions for structures and the return-code definitions for robot API functions.

filterrules.h

Contains type definitions for structures needed by filter rules.

PortalServer-base/sdk/robot/include/base

Contains the following header file to handle low-level, platform independent functions such as memory, file, and network access.

systems.h

Contains functions that handle system information.

PortalServer-base/sdk/robot/include/libcs

Contains header files of functions that handle robot and HTTP-specific functions such as handling access to configuration files and HTTP. The header files in this directory include:

adt.h

Contains type definitions and function prototypes for utilities needed by the robot, such as linked lists, queues, and hash tables.

cs.h

Contains a library of common functions used by the Search Engine.

csidcf.h

Contains configuration definitions for Search Engine.

getopt.h

Contains routines to get options from the command line, for example, command line prog -n arg1 -p arg2, to get arg1 and arg2.

log.h

Contains routines for writing information to log files.

pblock.h

Contains functions that manage parameter passing and robot internal variables. It also contains functions to get values from a user via the server.