jcl.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* jcl deck interpreter
*
* Glenn Fowler
* AT&T Research
*/
#include "jcl.h"
#include <tm.h>
static const char usage[] =
"[-?\n@(#)$Id: jcl (AT&T Research) 2006-11-11 $\n]"
"[+NAME?jcl - jcl deck interpreter]"
"[+DESCRIPTION?\bjcl\b interprets the JCL decks named by the \afile\a"
" operands. The standard input is read if no \afile\a operands"
" are specified. If \b--map\b is not specified then"
" operands override any values specified JCL decks.]"
"[+?control-M scheduler auto edit variable \b%%\b\aname\a values"
" or by \b%%\b\aname\a=\avalue\a on the command line.]"
"[d:debug?Set the debug trace level. Higher levels produce more"
" output.]#[level]"
"[g:global?Like \b--map\b=\afile\a except that the default "
JCL_MAPFILE ", if it exists, is still read after the command"
" line options are processed.]:[file]"
"[i:import?Environment variable definitions take precedence over"
" corresponding \b--map\b file definitions.]"
"[I:include?Search \adirectory\a for DSN names. More than one"
" \b--include\b option may be specified.]:[directory]"
"[k:marklength?Mark fixed length record file names by appending"
" \b%\b\alrecl\a to the names.]"
"[l:list?List all referenced \aitem\as. Only the last \b--list\b"
" \aitem\a is listed. \aitem\a may be:]:[item]{"
" [a:autoedit?List the %%\aname\a autoedit variables.]"
" [c:count?List the \aitem\a dup counts too.]"
" [e:exec?List the EXEC job and command names.]"
" [i:inputs?List the DD input data file paths.]"
" [o:outputs?List the DD output data file paths.]"
" [p:programs?List the EXEC PGM=\aprogram\a program names.]"
" [s:scripts?List the EXEC [PROC=]]\ascript\a script names.]"
" [v:variables?List the &\aname\a variables.]"
"}"
"[m:map?Read the dataset file path prefix map \afile\a. Each line in \afile\a"
" contains an operation followed by 0 or more space separated fields."
" \b#\b in the first column denotes a comment; comments and blank lines"
" If \afile\a is not found and contains no \b/\b then"
" is read after the command line options are processed. The operations"
" are:]:[file]{"
" [+export \aname\a=\avalue ...?Set export variable values."
" Export variable expansions are preserved in the"
" generated scripts.]"
" [+map \aprefix\a \amap\a [\asuffix\a]]?Dataset paths are"
" mapped by doing a longest prefix match on the"
" prefixes. The matching dataset prefix is replaced"
" by \amap\a, and \asuffix\a, if specified, is"
" appended. The prefix \b\"\"\b matches when no other"
" prefix matches. Leading \b*.\b and trailing \b.*\b"
" match any \b.\b-separated component. \b${\b\an\a\b}\b"
" in \amap\a expands to the component matched by the"
" \an\a-th \b*\b in \aprefix\a, counting from 1, left"
" to right.]"
" [+set --[no]]\aoption\a[=\avalue]] ...?Set command line options.]"
" [+set %%\aname\a=\avalue ...?Set auto edit variable values.]"
" [+set \aname\a=\avalue ...?Set variable values.]"
" }"
"[n!:exec?Enable command execution. \b--noexec\b disables.]"
"[N:never?Disable all command and recursive script execution.]"
"[p:parameterize?Parameterize simple &\aname\a variable references by"
" substituting the \bsh\b(1) equivalent ${\aname\a}.]"
"[r:resolve?Resolve each operand as a path name using the \b--map\b files"
" and print the resulting path on the standard output, one path per line.]"
"[s:subdir?Execute each job in a separate subdirectory named"
" \ajobname\a.\ayy-mm-dd.n\a]]. \an\a starts at \b1\b and"
" is incremeted by \b1\b for each run of \ajobname\a within"
" the same day.]"
"[v:verbose?For \b--noexec\b the equivalent \bsh\b(1) script is listed"
" on the standard output. For \b--exec\b verbose execution output,"
" like start and completion times, is enabled.]"
"[w:warn?Enable verbose warning messages.]"
"[x:trace?Enable command execution trace.]"
"[O:odate?Set the control-M original date to \adate\a.]:[date:=now]"
"[R:rdate?Set the control-M current run date to \adate\a.]:[date:=now]"
"[S:date?Set the control-M system date to \adate\a.]:[date:=now]"
"\n"
"\n[ name=value ... ] [ file ... ]\n"
"\n"
"[+FILES]{"
"}"
"[+SEE ALSO?\bsh\b(1)]"
;
#include <tm.h>
struct Map_s
{
char* arg;
int map;
};
typedef struct State_s
{
int resolve;
} State_t;
static int
{
unsigned long f;
char* s;
time_t* t;
Map_t* p;
switch (c)
{
case 'd':
return 1;
case 'g':
case 'm':
{
return 0;
}
p->map = c == 'm';
else
return 1;
case 'i':
f = JCL_IMPORT;
break;
case 'I':
return 1;
case 'k':
f = JCL_MARKLENGTH;
break;
case 'l':
{
case 'a':
break;
case 'c':
break;
case 'e':
break;
case 'i':
break;
case 'o':
break;
case 'p':
break;
case 's':
break;
case 'v':
break;
}
return 1;
case 'n':
return 1;
case 'N':
return 1;
case 'O':
date:
if (*s)
{
return 0;
}
return 1;
case 'p':
f = JCL_PARAMETERIZE;
break;
case 'r':
return 1;
case 'R':
goto date;
case 's':
f = JCL_SUBDIR;
break;
case 'S':
goto date;
case 'v':
f = JCL_VERBOSE;
break;
case 'w':
f = JCL_WARN;
break;
case 'x':
f = JCL_TRACE;
break;
case ':':
return 0;
case '?':
return 0;
}
{
else
}
return 1;
}
int
{
char* s;
char* t;
Map_t* p;
int c;
{
if (error_info.errors)
argv++;
c = 0;
{
return 1;
c |= p->map;
free(p);
}
return 1;
{
while (s = *argv++)
else
}
else
{
}
}
c = 1;
return c;
}