1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
/* Copyright (C) 2001-2021 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
CA 94945, U.S.A., +1(415)492-9861, for further information.
*/
/* OSK-specific routines for Ghostscript */
#include "pipe_.h"
#include "string_.h"
#include "time_.h"
#include "gx.h"
#include "gp.h"
#include <signal.h>
#include <stdlib.h> /* for exit */
int interrupted;
/* Forward declarations */
static void signalhandler(int);
static FILE *rbfopen(char *, char *);
/* Do platform-dependent initialization */
void
gp_init(void)
{
intercept(signalhandler);
}
/* Do platform-dependent cleanup. */
void
gp_exit(int exit_status, int code)
{
}
/* Exit the program. */
void
gp_do_exit(int exit_status)
{
exit(exit_status);
}
static void
signalhandler(int sig)
{
clearerr(stdin);
switch (sig) {
case SIGINT:
case SIGQUIT:
interrupted = 1;
break;
case SIGFPE:
interrupted = 2;
break;
default:
break;
}
}
/* ------ Date and time ------ */
/* Read the current time (in seconds since Jan. 1, 1980) */
/* and fraction (in nanoseconds). */
#define PS_YEAR_0 80
#define PS_MONTH_0 1
#define PS_DAY_0 1
void
gp_get_realtime(long *pdt)
{
long date, time, pstime, psdate, tick;
short day;
_sysdate(0, &time, &date, &day, &tick);
_julian(&time, &date);
pstime = 0;
psdate = (PS_YEAR_0 << 16) + (PS_MONTH_0 << 8) + PS_DAY_0;
_julian(&pstime, &psdate);
pdt[0] = (date - psdate) * 86400 + time;
pdt[1] = 0;
#ifdef DEBUG_CLOCK
printf("pdt[0] = %ld pdt[1] = %ld\n", pdt[0], pdt[1]);
#endif
}
/* Read the current user CPU time (in seconds) */
/* and fraction (in nanoseconds). */
void
gp_get_usertime(long *pdt)
{
return gp_get_realtime(pdt); /* not yet implemented */
}
/* ------ Printer accessing ------ */
/* Open a connection to a printer. A null file name means use the */
/* standard printer connected to the machine, if any. */
/* "|command" opens an output pipe. */
/* Return NULL if the connection could not be opened. */
FILE *
gp_open_printer_impl(gs_memory_t *mem,
const char *fname,
int *binary_mode,
void (**close)(FILE *))
{
int pipe;
if (fname[0] == 0)
return NULL;
pipe = fname[0] == '|';
*close = (pipe ? pclose : fclose);
return (pipe ? popen(fname + 1, "w") :
rbfopen(fname, "w"));
}
FILE *
rbfopen(const char *fname, char *perm)
{
FILE *file = fopen(fname, perm);
file->_flag |= _RBF;
return file;
}
/* Close the connection to the printer. */
void
gp_close_printer(gp_file *pfile, const char *fname)
{
gp_fclose(pfile);
}
/* ------ File accessing -------- */
/* Set a file into binary or text mode. */
int
gp_setmode_binary_impl(FILE * pfile, bool binary)
{
if (binary)
file->_flag |= _RBF;
else
file->_flag &= ~_RBF;
return 0;
}
/* ------ Font enumeration ------ */
/* This is used to query the native os for a list of font names and
* corresponding paths. The general idea is to save the hassle of
* building a custom fontmap file.
*/
void *gp_enumerate_fonts_init(gs_memory_t *mem)
{
return NULL;
}
int gp_enumerate_fonts_next(void *enum_state, char **fontname, char **path)
{
return 0;
}
void gp_enumerate_fonts_free(void *enum_state)
{
}
|