/*
* PSres.c
*
* (c) Copyright 1991-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Author: Adobe Systems Incorporated
*/
#include <stdio.h>
#include <stdlib.h>
#ifdef XENVIRONMENT
#else
#include <string.h>
#endif
#define USE_POSIX
#ifdef NeXT
#endif /* NeXT */
#ifdef USE_POSIX
#include <dirent.h>
#else
#endif
#ifndef PSRES_NAME
#endif /* PSRES_NAME */
#ifndef PSRES_EXT
#endif /* PSRES_EXT */
#ifndef SEEK_SET
#define SEEK_SET 0
#endif /* SEEK_SET */
/* MT is the right pointer type to pass to memcpy, MST the size type */
#define MT void *
typedef int (*ReadContentsFunction)();
typedef struct _ResourceNameStruct {
char *name;
char *file;
typedef struct _ResourceTypeStruct {
char *type;
int nameCount;
char *nameBuffer;
char **oldNameBuffers;
int oldNameCount;
typedef struct _ResourceDirectoryStruct {
char *directory;
int typeCount;
char *typeNameBuffer;
char *filePrefix;
long endOfHeader;
int exclusive;
typedef struct {
char *type;
char *name;
} TypeName;
typedef struct {
char *type;
char *name;
char *private;
int done;
/* Wrappers */
int size;
{
char *ret;
#ifdef XENVIRONMENT
#ifdef MALLOC_0_RETURNS_NULL
#endif
#else
#endif
exit(1);
return NULL;
}
char *ptr;
int size;
{
char *ret;
#ifdef XENVIRONMENT
#ifdef MALLOC_0_RETURNS_NULL
#endif
#else
#endif
#ifdef NO_VOID_STAR
#else
#endif
exit(1);
return NULL;
}
char *ptr;
{
#ifdef NO_VOID_STAR
#else
#endif
}
char *file;
char *extraInfo;
{
"Syntax error found in PostScript resource file %s:\n %s\n",
}
/* Just like fgets, but strips trailing newline, eliminates trailing comments,
skips trailing white space, skips blank lines, and chops lines longer
than size */
char *buf;
register int size;
FILE *f;
{
register int ch;
register int count = 0;
#define STRIP_BLANKS \
#define RETURN_BUF \
size--;
return NULL;
}
if (ch == '\n') {
}
do {
else RETURN_BUF;
}
}
count++;
}
/* Overflow, flush */
do {
else RETURN_BUF;
}
char *buf;
char dontDequote;
{
while (*src != '\0') {
if (*src == '\\') {
src++;
if (*src == '\0') {
*dst = '\0';
return 1;
}
}
*dst = '\0';
return 0;
}
/* Sep returns the first unquoted position of the break character. The
dontDequote character only applies after the break character. If the
separator character is doubled, doubleSep is set to 1 and only one
of the separators is installed */
char *buf;
char **sep;
char bchar;
char dontDequote;
int *doubleSep;
{
*doubleSep = 0;
while (*src != '\0') {
if (*src == '\\') {
src++;
if (*src == '\0') {
*dst = '\0';
return 1;
src++;
*doubleSep = 1;
}
}
}
*dst = '\0';
return 0;
}
FILE *f;
int *excl;
{
int count;
/* Compare against magic value */
if (count == 1) {
*excl = 1;
return version;
}
if (count == 1) {
*excl = 0;
return version;
}
return 0.0;
}
FILE *f;
{
int count, i;
typebuf[0] = '\0';
count = 0;
while (1) {
return 1;
}
}
else count++;
}
else {
}
len = 0;
for (i = 0; i < count; i++) {
}
return 0;
}
FILE *f;
char *dirName;
{
int continued;
int len;
long savePos;
char *prefix;
if (inBuf[0] != '/') {
return 0;
}
if (!continued) {
return 0;
}
while (1) {
if (!continued) {
return 0;
}
}
}
FILE *f;
{
float version;
int exclusive;
rewind(f);
if (ParseResourceTypes(f, dir)) {
return NULL;
}
return dir;
}
/* Store away old name buffer so pointers to it do not become invalid */
{
type->oldNameCount++;
type->oldNameCount);
}
/* Verify that the name matches the name in the file */
FILE *f;
char *name;
{
int continued = 0;
int len;
int start = 0;
while (1) {
if (continued) {
} else {
else break;
}
}
return 0;
}
char *name;
{
int i;
}
return 0;
}
char *type;
{
/* Insert the prefix unless one of these special values */
return 1;
}
/* Returns a line, including continuations. Memory must be copied before
calling this again. */
static int linebuflen = 0;
static char *ReadFullLine(f)
FILE *f;
{
int start = 0;
int len;
while (1) {
}
}
return inputline;
}
static void FreeLineBuf()
{
linebuflen = 0;
}
/* Assumes being correctly positioned in the file */
FILE *f;
char *name; /* If NULL, enumerate */
{
char *linein;
int start;
int len;
int i, count = 0;
char *sep;
int prefixLen;
int insertPrefix;
char dontDequote;
int doubleEquals;
int addingPrefix;
int newsize;
if (insertPrefix) {
dontDequote = '\0';
} else {
prefixLen = 0;
dontDequote = ',';
}
while (1) {
linein = ReadFullLine(f);
FreeLineBuf();
return 1;
}
/* If no separator, a bogus line */
/* Next line is UNIX specific! */
}
*sep = '\0';
if (addingPrefix) {
}
else count++;
}
else {
}
len = 0;
for (i = 0; i < count; i++) {
}
FreeLineBuf();
return 0;
}
/* Assumes being correctly positioned in the file */
FILE *f;
int checkName;
{
int i;
/* If next type has offset, just go there */
return 0;
} else break;
}
}
}
while (1) {
}
}
/* Assumes being correctly positioned in the file */
FILE *f;
char *name; /* If NULL, enumerate */
int checkName;
{
}
}
int everything;
{
ResourceType t;
int i, j;
for (i = 0; i < d->typeCount; i++) {
t = d->types + i;
FREE(t->nameBuffer);
t->nameCount = 0;
t->oldNameCount = 0;
t->nameCount = 0;
t->filled = 0;
}
}
if (!everything) return;
resDir = d;
}
lastResDir = NULL;
}
int len;
char *data;
{
FILE *f;
int fullLen;
if (f != NULL) {
lastResDir = rd;
(void) fclose(f);
}
return rd;
}
char *dirName;
char *data;
{
#ifdef USE_POSIX
struct dirent *d;
#else
struct direct *d;
#endif
static int extensionLen = 0;
int namelen;
if (namelen < extensionLen) continue;
}
}
}
/* Returns nonzero if current paths different from saved ones */
char *pathOverride;
char *defaultPath;
{
if (savedPathOverride == NULL ||
return 1;
}
return 0;
}
/* Like SetUpSavedPaths, but never affects saved state */
char *pathOverride;
char *defaultPath;
{
if (savedPathOverride == NULL ||
else return 0;
}
char *string;
char *data;
{
char *pathChar;
char *path;
register char *dir;
int len;
register char ch;
do {
do {
while (*pathChar == '\\') {
pathChar++;
}
if (*path == '\0') {
}
} else {
}
} while (ch == ':');
return latestTime;
}
char *string;
{
char *pathChar;
char *path;
register char *dir;
int len;
register char ch;
do {
do {
while (*pathChar == '\\') {
pathChar++;
}
if (*path == '\0') {
}
} else {
}
} while (ch == ':');
return latestTime;
}
static char *GetPath()
{
return savedPathOverride;
}
if (environmentPath == NULL) {
}
return environmentPath;
}
int willList;
char **resourceTypes;
{
if (resourceTypes == NULL) {
} else {
int i = 0, len = 0;
i++;
cp++;
}
(char **) MALLOC((int) ((i+1) * sizeof(char *)));
len = 0;
i = 0;
cp = resourceTypes;
cp++;
}
currentResourceTypes[i] = NULL;
}
}
char *type;
{
}
return 0;
}
/* ARGSUSED */
FILE *f;
char *data;
{
int i;
ResourceType t;
long pos;
/* We're at the start of the resource section; read all of them */
if (!t->filled) {
return 1;
}
} else {
return 1;
}
}
continue;
}
if (VerifyName(f, t->type) == 0) {
t->fileOffset = pos;
return 1;
}
} else {
/* No resources of this type; try the next type */
t->fileOffset = -1;
"File changed during execution");
return 1;
}
}
}
return 0;
}
FILE *f;
char *type;
{
int i;
ResourceType t;
long pos;
/* We're at the start of the resource section; read the sections that
are in the cached type list or are the passed in type */
if (!t->filled &&
return 1;
}
return 1;
}
continue;
}
if (VerifyName(f, t->type) == 0) {
t->fileOffset = pos;
return 1;
}
} else if (SkipResourceSection(f, rd, t, 0)) {
return 1;
}
} else {
/* No resources of this type; try the next type */
t->fileOffset = -1;
"File changed during execution");
return 1;
}
}
}
return 0;
}
FILE *f;
char *data;
{
int i;
ResourceType t;
long pos;
/* We're at the start of the resource section; read the name in the
section for the passed in type */
return 1;
}
return 1;
}
continue;
}
if (VerifyName(f, t->type) == 0) {
t->fileOffset = pos;
"File changed during execution");
return 1;
}
return 1;
}
} else if (SkipResourceSection(f, rd, t, 0)) {
return 1;
}
} else {
/* No resources of this type; try the next type */
t->fileOffset = -1;
"File changed during execution");
return 1;
}
}
}
return 0;
}
char *resourceType;
char *resourceName;
{
TypeName t;
switch (currentPolicy) {
case PSSaveEverything:
break;
case PSSaveByType:
break;
case PSSaveReturnValues:
t.type = resourceType;
t.name = resourceName;
break;
}
}
char *resourceType;
char *resourceName;
{
int i;
FILE *f;
/* Make two passes; the first figures out if we're going to have to read
the file to service this request. If we are, open the file and read
in sections in the saved list (from SetPSResourcePolicy). If not
just saving return values, make sure we read in everything
in the section. */
f = NULL;
if (resourceName != NULL &&
break;
}
if (f == NULL) continue;
/* Nuts, have to read the file */
switch (currentPolicy) {
case PSSaveEverything:
break;
case PSSaveByType:
break;
case PSSaveReturnValues:
break;
}
"File changed during execution");
(void) fclose(f);
}
}
char *resourceType;
char *resourceName;
char ***resourceNamesReturn;
char ***resourceFilesReturn;
{
int i, j, k;
int nameCount = 0;
/* Make two passes; first count, then set and return */
else {
nameCount++;
}
}
}
}
}
if (nameCount == 0) return 0;
k = 0;
if (resourceName == NULL ||
}
}
}
}
return nameCount;
}
char *psResourcePathOverride;
char *defaultPath;
char *resourceType;
char *resourceName;
char ***resourceNamesReturn;
char ***resourceFilesReturn;
{
}
char *pathOverride;
char *defaultPath;
char ***typesReturn;
{
int sig;
char *ch;
if (currentPolicy != PSSaveEverything) {
(char *) NULL);
} else lastModifiedTime =
}
for (i = 0; i < d->typeCount; i++) {
for (j = 0; j < typeCount; j++) {
}
if (j >= typeCount) { /* Have to add */
if (typeCount >= typeBufSize) {
else typeBufSize += GROW;
typeBufSize * sizeof(char *));
typeBufSize * sizeof(int));
}
}
}
}
*typesReturn = types;
return typeCount;
}
/* Assumes being correctly positioned in the file */
FILE *f;
EnumeratorStruct *s;
int checkName;
{
char *linein;
int len;
char *sep;
int prefixLen;
int insertPrefix;
char *file;
char dontDequote;
int doubleEquals;
int addingPrefix;
if (insertPrefix) {
dontDequote = '\0';
} else {
prefixLen = 0;
dontDequote = ',';
}
while (1) {
linein = ReadFullLine(f);
FreeLineBuf();
return 1;
}
FreeLineBuf();
return 0;
}
/* If no separator, a bogus line */
/* Next line is UNIX specific! */
}
*sep = '\0';
if (addingPrefix) {
}
if (s->done) {
FreeLineBuf();
return 0;
}
}
}
}
FILE *f;
char *data;
{
int i;
ResourceType t;
long pos;
if (s->done) return 0;
return 1;
}
if (s->done) return 0;;
return 1;
}
continue;
}
if (VerifyName(f, t->type) == 0) {
t->fileOffset = pos;
if (s->done) return 0;
} else {
/* No resources of this type; try the next type */
t->fileOffset = -1;
}
}
return 0;
}
char *pathOverride;
char *defaultPath;
char *resourceType;
char *resourceName;
char *private;
{
FILE *f;
s.func = enumerator;
s.type = resourceType;
s.name = resourceName;
s.done = 0;
return;
}
if (f == NULL) continue;
(void) Enumerate(f, d, (char *) &s);
}
(void) fclose(f);
}
}
char *pathOverride;
char *defaultPath;
{
}