home *** CD-ROM | disk | FTP | other *** search
-
- /* Parent process which sets up windows and calls logo itself
- * Ttysw insists on forking, so we need two processes
- * Written by Philippe Lacroute at Sun Microsystems Inc. 1983
- */
-
- /*
- * Modified April 1985 for Sun release 2.0 software (PGL)
- */
-
- #include <stdio.h>
- #include <suntool/tool_hs.h>
- #include <suntool/ttysw.h>
- #include <suntool/emptysw.h>
-
- #define LOGOBIN "logo"
-
- struct tool *tool;
- struct toolsw *ttysw, /* tty subwindow */
- *gfxsw; /* to be overlaid with blanket */
-
- static short icon_data[256] = {
- #include "logo.icon"
- };
-
- mpr_static(turtle_pr, 64, 64, 1, icon_data); /* icon */
- static struct icon turtle_icon = {
- TOOL_ICONWIDTH, TOOL_ICONHEIGHT, NULL,
- {0, 0, TOOL_ICONWIDTH, TOOL_ICONHEIGHT},
- &turtle_pr, {0, 0, 0, 0}, NULL, NULL, 0
- };
- static int sigwinchcatcher(),
- sigchldcatcher(),
- mytoolsigwinchhandler(),
- (*toolsigwinchhandlercached)();
- char tool_name[] = "Sun Logo 2.0",
- name[WIN_NAMESIZE];
- int pidchld = -1, killchild();
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- char **tool_attrs = NULL;
- struct rect winsize;
- char *newargv[512];
- int c;
-
- if (tool_parse_all(&argc, argv, &tool_attrs, tool_name) == -1) {
- tool_usage(tool_name);
- exit(1);
- }
- tool = tool_make(WIN_NAME_STRIPE, 1,
- WIN_LABEL, tool_name,
- WIN_ICON, &turtle_icon, 0);
- if (tool == NULL) {
- fprintf(stderr, "Couldn't create tool.\n");
- fprintf(stderr, "Are you running suntools?\n");
- exit(1);
- }
- tool_free_attribute_list(tool_attrs);
-
- toolsigwinchhandlercached = tool->tl_io.tio_handlesigwinch;
- tool->tl_io.tio_handlesigwinch = mytoolsigwinchhandler;
- win_getrect(tool->tl_windowfd, &winsize);
-
- ttysw = ttysw_createtoolsubwindow(tool, "ttysw",
- winsize.r_width - 2 * tool_borderwidth(tool),
- winsize.r_height - tool_borderwidth(tool) - tool_stripeheight(tool));
- gfxsw = esw_createtoolsubwindow(tool, "gfxsw",
- winsize.r_width - 2 * tool_borderwidth(tool),
- winsize.r_height - tool_borderwidth(tool) - tool_stripeheight(tool));
-
- /* Gfxsw must be on the bottom of tree */
-
- win_remove(gfxsw->ts_windowfd);
- win_setlink(gfxsw->ts_windowfd, WL_YOUNGERSIB, win_fdtonumber(ttysw->ts_windowfd));
- win_setlink(gfxsw->ts_windowfd, WL_OLDERSIB, WIN_NULLLINK);
- win_insert(gfxsw->ts_windowfd);
-
- /* set environmanet vars */
-
- win_fdtoname(tool->tl_windowfd, name);
- setenv("LOGO_TOOL", name);
- win_fdtoname(ttysw->ts_windowfd, name);
- setenv("LOGO_TEXT", name);
- win_fdtoname(gfxsw->ts_windowfd, name);
- setenv("LOGO_GFX", name);
-
- /* set signals */
-
- signal(SIGWINCH, sigwinchcatcher);
- signal(SIGCHLD, sigchldcatcher);
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
-
- newargv[0] = LOGOBIN;
- for (c = 1; c < argc; c++)
- newargv[c] = argv[c];
- argv[c] = 0;
-
- /* install everything */
-
- tool_install(tool);
- if ((pidchld = ttysw_fork(ttysw->ts_data, newargv, &ttysw->ts_io.tio_inputmask,
- &ttysw->ts_io.tio_outputmask, &ttysw->ts_io.tio_exceptmask)) == -1) {
- perror("logotool");
- exit(1);
- }
-
- /* run the ttysw */
-
- tool_select(tool, 1); /* 1 child to wait for */
-
- /* clean up */
-
- tool_destroy(tool);
- exit(0);
- }
-
- static
- sigchldcatcher()
- {
- tool_sigchld(tool);
- }
-
- static
- sigwinchcatcher()
- {
- tool_sigwinch(tool);
- if (pidchld != -1)
- kill(pidchld, SIGWINCH);
- }
-
- nullfunc()
- {
- }
-
- /*
- toolsigwinchhandlercached will rearrange windows when it
- detects that its size has changed. The following procedure
- fools toolsigwinchhandlercached into thinking that there
- has been no change.
- */
-
- static int
- mytoolsigwinchhandler(tool)
- struct tool *tool;
- {
- struct rect rect;
-
- win_getsize(tool->tl_windowfd, &rect);
- tool->tl_rectcache = rect;
- toolsigwinchhandlercached(tool);
- }
-
-