From owner-freebsd-ports Thu Feb 18 21:57: 7 1999 Delivered-To: freebsd-ports@freebsd.org Received: from picalon.gun.de (picalon.gun.de [192.109.159.1]) by hub.freebsd.org (Postfix) with ESMTP id BDDD910E07; Thu, 18 Feb 1999 21:57:03 -0800 (PST) (envelope-from andreas@klemm.gtn.com) Received: from klemm.gtn.com (pppak04.gtn.com [194.231.123.169]) by picalon.gun.de (8.8.6/8.8.6) with ESMTP id GAA01376; Fri, 19 Feb 1999 06:56:59 +0100 (MET) Received: (from andreas@localhost) by klemm.gtn.com (8.9.2/8.9.2) id GAA35651; Fri, 19 Feb 1999 06:56:44 +0100 (CET) (envelope-from andreas) Date: Fri, 19 Feb 1999 06:56:44 +0100 From: Andreas Klemm To: ports@FreeBSD.org Cc: chuckr@FreeBSD.org, obrien@FreeBSD.org Subject: looking for more up to date a2ps for apsfilter, but need certain features Message-ID: <19990219065644.A35372@titan.klemm.gtn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i X-Disclaimer: A free society is one where it is safe to be unpopular X-Operating-System: FreeBSD 3.1-STABLE SMP Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi ! I'm currently reorganizing apsfilter a little bit. rewindstdin has gone and I'd be happy, if I could get rid of my old patched up version of a2ps in apsfilters src tree. I had to patch a2ps, so that page dimensions and other parameters can be changed on the command line. The page dimensions I fetched from ghostscript. OHere a list of commandline Options: -X letter paper format -M 2.4 set another margin (printer dependand) -Q andreas logname -Z titan.klemm.gtn.com machine name It would be fine, if the port maintainer of the two different a2ps versions could check, which one would be suitable, to be the new version that apsfilter uses. Of course, these or similar patches should go in into the main release. The command line option can get other names, that's easy to change in my shellscript. Could you please check, which a2ps version could be a candidate for me, to replace the old one, although it did a damn good job so far ?! Thanks Andreas /// Here the complete diff for a2ps 4.2: + #ifdef AKL + case 'X': /* gs page dimensions */ + set_paper_format(arg); + break; + case 'M': + if (arg[2] == NUL || (margin = atof(arg+2)) <= 0) + usage(EXIT_FAILURE); + break; + case 'Q': + logname=arg+2; + break; + case 'Z': + host=arg+2; + break; + #endif *** ../a2ps-4.2-orig/Makefile Mon Mar 29 15:26:23 1993 --- Makefile Sun Apr 17 16:10:19 1994 *************** *** 25,36 **** D =. O =. ! BINDIR =/usr/local/bin ! MANDIR =/usr/man/mann ! MANEXT =n ! CFLAGS = -DBSD -O # Default values for HEIGHT, WIDTH, MARGIN and DIR_SEP (11.64, 8.27, 1.2, '/'). # Default values for LPR_PRINT, LPR_COMMAND and LPR_OPT (TRUE, "lpr", "-l") # No values for TWOSIDED_DFLT, ONESIDED and TWOSIDED --- 25,36 ---- D =. O =. ! BINDIR =/usr/lib/apsfilter/bin ! MANDIR =/usr/man/man1 ! MANEXT =1 ! CFLAGS = -s -O -DBSD -DAKL # -DAKL_DEBUG # Default values for HEIGHT, WIDTH, MARGIN and DIR_SEP (11.64, 8.27, 1.2, '/'). # Default values for LPR_PRINT, LPR_COMMAND and LPR_OPT (TRUE, "lpr", "-l") # No values for TWOSIDED_DFLT, ONESIDED and TWOSIDED *** ../a2ps-4.2-orig/a2ps.c Fri Jul 30 13:55:35 1993 --- a2ps.c Sun Apr 17 16:09:19 1994 *************** *** 146,151 **** --- 146,152 ---- /* * Default page dimensions */ + #ifndef WIDTH #define WIDTH 8.27 #endif *************** *** 228,233 **** --- 229,239 ---- */ #ifdef __STDC__ /* Function prototypes */ + + #ifdef AKL + void set_paper_format(char *arg); + #endif + void usage(int failure); void set_global_option(char *arg); void set_positional_option(char *arg); *************** *** 331,344 **** --- 337,361 ---- char *prologue = NULL; /* postscript header file */ #if defined(SYSV) || defined(BSD) char *login = NULL; /* user's login name and host machine */ + #ifdef AKL + char *logname, *host = NULL; /* new commandline flags ... */ + #endif #endif /* * Sheet dimensions */ + #ifdef AKL + double page_height_inch = HEIGHT; /* Paper height in inch */ + double page_width_inch = WIDTH; /* Paper width in inch */ + double page_height; /* for Paper height in pixels */ + double page_width; /* for Paper width in pixels */ + double margin = MARGIN; + #else double page_height = HEIGHT; /* Paper height */ double page_width = WIDTH; /* Paper width */ + #endif /************************************************************************/ *************** *** 399,407 **** --- 416,537 ---- fprintf(stderr," \t-nu\tdon't print a filename footer\n"); fprintf(stderr," -v\t-nv\tVISIBLE (blank) display of unprintable chars\n"); fprintf(stderr," -8\t-n8\tdisplay (DON'T DISPLAY) 8-bit chars\n"); + #ifdef AKL + fprintf(stderr," -Xformat\tghostscripts page format = a0,a1,...,letter\n"); + fprintf(stderr," -Mmargin\tmargin size in inch, default: 1.4 inch\n"); + #endif exit(failure); } + #ifdef AKL + + /* + * AKL - set sheet dimensions using ghostscripts format names and sizes + * see: GS_LIBDIR/gs_statd.ps, note: these values are given in 1/72 inch + */ + + void + set_paper_format(arg) + char *arg; + { + if (strstr(arg,"letter")) { + page_width_inch = 8.50; page_height_inch = 11.00; + } else + if (strstr(arg,"note")) { + page_width_inch = 7.50; page_height_inch = 10.00; + } else + if (strstr(arg,"legal")) { + page_width_inch = 8.50; page_height_inch = 14.00; + } else + if (strstr(arg,"a0")) { + page_width_inch = 33.06; page_height_inch = 46.78; + } else + if (strstr(arg,"a1")) { + page_width_inch = 23.39; page_height_inch = 33.06; + } else + if (strstr(arg,"a2")) { + page_width_inch = 16.53; page_height_inch = 23.39; + } else + if (strstr(arg,"a3")) { + page_width_inch = 11.69; page_height_inch = 16.53; + } else + if (strstr(arg,"a4")) { + page_width_inch = 8.26; page_height_inch = 11.69; + } else + if (strstr(arg,"a5")) { + page_width_inch = 5.85; page_height_inch = 8.26; + } else + if (strstr(arg,"a6")) { + page_width_inch = 4.12; page_height_inch = 5.85; + } else + if (strstr(arg,"a7")) { + page_width_inch = 2.92; page_height_inch = 4.12; + } else + if (strstr(arg,"a8")) { + page_width_inch = 2.06; page_height_inch = 2.92; + } else + if (strstr(arg,"a9")) { + page_width_inch = 1.46; page_height_inch = 2.06; + } else + if (strstr(arg,"a10")) { + page_width_inch = 1.03; page_height_inch = 1.46; + } else + if (strstr(arg,"b0")) { + page_width_inch = 39.39; page_height_inch = 55.67; + } else + if (strstr(arg,"b1")) { + page_width_inch = 27.83; page_height_inch = 39.39; + } else + if (strstr(arg,"b2")) { + page_width_inch = 19.69; page_height_inch = 27.83; + } else + if (strstr(arg,"b3")) { + page_width_inch = 13.92; page_height_inch = 19.69; + } else + if (strstr(arg,"b4")) { + page_width_inch = 9.85; page_height_inch = 13.92; + } else + if (strstr(arg,"b5")) { + page_width_inch = 6.96; page_height_inch = 9.85; + } else + if (strstr(arg,"archE")) { + page_width_inch = 36.00; page_height_inch = 48.00; + } else + if (strstr(arg,"archD")) { + page_width_inch = 24.00; page_height_inch = 36.00; + } else + if (strstr(arg,"archC")) { + page_width_inch = 18.00; page_height_inch = 24.00; + } else + if (strstr(arg,"archB")) { + page_width_inch = 12.00; page_height_inch = 18.00; + } else + if (strstr(arg,"archA")) { + page_width_inch = 9.00; page_height_inch = 12.00; + } else + if (strstr(arg,"flsa")) { + page_width_inch = 8.50; page_height_inch = 13.00; + } else + if (strstr(arg,"flse")) { + page_width_inch = 8.50; page_height_inch = 13.00; + } else + if (strstr(arg,"halfletter")) { + page_width_inch = 5.50; page_height_inch = 8.50; + } else + if (strstr(arg,"11x17")) { + page_width_inch = 11.00; page_height_inch = 17.00; + } else + if (strstr(arg,"ledger")) { + page_width_inch = 17.00; page_height_inch = 11.00; + } else { + fprintf(stderr,"a2ps: %s : unknown paper format or\n",arg); + fprintf(stderr," ^--- missing paper format\n"); + exit(1); + } + } + + #endif /* AKL */ + /* * Set an option only if it's global. */ *************** *** 545,550 **** --- 675,695 ---- case 'H': case 'l': return; + #ifdef AKL + case 'X': /* gs page dimensions */ + set_paper_format(arg); + break; + case 'M': + if (arg[2] == NUL || (margin = atof(arg+2)) <= 0) + usage(EXIT_FAILURE); + break; + case 'Q': + logname=arg+2; + break; + case 'Z': + host=arg+2; + break; + #endif default: usage(EXIT_FAILURE); } *************** *** 1158,1171 **** --- 1303,1327 ---- fprintf(stderr, "Error getting file modification time\n"); exit(EXIT_FAILURE); } + #ifdef AKL + /* modifications for FreeBSD */ + /* Do we have a fifo ? */ + if (S_ISFIFO(statbuf.st_mode)) + printf("/date currdate def\n"); + /* Do we have a pipe ? */ + else if (!statbuf.st_mode) + printf("/date currdate def\n"); + #else /* Do we have a pipe? */ if (S_ISFIFO(statbuf.st_mode)) printf("/date currdate def\n"); + #endif else { string = ctime(&statbuf.st_mtime); printf("/date (%.6s %.4s %.5s) def\n", string+4, string+20, string+11); } + /* Start file impression */ putchar('('); for (p = title; *p != NUL;) *************** *** 1371,1377 **** --- 1527,1535 ---- FILE *f; char *datestring; #if defined(SYSV) || defined(BSD) + #ifndef AKL char *logname, *host; + #endif int rt; #endif *************** *** 1407,1412 **** --- 1565,1586 ---- #if defined(SYSV) || defined(BSD) /* Retrieve user's login name and hostname */ + #ifdef AKL + if (!logname) + logname = getlogin(); + if (!host) + { + host = (char *)malloc(MAX_HOSTNAME); + if (host != NULL) + { + if ((rt = gethostname(host, MAX_HOSTNAME)) == -1 || host[0] == NULL) + { + free(host); + host = NULL; + } + } + } + #else logname = getlogin(); host = (char *)malloc(MAX_HOSTNAME); if (host != NULL) { *************** *** 1415,1420 **** --- 1589,1595 ---- host = NULL; } } + #endif /* AKL */ #endif /* Print a general prologue */ *************** *** 1434,1442 **** --- 1609,1623 ---- printf("\n%% Initialize page description variables.\n"); printf("/x0 0 def\n"); printf("/y0 0 def\n"); + #ifdef AKL + printf("/sheetheight %g inch def\n", (double)page_height_inch); + printf("/sheetwidth %g inch def\n", (double)page_width_inch); + printf("/margin %g inch def\n", margin); + #else printf("/sheetheight %g inch def\n", (double)HEIGHT); printf("/sheetwidth %g inch def\n", (double)WIDTH); printf("/margin %g inch def\n", (double)MARGIN); + #endif printf("/rightmargin margin 3 div def\n"); printf("/leftmargin margin 2 mul 3 div def\n"); printf("/twinfiles %s def\n", twinfiles ? "true" : "false"); *************** *** 1457,1466 **** --- 1638,1650 ---- printf("/login (Printed from %s) def\n", host); } + #ifndef AKL + /* AKL: causes Segmentation fault, when running twice ... */ /* If the host string was allocated via malloc, release the memory */ if (host != NULL) free(host); #endif + #endif /* Close prolog */ printf("%%%%EndProlog\n\n"); *************** *** 1709,1716 **** --- 1893,1912 ---- /* Initialize variables not depending of positional options */ landscape = twinpages = -1; /* To force format switching */ fontsize = -1.0; /* To force fontsize switching */ + #ifdef AKL + page_height = (page_height_inch - margin) * PIXELS_INCH; + page_width = (page_width_inch - margin) * PIXELS_INCH; + # ifdef AKL_DEBUG + fprintf(stderr,"DEBUG... margin : %.1f\n", margin); + fprintf(stderr,"DEBUG... page_width_inch : %.2f\n", page_width_inch); + fprintf(stderr,"DEBUG... page_height_inch : %.2f\n", page_height_inch); + fprintf(stderr,"DEBUG... page_width pixel: %.2f\n", page_width); + fprintf(stderr,"DEBUG... page_height pixel: %.2f\n", page_height); + # endif /* AKL_DEBUG */ + #else page_height = (double)(HEIGHT - MARGIN) * PIXELS_INCH; page_width = (double)(WIDTH - MARGIN) * PIXELS_INCH; + #endif /* AKL */ /* Postcript prologue printing */ print_prologue(); -- Andreas Klemm http://www.FreeBSD.ORG/~andreas What gives you 90% more speed, for example, in kernel compilation ? http://www.FreeBSD.ORG/~fsmp/SMP/akgraph-a/graph1.html "NT = Not Today" (Maggie Biggs) ``powered by FreeBSD SMP'' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message