Beispiel #1
0
connect_and_exec()
{
    if (PostScript == 0 && ps_open_PostScript() == 0) {
	fprintf(stderr, "%s: Cannot connect to window server\n",
		programname);
	exit(0);
    }

    dup2(fileno(PostScriptInput), 0);
    dup2(0, 1);
    dup2(0, 2);
    fclose(PostScriptInput);
    fclose(PostScript);
    printf("%s\n", servicename);
    fflush(stdout);
    execv(args[0], &args[0]);
    perror("execv");
}
Beispiel #2
0
Boolean initNeWS(void)
{
    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 = globals.page.w;
    NeWS_page_h = globals.page.h;

    psp = news_procs;
    if (!resource.postscript)
	toggleNeWS(0);	/* if we got a 'v' already */

    return True;
}