System SAMPLIB member DFMXAGNT, for example, SYS1.SAMPLIB(DFMXAGNT)
shown in Figure 1, contains the DFM
DataAgent sample routine.
Figure 1. DFM DataAgent Sample Routine Part 1 of 5/*********************************************************************
* PROPRIETARY V3 STATEMENT *
* LICENSED MATERIALS - PROPERTY OF IBM *
* 5695-DF1 *
* (C) COPYRIGHT 1997 IBM CORP. *
* END PROPRIETARY V3 STATEMENT *
*********************************************************************/
/*********************************************************************
* *
* $MOD(DFMXAGNT) COMP(5695-DF120) *
* *
* MODULE NAME: DFMXAGNT *
* *
* DESCRIPTION: DFM DataAgent Sample Routine *
* *
* STATUS: Version 1 Release 4.0 (DFSMS) *
* *
* COPYRIGHT: See the copyright statement on the previous page.*
* *
* FUNCTION: This module illustrates how a DFM DataAgent can *
* be written in C. It gets control at file declaration time *
* and sets the reason code so that it will also get control *
* when the file declaration is deleted. Its sole function is *
* to issue printf statements displaying the parameters if its *
* internal debug flag is set. *
* *
* You can use the C compiler and your installation's linkedit *
* JCL to build the DFMXAGNT executable code on the mainframe. *
* *
* You can then copy DFMX0001 to produce a proclib *
* member (proclib member name is also referred to as the *
* DFM DataAgent name). You could then invoke the DataAgent *
* by means of the DFMACALL sample application provided by *
* SdU. (An analogous procedure is given by the installation *
* sample DFMXSRTI but in this case you might call the load *
* module DFMXAGNT and copy DMFX0001 to build PROCLIB(DFMXAGNT) *
* so that "dfmacall agent x:filename dfmxagent" could be used *
* to invoke it from the workstation.) *
* *
* An installation sample is not provided in order to *
* demonstrate that the manual process as outlined above is *
* straight-forward and because this sample would probably not *
* be used without significant changes anyway. *
* *
Figure 2. DFM DataAgent Sample Routine Part 2 of 5* PROCESSING: *
* *
* LOGIC: *
* Refer to block comments in the code. *
* *
* ERROR PROCESSING: *
* Issue a printf and then return with register 15 set to a *
* non-zero value and with the reason code in the extended *
* parameter list set to a unique value. *
* *
* NOTES: *
* *
* PATCH SPACE: None *
* XAX CONSIDERATIONS: AMODE(31) RMODE(ANY) ENV(PRI) *
* DEPENDENCIES: The Language Environment and the C runtime *
* library must be installed. *
* RESTRICTIONS: None *
* REGISTER CONVENTIONS: Standard conventions--refer to C *
* compiler documentation. *
* SERIALIZATION: No serialization techniques are used by this *
* module. *
* *
* MODULE TYPE: Procedure *
* PROCESSOR: C *
* ATTRIBUTES: *
* TYPE: Reentrant *
* PRIMARY ASID: Caller's ASID *
* SECONDARY ASID: Same as primary *
* HOME ASID: Same as primary *
* MODE: Task *
* KEY: 8 *
* STATE: Problem program *
* LOCATION: Link library *
* *
* ENTRY POINT: main *
* *
* PURPOSE: Show that a DataAgent routine can be written in C. *
* LINKAGE: Called by Distributed FileManager. *
* INPUT/OUTPUT: Refer to the DFM Guide and Reference for the *
* parameter list format. *
* *
* MESSAGES: Refer to printf statements. *
* *
* EXIT NORMAL: *
* RETURN CODE: Register 15 = 0 *
* REASON CODE: Not applicable *
* MESSAGE ID: None: *
Figure 3. DFM DataAgent Sample Routine Part 3 of 5* *
* EXIT ERRORS: *
* RETURN CODE: Register 15 = 8 *
* REASON CODE: Unique values set in the extended parameter *
* list *
* MESSAGE ID: See printf statements. *
* *
* EXTERNAL REFERENCES: None *
* *
* CHANGE ACTIVITY: *
* $L0=DFSMS14,HDZ11D0,960628,SJPLMMR: DFM DataAgent initial code *
*********************************************************************/
#pragma csect (static, "DFMXAGN")
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <string.h>
#pragma csect (code, "DFMXAGNT")
int main(argc, argv)
int argc; /* count of input parameters */
char **argv; /* input parameters */
{
int i; /* loop counter */
char dsname??(55??); /* data set name area */
int debug = 1; /* debug flag */
/******************************************************************/
/* Define additional parameter for DataAgent special processing */
/******************************************************************/
_Packed struct extra_parms {
short int extra_parms_len; /* length of extra parms */
/****************************************************************/
/* Basic section of the extra parameter structure */
/****************************************************************/
unsigned short int reserved; /* reserved field */
unsigned short int command_cp; /* command code point */
unsigned short int object_cp; /* object code point */
unsigned short int ofn_len; /* original filename length */
char ofn??(54??); /* original filename */
unsigned short int cfn_len; /* current/modified filename len */
char cfn??(54??); /* current/modified filename */
signed long int reason_code1; /* main reason code */
signed long int reason_code2; /* secondary reason code */
Figure 4. DFM DataAgent Sample Routine Part 4 of 5 /****************************************************************/
/* Any additions to the extra parameter structure in */
/* future DFSMS releases would go here. */
/****************************************************************/
} ep_area; /* extra parameters for DataAgent */
/* Define extra parameter instance */
struct extra_parms *p_extra;
/******************************************************************/
/* Begin DataAgent routine processing. */
/******************************************************************/
if (debug) {
/****************************************************************/
/* Display input parameters for debugging purposes. */
/****************************************************************/
printf ("DFMXAGNT: DataAgent routine entered.\n");
if (argc > 0) {
/**************************************************************/
/* Display standard parameters and the program name. */
/**************************************************************/
printf(" \n");
printf ("Parameters passed were the following:\n");
{
for (i = 1; i < argc; i++)
printf (" %s\n",argv??(i??));
}
/**************************************************************/
/* DataAgent has access to an extra parameter list in addition*/
/* to the standard format MVS parameter list. This parameter */
/* list is defined by the structure agent_parms. */
/**************************************************************/
/* Locate the extra parameters. */
/**************************************************************/
DFMXLPRM("DFMXAGNT",&p_extra);
if (p_extra == NULL) {
/************************************************************/
/* No parameters--something went wrong. */
/************************************************************/
printf ("DFMXAGNT: No DataAgent parameters!!\n");
return 8; /* exit with error */
}
Figure 5. DFM DataAgent Sample Routine Part 5 of 5 if (p_extra->extra_parms_len >= sizeof(ep_area)) {
/************************************************************/
/* Print the basic section of the extra parameter list. */
/************************************************************/
printf (" \n");
printf ("Extra DataAgent parameters were:\n");
printf (" DDM command code point: %X\n",p_extra->command_cp);
printf (" DDM object code point: %X\n",p_extra->object_cp);
printf (" DDM current filename length: %d\n",
p_extra->cfn_len);
printf (" DDM current filename: %s\n",
strncpy(dsname, p_extra->cfn, p_extra->cfn_len));
printf (" DDM original filename length: %d\n",
p_extra->ofn_len);
printf (" DDM original filename: %s\n",
strncpy(dsname, p_extra->ofn, p_extra->ofn_len));
/************************************************************/
/* Force recall of the exit (for DELDCL, etc.) */
/************************************************************/
p_extra->reason_code1 = -1;
} /* End, basic section exists */
} /* End, parameters exist */
else {
/**************************************************************/
/* No parameters--something went wrong. */
/**************************************************************/
printf ("DFMXAGNT: No parameters?\n");
p_extra->reason_code1 = 2; /* set reason code */
return 8; /* exit with error */
} /* End of missing parameters */
} /* End of input parameter display */
/******************************************************************/
/* Any further DataAgent routine processing would go here. */
/******************************************************************/
return 0;
}