/***********************************************************************
* *
* 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 program exec and script loop
*/
#include "jcllib.h"
#include <coshell.h>
#include <errno.h>
#include <ls.h>
#include <tm.h>
#include <tmx.h>
/*
* if name contains invalid export id chars then
* return a new name with those chars converted to '_<XX>_'
*/
static char*
{
register int c;
register const char* s;
register char* t;
register int n;
char* b;
s = name;
c = *s++;
if (isalpha(c) || c == '_')
do
{
if (!(c = *s++))
return (char*)name;
} while (isalnum(c) || c == '_');
n = 1;
while (c = *s++)
if (!isalnum(c) && c != '_')
n++;
for (s = name; c = *s++;)
if (!isalnum(c) && c != '_')
else
*t++ = c;
*t = 0;
return b;
}
/*
* output dd dsname with &path => /tmp file map
*/
static char*
{
char* s;
if (*path == '&')
{
if (*++path == '&')
path++;
}
return s;
}
/*
* create dd dir if it doesn't exist
*/
static void
{
register char* s;
{
{
}
}
}
/*
* execution loop
*/
int
{
register char* s;
char* arg;
char* t;
Dtlink_t k;
int code;
int del;
int n;
int i;
double pct;
double real;
double user;
double sys;
unsigned long flags;
return -1;
{
if (!(co = coopen(pathshell(), (jcl->flags & (JCL_EXEC|JCL_TRACE)) == (JCL_EXEC|JCL_TRACE) ? CO_ANY : (CO_ANY|CO_SILENT), NiL)))
{
return -1;
}
start = tmxgettime();
}
code = 0;
{
{
}
{
{
n = 0;
for (;;)
{
break;
{
return -1;
}
}
{
return -1;
}
for (i = 0; i < elementsof(redirect); i++)
{
if ((n = open(redirect[i].file, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != redirect[i].fd)
{
close(n);
}
}
}
{
sfprintf(sfstdout, "n=0\nt=$(date +%%y-%%m-%%d)\nwhile :\ndo d=%s.$t.$((++n))\n [[ -d $d ]] || break\ndone\nmkdir $d && cd $d || exit 1\n", jcl->name);
sfputr(sfstdout, "exec > SYSOUT 2> SYSERR\nTIMEFORMAT='USAGE CPU=%P%% REAL=%R USR=%U SYS=%S'\ntime {\ndate +'STARTED AT %K'", '\n');
}
}
}
else
{
{
xx = 0;
break;
if (!xx)
{
code = -1;
goto bad;
}
}
{
{
break;
break;
}
if (dd)
{
{
if (!(s = getenv("TMPDIR")))
s = "/tmp";
}
else
}
}
{
{
{
}
}
{
}
{
}
}
break;
{
{
{
case JCL_DD_DIR:
break;
case JCL_DD_SYSIN:
break;
case JCL_DD_SYSOUT:
break;
case JCL_DD_SYSERR:
break;
default:
if (!(dd->flags & JCL_DD_DUMMY) && (jcl->flags & (JCL_EXEC|JCL_VERBOSE)) && dd->path && *dd->path != '&' && dd->disp[0] == JCL_DISP_NEW && (*dd->path != '$' || *(dd->path + 1) != '(') && (s = strrchr(dd->path, '/')))
{
*s = 0;
*s = '/';
}
break;
}
if ((dd->flags & (JCL_DD_MARKED|JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) == JCL_DD_MARKED && (dd->disp[0] == JCL_DISP_NEW || dd->disp[0] == JCL_DISP_MOD))
{
}
if ((dd->flags & (JCL_DD_MARKED|JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) == JCL_DD_MARKED && (dd->disp[0] == JCL_DISP_NEW || dd->disp[0] == JCL_DISP_MOD))
{
}
{
}
s = " \\\n";
{
}
{
s = " \\\n";
}
del = 0;
s = "";
if (!(dd->flags & (JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) && dd->disp[0] != JCL_DISP_NEW && dd->disp[0] != JCL_DISP_MOD)
{
s = " ";
}
if (!(dd->flags & (JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) && dd->disp[0] != JCL_DISP_NEW && dd->disp[0] != JCL_DISP_MOD)
{
s = " ";
}
s = "";
if (!(dd->flags & (JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) && (dd->disp[0] == JCL_DISP_NEW || dd->disp[0] == JCL_DISP_MOD))
{
s = " ";
}
{
if (!(dd->flags & (JCL_DD_SYSIN|JCL_DD_SYSOUT|JCL_DD_SYSERR|JCL_DD_REFERENCE)) && (dd->disp[0] == JCL_DISP_NEW || dd->disp[0] == JCL_DISP_MOD))
{
s = " ";
}
del |= 1;
del |= 2;
}
{
if (*s == '(')
{
if (*s == ',')
s++;
for (t = s + strlen(s); t > s && *--t == ' ';);
if (*t == ')')
*++t = 0;
else if (*t == ',')
*t = 0;
}
}
sfprintf(jcl->tp, " %s=%s", fmtquote(sym->name, "'", "'", strlen(sym->name), FMT_SHELL), fmtquote(sym->value, "$'", "'", strlen(sym->value), 0));
{
std[3] = 0;
}
sfprintf(jcl->tp, " <<%s\n%s%s", fmtquote(dd->dlm, "'", "'", strlen(dd->dlm), 1), dd->here, dd->dlm);
if (del)
{
if (del & 1)
{
}
if (del & 2)
{
if (del & 1)
else
}
}
}
{
{
code = -1;
break;
}
code = 0;
else if (!(cj = coexec(co, s, CO_APPEND, redirect[0].file, redirect[1].file, NiL)) || !(cj = cowait(co, cj, -1)))
code = 127;
else
}
else
code = 0;
if (code)
else
break;
}
}
bad:
{
}
{
{
s = "gdgupdate";
}
{
else
}
if ((jcl->flags & (JCL_EXEC|JCL_SUBDIR)) == (JCL_EXEC|JCL_SUBDIR) && chdir("..") && jcl->disc->errorf)
(*jcl->disc->errorf)(NiL, jcl->disc, ERROR_SYSTEM|2, "%s: cannot chdir to job subdirectory parent", subdir);
{
}
}
if (scope)
return code;
}