Documentation
Advanced Search


Oracle Outside In Transformation Server Developer's Guide

4 Initiating Transformations Using the C/C++ API

To use Transformation Server in a C or C++ application, the application should load the sccts module and communicate with its API functions. General operation consists of the following steps:

The module SCCTS implements the Transformation Server C/C++ interface. Source files that use SCCTS should include the header file sccts.h, and make sure that the other header files included in the Transformation Server SDK are in the project's include path. Projects using SCCTS should link with SCCTS.LIB, which is included in the Transformation Server SDK. Additionally, the modules that reside in the root level of the Outside In Transformation Suite directory are required to be in the same directory as SCCTS.

Note:

The return values listed for these functions are only a selection of the most common error messages returned. For each function, other error messages are possible. These messages can be found in sccerr.h and tserr.h.

This chapter includes the following sections:

4.1 TSInit

This function must be called before any attempt to perform a transformation or option setting can be made. If TSInit succeeds, TSDeInit must be called regardless of any other API calls.

Prototype

TSERR TSInit(
    LPTSINITPARAMS pParams,
    PTSHANDLE      phSession);

Parameters

  • pParams: Pointer to a data structure, TSINITPARAMS, that describes C-Stub initialization parameters.

  • phSession: Pointer to a variable of type TSHANDLE. Upon successful return from TSInit, this variable will be set to the "session handle" to be used in subsequent calls to the SCCTS interface. Note that this handle must not be used simultaneously in multiple threads.

Return Values

  • TSERR_OK: Indicates success.

  • TSERR_UNKNOWN: Error trapping caught an unforeseen exception, such as an operating system or hardware exception. Please examine the status of the machine running the sccts module (including available memory, hard drive space and connectivity).

4.1.1 TSINITPARAMSVER2 Structure

This structure is used to describe C-Stub initialization parameters.

This structure replaces the older TSINITPARAMS structure. While still valid, the TSINITPARAMS structure does not support client-side redirected IO on Linux systems where client and server reside on different machines. This new structure does support such configurations. It should also be noted that the newer structure resolves an issue seen in previous releases that affected developers on multi-homed machines.

Structure

A C data structure defined in sccts.h as follows:

typedef struct TSINITPARAMStagVer2
{
   VTDWORD    dwVersion;
   VTLPSTR    szServer;
   VTWORD     wPort;
   OpenIOProc openIO;
   VTWORD     wIOPort;
   VTLPSTR    szIOServer;
} TSINITPARAMSVER2, *PTSINITPARAMSVER2;
  • dwVersion: Identifies the version of this structure being used. Always set this value to SCCTS_INITPARAMS_CURRENTVERSION.

  • szServer: Null-terminated string that contains the address where Transformation Server is listening for transformation requests. May be either a host name or dotted-decimal IP address.

  • wPort: Port number upon which Transformation Server has been configured to listen for connections.

  • openIO: Points to an OpenIO function (see Section 8.5.1, "Handling Redirected IO" for more information). May be set to null if redirected IO is not being used.

  • wIOPort: Port number on the local machine to be used for IO-related TCP communication between Transformation Server and sccts. If redirected IO is not used, this parameter is ignored. If redirected IO is used and this parameter is set to zero, an available port will be arbitrarily chosen for the IO communication.

  • szIOServer: Host name/IP address of where redirected IO is taking place, needed only when the source or sink uses redirected IO. This is used in conjunction with the wIOPort parameter (null-terminated).

Note:

Redirected IO occurs when the specType field of a TS_IOSpec structure is set to the value of "redirect". Setting specType to "redirect" means that the file referenced in the TS_IOSpec structure needs to be accessed via client supplied IO functions. The wIOPort and szIOServer parameters are ignored if the OpenIO parameter is null.

Example

TSINITPARAMSVER2   initParms;
initParms.dwVersion = SCCTS_INITPARAMS_CURRENTVERSION;
initParms.szServer = "server1.example.com";
initParms.wPort = 747;


if( TSERR_OK != TSInit(&initParms) )
{
   /* exit with an error */
}

4.2 TSMemFree

This function allows the application using SCCTS to free allocated memory that was returned through the SCCTS interface. This function is not a generic de-allocator, and should only be called to free memory returned from an SCCTS interface function. Upon return from this function, the memory location pointed to by pvMem will be invalid.

Prototype

TSMemFree (
   TSHANDLE    hSession,
   void* pvMem);

Parameters

  • hSession: The handle for the Transformation Server session.

  • pvMem: A pointer to allocated memory returned from the SCCTS interface.

4.3 TSSetOption

This function is called to set the value of a transformation option.

For HTML Export and XML Export: The identifier (hOptions) indicates what particular option is being specified. sccts supports two type of identifiers: predefined numeric ID values or text names. Numeric option identifiers may only be used to specify options for the Outside In Transformation Engines; all other transformation engines must use names for option identifiers. An option name may be any character string; its character set must be UTF-8 encoded Unicode. The names used for option identifiers are defined by the Export Engine.

The option value data (pOptionValue) must be in a form that conforms to the set of supported data types (see Appendix B, "C/C++ Client Data Types" ).

Prototype

TSERR TSSetOption(
   TSHANDLE    hSession,
   VTLPSTR     szOptionName,
   VTLPVOID    pOptionValue,
   VTDWORD     dwOptionType
   );

Parameters

  • hSession: The handle for the Transformation Server session.

  • szOptionName: Name of the option to be set in Unicode, null-terminated.

  • pOptionValue: Pointer to the value of the option.

  • dwOptionType: Type identifier indicating what type of option value is pointed to by pOptionValue. Allowable option types and their identifiers are described later in this book.

Return Values

  • TSERR_OK: Indicates success.

  • TSERR_BADPARAM: One of the parameter values in the function call is incorrect.

  • TSERR_UNKNOWN: Error trapping caught an unforeseen exception, such as an operating system or hardware exception. Please examine the status of the machine running the sccts module (including available memory, hard drive space and connectivity).

  • TSERR_BADOPTIONTYPE: dwOptionType was invalid.

4.4 TSSetOptionById

This function is called to set the value of a transformation option. It is provided to ease compatibility with code that was written to consume the embedded versions of Outside In Export Technologies. The options set-able by this function are specific to Outside In Export Technologies.

Prototype

TSERR TSSetOptionById(
   TSHANDLE   hSession,
   VTDWORD    dwOptionId,
   VTLPVOID   pOptionValue,
   VTDWORD    dwOptionSize
   );

Parameters

  • hSession: The handle for the Transformation Server session.

  • dwOptionId: The identifier of the option to be set.

  • pOptionValue: Pointer to a buffer containing the value of the option.

  • dwOptionSize: The size in bytes of the data pointed to by pOptionValue. For a string value, the null terminator should be included when calculating dwOptionSize.

Return Values

  • TSERR_OK: Indicates success.

  • TSERR_BADPARAM: One of the parameter values in the function call is incorrect.

  • TSERR_UNKNOWN: Error trapping caught an unforeseen exception, such as an operating system or hardware exception. Please examine the status of the machine running the sccts module (including available memory, hard drive space and connectivity).

  • TSERR_INVALIDOPTION: dwOptionId was invalid.

4.5 TSRunTransform

TSRunTransform is used to send the transformation request to the server.

Prototype

TSERR TSRunTransform(
   TSHANDLE              hSession,
   LPTS_IOSpec           pSource,
   LPTS_IOSpec           pSink,
   VTLPSTR               szOutputFormat,
   VTLPSTR               szOptionSet,
   TS_TransformResult ** ppResults);

Parameters

  • hSession: The handle for the Transformation Server session.

  • pSource: Pointer to a TS_IOSpec structure defining the transformation source. The valid values for this parameter are defined in the server-side configuration file, agent_iospec_types.xml. If unedited, this file specifies path, url or riot as the three valid values. See Section 8.4.1, "Specifying Inputs and Outputs with TS_IOSpec" for more details.

  • pSink: Pointer to a TS_IOSpec structure defining the transformation sink. The valid values for this parameter are defined in the server-side configuration file, agent_iospec_types.xml. If unedited, this file specifies path, url or riot as the three valid values. See Section 8.4.1, "Specifying Inputs and Outputs with TS_IOSpec".

  • szOutputFormat: Output format name in UTF-8 encoded Unicode, null-terminated. The valid output formats are contained in the configuration file called agent_engine_list.xml.

  • szOptionSet: Option set name in UTF-8 encoded Unicode, null-terminated. Option sets can be coded by hand, or using the included option set editor (see Section 2.4, "The Option Set Editor").

  • ppResults: Results of the transformation. It should also be noted that the data returned in the TS_TransformResult pointer must be freed by the calling application. This is done through a single call to TSMemFree. See Section 4.2, "TSMemFree" for details.

Return Values

  • TSERR_OK: Indicates success.

  • TSERR_BADPARAM: One of the parameter values in the function call is incorrect.

  • TSERR_UNKNOWN: Error trapping caught an unforeseen exception, such as an operating system or hardware exception. Please examine the status of the machine running the sccts module (including available memory, hard drive space and connectivity).

  • TSERR_OBJECTREFERENCEINVALID: AddReference method of the Options object returned NULL. Check that the Options parameter is valid.

  • TSERR_OUTPUTFORMAT_NOTSUPPORTED: The output format designated in the call is not supported for the transform being attempted.

  • TSERR_OPTIONSET_NOTSUPPORTED: The option set designated in the call is not supported for the transform being attempted.

  • TSERR_ALLOCFAILED: Memory allocation failed.

  • TSERR_INPUTOPENFAILED: Could not open the designated input file.

  • TSERR_OUTPUTOPENFAILED: Could not create the designated output file.

  • TSERR_FILECLOSEFAILED: A resource failed to be closed properly.

4.6 TSDeInit

After the client application is done with all the possible transformations it needed to perform, TSDeInit needs to be called. This function should be called right before the sccts module is ready to be released. Make sure that this function is called in tandem with TSInit initialization function.

Prototype
TSERR TSDeInit(
   TSHANDLE hSession
   );

Parameters

  • hSession: The handle for the Transformation Server session.

Return Values

  • TSERR_OK: Indicates success.

  • TSERR_UNKNOWN: Error trapping caught an unforeseen exception, such as an operating system or hardware exception. Please examine the status of the machine running the sccts module (including available memory, hard drive space and connectivity).

4.7 Sample Applications

Transformation Server ships with two sample applications that demonstrate the use of the SCCTS module: TSCLIENT and TSDEMO.

Some notes concerning these sample applications:

  • The source code for these applications is provided, along with Microsoft Developer Studio project files. These applications were designed to demonstrate the use of the Transformation Server and the SCCTS module. They are freely modifiable, but are not warranteed and should not be assumed to be of commercial quality.

  • TSCLIENT makes use of Microsoft Foundation Classes (MFC) and therefore must be built using Microsoft Developer Studio.

  • Both of these applications demonstrate the use of custom IO Providers (also referred to as redirected IO). In both cases, the redirected IO code does nothing more than implement a thin layer on top of the file system input and output. As a result, the file specifications for these examples of redirected IO are identical to normal file system paths (unless the URL IO type is chosen, in which case the file specification must be a URL, not a file system path).

  • In order to transform documents, both of these applications require Transformation Server (tsmanager) to be running and accessible via TCP/IP.

  • These applications must be linked with SCCTS, which in turn requires access to various support DLL files located in the root level of the Outside In Transformation Suite directory. Running these sample applications from any other directory will result in an error, unless you add Transformation Suite's root directory to your path.

  • The following information is needed to build the sample app tsdemo on Unix.

    To build on Solaris:

    make _solaris=1 clean all
    

    To build on Linux:

    make _linux=1 clean all
    

4.7.1 tsclient

This is a Win32 application written in C++, with a dialog-based interface. Various controls and dialog boxes allow you to specify the options that affect how a document is transformed.

4.7.2 tsdemo

Note:

To build tsdemo, you will need to link to lib/sccts.lib and include common/* in your path.

This is a command-line application written in C. The options that affect the transformation itself are controlled via a text-based configuration file. The command line parameters include the TCP host and port where Transformation Server is running, as well as the input, output, and configuration files to be used.

The command-line syntax is as follows:

tsdemo ServerName PortNumber InputFile OutputFile ConfigurationFile [IO Type switch] [IOServerName]

Here is a guide to the valid command-line parameters for tsdemo:

  • ServerName: The host name or IP address where Transformation Server is running. (Required)

  • PortNumber: The port number on which Transformation Server will accept connections. (Required)

  • InputFile: The path/URL to the input file. This parameter requires either an absolute path to a file, or a path to a file that is relative to Transformation Suite's root install directory. (Required)

  • OutputFile: The path/URL to the output file. (Required)

  • ConfigurationFile: The desired output format. (Required)

  • IO Type: The type of IO specification used for the input and output parameters. May be a file system path (p), redirected (r), or URL (u). Default is p. (Optional)

    Note:

    Note for HTML Export: Even when u is specified for this parameter, tsdemo still expects a file path for the template and not a URL path.

  • IOServerName: Host name/IP address of where redirected IO is taking place, needed only when the source or sink uses redirected IO. (Optional)

Close Window

Table of Contents

Oracle Outside In Transformation Server Developer's Guide

Expand | Collapse