|
|
b7f097 |
diff -pruN paps-0.6.8.orig/configure.in paps-0.6.8/configure.in
|
|
|
b7f097 |
--- paps-0.6.8.orig/configure.in 2007-01-19 20:06:10.000000000 +0900
|
|
|
b7f097 |
+++ paps-0.6.8/configure.in 2008-11-07 08:21:19.000000000 +0900
|
|
|
b7f097 |
@@ -7,6 +7,19 @@ AC_LANG_C
|
|
|
b7f097 |
AC_PROG_CC
|
|
|
b7f097 |
AM_PROG_LIBTOOL
|
|
|
b7f097 |
|
|
|
b7f097 |
+dnl ======================================================
|
|
|
b7f097 |
+dnl check for CUPS
|
|
|
b7f097 |
+dnl ======================================================
|
|
|
b7f097 |
+AC_PATH_PROG(CUPS_CONFIG, cups-config, no)
|
|
|
b7f097 |
+if test "$CUPS_CONFIG" = "no"; then
|
|
|
b7f097 |
+ AC_MSG_ERROR([Please install cups development packages/files])
|
|
|
b7f097 |
+fi
|
|
|
b7f097 |
+CUPS_CFLAGS=`$CUPS_CONFIG --cflags | sed -e 's/-O[0-9]*//' -e 's/-m[^\t]*//g'`
|
|
|
b7f097 |
+CUPS_LIBS=`$CUPS_CONFIG --libs`
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+AC_SUBST(CUPS_CFLAGS)
|
|
|
b7f097 |
+AC_SUBST(CUPS_LIBS)
|
|
|
b7f097 |
+
|
|
|
b7f097 |
DX_HTML_FEATURE(ON)
|
|
|
b7f097 |
DX_CHM_FEATURE(OFF)
|
|
|
b7f097 |
DX_CHI_FEATURE(OFF)
|
|
|
b7f097 |
diff -pruN paps-0.6.8.orig/src/Makefile.am paps-0.6.8/src/Makefile.am
|
|
|
b7f097 |
--- paps-0.6.8.orig/src/Makefile.am 2008-11-07 08:21:05.000000000 +0900
|
|
|
b7f097 |
+++ paps-0.6.8/src/Makefile.am 2008-11-07 08:21:19.000000000 +0900
|
|
|
b7f097 |
@@ -5,10 +5,10 @@ libpapsinc_HEADERS = libpaps.h
|
|
|
b7f097 |
libpapsincdir = $(includedir)
|
|
|
b7f097 |
|
|
|
b7f097 |
bin_PROGRAMS = paps
|
|
|
b7f097 |
-paps_CFLAGS = -Wall
|
|
|
b7f097 |
+paps_CFLAGS = -Wall $(CUPS_CFLAGS)
|
|
|
b7f097 |
paps_SOURCES = paps.c
|
|
|
b7f097 |
paps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
|
|
|
b7f097 |
-paps_LDFLAGS = `pkg-config --libs pangoft2`
|
|
|
b7f097 |
+paps_LDFLAGS = `pkg-config --libs pangoft2` $(CUPS_LIBS)
|
|
|
b7f097 |
paps_DEPENDENCIES = $(lib_LTLIBRARIES)
|
|
|
b7f097 |
|
|
|
b7f097 |
EXTRA_DIST = test_libpaps.c paps.1
|
|
|
b7f097 |
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
|
|
|
b7f097 |
--- paps-0.6.8.orig/src/paps.c 2008-11-07 08:21:05.000000000 +0900
|
|
|
b7f097 |
+++ paps-0.6.8/src/paps.c 2008-11-07 08:26:28.000000000 +0900
|
|
|
b7f097 |
@@ -31,6 +31,8 @@
|
|
|
b7f097 |
#include <string.h>
|
|
|
b7f097 |
#include <time.h>
|
|
|
b7f097 |
#include <locale.h>
|
|
|
b7f097 |
+#include <cups/cups.h>
|
|
|
b7f097 |
+#include <cups/ppd.h>
|
|
|
b7f097 |
|
|
|
b7f097 |
#define BUFSIZE 1024
|
|
|
b7f097 |
#define DEFAULT_FONT_FAMILY "Monospace"
|
|
|
b7f097 |
@@ -86,9 +88,11 @@ typedef struct {
|
|
|
b7f097 |
gboolean do_wordwrap;
|
|
|
b7f097 |
gboolean do_use_markup;
|
|
|
b7f097 |
gboolean do_stretch_chars;
|
|
|
b7f097 |
+ gboolean cups_mode;
|
|
|
b7f097 |
PangoDirection pango_dir;
|
|
|
b7f097 |
gchar *filename;
|
|
|
b7f097 |
gchar *header_font_desc;
|
|
|
b7f097 |
+ gchar *owner;
|
|
|
b7f097 |
gint lpi;
|
|
|
b7f097 |
gint cpi;
|
|
|
b7f097 |
} page_layout_t;
|
|
|
b7f097 |
@@ -320,8 +324,8 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
int num_pages = 1;
|
|
|
b7f097 |
int gutter_width = 40;
|
|
|
b7f097 |
int total_gutter_width;
|
|
|
b7f097 |
- int page_width = paper_sizes[0].width;
|
|
|
b7f097 |
- int page_height = paper_sizes[0].height;
|
|
|
b7f097 |
+ int page_width = -1;
|
|
|
b7f097 |
+ int page_height = -1;
|
|
|
b7f097 |
int do_tumble = -1; /* -1 means not initialized */
|
|
|
b7f097 |
int do_duplex = -1;
|
|
|
b7f097 |
gchar *paps_header = NULL;
|
|
|
b7f097 |
@@ -331,6 +335,8 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
int max_width = 0, w;
|
|
|
b7f097 |
GIConv cvh = NULL;
|
|
|
b7f097 |
GOptionGroup *options;
|
|
|
b7f097 |
+ gboolean cups_mode = FALSE;
|
|
|
b7f097 |
+ gchar *page_owner = NULL;
|
|
|
b7f097 |
|
|
|
b7f097 |
/* Set locale from environment. */
|
|
|
b7f097 |
setlocale(LC_ALL, "");
|
|
|
b7f097 |
@@ -348,6 +354,130 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
g_option_context_add_main_entries(ctxt, entries, NULL);
|
|
|
b7f097 |
#endif
|
|
|
b7f097 |
|
|
|
b7f097 |
+ /* check if the process is being invoked as CUPS filter */
|
|
|
b7f097 |
+ G_STMT_START {
|
|
|
b7f097 |
+ gchar *prgname = g_path_get_basename(argv[0]);
|
|
|
b7f097 |
+ cups_option_t *options = NULL;
|
|
|
b7f097 |
+ ppd_file_t *ppd;
|
|
|
b7f097 |
+ ppd_size_t *pagesize;
|
|
|
b7f097 |
+ int num_options;
|
|
|
b7f097 |
+ const char *val;
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if (strncmp(prgname, "texttopaps", 10) == 0 ||
|
|
|
b7f097 |
+ getenv("CUPS_SERVER") != NULL) {
|
|
|
b7f097 |
+ g_set_prgname(prgname);
|
|
|
b7f097 |
+ /* argument format should be job-id user title copies options [file] */
|
|
|
b7f097 |
+ cups_mode = TRUE;
|
|
|
b7f097 |
+ /* set default values */
|
|
|
b7f097 |
+ page_layout.lpi = 6.0L;
|
|
|
b7f097 |
+ page_layout.cpi = 10.0L;
|
|
|
b7f097 |
+ left_margin = 18;
|
|
|
b7f097 |
+ right_margin = 18;
|
|
|
b7f097 |
+ top_margin = 36;
|
|
|
b7f097 |
+ bottom_margin = 36;
|
|
|
b7f097 |
+ page_width = 612;
|
|
|
b7f097 |
+ page_height = 792;
|
|
|
b7f097 |
+ font = g_strdup(MAKE_FONT_NAME ("Courier", DEFAULT_FONT_SIZE));
|
|
|
b7f097 |
+ header_font_desc = g_strdup(MAKE_FONT_NAME ("Courier", HEADER_FONT_SCALE));
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if (argc < 6 || argc > 7) {
|
|
|
b7f097 |
+ fprintf(stderr, "ERROR: %s job-id user title copies options [file]\n", prgname);
|
|
|
b7f097 |
+ exit(1);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if (argc == 6) {
|
|
|
b7f097 |
+ filename_in = "stdin";
|
|
|
b7f097 |
+ IN = stdin;
|
|
|
b7f097 |
+ } else {
|
|
|
b7f097 |
+ filename_in = argv[6];
|
|
|
b7f097 |
+ if ((IN = fopen(filename_in, "rb")) == NULL) {
|
|
|
b7f097 |
+ fprintf(stderr, "ERROR: unable to open print file -\n");
|
|
|
b7f097 |
+ exit(1);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ title = argv[3];
|
|
|
b7f097 |
+ page_owner = argv[2];
|
|
|
b7f097 |
+ num_options = cupsParseOptions(argv[5], 0, &options);
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(val, "no") &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(val, "off") &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(val, "false")) {
|
|
|
b7f097 |
+ /* XXX: need to support the keywords highlighting */
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ ppd = ppdOpenFile(getenv("PPD"));
|
|
|
b7f097 |
+ ppdMarkDefaults(ppd);
|
|
|
b7f097 |
+ cupsMarkOptions(ppd, num_options, options);
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if ((pagesize = ppdPageSize(ppd, NULL)) != NULL) {
|
|
|
b7f097 |
+ page_width = pagesize->width;
|
|
|
b7f097 |
+ page_height = pagesize->length;
|
|
|
b7f097 |
+ top_margin = pagesize->length - pagesize->top;
|
|
|
b7f097 |
+ bottom_margin = pagesize->bottom;
|
|
|
b7f097 |
+ left_margin = pagesize->left;
|
|
|
b7f097 |
+ right_margin = pagesize->width - pagesize->right;
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if ((val = cupsGetOption("landscape", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ if (g_ascii_strcasecmp(val, "no") &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(val, "off") &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(val, "false"))
|
|
|
b7f097 |
+ do_landscape = TRUE;
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ /* XXX: need to support orientation-requested? */
|
|
|
b7f097 |
+ if ((val = cupsGetOption("page-left", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ left_margin = (int)atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("page-right", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ right_margin = (int)atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("page-bottom", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ bottom_margin = (int)atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("page-top", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ top_margin = (int)atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if (ppdIsMarked(ppd, "Duplex", "DuplexNoTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "Duplex", "DuplexTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexNoTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "EFDuplex", "DuplexNoTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "EFDuplex", "DuplexTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexNoTumble") ||
|
|
|
b7f097 |
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexTumble")) {
|
|
|
b7f097 |
+ do_duplex = TRUE;
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("wrap", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ do_wordwrap = !g_ascii_strcasecmp(val, "true") ||
|
|
|
b7f097 |
+ !g_ascii_strcasecmp(val, "on") ||
|
|
|
b7f097 |
+ !g_ascii_strcasecmp(val, "yes");
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("columns", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ num_columns = atoi(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("cpi", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ page_layout.cpi = atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if ((val = cupsGetOption("lpi", num_options, options)) != NULL) {
|
|
|
b7f097 |
+ page_layout.lpi = atof(val);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if (getenv("CHARSET") != NULL) {
|
|
|
b7f097 |
+ char *charset = getenv("CHARSET");
|
|
|
b7f097 |
+ /* Map CUPS charset names to real ones.
|
|
|
b7f097 |
+ * http://cups.org/newsgroups.php?s9797+gcups.general+v9797+T1
|
|
|
b7f097 |
+ */
|
|
|
b7f097 |
+ if (!g_ascii_strcasecmp(charset, "windows-932")) {
|
|
|
b7f097 |
+ charset = "WINDOWS-31J";
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ if (g_ascii_strcasecmp(charset, "utf-8") &&
|
|
|
b7f097 |
+ g_ascii_strcasecmp(charset, "utf8")) {
|
|
|
b7f097 |
+ encoding = g_strdup(charset);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ } G_STMT_END;
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ if (!cups_mode) {
|
|
|
b7f097 |
+
|
|
|
b7f097 |
/* Parse command line */
|
|
|
b7f097 |
if (!g_option_context_parse(ctxt, &argc, &argv, &error))
|
|
|
b7f097 |
{
|
|
|
b7f097 |
@@ -374,6 +504,8 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
IN = stdin;
|
|
|
b7f097 |
}
|
|
|
b7f097 |
title = filename_in;
|
|
|
b7f097 |
+
|
|
|
b7f097 |
+ } /* if (!cups_mode) */
|
|
|
b7f097 |
|
|
|
b7f097 |
paps = paps_new();
|
|
|
b7f097 |
pango_context = paps_get_pango_context (paps);
|
|
|
b7f097 |
@@ -392,8 +524,10 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
pango_context_set_font_description (pango_context, font_description);
|
|
|
b7f097 |
|
|
|
b7f097 |
/* Page layout */
|
|
|
b7f097 |
- page_width = paper_sizes[(int)paper_type].width;
|
|
|
b7f097 |
- page_height = paper_sizes[(int)paper_type].height;
|
|
|
b7f097 |
+ if (page_width < 0)
|
|
|
b7f097 |
+ page_width = paper_sizes[(int)paper_type].width;
|
|
|
b7f097 |
+ if (page_height < 0)
|
|
|
b7f097 |
+ page_height = paper_sizes[(int)paper_type].height;
|
|
|
b7f097 |
|
|
|
b7f097 |
if (num_columns == 1)
|
|
|
b7f097 |
total_gutter_width = 0;
|
|
|
b7f097 |
@@ -456,6 +590,8 @@ int main(int argc, char *argv[])
|
|
|
b7f097 |
page_layout.pango_dir = pango_dir;
|
|
|
b7f097 |
page_layout.filename = filename_in;
|
|
|
b7f097 |
page_layout.header_font_desc = header_font_desc;
|
|
|
b7f097 |
+ page_layout.owner = page_owner;
|
|
|
b7f097 |
+ page_layout.cups_mode = cups_mode;
|
|
|
b7f097 |
|
|
|
b7f097 |
/* calculate x-coordinate scale */
|
|
|
b7f097 |
if (page_layout.cpi > 0.0L)
|
|
|
b7f097 |
@@ -756,6 +892,12 @@ split_text_into_paragraphs (PangoContext
|
|
|
b7f097 |
if (wc == (gunichar)-1)
|
|
|
b7f097 |
{
|
|
|
b7f097 |
fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ());
|
|
|
b7f097 |
+ if (page_layout->cups_mode)
|
|
|
b7f097 |
+ {
|
|
|
b7f097 |
+ /* try to continue parsing texts */
|
|
|
b7f097 |
+ p = next;
|
|
|
b7f097 |
+ continue;
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
wc = 0;
|
|
|
b7f097 |
}
|
|
|
b7f097 |
if (!*p || !wc || wc == '\n' || wc == '\f')
|
|
|
b7f097 |
@@ -925,21 +1067,32 @@ void print_postscript_header(FILE *OUT,
|
|
|
b7f097 |
int orientation = page_layout->page_width > page_layout->page_height;
|
|
|
b7f097 |
int bb_page_width = page_layout->page_width;
|
|
|
b7f097 |
int bb_page_height = page_layout->page_height;
|
|
|
b7f097 |
+ char *owner = NULL;
|
|
|
b7f097 |
|
|
|
b7f097 |
/* Keep bounding box non-rotated to make ggv happy */
|
|
|
b7f097 |
- if (orientation)
|
|
|
b7f097 |
+ /* ensure the correct bounding box for CUPS */
|
|
|
b7f097 |
+ if (orientation && !page_layout->cups_mode)
|
|
|
b7f097 |
{
|
|
|
b7f097 |
int tmp = bb_page_width;
|
|
|
b7f097 |
bb_page_width = bb_page_height;
|
|
|
b7f097 |
bb_page_height = tmp;
|
|
|
b7f097 |
}
|
|
|
b7f097 |
|
|
|
b7f097 |
+ if (page_layout->owner)
|
|
|
b7f097 |
+ {
|
|
|
b7f097 |
+ owner = g_strdup_printf("%%%%For: %s\n", page_layout->owner);
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
+ else
|
|
|
b7f097 |
+ {
|
|
|
b7f097 |
+ owner = g_strdup("");
|
|
|
b7f097 |
+ }
|
|
|
b7f097 |
fprintf(OUT,
|
|
|
b7f097 |
"%%!PS-Adobe-3.0\n"
|
|
|
b7f097 |
+ "%s"
|
|
|
b7f097 |
"%%%%Title: %s\n"
|
|
|
b7f097 |
"%%%%Creator: paps version 0.6.7 by Dov Grobgeld\n"
|
|
|
b7f097 |
"%%%%Pages: (atend)\n"
|
|
|
b7f097 |
- "%%%%BoundingBox: 0 0 %d %d\n"
|
|
|
b7f097 |
+ "%%%%BoundingBox: 0 0 %d %d\n%s"
|
|
|
b7f097 |
"%%%%BeginProlog\n"
|
|
|
b7f097 |
"%%%%Orientation: %s\n"
|
|
|
b7f097 |
"/papsdict 1 dict def\n"
|
|
|
b7f097 |
@@ -961,7 +1114,7 @@ void print_postscript_header(FILE *OUT,
|
|
|
b7f097 |
" pagewidth\n"
|
|
|
b7f097 |
" /pagewidth pageheight def\n"
|
|
|
b7f097 |
" /pageheight exch def\n"
|
|
|
b7f097 |
- " /orientation 3 def\n"
|
|
|
b7f097 |
+ " /orientation %d def\n"
|
|
|
b7f097 |
" } if\n"
|
|
|
b7f097 |
" 2 dict\n"
|
|
|
b7f097 |
" dup /PageSize [pagewidth pageheight] put\n"
|
|
|
b7f097 |
@@ -986,11 +1139,21 @@ void print_postscript_header(FILE *OUT,
|
|
|
b7f097 |
" 90 rotate\n"
|
|
|
b7f097 |
" 0 pageheight neg translate\n"
|
|
|
b7f097 |
"} def\n",
|
|
|
b7f097 |
+ /*
|
|
|
b7f097 |
+ * Put %%cupsRotation tag to prevent the rotation in pstops.
|
|
|
b7f097 |
+ * This breaks paps's behavior to make it in landscape say.
|
|
|
b7f097 |
+ * (RH#222137)
|
|
|
b7f097 |
+ */
|
|
|
b7f097 |
+ (page_layout->cups_mode ? "%cupsRotation: 0\n" : ""),
|
|
|
b7f097 |
title,
|
|
|
b7f097 |
bb_page_width,
|
|
|
b7f097 |
bb_page_height,
|
|
|
b7f097 |
- orientation_names[orientation]
|
|
|
b7f097 |
+ owner,
|
|
|
b7f097 |
+ orientation_names[orientation],
|
|
|
b7f097 |
+ /* For landscape, rotate page to portrait orientation for CUPS (RH#222137) */
|
|
|
b7f097 |
+ page_layout->cups_mode ? 2 : 3
|
|
|
b7f097 |
);
|
|
|
b7f097 |
+ g_free(owner);
|
|
|
b7f097 |
|
|
|
b7f097 |
fprintf(OUT,
|
|
|
b7f097 |
"%% User settings\n"
|