/***********************************************************************
* *
* 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
static const char usage[] =
"[-?\n@(#)$Id: jcm (AT&T Research) 2006-08-16 $\n]"
"[+NAME?jcm - job control-M deck converter]"
"[+DESCRIPTION?\bjcm\b converts the control-M job scheduler decks named by"
" the \afile\a operands to an \bnmake\b(1) makefile on the"
" standard output. The standard input is read if no \afile\a"
" operands are specified.]"
"[c:cards?List control card lines instead of the generated makefile on the"
" standard output.]"
"[d:debug?Set the debug trace level. Higher levels produce more"
" output.]#[level]"
"[h:comment?Include H card comments in the generated output.]"
"[i:initialize?Initialize variable values from \aidentifier\a=\avalue\a "
"lines in \afile\a. \afile\a may contain # style comments.]:[file]"
"[I:index?Expand the first input condition to the condition plus "
"\aindex\a-1 conditions suffixed by \b-%02d\b from 1 through "
"\aindex\a-1.]#[index]"
"[l:lowercase?Convert job and library names to lower case.]"
"[v:verbose?Enable verbose tracing.]"
"[T:test?Implementation-specific test and tracing bitmask.]#[test-mask]{"
" [+0x0010?List `-' OUT dependents (these are marked for delete).]"
"}"
"\n"
"\n[ file ... ]\n"
"\n"
"[+SEE ALSO?\bjcl\b(1), \bnmake\b(1)]"
;
#include <ast.h>
#include <cdt.h>
#include <ccode.h>
#include <ctype.h>
#include <error.h>
#include <jcl.h>
#include <vmalloc.h>
#define circular(p) (strneq((p)->value, "$(", 2) && strneq((p)->value + 2, JCL_AUTO, sizeof(JCL_AUTO) - 1) && strneq((p)->value + sizeof(JCL_AUTO) + 1, (p)->name, strlen((p)->name)) && streq((p)->value + sizeof(JCL_AUTO) + strlen((p)->name) + 1, ")"))
struct Jcmcard_s
{
};
struct Jcmvar_s
{
unsigned long dup;
int init;
char* value;
};
struct Jcmlib_s
{
};
struct Jcmset_s
{
char* value;
};
struct Jcmshout_s
{
int when;
int pri;
};
struct Jcmjob_s
{
int namelen;
int relationship;
char* docmem;
char* name;
char* tag;
};
struct Jcmlist_s
{
};
struct Jcmevent_s
{
unsigned long dup;
int mark;
};
static struct State_s
{
char* data;
char* last;
unsigned long pseudo;
unsigned long test;
int cards;
int comment;
int index;
int lowercase;
int portable;
int verbose;
} state;
static void
nospace(void)
{
}
static char*
stash(const char* s)
{
char* r;
if (!(r = strdup(s)))
nospace();
return r;
}
static void
lower(register char* s)
{
for (; *s; s++)
if (isupper(*s))
*s = tolower(*s);
}
static void
upper(register char* s)
{
for (; *s; s++)
if (islower(*s))
*s = toupper(*s);
}
static char*
{
register const char* e = s + n;
while (s < e && *s && *s != ' ')
*t++ = *s++;
*t = 0;
return t;
}
static char*
{
register char* s;
register char* t;
register int c;
register int o;
size_t z;
size_t n;
size_t m;
z = CARD;
for (;;)
{
{
nospace();
}
break;
error_info.line++;
o = *(unsigned char*)s;
break;
if (c != o)
{
break;
}
{
{
break;
}
{
break;
}
}
z = CARD - 1;
}
return 0;
*s = 0;
if (!*--s)
*s = ' ';
}
static const char*
prefix(const char* s, const char* e, int d)
{
register Jcmvar_t* v;
register int n;
n = (e ? (e - s) : strlen(s)) + 1;
if (*v->name != *s)
{
return s + n;
}
while (s < e && *s != d && isalnum(*s))
s++;
return s;
}
static char*
parameterize(register Sfio_t* sp, register const char* s, register const char* e, int append, int index)
{
register int c;
register int d;
register const char* t;
if (e)
d = ' ';
else
{
e = s + strlen(s);
d = 0;
}
while (s < e && (c = *s++) != d)
{
if (c == '~' && s < e && *s != d)
{
switch (c = *s++)
{
case '#':
break;
case '@':
break;
case '&':
break;
case '!':
break;
default:
{
s = t;
}
else
break;
}
c = ')';
}
else if (c == '%' && s < e && *s == c)
{
c = ')';
}
c = '_';
}
if (index)
if (append)
{
nospace();
}
nospace();
return (char*)s;
}
static Jcmevent_t*
{
if (s)
{
{
if (!uniq)
{
return event;
}
}
}
else
nospace();
if (d)
return event;
}
static Jcmjob_t*
getjob(const char* s)
{
nospace();
return job;
}
static Jcmvar_t*
{
{
return var;
}
else
{
nospace();
}
return var;
}
static Jcmlib_t*
getlib(const char* s)
{
register char* t;
if (!*name)
return 0;
{
nospace();
{
do
{
}
}
return lib;
}
static Jcmlist_t*
{
register Jcmlist_t* p;
register Jcmlist_t* q;
{
return list;
if (!p->next)
break;
}
nospace();
if (p)
{
p->next = q;
return list;
}
return q;
}
static void
assert(register Jcmjob_t* job, register Jcmlist_t* reqs, register Jcmlist_t* deps, Jcmevent_t* group)
{
if (group)
}
static int
{
register char* s;
register char* t;
register char* e;
register int i;
char* file;
{
return -1;
}
error_info.line = 0;
{
error_info.line++;
while (isspace(*s))
s++;
if (!*s || *s == '#')
continue;
i = 0;
for (t = s; *s; s++)
if (*s == '=')
{
i = 1;
*s++ = 0;
break;
}
else if (isspace(*s) && !i)
{
i = -1;
*s = 0;
}
if (i > 0 && isalpha(*t))
{
while (isspace(*s))
s++;
while (e > s && isspace(*(e - 1)))
e--;
*e = 0;
t += sizeof(JCL_AUTO) - 1;
if (*t)
setvar(t, s, 1);
}
else
}
return 0;
}
static void
{
register Jcmlist_t* p;
register Jcmset_t* v;
{
{
}
else
{
if (v->value)
else
}
}
else
{
}
}
int
{
register char* file;
register char* s;
register char* t;
unsigned char* map;
int n;
int index;
nospace();
nospace();
index = 0;
for (;;)
{
{
case 'c':
continue;
case 'd':
continue;
case 'h':
continue;
case 'i':
return 1;
continue;
case 'I':
continue;
case 'l':
continue;
case 'p':
continue;
case 'v':
continue;
case 'T':
continue;
case ':':
break;
case '?':
break;
}
break;
}
if (error_info.errors)
{
n = 0;
{
n = 1;
}
if (n)
}
do
{
if (!file)
{
continue;
}
error_info.line = 0;
{
{
continue;
}
nospace();
if (lastcard)
else
}
{
job = 0;
do
{
{
continue;
}
switch (s[0])
{
case 'B':
/* XXX: unknown per-job sparse */
break;
case 'C':
/* XXX: event control */
break;
case 'D':
case 'J':
case 'K':
case 'W':
/* XXX: cron info */
break;
case 'E':
/* XXX: event relationships */
break;
case 'G':
/* XXX: group info */
break;
case 'H':
break;
case 'I':
if (job)
{
if (index)
{
s++;
for (n = 0; n < index; n++)
s += 23;
}
for (s++; *s; s += 24)
}
break;
case 'L':
if (job)
break;
case 'M':
if (s[60] == 'G')
{
job = 0;
}
else
{
}
break;
case 'N':
if (job)
break;
case 'O':
if (job)
{
if (*(s + 4) == '-')
{
*t = 0;
}
for (s++; *s; s += 25)
}
break;
case 'Q':
for (s++; *s; s += 24)
break;
case 'R':
/* XXX: unknown per-job sparse */
break;
case 'S':
if (job)
{
s++;
while (*s)
{
nospace();
if (lastshout)
else
*t++ = *s;
*t = 0;
n = 0;
while (*s >= '0' && *s <= '9')
n = n * 10 + (*s++ - '0');
s += n;
}
}
break;
case 'T':
if (job)
{
n = strlen(s) + 2;
nospace();
{
*s++ = 0;
}
else
if ((!(var = (Jcmvar_t*)dtmatch(state.vars, set->name)) || !var->init) && (!(global = (Jcmset_t*)dtmatch(state.set, set->name)) || streq(global->value, set->value) || circular(set)))
{
if (!global)
{
nospace();
}
}
{
}
else
}
break;
case 'V':
if (job)
break;
case 'Z':
if (job)
{
}
break;
default:
break;
}
}
error_info.file = 0;
error_info.line = 0;
{
}
return error_info.errors != 0;
}