/*
*
* (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
*/
/* $XFree86: xc/programs/makepsres/makepsres.c,v 1.8tsi Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#ifdef XENVIRONMENT
#else
#include <string.h>
#endif
#include <dirent.h>
#ifndef S_ISDIR
#ifdef S_IFDIR
#else
#endif /* S_IFDIR */
#endif /* S_ISDIR */
#define true 1
#define false 0
/* The max line length is really 256, but why make things that are hard
to read??? */
#ifndef DEBUG
#define DEBUG false
#endif
/* Command line information */
char **directories;
int *directoryLen;
int directoryCount;
int recursive;
int discard;
int keep;
char *outputFilename;
char **inputFiles;
int inputCount;
int makeExclusive;
int interactive;
int strict;
int noPrefix;
int issueWarnings;
int noBackup;
int noSuffix;
typedef struct _t_Resource {
char *name;
char *file;
int noPrefix;
} Resource;
typedef struct _t_Duplicate {
char *name;
char *file1;
char *file2;
} Duplicate;
typedef struct _t_Category {
char *name;
} Category;
char *program;
#if 0
extern char *sys_errlist[];
extern int errno;
#endif
{
char *result;
exit(1);
}
return result;
}
{
char *result;
exit(1);
}
return result;
}
{
char *result;
exit(1);
}
return result;
}
char *name;
{
"Failed to allocate Category record.");
"Failed to allocate Category name.");
if (categories == NULL) {
} else {
/* Insert into alphabetical position */
*previous;
break;
} else {
}
}
} else {
if (current == categories) {
} else {
}
}
}
return (newCategory);
}
char *name;
{
break;
else
}
return (category);
}
char *string;
{
int hash = 0;
while (1) {
}
}
}
{
"Failed to allocate hash table.");
}
if (comparison > 0) break;
if (comparison == 0 &&
}
} else {
} else {
}
}
}
{
if (!issueWarnings) return;
"Failed to allocate Duplicate record.");
}
} else {
}
}
char *resourceName;
char *categoryName;
char *fileName;
int noPrefix;
{
*current,
*previous;
int comparison;
"Failed to allocate Resource record.");
"Failed to allocate Resource name.");
"Failed to allocate Resource filename.");
return;
}
if (comparison > 0) break;
else if (comparison == 0) {
if (comparison > 0) {
}
break;
} else if (comparison == 0) { /* Same file */
return;
}
}
}
} else {
} else {
}
}
}
char *categoryName;
char *resourceName;
{
int i;
for (i = 0; i < HASHSIZE; i++) {
}
return false;
}
typedef struct _t_UPRResource {
char *name;
char *file;
char *category;
int found;
int noPrefix;
} UPRResource;
#if DEBUG
int totalHashed = 0;
#endif
char *resourceName;
char *categoryName;
char *fileName;
char *prefix;
int noPrefix;
{
prefix = "";
} else {
prefix++; /* Skip over leading / */
}
"Failed to allocate Resource record.");
"Failed to allocate Resource name.");
"Failed to allocate Resource filename.");
"Failed to allocate Resource name.");
if (comparison > 0) break;
if (comparison == 0) {
if (noPrefix) break;
/* Replace "NONRESOURCE" entry with resource one */
return;
}
"%s: Warning: file %s identified as different resources\n",
}
return;
}
}
} else {
} else {
}
}
#if DEBUG
totalHashed++;
bucketCount[hash]++;
#endif
}
char *font;
char *sizes;
{
char *buf;
while (*ch != '\0') {
if (*ch == ',') {
*ch = '\0';
if (*sizes != '\0') {
/* Stick in the font size to spread out the hash table */
"Failed to allocate BDF string");
}
}
}
}
char *family;
char *faces;
{
char old;
while (true) {
while (true) {
if (*ch == '\0') return;
else break;
}
/* Found the first , look for the second */
ch++;
while (true) {
if (*ch == '\0') break;
else break;
}
*ch = '\0';
if (old == '\0') return;
}
}
{
int c;
while (1) {
if (c == ' ' || c == '\t') continue;
if (c == EOF) return false;
return true;
}
}
char *buf;
int size;
{
int c;
openchar = '\0';
if (c == EOF) return false;
else {
closechar = '\0';
}
if (c == EOF) break;
if (c == closechar) {
if (nesting == 0) break;
else nesting--;
}
}
return true;
}
char *key;
{
while (true) {
break;
result++;
break;
}
}
}
return (result);
}
char *name;
{
char *pointer;
while (true) {
else break;
*pointer = '\0';
} else break; /* No close character */
}
else {
}
}
static char *bugFamilies[] = {
"Berkeley", "CaslonFiveForty", "CaslonThree", "GaramondThree",
};
static char *fixedFamilies[] = {
"ITC Berkeley Oldstyle", "Caslon 540", "Caslon 3", "Garamond 3",
};
static char *missingFoundries[] = {
};
static int missingFoundryLen[] = {
9, 4, 9, 0
};
{
int digits = 0;
int i, diff;
/* Copy the fullname into buf, enforcing one space between words.
Eliminate leading digits and spaces, ignore asterisks, if the
full name ends with 5 digits strip them, and replace periods that
aren't followed by a space with a space. If leading digits are
followed by " pt " skip that too. */
prev = ' ';
while (*src != '\0') {
if (*src == '*') {
src++;
continue;
}
if (*src == '.') {
src++;
continue;
}
else digits = 0;
*dst++ = ' ';
if (prev == ' ') {
src++;
continue;
}
src++;
}
if (digits == 5) {
dst -= 5;
}
*dst = '\0';
}
/* From here on fullname should not be used */
/* Done with the full name; now onto the family */
for (i = 0; bugFamilies[i] != NULL; i++) {
if (diff < 0) break;
if (diff == 0) {
goto FAMILY_DONE;
}
}
/* Copy the family into buf, enforcing one space between words */
prev = ' ';
while (*src != '\0') {
*dst++ = ' ';
if (prev == ' ') {
src++;
continue;
}
src++;
}
*dst = '\0';
/* Compensate for fonts with foundries in the full name but not the
family name by adding to the family name */
for (i = 0; missingFoundries[i] != NULL; i++) {
missingFoundryLen[i]);
if (diff > 0) continue;
missingFoundryLen[i] != 0)) {
dst--;
}
}
break;
}
/* From here on dst no longer points to the end of the buffer */
}
/* From here on family should not be used */
/* Now to find the face in all this */
dst = familyReturn;
src++;
dst++;
}
if (*src == '\0') {
if (*weight != '\0') {
/* Handle Multiple Master fonts */
else {
}
} else src = "Medium";
}
}
char *buf;
{
while (true) {
if (*ch == '\0') break;
*ch = '\0';
break;
}
ch++;
}
/* ch points to '\0' right now */
ch--;
*ch = '\0';
ch--;
}
}
/* Caller must free returned line */
{
char *line;
while (true) {
return line;
}
"Failed to reallocate input line.");
oldlen--;
}
}
return line;
}
char *filename;
int err;
{
if (issueWarnings) {
}
}
char *fullname;
{
char *category;
char *line;
int noPrefix;
return;
}
/* Skip over list of categories */
while (true) {
if (lineBuffer[0] == '.') break;
}
while (true) {
/* Process category */
return;
}
continue;
}
while (true) {
char *resourceFile;
}
if (line[0] == '.') {
break;
}
resourceFile = line;
while (true) {
*resourceFile++ = '\0';
if (noPrefix) resourceFile++;
noPrefix);
break;
}
resourceFile++;
} else break; /* Bogus line */
}
}
}
}
char character;
{
int c;
if (c == character)
return (true);
}
return (false);
}
char character1, character2;
char *outchar;
{
register int c;
if (c == character1 || c == character2) {
*outchar = c;
return (true);
}
}
return (false);
}
char *fileName;
{
char out;
int found = 0;
/* If we encounter an eexec, skip the rest of the file */
if (out == 'e') {
continue;
}
if (!SkipWhiteSpace(file)) break;
found |= 0x1;
continue;
}
found |= 0x2;
continue;
}
found |= 0x4;
continue;
}
found |= 0x8;
continue;
}
found |= 0x10;
continue;
}
found |= 0x20;
continue;
}
found |= 0x40;
continue;
}
}
if (fontName[0] != '\0') {
if (fontFullName[0] == '\0') {
}
#if DEBUG
#endif
blendAxisTypes[0] != '\0') {
#if DEBUG
#endif
}
}
}
char *fileName;
{
char *pointer;
return;
}
}
char *fileName;
{
unsigned int found = 0;
if (!SkipWhiteSpace(file)) break;
if (!SkipWhiteSpace(file)) break;
found |= 1;
continue;
}
found |= 2;
continue;
}
found |= 4;
continue;
}
found |= 8;
continue;
}
found |= 16;
continue;
}
size /= 10;
found |= 32;
}
}
}
char *fileName;
{
char *pointer;
char *extraCr;
return;
}
/* ARGSUSED */
char *fileName;
{
}
char *filename;
{
}
char *userCategories[] = {
"Encoding",
"File",
"FontAFM",
"FontBDF",
"FontOutline",
"FontPrebuilt",
"Form",
"Pattern",
"ProcSet",
};
char *filename;
{
static int stdinEOF = false;
if (stdinEOF) return;
while (1) {
printf("Please indentify the file\n");
printf(" 0 - Not a resource file\n");
i = 0;
while (userCategories[i] != NULL) {
i++;
}
numCats = i;
printf("> ");
stdinEOF = true;
return;
}
/* Skip the last of the number input line */
stdinEOF = true;
return;
}
printf("Invalid choice\n\n");
continue;
}
printf("\n");
for (i = 0; i < 10; i++) {
}
printf("\n");
continue;
}
if (choice == 0) {
return;
}
printf("Please enter resource category: ");
stdinEOF = true;
return;
}
if (buf[0] == '\0') continue;
printf("Please enter resource name: ");
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
return;
}
printf("Please enter font name: ");
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
printf("Please enter font size: ");
stdinEOF = true;
return;
}
/* Skip the last of the number input line */
stdinEOF = true;
return;
}
if (size <= 0) continue;
return;
}
printf("Please enter font name: ");
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
printf("Please enter font family: ");
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
printf("Please enter font face: ");
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
return;
}
stdinEOF = true;
return;
}
if (name[0] == '\0') continue;
return;
}
}
char *filename;
{
}
return true;
}
char *fileName;
{
register char *ch;
/* The only files we can get anything useful from without looking inside
are AFM files and prebuilt files */
if (len < 5) return false;
len1 = 0;
else len1++;
return true;
}
if (len < 6) return false;
len1 = 0;
else len1++;
return true;
}
return false;
}
char *filename;
int err;
{
if (IdentifyFromUPRList(filename)) return;
if (issueWarnings) {
}
else MarkAsNonResource(filename);
}
char *filename;
{
if (IdentifyFromUPRList(filename)) return;
if (issueWarnings) {
}
else MarkAsNonResource(filename);
}
typedef struct {
char *key;
int keyLength;
char *key2;
int key2Length;
} ResourceKey;
};
char *fileName;
char *filePath;
{
if (fileName[0] == '.')
return;
return;
}
resourceType++) {
resourceType->keyLength) == 0) {
break;
} else {
resourceType->key2Length) == 0) {
break;
}
}
}
}
}
char *fileName;
char *filePath;
{
int len;
if (fileName[0] == '.')
return;
if (len < 4) return;
}
char *directoryName;
int top;
void (*fileFunction)();
{
#if DEBUG
#endif
/* Treat top level failures to open differently from subdirectories */
if (top || issueWarnings) {
}
return;
}
if (fileName[0] == '.') continue;
"Failed to allocate file name string.");
if (issueWarnings) {
}
continue;
}
}
}
void GenerateEntriesFromUPRList()
{
int i, bucket;
continue;
}
}
}
}
}
}
if (!keep) {
/* If this file is in one of the input dirs, but wasn't
found, it must have been deleted since the previous run */
for (i = 0; i < directoryCount; i++) {
directoryLen[i]) == 0 &&
}
}
}
NEXT_UPR: ;
}
}
/* Now do BDFSizes and Families */
/* We know there's a comma since we put one in. Anything
before the comma is just there to make hashing work better */
"Failed to allocate BDF name\n");
}
while (true) {
if (*ch == '\0') break;
else break;
}
if (*ch == ',') {
ch++;
}
}
}
}
}
}
static char *ExtractDirectoryPrefix()
{
int bucket;
continue;
}
continue;
}
"Failed to allocate directory prefix");
#if DEBUG
#endif
} else {
}
#if DEBUG
if (*ch1 != '\0') {
*ch1 = '\0';
}
#endif
*ch1 = '\0';
}
}
"Failed to allocate directory prefix");
#if DEBUG
#endif
} else {
}
#if DEBUG
if (*ch1 != '\0') {
*ch1 = '\0';
}
#endif
*ch1 = '\0';
}
}
}
}
}
while (*ch1 != '\0') {
ch1++;
}
*ch2 = '\0';
}
/* Prefixes must be absolute path names */
return prefix;
}
char c;
{
if (c == '\n') len = 0;
else {
len++;
if (len == MAXLINELEN) {
len = 1;;
}
}
}
char *s;
{
}
char *directoryName;
{
char *pname;
int prefixlen;
int bucket;
else outs("PS-Resources-1.0\n");
outc('\n');
}
outs(".\n");
if (prefixlen > 1) {
outc('/');
outc('\n');
}
outc('\n');
outc('=');
outc('=');
outc('\n');
}
} else {
outc('=');
outc(',');
}
outc('\n');
}
}
outc('=');
outc('=');
outc('\n');
}
}
}
outs(".\n");
}
}
void Usage()
{
"Usage: %s [-o outputfile] [-f inputfile]... [-dir directory]...\n",
program);
" [-e] [-i] [-nr] [-s] [-p] [-d] [-k] [-q] directory...\n");
exit(1);
}
int stdinDirectories = false;
void ReadStdinDirectories()
{
if (stdinDirectories) {
program);
Usage();
}
stdinDirectories = true;
directoryCount * sizeof(char *),
"Failed to reallocate directory list.");
"Failed to allocate directory name.");
}
}
int argc;
char *argv[];
{
int i = 1, j;
if (argc > 0) {
} else program = "makepsres";
"Failed to allocate directory list.");
while (i < argc) {
i++;
if (inputFiles == NULL) {
"Failed to allocat input file list.");
}
}
i++;
outputFilename = argv[i];
}
i++;
}
i++;
}
if (directoryCount == 0) {
directoryCount = 1;
directories[0] = ".";
} else {
for (i = 0; i < directoryCount; i++) {
}
}
if (stdinDirectories) {
j = 0;
for (i = 0; i < directoryCount; i++) {
directories[j] = directories[i];
j++;
}
}
}
for (i = 0; i < inputCount; i++) {
"%s: Cannot read stdin as both directory list and input file\n",
program);
Usage();
}
}
#if DEBUG
printf("Input directory list:\n");
#endif
"Failed to allocate directory length list.");
for (i = 0; i < directoryCount; i++) {
}
}
char *filename;
{
char *backupname;
"Failed to allocate backup file name.'");
#ifndef __UNIXOS2__
exit(1);
}
#else
exit(1);
}
#endif
}
void IssueDuplicateWarnings()
{
int headerIssued = false;
if (!headerIssued) {
headerIssued = true;
"%s: Warning: The output resource file contains the following\n",
program);
" duplicates. Edit them out if you wish.\n");
}
}
}
}
int
int argc;
char *argv[];
{
int i, len;
char *prefix;
directories = NULL;
directoryCount = 0;
recursive = true;
discard = false;
keep = false;
inputFiles = NULL;
inputCount = 0;
makeExclusive = false;
interactive = false;
strict = false;
noPrefix = false;
issueWarnings = true;
noBackup = false;
noSuffix = false;
for (i = 0; i < inputCount; i++) {
}
/* Make two passes; the first time we just look for .upr files, and the
second time we look for everything. This gives us a better chance at
identifying files. */
for (i = 0; i < directoryCount; i++) {
}
#if DEBUG
{
emptyCount = biggestBucket = 0;
for (i = 0; i < HASHSIZE; i++) {
if (bucketCount[i] == 0) emptyCount++;
}
if (biggestBucket != 0) {
for (i = 0; i < HASHSIZE; i++) {
}
}
if (biggestBucket != 0) {
for (i = 0; i < 10; i++) {
printf("Number of buckets <= %d entries: %d\n",
}
}
}
#endif
for (i = 0; i < directoryCount; i++) {
}
else {
}
if (outputFile == NULL) {
"%s: Failed to open %s for writing: %s\n",
exit (1);
}
if (!discard) GenerateEntriesFromUPRList();
exit (0);
}