commit fac862fb945600e122307dbb4dadddb2b5738fc8
parent 17d81237615b92cd658f1d55fa2d463da4f2b8d4
Author: Kyle Milz <krwmilz@gmail.com>
Date: Fri, 20 Aug 2021 21:55:19 +0000
Remove PS_NEWS support
Diffstat:
D | psnews.c | | | 919 | ------------------------------------------------------------------------------- |
M | special.c | | | 8 | -------- |
M | xdvi.c | | | 9 | --------- |
M | xdvi.h | | | 8 | +------- |
4 files changed, 1 insertion(+), 943 deletions(-)
diff --git a/psnews.c b/psnews.c
@@ -1,919 +0,0 @@
-/*========================================================================*\
-
-Copyright (c) 1994-2002 Paul Vojta
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-PAUL VOJTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-NOTES:
- This code was originally written by Ricardo Telichevesky
- (ricardo@rle-vlsi-mit.edu) and Luis Miguel Silveira
- (lms@rle-vlsi-mit.edu).
- It was largely influenced by similar code in the SeeTeX/XTeX
- package by Dirk Grunwald (grunwald@colorado.edu).
-
-\*========================================================================*/
-
-/* ||| To do:
- * ALWAYS_CLOSE_SERVER_CONNECTION?
- * Is there some way of interrupting a process?
- * fork
- * extra bytes on input
- */
-
-#include "xdvi.h"
-#include <memory.h>
-#include <signal.h>
-#include <sys/file.h> /* this defines FASYNC */
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <NeWS/psio.h>
-#include <xvps/pscanvas.h>
-
-/* if POSIX O_NONBLOCK is not available, use O_NDELAY */
-#if !defined(O_NONBLOCK) && defined(O_NDELAY)
-#define O_NONBLOCK O_NDELAY
-#endif
-
-/* Condition for retrying a write */
-#include <errno.h>
-
-#ifdef EWOULDBLOCK
-#ifdef EAGAIN
-#define AGAIN_CONDITION (errno == EWOULDBLOCK || errno == EAGAIN)
-#else /* EAGAIN */
-#define AGAIN_CONDITION (errno == EWOULDBLOCK)
-#endif /* EAGAIN */
-#else /* EWOULDBLOCK */
-#ifdef EAGAIN
-#define AGAIN_CONDITION (errno == EAGAIN)
-#endif /* EAGAIN */
-#endif /* EWOULDBLOCK */
-
-#if HAVE_POLL
-# include <poll.h>
-# define XIO_IN POLLIN
-# define XIO_OUT POLLOUT
-#else
-# define XIO_IN 1
-# define XIO_OUT 2
-#endif
-
-/* Linux prefers O_ASYNC over FASYNC; SGI IRIX does the opposite. */
-#if !defined(FASYNC) && defined(O_ASYNC)
-#define FASYNC O_ASYNC
-#endif
-
-#if !defined(FLAKY_SIGPOLL) && !HAVE_STREAMS && !defined(FASYNC)
-#define FLAKY_SIGPOLL 1
-#endif
-
-char *strtok ARGS((char *, const char *));
-
-#define Fprintf (void) fprintf
-
-
-/* define ALWAYS_CLOSE_SERVER_CONNECTION if you want to close the server
- connection all the time */
-#undef ALWAYS_CLOSE_SERVER_CONNECTION
-
-
- /*
- * Some setup code.
- */
-static const char str0[] = "\
-/OW2? version cvi 2 eq def \
-OW2? \
-{ /setlinewidth { pop } def} \
-{ /NeWS 3 0 findpackage beginpackage \
- /X11 3 0 findpackage beginpackage} \
-ifelse \
-currentcanvas /Color get \
-currentcanvas /Colormap get getcubedescription null eq and \
- {8 {{currentcanvas /Colormap get 1 index dup dup dup newcube} stopped \
- {pop pop pop pop pop} {exit} ifelse \
- 2 div cvi dup 1 eq {exit} if} loop pop} \
-if\n";
- /*
- * This string reads chunks (delimited by %%xdvimark).
- * The first character of a chunk tells whether a given chunk
- * is to be done within save/restore or not.
- * The `H' at the end tells it that the first group is a
- * header; i.e., no save/restore.
- */
-static const char preamble[] = "\
-/xdvi$line 81 string def \
-/xdvi$run {$error null ne {$error /newerror false put} if \
- {currentfile cvx stopped \
- $error null eq {false} {$error /newerror get} ifelse and \
- {handleerror} if} stopped pop} def \
-/xdvi$dslen countdictstack def \
-{currentfile read not {exit} if 72 eq \
- {xdvi$run} \
- {/xdvi$sav save def xdvi$run \
- clear countdictstack xdvi$dslen sub {end} repeat xdvi$sav restore} \
- ifelse \
- {(%%xdvimark) currentfile xdvi$line {readline} stopped \
- {clear} {{eq {false exit} if} {true exit} ifelse} ifelse }loop {exit} if \
- 58 tagprint flush \
-}loop\nH";
-
-extern const char psheader[];
-extern unsigned psheaderlen;
-
-static const char preamble2[] = " stop\n%%xdvimark\n";
-#define stopstring preamble2
-
-#define postscript resource._postscript
-
-
-/* global procedures (besides initNeWS) */
-
-static void toggleNeWS ARGS((void));
-static void destroyNeWS ARGS((void));
-static void interruptNeWS ARGS((void));
-static void endpageNeWS ARGS((void));
-static void drawbeginNeWS ARGS((int, int, const char *));
-static void drawrawNeWS ARGS((const char *));
-static void drawfileNeWS ARGS((const char *, FILE *));
-static void drawendNeWS ARGS((const char *));
-static void beginheaderNeWS ARGS((void));
-static void endheaderNeWS ARGS((void));
-static void newdocNeWS ARGS((void));
-
-static struct psprocs news_procs = {
- /* toggle */ toggleNeWS,
- /* destroy */ destroyNeWS,
- /* interrupt */ interruptNeWS,
- /* endpage */ endpageNeWS,
- /* drawbegin */ drawbeginNeWS,
- /* drawraw */ drawrawNeWS,
- /* drawfile */ drawfileNeWS,
- /* drawend */ drawendNeWS,
- /* beginheader */ beginheaderNeWS,
- /* endheader */ endheaderNeWS,
- /* newdoc */ newdocNeWS};
-
-/* define local static variables */
-static int NeWS_mag; /* magnification currently in use */
-static int NeWS_shrink; /* shrink factor currently in use */
-static unsigned int NeWS_page_w; /* how big our current page is */
-static unsigned int NeWS_page_h;
-static Boolean NeWS_active; /* if we've started a page yet */
-static int NeWS_pending; /* number of ack's we're expecting */
-static const char *NeWS_send_byte; /* next byte to send to NeWS */
-static const char *NeWS_send_end; /* last + 1 byte to send */
-static Boolean NeWS_in_header; /* if we're sending a header */
-static Boolean NeWS_in_doc; /* if we've sent header information */
-static int NeWS_ev_mask; /* events for which we'll stop */
-static Boolean NeWS_destroyed = False;
-
-#define NEWS_MASK_NORMAL EV_GE_NEWPAGE
-#define NEWS_MASK_HEADER EV_GE_PS_TOGGLE
-#define NEWS_MASK_INIT (EV_GE_TERM | EV_PS_TOGGLE)
-
-
-/*
- * NeWS I/O code. This should send PS code to NeWS,
- * receive acknowledgements, and receive X events in the meantime.
- * It also checks for SIGPIPE errors.
- */
-
-static void read_from_NeWS ARGS((void));
-static void write_to_NeWS ARGS((void));
-
-static struct xio NeWS_xout = {NULL, 0, XIO_IN,
-#if HAVE_POLL
- NULL,
-#endif
- read_from_NeWS, write_to_NeWS};
-
-static struct xio NeWS_xin = {NULL, 0, XIO_IN,
-#if HAVE_POLL
- NULL,
-#endif
- read_from_NeWS, NULL};
-
-
-/*---------------------------------------------------------------------------*
- psio_sigpipe_handler ()
-
- Arguments: sig, code, scp, addr (see man page for signal)
- Returns: (void)
- Side-Effects: SIGPIPE signal is flagged as sigpipe_error variable is set.
-
- Description:
- Handler for SIGPIPE error generated by a broken pipe in the connection
- to the NeWS server; this may be duer to some abnormal condition, or some
- hairy PostScript code containing commands not implemented by the server.
-
-+----------------------------------------------------------------------------*/
-
-static Boolean sigpipe_error = False;
-
-static struct sigaction psio_sigpipe_handler_struct;
- /* initialized to {psio_sigpipe_handler, (sigset_t) 0, 0} in initNeWS */
-
-/* ARGSUSED */
-static RETSIGTYPE
-psio_sigpipe_handler(sig, code, scp, addr)
- int sig;
- int code;
- struct sigcontext *scp;
- char *addr;
-{
- sigpipe_error = True;
-}
-
-
-/*
- * read_from_NeWS - This does the actual retrieving of acknowledgements.
- * If other bytes appear on the file - tough.
- */
-
-static void
-read_from_NeWS()
-{
- for (;;) {
- int retval;
-
- retval = ps_checkfor(PostScriptInput, PSIO_FIND_TAG, 58);
- if (retval == 0) break;
- if (retval < 0) {
- WARN1(XmDIALOG_WARNING,
- "xdvi internal error\nps_checkfor returned negative value %d",
- retval);
- return;
- }
- (void) ps_checkfor(PostScriptInput, PSIO_WAIT_TAG, 58);
- --NeWS_pending;
- if (NeWS_pending == 0)
- ev_flags |= EV_ACK;
- if (debug & DBG_PS)
- Printf("Got NeWS ack; %d pending.\n", NeWS_pending);
- }
-}
-
-
-/*
- * write_to_NeWS - Write to the PostScript interpreter.
- */
-
-static void
-write_to_NeWS()
-{
- int old_flags;
- int bytes;
-
- old_flags = fcntl(PostScript->file, F_GETFL, 0);
- if (old_flags < 0) return;
- /* set to be non-blocking */
- if (fcntl(PostScript->file, F_SETFL, old_flags | O_NONBLOCK) < 0)
- return;
-
- for (;;) {
- bytes = write(PostScript->file, NeWS_send_byte,
- NeWS_send_end - NeWS_send_byte);
- if (bytes < 0) {
- if (AGAIN_CONDITION)
- break;
- perror("xdvi NeWS_send");
- break;
- }
- NeWS_send_byte += bytes;
- if (NeWS_send_byte == NeWS_send_end) {
- NeWS_send_byte = NULL;
- NeWS_xout.xio_events &= ~XIO_OUT;
-#if HAVE_POLL
- /* This check is necessary, since write_to_NeWS can be called
- directly. */
- if (NeWS_xout.pfd != NULL)
- NeWS_xout.pfd->events &= ~POLLOUT;
- ev_flags |= EV_ACK;
- break;
-#endif
- }
- }
-
- fcntl(PostScript->file, F_SETFL, old_flags);
-}
-
-
-/*
- * Clean up after NeWS_send()
- */
-
-static void
-post_send()
-{
- if (sigpipe_error) {
- WARN(XmDIALOG_WARNING, "NeWS died unexpectedly");
- destroyNeWS();
- draw_bbox();
- }
-}
-
-
-/*
- * Main routine for writing to the NeWS interpreter.
- */
-
-static void
-NeWS_send(cp, len)
- const char *cp;
- size_t len;
-{
- struct sigaction orig;
-
- if (PostScript == (PSFILE *) NULL || (ev_flags & NeWS_ev_mask))
- return;
-
- (void) sigaction(SIGPIPE, &psio_sigpipe_handler_struct, &orig);
- sigpipe_error = False;
-
- NeWS_send_byte = cp;
- NeWS_send_end = cp + len;
- NeWS_xout.xio_events |= XIO_OUT;
-#if HAVE_POLL
- if (NeWS_xout.pfd != NULL)
- NeWS_xout.pfd->events |= POLLOUT;
-#endif
-
- write_to_NeWS();
- (void) read_events(NeWS_ev_mask | EV_ACK);
-
- if (!(ev_flags & EV_ACK)) { /* if interrupted */
- /* ||| Do somthing more severe here */
- }
-
- ev_flags &= ~EV_ACK;
-
- /* put back generic handler for SIGPIPE */
- (void) sigaction(SIGPIPE, &orig, (struct sigaction *) NULL);
-
- if (!NeWS_in_header) post_send();
-}
-
-/*
- * Wait for acknowledgement from NeWS. With NeWS we have no choice but
- * to wait (||| I think).
- */
-
-static void
-waitack()
-{
- if (PostScript == (PSFILE *) NULL) return;
-
- if (NeWS_pending > 0)
- (void) read_events(EV_GE_ACK);
-
- if (ev_flags & EV_ACK) {
- ev_flags &= ~EV_ACK;
- return;
- }
-
- /* ||| Do something more serious here */
-}
-
-
-/*---------------------------------------------------------------------------*
- initNeWS()
-
- Arguments: None.
- Returns: True if and only if initialization succeeded
- Side-Effects: Static variables may be set.
-
- Description:
- Initializes variables for the application main loop.
-
-+----------------------------------------------------------------------------*/
-
-Boolean
-initNeWS()
-{
- static NeWStoken newstoken;
-
- /* now try to open the connection to the NeWS server */
- if (ps_open_PostScript() == (PSFILE *) NULL)
- return False;
-
- psio_sigpipe_handler_struct.sa_handler = psio_sigpipe_handler;
- sigemptyset(&psio_sigpipe_handler_struct.sa_mask);
-
-#if !FLAKY_SIGPOLL
- if (fcntl(PostScript->file, F_SETOWN, getpid()) == -1)
- perror("xdvi: fcntl F_SETOWN");
- if (fcntl(PostScript->file, F_SETFL,
- fcntl(PostScript->file, F_GETFL, 0) | FASYNC) == -1)
- perror("xdvi: fcntl F_SETFL");
-#endif /* not FLAKY_SIGPOLL */
- if (PostScriptInput->file != PostScript->file) {
-#if !FLAKY_SIGPOLL
- if (fcntl(PostScriptInput->file, F_SETOWN, getpid()) == -1)
- perror("xdvi: fcntl F_SETOWN");
- if (fcntl(PostScriptInput->file, F_SETFL,
- fcntl(PostScriptInput->file, F_GETFL, 0) | FASYNC) == -1)
- perror("xdvi: fcntl F_SETFL");
-#endif /* not FLAKY_SIGPOLL */
- NeWS_xout.xio_events &= ~XIO_IN;
- NeWS_xin.fd = PostScriptInput->file;
- set_io(&NeWS_xin);
- }
- NeWS_xout.fd = PostScript->file;
- set_io(&NeWS_xout);
-
- NeWS_active = False;
- NeWS_in_header = True;
- NeWS_ev_mask = NEWS_MASK_INIT;
- NeWS_pending = 1;
-
- ps_flush_PostScript();
- NeWS_send(str0, sizeof(str0) - 1);
- /* get xid of window, then make this window the NeWS canvas */
- (void) ps_token_from_xid(mane.win, &newstoken);
- if (newstoken != -1) {
- ps_setcanvas(newstoken);
- ps_flush_PostScript();
-
- NeWS_send(preamble, sizeof(preamble) - 1);
- NeWS_send(psheader, psheaderlen);
- NeWS_send(preamble2, sizeof(preamble2) - 1);
- NeWS_in_header = False;
- post_send();
- waitack();
- }
-
- if (NeWS_destroyed) return False;
-
- /* success */
-
- NeWS_mag = NeWS_shrink = -1;
- NeWS_page_w = page_w;
- NeWS_page_h = page_h;
-
- psp = news_procs;
- if (!postscript) toggleNeWS(); /* if we got a 'v' already */
-
- return True;
-}
-
-
-/*---------------------------------------------------------------------------*
- toggleNeWS()
-
- Arguments: none
- Returns: (void)
- Side-Effects: psp.drawbegin is changed
-
- Description:
- Used to toggle the rendering of PostScript by the NeWS server
- Callable from within read_events().
-
-+----------------------------------------------------------------------------*/
-
-static void
-toggleNeWS()
-{
- if (debug & DBG_PS) Puts("Toggling NeWS on or off");
-
- psp.drawbegin = (postscript ? drawbeginNeWS : drawbegin_none);
-}
-
-
-/*---------------------------------------------------------------------------*
- destroyNeWS()
-
- Arguments: none
- Returns: (void)
- Side-Effects: the pointer to the NeWS file is nulled
-
- Description:
- Close the connection to the NeWS server; used when rendering is terminated
- in any way.
-
-+----------------------------------------------------------------------------*/
-
-static void
-destroyNeWS()
-{
- psp = no_ps_procs;
- NeWS_destroyed = True;
- scanned_page = scanned_page_ps = scanned_page_reset;
-}
-
-
-/*---------------------------------------------------------------------------*
- interruptNeWS()
-
- Arguments: none
- Returns: void
-
- Description:
- Close the connection to the NeWS server; used when rendering is terminated
- because of an interruption in the viewing of the current page.
- ||| It would be nice if we could asynchronously ``wake up'' a NeWS process
- (preferably by sending something along the X socket); then we could do
- better than just to wait.
-
-+----------------------------------------------------------------------------*/
-
-static void
-interruptNeWS()
-{
- if (debug & DBG_PS) Puts("Running interruptNeWS()");
- if (NeWS_pending <= 0) return; /* if nothing to do */
-
- if (NeWS_active) {
- NeWS_send(stopstring, sizeof(stopstring) - 1);
- NeWS_active = False;
- }
-
- for (;;) {
- ps_flush_PostScript();
- if (NeWS_pending <= 0) break;
- waitack();
- }
-}
-
-
-/*---------------------------------------------------------------------------*
- endpageNeWS()
-
- Arguments: none
- Returns: (void)
- Side-Effects: the NeWS_active variable is cleared.
-
- Description:
- Should be called at the end of a page to end this chunk for the NeWS server.
-
-+----------------------------------------------------------------------------*/
-
-static void
-endpageNeWS()
-{
- if (debug & DBG_PS)
- Puts("endpage sent to NeWS Server");
- if (NeWS_active) {
- NeWS_send(stopstring, sizeof(stopstring) - 1);
- NeWS_active = False;
- waitack();
- }
-}
-
-
-/*---------------------------------------------------------------------------*
- drawbeginNeWS ()
-
- Arguments: xul, yul - coordinates of the upper left corner of the figure
- cp - string with the bounding box line data
- Returns: (void)
-
- Description:
- Opens a connection to the NeWS server and send in the preamble and the
- bounding box information after correctly computing resolution factors.
- In case no rendering is to be done, outlines the figure. An outline is
- also generated whenever the PostScript code is too hairy and generates
- a SIGPIPE signal.
-
-+----------------------------------------------------------------------------*/
-
-static void
-drawbeginNeWS(xul, yul, cp)
- int xul, yul;
- const char *cp;
-{
- char buf[100];
- static const char str[] = " TeXDict begin\n";
- static const char str2[] = "Hinitgraphics stop\n%%xdvimark\n";
-
- if (debug & DBG_PS) {
- Printf("xul= %d yul= %d\n", xul, yul);
- Printf("String = < %s >\n", cp);
- }
-
- /* catch up on the X side */
- XSync(DISP, False);
-
- if (!NeWS_active) {
- /* send initialization to NeWS server */
- if (NeWS_page_w < page_w || NeWS_page_h < page_h) {
- if (ev_flags & NEWS_MASK_NORMAL)
- longjmp(canit_env, 1);
- ++NeWS_pending;
- NeWS_page_w = page_w;
- NeWS_page_h = page_h;
- NeWS_send(str2, sizeof(str2) - 1);
- }
- if (magnification != NeWS_mag) {
- if (ev_flags & NEWS_MASK_NORMAL)
- longjmp(canit_env, 1);
- ++NeWS_pending;
- Sprintf(buf, "H TeXDict begin /DVImag %d 1000 div def \
-end stop\n%%%%xdvimark\n",
- NeWS_mag = magnification);
- NeWS_send(buf, strlen(buf));
- }
- if (mane.shrinkfactor != NeWS_shrink) {
- if (ev_flags & NEWS_MASK_NORMAL)
- longjmp(canit_env, 1);
- ++NeWS_pending;
- Sprintf(buf, "H TeXDict begin %d %d div dup \
-/Resolution X /VResolution X \
-end stop\n%%%%xdvimark\n",
- pixels_per_inch, NeWS_shrink = mane.shrinkfactor);
- NeWS_send(buf, strlen(buf));
- }
- if (ev_flags & NEWS_MASK_NORMAL)
- longjmp(canit_env, 1);
- ++NeWS_pending;
- NeWS_send(str, sizeof(str) - 1);
- NeWS_active = True;
- }
-
- Sprintf(buf, "%d %d moveto\n", xul, yul);
- NeWS_send(buf, strlen(buf));
- NeWS_send(cp, strlen(cp));
-}
-
-
-/*---------------------------------------------------------------------------*
- drawrawNeWS()
-
- Arguments: origcp - the raw string to be sent to the postscript interpreter
- Returns: (void)
- Side-Effects: (none)
-
- Description:
- If there is a valid connection to the NeWS server, just send the string to
- the interpreter, else leave.
-
-+----------------------------------------------------------------------------*/
-
-static void
-drawrawNeWS(origcp)
- const char *origcp;
-{
- const char *pt, *ptm1, *ocp1;
- static char *cp;
- char *cp1;
- static unsigned int cplen = 0;
- unsigned int len;
- double angle;
- Boolean found = False;
-
- if (!NeWS_active)
- return;
-
- if (debug & DBG_PS)
- Printf("Raw PS sent to context: <%s>\n", origcp);
-
- /* take a look at the string: NeWS bums on certain rotations */
- len = strlen(origcp) + 4;
- if (cplen < len) {
- if (cplen != 0) free(cp);
- cplen = len;
- cp = xmalloc(cplen);
- }
- ocp1 = origcp;
- pt = origcp;
- while (*pt == ' ' || *pt == '\t') ++pt;
- cp1 = cp;
- for (;;) {
- ptm1 = pt;
- while (*pt != '\0' && *pt != ' ' && *pt != '\t') ++pt;
- if (*pt == '\0') break;
- while (*pt == ' ' || *pt == '\t') ++pt;
- if (strncmp(pt, "rotate", 6) == 0
- && (pt[6] == '\0' || pt[6] == ' ' || pt[6] == '\t')) {
- /* found rotate; check angle */
- if (sscanf(ptm1, "%lf", &angle) >= 1) {
- found = True;
- while (angle > 360.0)
- angle -= 360;
- while (angle < -360.0)
- angle += 360;
- if (angle == 90.0) {
- angle = 89.999;
- (void) memcpy(cp1, ocp1, ptm1 - ocp1);
- cp1 += ptm1 - ocp1;
- Strcpy(cp1, "89.999 rotate ");
- cp1 += strlen(cp1);
- while (*pt != '\0' && *pt != ' ' && *pt != '\t') ++pt;
- while (*pt == ' ' || *pt == '\t') ++pt;
- ocp1 = pt;
- } else if (angle == -90.0) {
- angle = -89.999;
- (void) memcpy(cp1, ocp1, ptm1 - ocp1);
- cp1 += ptm1 - ocp1;
- Strcpy(cp1, "-89.999 rotate ");
- cp1 += strlen(cp1);
- while (*pt != '\0' && *pt != ' ' && *pt != '\t') ++pt;
- while (*pt == ' ' || *pt == '\t') ++pt;
- ocp1 = pt;
- } else if (angle == 0.0) {
- (void) memcpy(cp1, ocp1, ptm1 - ocp1);
- cp1 += ptm1 - ocp1;
- while (*pt != '\0' && *pt != ' ' && *pt != '\t') ++pt;
- while (*pt == ' ' || *pt == '\t') ++pt;
- ocp1 = pt;
- }
- }
- }
- }
- Strcpy(cp1, ocp1);
- if ((debug & DBG_PS) && found) {
- Printf("String is now <%s>\n", cp);
- Printf("Found rotate string. Angle is %g degrees.\n", angle);
- }
-
- len = strlen(cp);
- cp[len] = '\n';
- NeWS_send(cp, len + 1);
-}
-
-
-/*---------------------------------------------------------------------------*
- drawfileNeWS()
-
- Arguments: cp - string with the postscript file pathname
- psfile - file, already opened
- Returns: (void)
- Side-Effects: none
-
- Description:
- Postscript file containing the figure is opened and sent to the NeWS server.
- Figure is outlined in case hairy code produces a SIGPIPE signal.
-
-+----------------------------------------------------------------------------*/
-
-static void
-drawfileNeWS(cp, psfile)
- const char *cp;
- FILE *psfile;
-{
- char buffer[1025];
- int blen;
- struct sigaction orig;
-
- if (!NeWS_active) {
- Fclose(psfile);
- ++n_files_left;
- return;
- }
-
- if (debug & DBG_PS)
- Printf("printing file %s\n", cp);
-
- sigpipe_error = False;
- for (;;) {
- blen = fread(buffer, sizeof(char), 1024, psfile);
- if (blen == 0) break;
- NeWS_send(buffer, blen);
- if (sigpipe_error || (ev_flags & NeWS_ev_mask))
- break;
- }
- Fclose(psfile);
- ++n_files_left;
-
- if (sigpipe_error) {
- WARN(XmDIALOG_WARNING, "NeWS died unexpectedly");
- destroyNeWS();
- draw_bbox();
- }
-}
-
-
-/*---------------------------------------------------------------------------*
- drawendNeWS()
-
- Arguments: cp - string with indication of the end of the special
- Returns: (void)
-
- Description:
- Sends the indication of end of the figure PostScript code.
-
-+----------------------------------------------------------------------------*/
-
-static void
-drawendNeWS(cp)
- const char *cp;
-{
- if (!NeWS_active)
- return;
-
- if (debug & DBG_PS)
- Puts("drawend sent to NeWS Server");
- NeWS_send(cp, strlen(cp));
- NeWS_send("\n", 1);
-}
-
-
-/*---------------------------------------------------------------------------*
- beginheaderNeWS()
-
- Arguments: none
- Returns: (void)
-
- Description:
- Prepares the PostScript interpreter for receipt of header code.
-
-+----------------------------------------------------------------------------*/
-
-static void
-beginheaderNeWS()
-{
- static const char str[] = "Hsave /xdvi$doc exch def\n";
-
- if (debug & DBG_PS) Puts("Running beginheaderNeWS()");
-
- if (NeWS_active) {
- if (!NeWS_in_header)
- oops("Internal error in beginheaderNeWS().\n");
- return;
- }
-
- if (ev_flags & NEWS_MASK_HEADER)
- longjmp(canit_env, 1);
-
- NeWS_in_header = True;
- NeWS_ev_mask = NEWS_MASK_HEADER;
- ++NeWS_pending;
- if (NeWS_in_doc)
- NeWS_send("H", 1);
- else {
- NeWS_send(str, sizeof(str) - 1);
- NeWS_in_doc = True;
- }
- NeWS_active = True;
-}
-
-
-/*---------------------------------------------------------------------------*
- endheaderNeWS()
-
- Arguments: none
- Returns: (void)
-
- Description:
- Prepares the PostScript interpreter for receipt of header code.
-
-+----------------------------------------------------------------------------*/
-
-static void
-endheaderNeWS()
-{
- static const char str[] = "stop\n%%xdvimark\n";
-
- if (debug & DBG_PS) Puts("Running endheaderNeWS()");
-
- if (NeWS_active) {
- NeWS_send(str, sizeof(str) - 1);
- NeWS_active = False;
- post_send();
- waitack();
- NeWS_in_header = False;
- NeWS_ev_mask = NEWS_MASK_NORMAL;
- }
-}
-
-
-/*---------------------------------------------------------------------------*
- newdocNeWS()
-
- Arguments: none
- Returns: (void)
-
- Description:
- Clears out headers stored from the previous document.
-
-+----------------------------------------------------------------------------*/
-
-static void
-newdocNeWS()
-{
- static const char str[] =
- "H xdvi$doc restore stop\n%%xdvimark\n";
-
- if (debug & DBG_PS) Puts("Running newdocNeWS()");
-
- if (NeWS_in_doc) {
- ++NeWS_pending;
- NeWS_send(str, sizeof(str) - 1);
- NeWS_mag = NeWS_shrink = -1;
- NeWS_in_doc = False;
- }
-}
diff --git a/special.c b/special.c
@@ -732,14 +732,6 @@ actual_startup()
* Choose DPS then NEWS then Ghostscript if they are available
*/
if (!(
-
-#ifdef PS_NEWS
- (resource.useNeWS && initNeWS())
-#ifdef PS_GS
- ||
-#endif
-#endif /* PS_NEWS */
-
#ifdef PS_GS
(resource.useGS && initGS())
#endif
diff --git a/xdvi.c b/xdvi.c
@@ -67,7 +67,6 @@ NOTE:
* TEXXET support reflection dvi codes (right-to-left typesetting)
* GREY use grey levels to shrink fonts
* PS_GS use Ghostscript to render pictures/bounding boxes
- * PS_NEWS use the NeWS server to render pictures/bounding boxes
* GS_PATH path to call the Ghostscript interpreter by
*/
@@ -309,10 +308,6 @@ static XrmOptionDescRec options[] = {
{"+nopostscript",".postscript", XrmoptionNoArg, (XPointer) "on"},
{"-allowshell", ".allowShell", XrmoptionNoArg, (XPointer) "on"},
{"+allowshell", ".allowShell", XrmoptionNoArg, (XPointer) "off"},
-#ifdef PS_NEWS
-{"-nonews", ".news", XrmoptionNoArg, (XPointer) "off"},
-{"+nonews", ".news", XrmoptionNoArg, (XPointer) "on"},
-#endif
#ifdef PS_GS
{"-noghostscript",".ghostscript", XrmoptionNoArg, (XPointer) "off"},
{"+noghostscript",".ghostscript", XrmoptionNoArg, (XPointer) "on"},
@@ -511,10 +506,6 @@ static XtResource application_resources[] = {
offset(_postscript), XtRString, "true"},
{"allowShell", "AllowShell", XtRBoolean, sizeof(Boolean),
offset(allow_shell), XtRString, "false"},
-#ifdef PS_NEWS
-{"news", "News", XtRBoolean, sizeof(Boolean),
- offset(useNeWS), XtRString, "true"},
-#endif
#ifdef PS_GS
{"ghostscript", "Ghostscript", XtRBoolean, sizeof(Boolean),
offset(useGS), XtRString, "true"},
diff --git a/xdvi.h b/xdvi.h
@@ -218,7 +218,7 @@ unsigned int page_w, page_h;
#define PS_GS 1
#endif
-#if defined(PS_NEWS) || defined(PS_GS)
+#if defined(PS_GS)
#define PS 1
#else
#define PS 0
@@ -454,9 +454,6 @@ extern struct _resource {
* we will figure out later on which one we will use */
Boolean _postscript;
Boolean allow_shell;
-#ifdef PS_NEWS
- Boolean useNeWS;
-#endif
#ifdef PS_GS
Boolean useGS;
Boolean gs_safer;
@@ -1059,9 +1056,6 @@ extern void ps_init_paths(void);
extern void drawbegin_none(int, int, const char *);
extern void draw_bbox(void);
extern void NullProc(void);
-#ifdef PS_NEWS
-extern Boolean initNeWS(void);
-#endif
#ifdef PS_GS
extern Boolean initGS(void);
extern void gs_resume_prescan(void);