1 /* Copyright (C) 1992, 2001 Free Software Foundation, Inc.
2 Written by James Clark (jjc@jclark.com)
4 This file is part of groff.
6 groff is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License along
17 with groff; see the file COPYING. If not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* This translates ps fonts in .pfb format to ASCII ps files. */
33 /* Binary bytes per output line. */
34 #define BYTES_PER_LINE (64/2)
35 #define HEX_DIGITS "0123456789abcdef"
37 static char *program_name;
42 fprintf(stderr, "%s: %s\n", program_name, s);
46 static void usage(FILE *stream)
48 fprintf(stream, "usage: %s [-v] [pfb_file]\n", program_name);
57 static const struct option long_options[] = {
58 { "help", no_argument, 0, CHAR_MAX + 1 },
59 { "version", no_argument, 0, 'v' },
63 program_name = argv[0];
65 while ((opt = getopt_long(argc, argv, "v", long_options, NULL)) != EOF) {
69 extern const char *Version_string;
70 printf("GNU pfbtops (groff) version %s\n", Version_string);
74 case CHAR_MAX + 1: /* --help */
85 if (argc - optind > 1) {
89 if (argc > optind && !freopen(argv[optind], "r", stdin))
95 SET_BINARY(fileno(stdin));
104 error("first byte of packet not 0x80");
108 if (type != 1 && type != 2)
109 error("bad packet type");
111 for (i = 0; i < 4; i++)
115 error("end of file in packet header");
116 n |= (long)c << (i << 3);
119 error("negative packet length");
126 error("end of file in text packet");
141 error("end of file in binary packet");
142 if (count >= BYTES_PER_LINE)
148 putchar(HEX_DIGITS[(c >> 4) & 0xf]);
149 putchar(HEX_DIGITS[c & 0xf]);