824N/A/*
824N/A * dpsabbrev.c -- Implementation of Client Library abbrev mode
824N/A *
824N/A * (c) Copyright 1993-1994 Adobe Systems Incorporated.
824N/A * All rights reserved.
824N/A *
824N/A * Permission to use, copy, modify, distribute, and sublicense this software
824N/A * and its documentation for any purpose and without fee is hereby granted,
824N/A * provided that the above copyright notices appear in all copies and that
824N/A * both those copyright notices and this permission notice appear in
824N/A * supporting documentation and that the name of Adobe Systems Incorporated
824N/A * not be used in advertising or publicity pertaining to distribution of the
824N/A * software without specific, written prior permission. No trademark license
824N/A * to use the Adobe trademarks is hereby granted. If the Adobe trademark
824N/A * "Display PostScript"(tm) is used to describe this software, its
824N/A * functionality or for any other purpose, such use shall be limited to a
824N/A * statement that this software works in conjunction with the Display
824N/A * PostScript system. Proper trademark attribution to reflect Adobe's
824N/A * ownership of the trademark shall be given whenever any such reference to
824N/A * the Display PostScript system is made.
824N/A *
824N/A * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
824N/A * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
824N/A * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
824N/A * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
824N/A * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
824N/A * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
824N/A * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
824N/A * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
824N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
824N/A * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
824N/A *
824N/A * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
824N/A * Incorporated which may be registered in certain jurisdictions
824N/A *
824N/A * Author: Adobe Systems Incorporated
824N/A */
824N/A/* $XFree86$ */
824N/A
824N/A#include <string.h>
824N/A#include "publictypes.h"
824N/A#include "DPS/dpsclient.h"
824N/A#include "dpsprivate.h"
824N/A
824N/Astatic DPSAbbrevRec abbrev[] = {
824N/A {1, "add", "!+"},
824N/A {10, "ashow", "!a"},
824N/A {12, "awidthshow", "!A"},
824N/A {13, "begin", "!B"},
824N/A {14, "bind", "!b"},
824N/A {20, "clip", "!CL"},
824N/A {22, "closepath", "!c"},
824N/A {23, "concat", "!CC"},
824N/A {25, "copy", "!CP"},
824N/A {39, "currentmatrix", "!CM"},
824N/A {40, "currentpoint", "!Cp"},
824N/A {43, "curveto", "!C"},
824N/A {51, "def", "!D"},
824N/A {53, "dict", "!d"},
824N/A {62, "exch", "!E"},
824N/A {63, "exec", "!e"},
824N/A {66, "fill", "!F"},
824N/A {67, "findfont", "!f"},
824N/A {77, "grestore", "!G"},
824N/A {78, "gsave", "!g"},
824N/A {85, "ifelse", "!I"},
824N/A {88, "index", "!i"},
824N/A {98, "length", "!LE"},
824N/A {99, "lineto", "!L"},
824N/A {100, "load", "!l"},
824N/A {103, "makefont", "!MF"},
824N/A {104, "matrix", "!m"},
824N/A {107, "moveto", "!M"},
824N/A {111, "newpath", "!N"},
824N/A {113, "null", "!n"},
824N/A {117, "pop", "!p"},
824N/A {122, "rcurveto", "!RC"},
824N/A {127, "rectclip", "!R"},
824N/A {128, "rectfill", "!RF"},
824N/A {129, "rectstroke", "!RS"},
824N/A {131, "repeat", "!RP"},
824N/A {132, "restore", "!Rs"},
824N/A {133, "rlineto", "!r"},
824N/A {134, "rmoveto", "!RM"},
824N/A {135, "roll", "!RL"},
824N/A {136, "rotate", "!RO"},
824N/A {137, "round", "!RN"},
824N/A {138, "save", "!SV"},
824N/A {139, "scale", "!SC"},
824N/A {140, "scalefont", "!SF"},
824N/A {142, "selectfont", "!s"},
824N/A {147, "setcmykcolor", "!Sc"},
824N/A {148, "setdash", "!SD"},
824N/A {149, "setfont", "!Sf"},
824N/A {150, "setgray", "!Sg"},
824N/A {152, "sethsbcolor", "!Sh"},
824N/A {153, "setlinecap", "!SL"},
824N/A {154, "setlinejoin", "!SJ"},
824N/A {155, "setlinewidth", "!SW"},
824N/A {156, "setmatrix", "!SM"},
824N/A {157, "setrgbcolor", "!Sr"},
824N/A {158, "setshared", "!SS"},
824N/A {160, "show", "!S"},
824N/A {161, "showpage", "!SP"},
824N/A {167, "stroke", "!ST"},
824N/A {170, "systemdict", "!Sd"},
824N/A {173, "translate", "!T"},
824N/A {182, "userdict", "!u"},
824N/A {186, "where", "!w"},
824N/A {187, "widthshow", "!W"},
824N/A {194, "xshow", "!X"},
824N/A {195, "xyshow", "!x"},
824N/A {196, "yshow", "!Y"},
824N/A};
824N/A
824N/Astatic short abbrevPtr[] = {
824N/A -1, /* 0 */
824N/A 0, /* 1 */
824N/A -1, /* 2 */
824N/A -1, /* 3 */
824N/A -1, /* 4 */
824N/A -1, /* 5 */
824N/A -1, /* 6 */
824N/A -1, /* 7 */
824N/A -1, /* 8 */
824N/A -1, /* 9 */
824N/A 1, /* 10 */
824N/A -1, /* 11 */
824N/A 2, /* 12 */
824N/A 3, /* 13 */
824N/A 4, /* 14 */
824N/A -1, /* 15 */
824N/A -1, /* 16 */
824N/A -1, /* 17 */
824N/A -1, /* 18 */
824N/A -1, /* 19 */
824N/A 5, /* 20 */
824N/A -1, /* 21 */
824N/A 6, /* 22 */
824N/A 7, /* 23 */
824N/A -1, /* 24 */
824N/A 8, /* 25 */
824N/A -1, /* 26 */
824N/A -1, /* 27 */
824N/A -1, /* 28 */
824N/A -1, /* 29 */
824N/A -1, /* 30 */
824N/A -1, /* 31 */
824N/A -1, /* 32 */
824N/A -1, /* 33 */
824N/A -1, /* 34 */
824N/A -1, /* 35 */
824N/A -1, /* 36 */
824N/A -1, /* 37 */
824N/A -1, /* 38 */
824N/A 9, /* 39 */
824N/A 10, /* 40 */
824N/A -1, /* 41 */
824N/A -1, /* 42 */
824N/A 11, /* 43 */
824N/A -1, /* 44 */
824N/A -1, /* 45 */
824N/A -1, /* 46 */
824N/A -1, /* 47 */
824N/A -1, /* 48 */
824N/A -1, /* 49 */
824N/A -1, /* 50 */
824N/A 12, /* 51 */
824N/A -1, /* 52 */
824N/A 13, /* 53 */
824N/A -1, /* 54 */
824N/A -1, /* 55 */
824N/A -1, /* 56 */
824N/A -1, /* 57 */
824N/A -1, /* 58 */
824N/A -1, /* 59 */
824N/A -1, /* 60 */
824N/A -1, /* 61 */
824N/A 14, /* 62 */
824N/A 15, /* 63 */
824N/A -1, /* 64 */
824N/A -1, /* 65 */
824N/A 16, /* 66 */
824N/A 17, /* 67 */
824N/A -1, /* 68 */
824N/A -1, /* 69 */
824N/A -1, /* 70 */
824N/A -1, /* 71 */
824N/A -1, /* 72 */
824N/A -1, /* 73 */
824N/A -1, /* 74 */
824N/A -1, /* 75 */
824N/A -1, /* 76 */
824N/A 18, /* 77 */
824N/A 19, /* 78 */
824N/A -1, /* 79 */
824N/A -1, /* 80 */
824N/A -1, /* 81 */
824N/A -1, /* 82 */
824N/A -1, /* 83 */
824N/A -1, /* 84 */
824N/A 20, /* 85 */
824N/A -1, /* 86 */
824N/A -1, /* 87 */
824N/A 21, /* 88 */
824N/A -1, /* 89 */
824N/A -1, /* 90 */
824N/A -1, /* 91 */
824N/A -1, /* 92 */
824N/A -1, /* 93 */
824N/A -1, /* 94 */
824N/A -1, /* 95 */
824N/A -1, /* 96 */
824N/A -1, /* 97 */
824N/A 22, /* 98 */
824N/A 23, /* 99 */
824N/A 24, /* 100 */
824N/A -1, /* 101 */
824N/A -1, /* 102 */
824N/A 25, /* 103 */
824N/A 26, /* 104 */
824N/A -1, /* 105 */
824N/A -1, /* 106 */
824N/A 27, /* 107 */
824N/A -1, /* 108 */
824N/A -1, /* 109 */
824N/A -1, /* 110 */
824N/A 28, /* 111 */
824N/A -1, /* 112 */
824N/A 29, /* 113 */
824N/A -1, /* 114 */
824N/A -1, /* 115 */
824N/A -1, /* 116 */
824N/A 30, /* 117 */
824N/A -1, /* 118 */
824N/A -1, /* 119 */
824N/A -1, /* 120 */
824N/A -1, /* 121 */
824N/A 31, /* 122 */
824N/A -1, /* 123 */
824N/A -1, /* 124 */
824N/A -1, /* 125 */
824N/A -1, /* 126 */
824N/A 32, /* 127 */
824N/A 33, /* 128 */
824N/A 34, /* 129 */
824N/A -1, /* 130 */
824N/A 35, /* 131 */
824N/A 36, /* 132 */
824N/A 37, /* 133 */
824N/A 38, /* 134 */
824N/A 39, /* 135 */
824N/A 40, /* 136 */
824N/A 41, /* 137 */
824N/A 42, /* 138 */
824N/A 43, /* 139 */
824N/A 44, /* 140 */
824N/A -1, /* 141 */
824N/A 45, /* 142 */
824N/A -1, /* 143 */
824N/A -1, /* 144 */
824N/A -1, /* 145 */
824N/A -1, /* 146 */
824N/A 46, /* 147 */
824N/A 47, /* 148 */
824N/A 48, /* 149 */
824N/A 49, /* 150 */
824N/A -1, /* 151 */
824N/A 50, /* 152 */
824N/A 51, /* 153 */
824N/A 52, /* 154 */
824N/A 53, /* 155 */
824N/A 54, /* 156 */
824N/A 55, /* 157 */
824N/A 56, /* 158 */
824N/A -1, /* 159 */
824N/A 57, /* 160 */
824N/A 58, /* 161 */
824N/A -1, /* 162 */
824N/A -1, /* 163 */
824N/A -1, /* 164 */
824N/A -1, /* 165 */
824N/A -1, /* 166 */
824N/A 59, /* 167 */
824N/A -1, /* 168 */
824N/A -1, /* 169 */
824N/A 60, /* 170 */
824N/A -1, /* 171 */
824N/A -1, /* 172 */
824N/A 61, /* 173 */
824N/A -1, /* 174 */
824N/A -1, /* 175 */
824N/A -1, /* 176 */
824N/A -1, /* 177 */
824N/A -1, /* 178 */
824N/A -1, /* 179 */
824N/A -1, /* 180 */
824N/A -1, /* 181 */
824N/A 62, /* 182 */
824N/A -1, /* 183 */
824N/A -1, /* 184 */
824N/A -1, /* 185 */
824N/A 63, /* 186 */
824N/A 64, /* 187 */
824N/A -1, /* 188 */
824N/A -1, /* 189 */
824N/A -1, /* 190 */
824N/A -1, /* 191 */
824N/A -1, /* 192 */
824N/A -1, /* 193 */
824N/A 65, /* 194 */
824N/A 66, /* 195 */
824N/A 67, /* 196 */
824N/A -1, /* 197 */
824N/A -1, /* 198 */
824N/A -1, /* 199 */
824N/A -1, /* 200 */
824N/A -1, /* 201 */
824N/A -1, /* 202 */
824N/A -1, /* 203 */
824N/A -1, /* 204 */
824N/A -1, /* 205 */
824N/A -1, /* 206 */
824N/A -1, /* 207 */
824N/A -1, /* 208 */
824N/A -1, /* 209 */
824N/A -1, /* 210 */
824N/A -1, /* 211 */
824N/A};
824N/A
824N/Avoid DPSFetchAbbrevList(DPSAbbrevRec **list, int *count)
824N/A{
824N/A *list = abbrev;
824N/A *count = sizeof(abbrev) / sizeof(abbrev[0]);
824N/A}
824N/A
824N/Achar *DPSGetSysnameAbbrev(int n)
824N/A{
824N/A if ((unsigned) n > sizeof(abbrevPtr) / sizeof(abbrevPtr[0])) return NULL;
824N/A if (abbrevPtr[n] == -1) return NULL;
824N/A return abbrev[abbrevPtr[n]].abbrev;
824N/A}
824N/A
824N/Achar *DPSGetOperatorAbbrev(char *op)
824N/A{
824N/A int min, max, n;
824N/A int res;
824N/A
824N/A min = 0;
824N/A max = sizeof(abbrev) / sizeof(abbrev[0]) - 1;
824N/A
824N/A while (min <= max) {
824N/A n = (max + min) / 2;
824N/A res = strcmp(op, abbrev[n].operatorName);
824N/A if (res == 0) return abbrev[n].abbrev;
824N/A if (res < 0) max = n - 1;
824N/A if (res > 0) min = n + 1;
824N/A }
824N/A return NULL;
824N/A}