/*
** FACILITY:
**
** CMS_EVENT.C
**
** ABSTRACT:
**
** Event handler for CMS ACTION ACE mechanism - sets 3 global symbols:
**
** CMS$$EVENT_LIBRARY_SPEC - library_specification_id;
** = CMS Library Specification
** CMS$$EVENT_PARAMETER_ID - ace_parameter_id;
** = the PARAMETER clause (any string value specified on the ACE)
** CMS$$EVENT_HISTORY_RECORD - history_record_id;
** = The history line
**
** then calls CMS$HANDLER:CMS_ACTION.COM.
*/
#include <descrip.h>
#include <lib$routines.h>
#include <ssdef.h>
#include <stdio.h>
#include <string.h>
#define BUF_SIZE 2048
#define DEL 127
#define LDB_SIZE 50
#define LIB$K_CLI_GLOBAL_SYM 2
typedef struct dsc$descriptor_s DESCRIPTOR;
#define DESC_BLD(name) DESCRIPTOR name = {0,DSC$K_DTYPE_T,DSC$K_CLASS_D,0}
#define DESC_FIL(name,str) \
name.dsc$w_length = strlen(str); \
name.dsc$a_pointer = str
/*
** CMS$EVENT_ACTION should follow the rules for callback routines. The
** routine calling format and arguments are described in CMS Guide, section
** 8.1.3 "Using Your Own Event Handler"
*/
CMS$EVENT_ACTION(
library_data_block, /* LDB for the current library */
user_param, /* user_arg value from callable CMS routine */
library_specification_id, /* string id for CMS library directory spec */
ace_parameter_id, /* string id from PARAMETER clause of ACE */
history_record_id) /* string id from history record */
/*
** Allocating space for the library data block (LDB). The LDB is a user-
** allocated structure, CMS uses to maintain information about the library.
*/
int library_data_block [LDB_SIZE];
int user_param;
DESCRIPTOR **library_specification_id;
DESCRIPTOR **ace_parameter_id;
DESCRIPTOR **history_record_id;
{
int i;
int status;
char hist_rec [BUF_SIZE];
DESCRIPTOR hist_id;
$DESCRIPTOR(command,"@CMS$HANDLER:CMS_ACTION.COM");
$DESCRIPTOR(library_symb,"CMS$$EVENT_LIBRARY_SPEC");
$DESCRIPTOR(history_symb,"CMS$$EVENT_HISTORY_RECORD");
$DESCRIPTOR(param_symb,"CMS$$EVENT_PARAMETER_ID");
DESC_BLD(history_desc);
hist_id = **history_record_id;
/* Get history record specification */
strncpy ( hist_rec, hist_id.dsc$a_pointer, hist_id.dsc$w_length);
/* Change embedded 'DEL' characters to spaces */
for (i=hist_id.dsc$w_length; i>=0; i--)
{
if (hist_rec[i] == DEL)
{
hist_rec[i] = ' ';
}
}
DESC_FIL(history_desc, hist_rec);
/* Set the symbols */
status = lib$set_symbol(¶m_symb, *ace_parameter_id,
&LIB$K_CLI_GLOBAL_SYM);
if (! (status & SS$_NORMAL))
{
lib$signal(status);
return status;
}
status = lib$set_symbol(&library_symb, *library_specification_id,
&LIB$K_CLI_GLOBAL_SYM);
if (! (status & SS$_NORMAL))
{
lib$signal(status);
return status;
}
status = lib$set_symbol(&history_symb, &history_desc,
&LIB$K_CLI_GLOBAL_SYM);
if (! (status & SS$_NORMAL))
{
lib$signal(status);
return status;
}
/* Call the command procedure */
status = lib$spawn (&command);
if (! (status & SS$_NORMAL))
{
lib$signal(status);
return status;
}
/* Delete the symbols */
lib$delete_symbol(&library_symb,&LIB$K_CLI_GLOBAL_SYM);
lib$delete_symbol(&history_symb,&LIB$K_CLI_GLOBAL_SYM);
lib$delete_symbol(¶m_symb,&LIB$K_CLI_GLOBAL_SYM);
return SS$_NORMAL;
}
|