1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1989 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 /* from OpenSolaris "daps.h 1.5 05/06/08 SMI" */ 32 33 /* 34 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany 35 * 36 * Sccsid @(#)daps.h 1.3 (gritter) 8/9/05 37 */ 38 39 /* 40 * University Copyright- Copyright (c) 1982, 1986, 1988 41 * The Regents of the University of California 42 * All Rights Reserved 43 * 44 * University Acknowledgment- Portions of this document are derived from 45 * software developed by the University of California, Berkeley, and its 46 * contributors. 47 */ 48 49 50 51 52 /******************************************************************** 53 * * 54 * The following defined constants and macros must be properly * 55 * set up for your APS-5 photo-typesetter. * 56 * * 57 ********************************************************************/ 58 59 60 61 #define ADJUST 1 /* conditional compilation flag */ 62 63 #define LENS3 1 /* used for conditional compilation */ 64 #define MAX_RANGE 3 /* largest master range on this APS-5 */ 65 66 67 68 #ifdef LENS1 /* standard 2.22X lens */ 69 70 #define RANGE1_SIZE 10 /* used in macro BASE_SIZE */ 71 #define SCALEFACTOR 1.25 /* can scale lower ranges up this far */ 72 73 74 #define BASE_SIZE(Range) /* base size for master range Range */ \ 75 \ 76 (RANGE1_SIZE * (1 << (Range - 1))) 77 78 79 #define SCALE_UP(Bsize) /* max size for lower ranges */ \ 80 \ 81 (Bsize * SCALEFACTOR) 82 83 #endif 84 85 86 87 #ifdef LENS2 /* standard 2.667X lens */ 88 89 #define RANGE1_SIZE 12 /* master range 1 base size */ 90 #define SCALEFACTOR 1.25 /* can scale lower ranges up this far */ 91 92 93 #define BASE_SIZE(Range) /* base size for master range Range */ \ 94 \ 95 (RANGE1_SIZE * (1 << (Range - 1))) 96 97 98 #define SCALE_UP(Bsize) /* max size for lower ranges */ \ 99 \ 100 (Bsize * SCALEFACTOR) 101 102 #endif 103 104 105 #ifdef LENS3 /* 2.667X lens - special case */ 106 107 #define RANGE1_SIZE 12 /* master range 1 base size */ 108 #define SCALEFACTOR 1.50 /* can scale lower ranges up this far */ 109 110 111 #define BASE_SIZE(Range) /* base size for master range Range */ \ 112 \ 113 (RANGE1_SIZE * (1 << (Range - 1))) 114 115 116 #define SCALE_UP(Bsize) /* max size for lower ranges */ \ 117 \ 118 (Bsize * SCALEFACTOR - 1) 119 120 #endif 121 122 123 124 125 /******************************************************************** 126 * * 127 * POST-PROCESSOR DEFINED CONSTANTS * 128 * * 129 ********************************************************************/ 130 131 132 133 #define NON_FATAL 0 /* don't abort the job */ 134 #define FATAL 1 /* fatal error - abort the job */ 135 #define OFF 0 /* debug mode is off */ 136 #define ON 1 /* debug mode is on */ 137 #define NO 0 /* don't ignore fatal errors - debug */ 138 #define YES 1 /* ignore fatal errors - debug only! */ 139 #define SAME_STR 0 /* strings are the same */ 140 141 #define RES 723.0 /* use this constant for accounting! */ 142 #define PAGE_LENGTH 11.0 /* inches per page for accounting */ 143 144 #define CUTOFF 10.0 /* beam cutoff position (inches) */ 145 #define HCUTOFF 7230 /* beam cutoff in device units */ 146 147 148 #define BMASK 0377 /* used for character mask */ 149 150 #define MAX_INT 30000 /* used in t_reset() */ 151 #define MAX_DEBUG 20 /* number of debug states */ 152 153 #define MAX_OUTLIST 30 /* number of page pairs olist array */ 154 155 #define NAME_LENGTH 10 /* max length of typesetter name */ 156 157 #define FSIZE 200 /* size of a physical font */ 158 159 #define SLOP 2 /* error factor used in hflush() */ 160 161 #define NFONT 10 /* number of font positions available */ 162 163 #define POS_SLANT 14 /* angle used for positive slants */ 164 #define NEG_SLANT -14 /* angle used for negative slants */ 165 166 #define TWO_BITS 3 /* mask for two rightmost bits */ 167 168 #define BIT0 1 /* mask for bit 0 */ 169 #define BIT1 2 /* mask for bit 1 */ 170 #define BIT2 4 /* mask for bit 2 */ 171 #define BIT3 8 /* mask for bit 3 */ 172 173 #define SLANT_BIT BIT0 /* slant bit is bit 0 */ 174 #define FONT_BIT BIT1 /* alternate font is bit 1 */ 175 #define RANGE_BIT BIT2 /* max range is bit 2 */ 176 177 #define SLANT_VAL 3 /* slant angle starts in bit 3 */ 178 #define RANGE_VAL 5 /* range value starts in bit 5 */ 179 180 #define DO_ACCT BIT0 /* still have to do accounting if on */ 181 #define FILE_STARTED BIT1 /* file started but not completed */ 182 #define NO_OUTFILE BIT2 /* no output file if on */ 183 #define NO_ACCTFILE BIT3 /* no accounting file if on */ 184 185 #define BAN_LENGTH 130 /* max length of banner string */ 186 #define BAN_SIZE 10 /* point size to use in banner */ 187 188 #define VSPACE0 6 /* space down for first cut marks */ 189 #define VSPACE1 180 /* space at start of banner */ 190 #define VSPACE2 180 /* space before printing user string */ 191 #define VSPACE3 180 /* space before printing separator */ 192 #define VSPACE4 180 /* space before starting user job */ 193 194 #define HSPACE0 5346 /* space right for second cut marks */ 195 #define HSPACE1 50 /* indent before first separator */ 196 #define HSPACE2 100 /* indent before user string */ 197 #define HSPACE3 50 /* indent before second separator */ 198 #define HSPACE4 0 /* start cut marks at this position */ 199 200 201 202 203 /******************************************************************** 204 * * 205 * POST-PROCESSOR MACROS * 206 * * 207 ********************************************************************/ 208 209 210 211 212 #define SET_ARGS(save) /* set up internal argc and argv */ \ 213 \ 214 save = argc; /* save current value of argc */ \ 215 argc -= arg_index; /* count arguments read already */ \ 216 argv += arg_index 217 218 219 220 221 #define COUNT_ARGS(save) /* count the arguments processed */ \ 222 \ 223 arg_index = save - argc /* arg_index counts the arguments */ 224 225 226 227 228 #define STR_CONVERT(s,i) /* convert string s to integer i */ \ 229 \ 230 do { \ 231 i = 0; \ 232 do \ 233 i = 10 * i + *s++ - '0'; \ 234 while ( isdigit(*s) ); \ 235 } while ( 0 ) 236 237 238 239 240 #define TOGGLE(a) /* toggle the value in argument a */ \ 241 \ 242 a = (a + 1) % 2 243 244 245 246 247 #define GET_DIG(fp,c) /* get a single ASCII digit */ \ 248 \ 249 c = getc(fp); \ 250 if ( !isdigit(c) || c == EOF ) /* illegal character */ \ 251 error(FATAL, "internal error - digit not found in GET_DIG") 252 253 254 255 256 #define GET_CHAR(fp,c) /* get a single ASCII character */ \ 257 \ 258 if ( (c = getc(fp)) == EOF ) /* end of file - abort */ \ 259 error(FATAL, "internal error - char not found in GET_CHAR") 260 261 262 263 264 #define GET_INT(fp,n) /* get an integer from file fp */ \ 265 \ 266 if ( fscanf(fp, "%d", &n) != 1 ) /* end of file - abort */ \ 267 error(FATAL,"internal error - integer not found in GET_INT") 268 269 270 271 272 #define GET_STR(fp,str) /* get a string from file fp */ \ 273 \ 274 if ( fscanf(fp, "%s", str) != 1 ) /* end of file - abort */ \ 275 error(FATAL, "internal error - string not found in GET_STR") 276 277 278 279 280 #define GET_LINE(fp,buf) /* read a line from file fp into buf */ \ 281 \ 282 if ( fgets(buf, sizeof(buf), fp) == NULL ) \ 283 error(FATAL, "internal error - line not found in GET_LINE") 284 285 286 287 288 #define SKIP_LINE(fp,c) /* skip to the next line of the file fp */ \ 289 \ 290 while ( ((c = getc(fp)) != '\n') && c != EOF ) \ 291 ; 292 293 294 295 296 #define SCAN1(buf,n1) /* read one number from buf */ \ 297 \ 298 if ( sscanf(buf, "%d", &n1) != 1 ) \ 299 error(FATAL, "internal error - integer not found in SCAN1") 300 301 302 303 304 #define SCAN2(buf,n1,n2) /* read two numbers from buf */ \ 305 \ 306 if ( sscanf(buf, "%d %d", &n1, &n2) != 2 ) \ 307 error(FATAL, "internal error - integers not found in SCAN2") 308 309 310 311 312 #define SCAN3(buf,n1,n2,n3) /* read three numbers from buf */ \ 313 \ 314 if ( sscanf(buf, "%d %d %d", &n1, &n2, &n3) != 3 ) \ 315 error(FATAL, "internal error - integers not found in SCAN3") 316 317 318 319 320 #define SCAN4(buf,n1,n2,n3,n4) /* read four numbers from buf */ \ 321 \ 322 if ( sscanf(buf, "%d %d %d %d", &n1, &n2, &n3, &n4) != 4 ) \ 323 error(FATAL, "internal error - integers not found in SCAN4") 324 325 326 327 328 #define SCAN_STR(buf,str) /* read a string from buf */ \ 329 \ 330 sscanf(buf, "%s", str) 331 332 333 334 335 #ifdef pdp11 /* sign extension problems on pdp11s */ 336 337 #define PUTC(ch, fp) /* don't check for error if ch = 0377 */ \ 338 \ 339 if ( (putc(ch, fp) == EOF) && ((ch & BMASK) != 0377) ) \ 340 error(FATAL, "internal error - PUTC can't output character") 341 342 #else /* don't worry about char 0377 */ 343 344 #define PUTC(ch, fp) /* write character ch to file fp */ \ 345 \ 346 if ( putc(ch, fp) == EOF ) /* error in writing to fp */ \ 347 error(FATAL, "internal error - PUTC can't output character") 348 349 #endif 350 351 352 353 354 #define READ(fd, buf, n) /* read n chars from file fd into buf */ \ 355 \ 356 if ( read(fd, buf, n) < 0 ) /* error in reading from fd */ \ 357 error(FATAL, "internal error - READ can't read input file") 358 359 360 361 362 #define DECODE(value, start, bitmask) \ 363 \ 364 (value >> start) & bitmask 365 366 367 368 369 #define CHANGE_FONT(newfont, oldrange) /* set font to newfont */ \ 370 \ 371 do { \ 372 change_font(newfont); \ 373 if ( oldrange != range ) { /* range has changed */ \ 374 PUTC(HVSIZE, tf); /* so set the point size */ \ 375 putint(10*pstab[size-1]); /* to current size */ \ 376 oldrange = range; \ 377 } /* End if */ \ 378 } while ( 0 ) 379 380 381 382 383 #define SETSLANT(code, angle) /* set slant to value encoded in code */ \ 384 \ 385 do { \ 386 angle = DECODE(code, SLANT_VAL, TWO_BITS); \ 387 if ( angle & BIT0 ) /* have positive APS-5 slant */ \ 388 angle = POS_SLANT; \ 389 else if ( angle & BIT1 ) /* have negative slant */ \ 390 angle = NEG_SLANT; \ 391 t_slant(angle + last_req_slant); /* set the correct slant */ \ 392 } while ( 0 ) 393 394 395 396 397 /* build.c */ 398 int newfile(char *, int); 399 FILE *charfile(char *, int); 400 void save_env(void); 401 void restore_env(void); 402 void nconv(FILE *); 403 /* daps.c */ 404 void get_options(int, char *[]); 405 void process_input(int, char *[]); 406 void init_signals(void); 407 void debug_select(char *); 408 void debug_file(char *); 409 void log_file(char *); 410 void acct_file(void); 411 void ban_file(char *); 412 void out_file(void); 413 void outlist(char *); 414 void error(int, char *, ...); 415 int done(void); 416 void float_err(int); 417 void wrap_up(int); 418 void conv(register FILE *); 419 void drawfunct(char [], FILE *); 420 void devcntrl(FILE *); 421 void t_init(void); 422 void t_banner(void); 423 void t_page(int); 424 void t_newline(void); 425 int t_size(int); 426 void t_charht(int); 427 int upper_limit(int); 428 void t_slant(int); 429 int t_font(char *); 430 void t_text(char *); 431 void t_reset(int); 432 void hflush(void); 433 void hmot(int); 434 void hgoto(int); 435 void vgoto(int); 436 void vmot(int); 437 void put1s(char *); 438 void t_adjust(char *); 439 void put1(int); 440 void putint(int); 441 void setsize(int); 442 void setfont(int); 443 void change_font(int); 444 void t_fp(int, char *, char *); 445 void account(void); 446 int special_case(int, int); 447 int get_range(int); 448 void fileinit(void); 449 void fontprint(int); 450 void loadfont(int, char *, char *); 451 void load_alt(int); 452 /* ../draw.c */ 453 void drawline(int, int, char *); 454 void drawwig(char *); 455 char *getstr(char *, char *); 456 void drawcirc(int); 457 int dist(int, int, int, int); 458 void drawarc(int, int, int, int); 459 void drawellip(int, int); 460 void conicarc(int, int, int, int, int, int, int, int); 461 void putdot(int, int); 462