From 0d9875c1ca837dd4df4d370853649c096e73e54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Pettersen?= Date: Sat, 1 May 1999 17:54:43 +0000 Subject: [PATCH] os2 printing --- ChangeLog | 2 + plug-ins/print/print-ps.c | 6 +++ plug-ins/print/print.c | 83 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8b75ee845d..1cb4b8cbea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ Sat May 1 11:05:02 1999 ape@lrdpf.spacetec.no (Asbjorn Pettersen) + * plug-ins/print/print.c (get_printers): OS/2 printing. + * plug-ins/print/print-ps.c (ps_print): set prn in text mode. * plug-ins/ps/ps.c (read_pnmraw_type): skip '\r'; * plug-ins/screenshot/screenshot.c (shoot): Use spawnlp() instead of fork(). diff --git a/plug-ins/print/print-ps.c b/plug-ins/print/print-ps.c index 2f2bb8bd8d..bce67c5dc9 100644 --- a/plug-ins/print/print-ps.c +++ b/plug-ins/print/print-ps.c @@ -32,6 +32,9 @@ * Revision History: * * $Log$ + * Revision 1.12 1999/05/01 17:54:09 asbjoer + * os2 printing + * * Revision 1.11 1999/04/15 21:49:01 yosh * * applied gimp-lecorfec-99041[02]-0, changes follow * @@ -630,6 +633,9 @@ ps_print(int model, /* I - Model (Level 1 or 2) */ printf("left = %d, top = %d\n", left, top); #endif /* DEBUG */ +#ifdef __EMX__ + _fsetmode(prn, "t"); +#endif fputs("%!PS-Adobe-3.0\n", prn); fputs("%%Creator: " PLUG_IN_NAME " plug-in V" PLUG_IN_VERSION " for GIMP.\n", prn); fprintf(prn, "%%%%CreationDate: %s", ctime(&curtime)); diff --git a/plug-ins/print/print.c b/plug-ins/print/print.c index 31a9ca8b05..f7fd716de9 100644 --- a/plug-ins/print/print.c +++ b/plug-ins/print/print.c @@ -39,6 +39,9 @@ * Revision History: * * $Log$ + * Revision 1.12 1999/05/01 17:53:52 asbjoer + * os2 printing + * * Revision 1.11 1999/01/15 17:34:25 unammx * 1999-01-15 Federico Mena Quintero * @@ -140,6 +143,11 @@ #include "print.h" #include #include +#ifdef __EMX__ +#define INCL_DOSDEVICES +#define INCL_DOSERRORS +#include +#endif /* @@ -375,12 +383,16 @@ printer_t printers[] = /* List of supported printer types */ * 'main()' - Main entry - just call gimp_main()... */ +#if 0 int main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line args */ { return (gimp_main(argc, argv)); } +#else +MAIN() +#endif /* @@ -429,6 +441,25 @@ query(void) } +#ifdef __EMX__ +static char * +get_tmp_filename() +{ + char *tmp_path, *s, filename[80]; + + tmp_path = getenv("TMP"); + if (tmp_path == NULL) + tmp_path = ""; + + sprintf(filename, "gimp_print_tmp.%d", getpid()); + s = tmp_path = g_strconcat(tmp_path, "\\", filename, NULL); + if (!s) + return NULL; + for ( ; *s; s++) + if (*s == '/') *s = '\\'; + return tmp_path; +} +#endif /* * 'run()' - Run the plug-in... */ @@ -453,6 +484,9 @@ run(char *name, /* I - Name of print program. */ guchar *cmap; /* Colormap (indexed images only) */ int ncolors; /* Number of colors in colormap */ GParam *values; /* Return values */ +#ifdef __EMX__ + char *tmpfile; /* temp filename */ +#endif /* @@ -591,7 +625,12 @@ run(char *name, /* I - Name of print program. */ */ if (plist_current > 0) +#ifndef __EMX__ prn = popen(vars.output_to, "w"); +#else + /* OS/2 PRINT command doesn't support print from stdin, use temp file */ + prn = (tmpfile = get_tmp_filename()) ? fopen(tmpfile, "w") : NULL; +#endif else prn = fopen(vars.output_to, "w"); @@ -643,7 +682,20 @@ run(char *name, /* I - Name of print program. */ vars.left, vars.top, 1, prn, drawable, lut, cmap); if (plist_current > 0) +#ifndef __EMX__ pclose(prn); +#else + { /* PRINT temp file */ + char *s; + fclose(prn); + s = g_strconcat(vars.output_to, tmpfile, NULL); + if (system(s) != 0) + values[0].data.d_status = STATUS_EXECUTION_ERROR; + g_free(s); + remove(tmpfile); + g_free(tmpfile); + } +#endif else fclose(prn); } @@ -1961,8 +2013,15 @@ printrc_load(void) strcpy(line, "/.gimp/printrc"); else sprintf(line, "%s/.gimp/printrc", getenv("HOME")); +#ifdef __EMX__ + _fnslashify(line); +#endif +#ifndef __EMX__ if ((fp = fopen(line, "r")) != NULL) +#else + if ((fp = fopen(line, "rt")) != NULL) +#endif { /* * File exists - read the contents and update the printer list... @@ -2081,8 +2140,15 @@ printrc_save(void) strcpy(filename, "/.gimp/printrc"); else sprintf(filename, "%s/.gimp/printrc", getenv("HOME")); +#ifdef __EMX__ + _fnslashify(filename); +#endif +#ifndef __EMX__ if ((fp = fopen(filename, "w")) != NULL) +#else + if ((fp = fopen(filename, "wt")) != NULL) +#endif { /* * Write the contents of the printer list... @@ -2125,6 +2191,9 @@ get_printers(void) line[129], name[17], defname[17]; +#ifdef __EMX__ + BYTE pnum; +#endif defname[0] = '\0'; @@ -2177,6 +2246,20 @@ get_printers(void) }; #endif /* LPSTAT_COMMAND */ +#ifdef __EMX__ + if (DosDevConfig(&pnum, DEVINFO_PRINTER) == NO_ERROR) + { + for (i = 1; i <= pnum; i++) + { + sprintf(plist[plist_count].name, "LPT%d:", i); + sprintf(plist[plist_count].command, "PRINT /D:LPT%d /B ", i); + strcpy(plist[plist_count].driver, "ps2"); + plist[plist_count].output_type = OUTPUT_COLOR; + plist_count ++; + } + } +#endif + if (plist_count > 2) qsort(plist + 1, plist_count - 1, sizeof(plist_t), (int (*)(const void *, const void *))compare_printers);