Use this template to create your own language environments.
Figure 2. Language Environment Template
/**********************************************************************/ /* */ /* File Name */ /* */ /* Description */ /* */ /* Functions */ /* */ /* Entry Points */ /* */ /* Change Activity */ /* */ /* Flag Reason Date Developer Description */ /* ------ ---------- -------- ------------ ---------------------- */ /* */ /**********************************************************************/ /*--------------------------------------------------------------------*/ /* Includes */ /*--------------------------------------------------------------------*/ #include "dtwle.h"
/*--------------------------------------------------------------------*/ /* */ /* Function */ /* dtw_initialize */ /* */ /* Purpose */ /* */ /* Format */ /* int dtw_initialize(dtw_lei_t *le_interface) */ /* */ /* Parameters */ /* le_interface A pointer to a structure containing the */ /* following fields: */ /* */ /* function_name */ /* flags */ /* exec_statement */ /* parm_data_array */ /* default_error_message */ /* le_opaque_data */ /* row */ /* */ /* Returns */ /* Success ....... 0 */ /* Failure ....... 0 */ /*--------------------------------------------------------------------*/ int dtw_initialize(dtw_lei_t *le_interface) { return rc; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* dtw_execute */ /* */ /* Purpose */ /* */ /* Format */ /* int dtw_execute(dtw_lei_t *le_interface) */ /* */ /* Parameters */ /* le_interface A pointer to a structure containing the */ /* following fields: */ /* */ /* function_name */ /* flags */ /* exec_statement */ /* parm_data_array */ /* default_error_message */ /* le_opaque_data */ /* row */ /* */ /* Returns */ /* Success ....... 0 */ /* Failure ....... 0 */ /*--------------------------------------------------------------------*/ int dtw_execute(dtw_lei_t *le_interface) { /*----------------------------------------------------------------*/ /* Determine if %exec statement was specified. */ /*----------------------------------------------------------------*/ if (le_interface->flags & DTW_STMT_EXEC) { /*------------------------------------------------------------*/ /* Parse the %exec statement */ /*------------------------------------------------------------*/ rc = processExecStmt(le_interface->exec_statement); if (rc) { } } else { /*------------------------------------------------------------*/ /* Parse the inline data */ /*------------------------------------------------------------*/ rc = processInlineData(le_interface->exec_statement); if (rc) { } } /*----------------------------------------------------------------*/ /* Parse the input parameters */ /*----------------------------------------------------------------*/ rc = processInputParms(le_interface->parm_data_array); if (rc) { } /*----------------------------------------------------------------*/ /* Process the request */ /*----------------------------------------------------------------*/ rc = processRequest(); if (rc) { } /*----------------------------------------------------------------*/ /* Process the output data */ /*----------------------------------------------------------------*/ rc = processOutputParms(le_interface->parm_data_array); if (rc) { } /*----------------------------------------------------------------*/ /* Process the return code and default error message */ /*----------------------------------------------------------------*/ if (rc) { setErrorMessage(rc, &(le_interface->default_error_message)); } /*----------------------------------------------------------------*/ /* Cleanup and exit program. */ /*----------------------------------------------------------------*/ return rc; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* dtw_getNextRow */ /* */ /* Purpose */ /* */ /* Format */ /* int dtw_getNextRow(dtw_lei_t *le_interface) */ /* */ /* Parameters */ /* le_interface A pointer to a structure containing the */ /* following fields: */ /* */ /* function_name */ /* flags */ /* exec_statement */ /* parm_data_array */ /* default_error_message */ /* le_opaque_data */ /* row */ /* */ /* Returns */ /* Success ....... 0 */ /* Failure ....... 0 */ /*--------------------------------------------------------------------*/ int dtw_getNextRow(dtw_lei_t *le_interface) { return rc; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* dtw_cleanup */ /* */ /* Purpose */ /* */ /* Format */ /* int dtw_cleanup(dtw_lei_t *le_interface) */ /* */ /* Parameters */ /* le_interface A pointer to a structure containing the */ /* following fields: */ /* */ /* function_name */ /* flags */ /* exec_statement */ /* parm_data_array */ /* default_error_message */ /* le_opaque_data */ /* row */ /* */ /* Returns */ /* Success ....... 0 */ /* Failure ....... 0 */ /*--------------------------------------------------------------------*/ int dtw_cleanup(dtw_lei_t *le_interface) { /*----------------------------------------------------------------*/ /* Determine if this is normal or abnormal termination. */ /*----------------------------------------------------------------*/ if (le_interface->flags & DTW_END_ABNORMAL) { /*------------------------------------------------------------*/ /* Do abnormal termination cleanup. */ /*------------------------------------------------------------*/ } else { /*------------------------------------------------------------*/ /* Do normal termination cleanup. */ /*------------------------------------------------------------*/ } return rc; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* processInputParms */ /* */ /* Purpose */ /* */ /* Format */ /* unsigned long processInputParms(dtw_parm_data_t *parm__data) */ /* */ /* Parameters */ /* dtw_parm_data_t *parm_data */ /* */ /* Returns */ /* Success ..... 0 */ /* Failure ..... */ /* */ /*--------------------------------------------------------------------*/ unsigned long processInputParms(dtw_parm_data_t *parm_data) { /*----------------------------------------------------------------*/ /* Loop through all the variables in the parameter data array. */ /* The array is terminated by a NULL entry, meaning the parm_name */ /* field is set to NULL, the parm_value field is set to NULL, and */ /* the parm_descriptor field is set to 0. However, the only valid */ /* check for the end of the parameter data array is to check */ /* parm_descriptor == 0, since the parm_name field is NULL when a */ /* literal string is passed in, and the parm_value field is set */ /* to NULL when an undeclared variable is passed in. */ /*----------------------------------------------------------------*/ for (; parm_data->parm_descriptor != 0; ++parm_data) { /*------------------------------------------------------------*/ /* Determine the usage of each input parameter. */ /*------------------------------------------------------------*/ switch(parm_data->parm_descriptor & DTW_USAGE) { case(DTW_IN): /*----------------------------------------------------*/ /* Determine the type of each input parameter. */ /*----------------------------------------------------*/ switch (parm_data->parm_descriptor & DTW_TYPE) { case DTW_STRING: break; case DTW_TABLE: break; default: /*--------------------------------------------*/ /* Internal error - unknown data type */ /*--------------------------------------------*/ break; } break; case(DTW_OUT): break; case(DTW_INOUT): break; default: /*----------------------------------------------------*/ /* Internal error - unknown usage */ /*----------------------------------------------------*/ break; } } return rc; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* processOutputParms() */ /* */ /* Purpose */ /* */ /* Format */ /* unsigned long processOutputParms(dtw_parm_data_t *parm_data) */ /* */ /* Parameters */ /* dtw_parm_data_t *parm_data */ /* */ /* Returns */ /* Success ........ 0 */ /* Failure ........ -1 */ /* */ /*--------------------------------------------------------------------*/ unsigned long processOutputParms(dtw_parm_data_t *parm_data) { /*----------------------------------------------------------------*/ /* Get output data in some language environment-specific manner. */ /* This is entirely dependent on what the language environment */ /* is interfacing to, and how the LE chooses to interface to it. */ /*----------------------------------------------------------------*/ / /*----------------------------------------------------------------*/ /* Loop through all the parms in the parameter data array, */ /* looking for output parameters. */ /*----------------------------------------------------------------*/ for (; parm_data->parm_descriptor != 0; ++parm_data) { /*------------------------------------------------------------*/ /* Determine usage of each parameter. */ /*------------------------------------------------------------*/ if (pd_i->parm_descriptor & DTW_OUT) { /*--------------------------------------------------------*/ /* Determine the type of each input parameter. */ /*--------------------------------------------------------*/ switch (pd_i->parm_descriptor & DTW_TYPE) { case DTW_STRING: /*------------------------------------------------*/ /* Give a string parameter a new value. If the */ /* parameter value is not currently NULL, the */ /* storage must be freed using an LE interface */ /* utility function if it was allocated by */ /* Net.Data. */ /*------------------------------------------------*/ if (parm_data->parm_value != NULL) dtw_free(parm_data->parm_value); parm_data->parm_value = dtw_strdup(newValue); break; case DTW_TABLE: /*------------------------------------------------*/ /* Change the size of a table parameter. Use the */ /* LE interface utility functions to modify the */ /* table object. */ /*------------------------------------------------*/ /*------------------------------------------------*/ /* First get the pointer to the table object. */ /*------------------------------------------------*/ void *myTable = (void *) parm_data->parm_value; /*------------------------------------------------*/ /* Next get the current size of the table. */ /*------------------------------------------------*/ cols = dtw_table_Cols(myTable); rows = dtw_table_Rows(myTable); /*------------------------------------------------*/ /* Now set the new size (assumes the new size */ /* values are valid). */ /*------------------------------------------------*/ /*------------------------------------------------*/ /* Set the columns first. */ /*------------------------------------------------*/ if (cols > newColValue) { dtw_table_DeleteCol(myTable, newColValue + 1, cols - newColValue); } else if (cols < new_col_value) { dtw_table_InsertCol(myTable, cols, newColValue - cols); } /*------------------------------------------------*/ /* Now set the rows. */ /*------------------------------------------------*/ if (newColValue > 0) { if (rows > newRowValue) { dtw_table_DeleteRow(myTable, newRowValue + 1, rows - newRowValue); } else if (rows < new_row_value) { dtw_table_InsertRow(myTable, rows, newRowValue - rows); } } /*------------------------------------------------*/ /* Now get the last row/column value. */ /*------------------------------------------------*/ dtw_table_GetV(myTable, &myValue;, newRowValue, newColValue); /*------------------------------------------------*/ /* Delete the last row/column value. */ /*------------------------------------------------*/ dtw_table_SetV(myTable, NULL, newRowValue, newColValue); /*------------------------------------------------*/ /* Set the last row/column value. */ /*------------------------------------------------*/ dtw_table_SetV(myTable, dtw_strdup(myNewValue), newRowValue, newColValue); break; default: /*------------------------------------------------*/ /* Internal error - unknown data type */ /*------------------------------------------------*/ break; } } } return 0; } /*--------------------------------------------------------------------*/ /* */ /* Function */ /* setErrorMessage() */ /* */ /* Purpose */ /* */ /* Format */ /* unsigned long setErrorMessage(int returnCode, */ /* char **defaultErrorMessage) */ /* */ /* Parameters */ /* int returnCode */ /* char **defaultErrorMessage */ /* */ /* Returns */ /* Success ........ 0 */ /* Failure ........ -1 */ /* */ /*--------------------------------------------------------------------*/ unsigned long setErrorMessage(int returnCode, char **defaultErrorMessage) { /*----------------------------------------------------------------*/ /* Set the default error message based on the return code. */ /*----------------------------------------------------------------*/ switch(returnCode) { case LE_SUCCESS: break; case LE_RC1: *defaultErrorMessage = dtw_strdup(LE_RC1_MESSAGE_TEXT); break; case LE_RC2: *defaultErrorMessage = dtw_strdup(LE_RC2_MESSAGE_TEXT); break; case LE_RC3: *defaultErrorMessage = dtw_strdup(LE_RC3_MESSAGE_TEXT); break; case LE_RC4: *defaultErrorMessage = dtw_strdup(LE_RC4_MESSAGE_TEXT); rc = LE_RC1INTERNAL; break; } return 0; } |