123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /* Copyright (C) 1989, 1995, 1998 Aladdin Enterprises. All rights reserved.
-
- This file is part of AFPL Ghostscript.
-
- AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
- distributor accepts any responsibility for the consequences of using it, or
- for whether it serves any particular purpose or works at all, unless he or
- she says so in writing. Refer to the Aladdin Free Public License (the
- "License") for full details.
-
- Every copy of AFPL Ghostscript must include a copy of the License, normally
- in a plain ASCII text file named PUBLIC. The License grants you the right
- to copy, modify and redistribute AFPL Ghostscript, but only under certain
- conditions described in the License. Among other things, the License
- requires that the copyright notice and this notice be preserved on all
- copies.
- */
- /*$Id: gp_dvx.c,v 1.4 2001/04/08 08:43:24 ghostgum Exp $ */
- /* Desqview/X-specific routines for Ghostscript */
- #include "string_.h"
- #include "gx.h"
- #include "gsexit.h"
- #include "gp.h"
- #include "time_.h"
- /* Do platform-dependent initialization. */
- void
- gp_init(void)
- {
- }
- /* Do platform-dependent cleanup. */
- void
- gp_exit(int exit_status, int code)
- {
- }
- /* Exit the program. */
- void
- gp_do_exit(int exit_status)
- {
- }
- /* ------ Miscellaneous ------ */
- /* Get the string corresponding to an OS error number. */
- /* All reasonable compilers support it. */
- const char *
- gp_strerror(int errnum)
- {
- return strerror(errnum);
- }
- /* ------ Date and time ------ */
- /* Read the current time (in seconds since Jan. 1, 1970) */
- /* and fraction (in nanoseconds). */
- void
- gp_get_realtime(long *pdt)
- {
- struct timeval tp;
- struct timezone tzp;
- if (gettimeofday(&tp, &tzp) == -1) {
- lprintf("Ghostscript: gettimeofday failed!\n");
- tp.tv_sec = tp.tv_usec = 0;
- }
- /* tp.tv_sec is #secs since Jan 1, 1970 */
- pdt[0] = tp.tv_sec;
- pdt[1] = tp.tv_usec * 1000;
- #ifdef DEBUG_CLOCK
- printf("tp.tv_sec = %d tp.tv_usec = %d pdt[0] = %ld pdt[1] = %ld\n",
- tp.tv_sec, tp.tv_usec, pdt[0], pdt[1]);
- #endif
- }
- /* Read the current user CPU time (in seconds) */
- /* and fraction (in nanoseconds). */
- void
- gp_get_usertime(long *pdt)
- {
- gp_get_realtime(pdt); /* Use an approximation for now. */
- }
- /* ------ Printer accessing ------ */
- /* Open a connection to a printer. A null file name means use the */
- /* standard printer connected to the machine, if any. */
- /* Return NULL if the connection could not be opened. */
- extern void gp_set_file_binary(P2(int, int));
- FILE *
- gp_open_printer(char fname[gp_file_name_sizeof], int binary_mode)
- {
- if (strlen(fname) == 0 || !strcmp(fname, "PRN")) {
- if (binary_mode)
- gp_set_file_binary(fileno(stdprn), 1);
- stdprn->_flag = _IOWRT; /* Make stdprn buffered to improve performance */
- return stdprn;
- } else
- return fopen(fname, (binary_mode ? "wb" : "w"));
- }
- /* Close the connection to the printer. */
- void
- gp_close_printer(FILE * pfile, const char *fname)
- {
- if (pfile == stdprn)
- fflush(pfile);
- else
- fclose(pfile);
- }
|