IBM Metal C

Examples

Example 4. Data Set Name Edit

I have frequently had the need to determine whether or not a data set name was a valid MVS data set name; not whether or not the data set existed, but whether the name was syntactically correct. Ordinarily, I would check for a length of up to 44 characters, segments of 8 characters, and characters of the allowed type, i.e. A-Z, 0-9, etc. I decided to develop a routine that I could call with the data set name as input, and receive a pass/fail indicator as to the validity of the name. Using an LL(k) parser tool called ANTLR, I created an Extended Backus–Naur Form (EBNF) grammar for an MVS data set name. After testing the grammar, I created a C lexer for the grammar, then converted the program to HLASM with Metal C.

The call signature for the routine vdsname is shown below. There are two structs passed by address to the routine. The first struct is used to pass the dsname to be verified as well as to return other information. The second struct is used as a work area (240 bytes) for the routine and for reentrancy. The dsname to be verified is stored in inputDsname, a 44 byte character field (not null terminated). Upon return, the struct contains the following:

Type Signature

extern int vdsname(struct dsnameData *, struct parserInfo *);

Testing the routine for performance, a 40 character data set name was passed to the routine. Calling the routine repeatedly 1,000,000 times took 67.54 CPU seconds, or about 68μ seconds per call, on a zEnterprise 114 3.8GHz processor.