/***********************************************************************
* *
* 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 file search
*/
#include "jcllib.h"
#include <ctype.h>
#include <ls.h>
static struct /* directory list state */
{
} state;
/*
* return >0 if path is a regular file
*/
static int
{
register char* s;
register char* t;
goto found;
s++;
else
s = path;
while (*s && !isupper(*s))
s++;
if (*s)
{
for (s = t + (s - path); *s; s++)
if (isupper(*s))
*s = tolower(*s);
{
goto found;
}
}
return 0;
/*
* catch recursive includes
*/
do
{
return 0;
return 1;
}
/*
* expand ${...} in name
* return expanded value returned in jcl->vp
* jcl->tp may be clobbered
*/
char*
{
register char* s;
register char* t;
register int c;
char* b;
char* v;
size_t n;
size_t p;
if (jcl)
for (s = (char*)name; *s; s++)
if (*s == '$' && *(s + 1) == '{')
{
if (n = s - (char*)name)
while (c = *s++)
if (c == '$' && *s == '{')
{
b = s;
s++;
if (*s == '%' && *(s + 1) == '%')
{
s += 2;
}
while ((c = *s++) && c != '}')
if (isdigit(*v) && !*(v + 1))
{
}
{
{
}
else
}
else if (flags & JCL_SYM_SET)
{
s = b;
}
}
else
return s;
}
return (char*)name;
}
/*
* append dir to jclfind() include list
*/
int
{
{
return 0;
{
return -1;
}
else
}
return 0;
}
/*
* check the jclinclude() directories
*/
static char*
{
register char* s;
{
return s;
}
if (*name != '/')
{
for (;;)
{
{
return s;
}
if (!jcl)
break;
}
}
return 0;
}
/*
* return path to name using jclinclude() list
* path allocated in jcl->vs
* !(flags&JCL_STANDARD) checks . and dir of including file
* level>0 is not found error message level
* { jcl->tp jcl->vp jcl->xp } may be clobbered
*/
char*
{
register char* s;
{
{
{
if (*spp)
return 0;
}
s = (char*)name;
goto save;
}
}
/*
* check the unadorned path first
* this handles . and absolute paths
*/
goto found;
if (*name != '/')
{
/*
* check the directory of the including file
* on the assumption that error_info.file is properly stacked
*/
{
goto found;
}
}
if (flags & JCL_CREATE)
{
if (spp)
*spp = 0;
s = (char*)name;
goto save;
}
return 0;
save:
}