bool
rxvt_term::init_vars ()
{
- PixColorsFocused = new rxvt_color [TOTAL_COLORS];
+ pix_colors_focused = new rxvt_color [TOTAL_COLORS];
#ifdef OFF_FOCUS_FADING
- PixColorsUnFocused = new rxvt_color [TOTAL_COLORS];
+ pix_colors_unfocused = new rxvt_color [TOTAL_COLORS];
#endif
- PixColors = PixColorsFocused;
+ pix_colors = pix_colors_focused;
- if (PixColors == NULL)
+ if (pix_colors == NULL)
return false;
#if defined(XPM_BACKGROUND) || defined(TRANSPARENT)
TermWin.pixmap = None;
#endif
-#ifdef UTMP_SUPPORT
- next_utmp_action = SAVE;
-#endif
-#ifndef NO_SETOWNER_TTYDEV
- next_tty_action = SAVE;
-#endif
MEvent.time = CurrentTime;
MEvent.button = AnyButton;
- Options = DEFAULT_OPTIONS;
+ options = DEFAULT_OPTIONS;
want_refresh = 1;
cmd_pid = -1;
- cmd_fd = tty_fd = -1;
- PrivateModes = SavedModes = PrivMode_Default;
+ pty.pty = pty.tty = -1;
+ priv_modes = SavedModes = PrivMode_Default;
TermWin.focus = 0;
TermWin.ncol = 80;
TermWin.nrow = 24;
TermWin.ext_bwidth = EXTERNALBORDERWIDTH;
TermWin.lineSpace = LINESPACE;
TermWin.saveLines = SAVELINES;
- numPixColors = TOTAL_COLORS;
+ numpix_colors = TOTAL_COLORS;
#ifndef NO_BRIGHTCOLOR
colorfgbg = DEFAULT_RSTYLE;
rxvt_term::init_secondary ()
{
int i;
-#ifdef TTY_GID_SUPPORT
- struct group *gr = getgrnam ("tty");
-
- if (gr)
- { /* change group ownership of tty to "tty" */
- ttymode = S_IRUSR | S_IWUSR | S_IWGRP;
- ttygid = gr->gr_gid;
- }
- else
-#endif /* TTY_GID_SUPPORT */
-
- {
- ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
- ttygid = getgid ();
- }
/*
* Close all unused file descriptors
* Look for -exec option. Find => split and make cmd_argv[] of command args
*/
for (r_argc = 0; r_argc < argc; r_argc++)
- if (!STRCMP (argv[r_argc], "-e") || !STRCMP (argv[r_argc], "-exec"))
+ if (!strcmp (argv[r_argc], "-e") || !strcmp (argv[r_argc], "-exec"))
break;
r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1));
#ifdef LOCAL_X_IS_UNIX
if (rs[Rs_display_name][0] == ':')
{
- val = rxvt_malloc (5 + STRLEN (rs[Rs_display_name]));
- STRCPY (val, "unix");
- STRCAT (val, rs[Rs_display_name]);
+ val = rxvt_malloc (5 + strlen (rs[Rs_display_name]));
+ strcpy (val, "unix");
+ strcat (val, rs[Rs_display_name]);
display = displays.get (val);
free (val);
}
if (!display
&& ! (display = displays.get (rs[Rs_display_name])))
- rxvt_fatal ("can't open display %s", rs[Rs_display_name]);
+ rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
extract_resources (display->display, rs[Rs_name]);
if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0)
TermWin.saveLines = BOUND_POSITIVE_INT16 (i);
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0)
TermWin.int_bwidth = min (i, 100); /* arbitrary limit */
if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0)
/* no point having a scrollbar without having any scrollback! */
if (!TermWin.saveLines)
- Options &= ~Opt_scrollBar;
+ options &= ~Opt_scrollBar;
#ifdef PRINTPIPE
if (!rs[Rs_print_pipe])
# endif
else
{
- val = STRDUP (rs[Rs_backspace_key]);
+ val = strdup (rs[Rs_backspace_key]);
rxvt_Str_trim (val);
rxvt_Str_escaped (val);
key_backspace = val;
# endif
else
{
- val = STRDUP (rs[Rs_delete_key]);
+ val = strdup (rs[Rs_delete_key]);
rxvt_Str_trim (val);
rxvt_Str_escaped (val);
key_delete = val;
#ifdef XTERM_REVERSE_VIDEO
/* this is how xterm implements reverseVideo */
- if (Options & Opt_reverseVideo)
+ if (options & Opt_reverseVideo)
{
if (!rs[Rs_color + Color_fg])
rs[Rs_color + Color_fg] = def_colorName[Color_bg];
#ifndef XTERM_REVERSE_VIDEO
/* this is how we implement reverseVideo */
- if (Options & Opt_reverseVideo)
+ if (options & Opt_reverseVideo)
SWAP_IT (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *);
#endif
if (rs[Rs_display_name] == NULL)
rs[Rs_display_name] = val; /* use broken `:0' value */
- i = STRLEN (val);
+ i = strlen (val);
env_display = (char *)rxvt_malloc ((i + 9) * sizeof (char));
sprintf (env_display, "DISPLAY=%s", val);
if (rs[Rs_term_name] != NULL)
{
- env_term = (char *)rxvt_malloc ((STRLEN (rs[Rs_term_name]) + 6) * sizeof (char));
+ env_term = (char *)rxvt_malloc ((strlen (rs[Rs_term_name]) + 6) * sizeof (char));
sprintf (env_term, "TERM=%s", rs[Rs_term_name]);
putenv (env_term);
}
if (!this->locale)
{
- rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale);
- setlocale (LC_CTYPE, "");
+ if (*locale)
+ {
+ rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale);
+ setlocale (LC_CTYPE, "");
+ }
+ else
+ rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n");
+
this->locale = "";
}
+
this->locale = rxvt_strdup (this->locale);
SET_LOCALE (this->locale);
mbstate.reset ();
#if HAVE_NL_LANGINFO
free (codeset);
codeset = strdup (nl_langinfo (CODESET));
- enc_utf8 = !STRCASECMP (codeset, "UTF-8")
- || !STRCASECMP (codeset, "UTF8");
+ enc_utf8 = !strcasecmp (codeset, "UTF-8")
+ || !strcasecmp (codeset, "UTF8");
#else
enc_utf8 = 1;
#endif
wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False);
XChangeProperty (display->display, TermWin.parent[0], wmlocale,
XA_STRING, 8, PropModeReplace,
- (unsigned char *)locale, STRLEN (locale));
+ (unsigned char *)locale, strlen (locale));
if (!XSupportsLocale ())
{
#endif
#ifdef META8_OPTION
- meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC);
+ meta_char = (options & Opt_meta8 ? 0x80 : C0_ESC);
#endif
get_ourmods ();
- if (!(Options & Opt_scrollTtyOutput))
- PrivateModes |= PrivMode_TtyOutputInh;
- if (Options & Opt_scrollTtyKeypress)
- PrivateModes |= PrivMode_Keypress;
- if (!(Options & Opt_jumpScroll))
- PrivateModes |= PrivMode_smoothScroll;
+ if (!(options & Opt_scrollTtyOutput))
+ priv_modes |= PrivMode_TtyOutputInh;
+ if (options & Opt_scrollTtyKeypress)
+ priv_modes |= PrivMode_Keypress;
+ if (!(options & Opt_jumpScroll))
+ priv_modes |= PrivMode_smoothScroll;
#ifndef NO_BACKSPACE_KEY
- if (STRCMP (key_backspace, "DEC") == 0)
- PrivateModes |= PrivMode_HaveBackSpace;
+ if (strcmp (key_backspace, "DEC") == 0)
+ priv_modes |= PrivMode_HaveBackSpace;
#endif
/* add value for scrollBar */
if (scrollbar_visible ())
{
- PrivateModes |= PrivMode_scrollBar;
+ priv_modes |= PrivMode_scrollBar;
SavedModes |= PrivMode_scrollBar;
}
if (menubar_visible ())
{
- PrivateModes |= PrivMode_menuBar;
+ priv_modes |= PrivMode_menuBar;
SavedModes |= PrivMode_menuBar;
}
#ifdef CURSOR_BLINK
- if (Options & Opt_cursorBlink)
+ if (options & Opt_cursorBlink)
(void)gettimeofday (&lastcursorchange, NULL);
#endif
int i;
#ifdef OFF_FOCUS_FADING
- PixColors = PixColorsFocused;
+ pix_colors = pix_colors_focused;
#endif
for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++)
if (!rXParseAllocColor (&xcol, rs[Rs_color + i]))
{
#ifndef XTERM_REVERSE_VIDEO
- if (i < 2 && (Options & Opt_reverseVideo))
+ if (i < 2 && (options & Opt_reverseVideo))
rs[Rs_color + i] = def_colorName[!i];
else
#endif
case Color_fg:
case Color_bg:
/* fatal: need bg/fg color */
- rxvt_fatal ("unable to get foreground/background colour, aborting");
+ rxvt_fatal ("unable to get foreground/background colour, aborting.\n");
/* NOTREACHED */
break;
#ifndef NO_CURSORCOLOR
case Color_cursor2:
- xcol = PixColors[Color_fg];
+ xcol = pix_colors[Color_fg];
break;
#endif /* ! NO_CURSORCOLOR */
case Color_pointer_fg:
- xcol = PixColors[Color_fg];
+ xcol = pix_colors[Color_fg];
break;
default:
- xcol = PixColors[Color_bg]; /* None */
+ xcol = pix_colors[Color_bg]; /* None */
break;
}
}
}
- PixColors[i] = xcol;
+ pix_colors[i] = xcol;
#ifdef OFF_FOCUS_FADING
if (rs[Rs_fade])
- PixColorsUnFocused[i] = xcol.fade (display, atoi (rs[Rs_fade]));
+ pix_colors_unfocused[i] = xcol.fade (display, atoi (rs[Rs_fade]));
#endif
SET_PIXCOLOR (i);
}
if (display->depth <= 2)
{
- if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg];
- if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg];
- if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg];
+ if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg];
+ if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg];
+ if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg];
}
/*
if (display->depth <= 2)
{ /* Monochrome */
- PixColors[Color_scroll] = PixColors[Color_fg];
- PixColors[Color_topShadow] = PixColors[Color_bg];
- PixColors[Color_bottomShadow] = PixColors[Color_bg];
+ pix_colors[Color_scroll] = pix_colors[Color_fg];
+ pix_colors[Color_topShadow] = pix_colors[Color_bg];
+ pix_colors[Color_bottomShadow] = pix_colors[Color_bg];
}
else
{
* xcol[1] == top shadow
* xcol[2] == bot shadow */
- xcol[1] = PixColors[Color_scroll];
+ xcol[1] = pix_colors[Color_scroll];
xcol[0].set (display, 65535, 65535, 65535);
unsigned short pr1, pg1, pb1, pr0, pg0, pb0;
xcol[0].get (display, pr0, pg0, pb0);
xcol[1].get (display, pr1, pg1, pb1);
- PixColors[Color_bottomShadow] = xcol[1].fade (display, 50);
+ pix_colors[Color_bottomShadow] = xcol[1].fade (display, 50);
/* topShadowColor */
if (!xcol[1].set (display,
min (pr0, max (pr0 / 5, pr1) * 7 / 5),
min (pg0, max (pg0 / 5, pg1) * 7 / 5),
min (pb0, max (pb0 / 5, pb1) * 7 / 5)))
- xcol[1] = PixColors[Color_White];
+ xcol[1] = pix_colors[Color_White];
- PixColors[Color_topShadow] = xcol[1];
+ pix_colors[Color_topShadow] = xcol[1];
}
#endif /* KEEP_SCROLLCOLOR */
}
requestedmeta = realmeta = realalt = 0;
rsmod = rs[Rs_modifier];
if (rsmod
- && STRCASECMP (rsmod, "mod1") >= 0 && STRCASECMP (rsmod, "mod5") <= 0)
+ && strcasecmp (rsmod, "mod1") >= 0 && strcasecmp (rsmod, "mod5") <= 0)
requestedmeta = rsmod[3] - '0';
map = XGetModifierMapping (display->display);
cm = "hyper";
break;
}
- if (rsmod && STRNCASECMP (rsmod, cm, STRLEN (cm)) == 0)
+ if (rsmod && strncasecmp (rsmod, cm, strlen (cm)) == 0)
requestedmeta = i;
}
}
{
XClassHint classHint;
XWMHints wmHint;
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
Atom prop = None;
MWMHints mwmhints;
#endif
XSetWindowAttributes attributes;
XWindowAttributes gattr;
- if (Options & Opt_transparent)
+ if (options & Opt_transparent)
{
XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr);
display->depth = gattr.depth; // doh //TODO, per-term not per-display?
}
-#ifndef NO_FRILLS
- if (Options & Opt_borderLess)
+#if ENABLE_FRILLS
+ if (options & Opt_borderLess)
{
prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True);
if (prop == None)
/* sub-window placement & size in rxvt_resize_subwindows () */
#ifdef PREFER_24BIT
- attributes.background_pixel = PixColors[Color_bg];
- attributes.border_pixel = PixColors[Color_border];
+ attributes.background_pixel = pix_colors[Color_bg];
+ attributes.border_pixel = pix_colors[Color_border];
attributes.colormap = display->cmap;
TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display),
szHint.x, szHint.y,
szHint.x, szHint.y,
szHint.width, szHint.height,
TermWin.ext_bwidth,
- PixColors[Color_border],
- PixColors[Color_bg]);
+ pix_colors[Color_border],
+ pix_colors[Color_bg]);
#endif
process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST);
wmHint.flags = InputHint | StateHint | WindowGroupHint;
wmHint.input = True;
- wmHint.initial_state = Options & Opt_iconic ? IconicState : NormalState;
+ wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState;
wmHint.window_group = TermWin.parent[0];
XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL,
(char **)argv, argc, &szHint, &wmHint, &classHint);
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
long pid = getpid ();
XChangeProperty (display->display, TermWin.parent[0],
display->atom ("_NET_WM_PID"), XA_CARDINAL, 32,
| StructureNotifyMask);
termwin_ev.start (display, TermWin.parent[0]);
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
if (mwmhints.flags)
{
prop = XInternAtom(display->display, "_MOTIF_WM_HINTS", False);
TermWin_TotalWidth (),
TermWin_TotalHeight (),
0,
- PixColors[Color_fg],
- PixColors[Color_bg]);
+ pix_colors[Color_fg],
+ pix_colors[Color_bg]);
#ifdef DEBUG_X
XStoreName (display->display, TermWin.vt, "vt window");
#endif
pointer_unblank ();
#ifdef POINTER_BLANK
- if (Options & Opt_pointerBlank)
+ if (options & Opt_pointerBlank)
vt_emask |= PointerMotionMask;
else
#endif
TermWin_TotalWidth (),
menuBar_TotalHeight (),
0,
- PixColors[Color_fg],
- PixColors[Color_scroll]);
+ pix_colors[Color_fg],
+ pix_colors[Color_scroll]);
#ifdef DEBUG_X
XStoreName (display->display, menuBar.win, "menubar");
#ifdef XPM_BACKGROUND
if (rs[Rs_backgroundPixmap] != NULL
- && ! (Options & Opt_transparent))
+ && ! (options & Opt_transparent))
{
const char *p = rs[Rs_backgroundPixmap];
- if ((p = STRCHR (p, ';')) != NULL)
+ if ((p = strchr (p, ';')) != NULL)
{
p++;
scale_pixmap (p);
#endif
/* graphics context for the vt window */
- gcvalue.foreground = PixColors[Color_fg];
- gcvalue.background = PixColors[Color_bg];
+ gcvalue.foreground = pix_colors[Color_fg];
+ gcvalue.background = pix_colors[Color_bg];
gcvalue.graphics_exposures = 1;
TermWin.gc = XCreateGC (display->display, TermWin.vt,
GCForeground | GCBackground | GCGraphicsExposures,
TermWin.drawable = new rxvt_drawable (display, TermWin.vt);
#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
- gcvalue.foreground = PixColors[Color_topShadow];
+ gcvalue.foreground = pix_colors[Color_topShadow];
topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
- gcvalue.foreground = PixColors[Color_bottomShadow];
+ gcvalue.foreground = pix_colors[Color_bottomShadow];
botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
- gcvalue.foreground = PixColors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
+ gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
#endif
#ifdef OFF_FOCUS_FADING
// initially we are in unfocused state
if (rs[Rs_fade])
- PixColors = PixColorsUnFocused;
-#endif
-}
-
-/*----------------------------------------------------------------------*/
-/*
- * Run the command in a subprocess and return a file descriptor for the
- * master end of the pseudo-teletype pair with the command talking to
- * the slave.
- */
-void
-rxvt_term::run_command (const char *const *argv)
-{
- int er;
-
- /* get master (pty) */
- if ((cmd_fd = rxvt_get_pty (&tty_fd, &ttydev)) < 0)
- rxvt_fatal ("can't open pseudo-tty");
-
- fcntl (cmd_fd, F_SETFL, O_NONBLOCK);
-
- /* get slave (tty) */
- if (tty_fd < 0)
- {
-#ifndef NO_SETOWNER_TTYDEV
- privileged_ttydev (SAVE);
-#endif
-
- if ((tty_fd = rxvt_get_tty (ttydev)) < 0)
- {
- close (cmd_fd);
- cmd_fd = -1;
- rxvt_fatal ("can't open slave tty %s", ttydev);
- }
- }
-
-#ifndef NO_BACKSPACE_KEY
- if (key_backspace[0] && !key_backspace[1])
- er = key_backspace[0];
- else if (STRCMP (key_backspace, "DEC") == 0)
- er = '\177'; /* the initial state anyway */
- else
-#endif
- er = -1;
-
- rxvt_get_ttymode (&tio, er);
-
-#ifndef __QNX__
- /* spin off the command interpreter */
- switch (cmd_pid = fork ())
- {
- case -1:
- rxvt_fatal ("can't fork");
- case 0:
- init_env ();
-
- if (rxvt_control_tty (tty_fd, ttydev) < 0)
- fprintf (stderr, "%s: could not obtain control of tty.", RESNAME);
- else
- {
- /* Reopen stdin, stdout and stderr over the tty file descriptor */
- dup2 (tty_fd, STDIN_FILENO);
- dup2 (tty_fd, STDOUT_FILENO);
- dup2 (tty_fd, STDERR_FILENO);
-
- // close all our file handles that we do no longer need
- for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
- {
- if ((*t)->cmd_fd > 2) close ((*t)->cmd_fd);
- if ((*t)->tty_fd > 2) close ((*t)->tty_fd);
- }
-
- run_child (argv);
- fprintf (stderr, "%s: unable to exec child.", RESNAME);
- }
-
- _exit (EXIT_FAILURE);
-
- default:
- {
-#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
- int fdstdin;
-
- fdstdin = dup (STDIN_FILENO);
- dup2 (tty_fd, STDIN_FILENO);
-#endif
-
-#ifdef UTMP_SUPPORT
- privileged_utmp (SAVE);
-#endif
-
-#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
-
- dup2 (fdstdin, STDIN_FILENO);
- close (fdstdin);
-#endif
- }
-
- close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */
- break;
- }
-#else /* __QNX__ uses qnxspawn () */
- fchmod (tty_fd, 0622);
- fcntl (tty_fd, F_SETFD, FD_CLOEXEC);
- fcntl (cmd_fd, F_SETFD, FD_CLOEXEC);
-
- if (run_child (argv) == -1)
- exit (EXIT_FAILURE);
+ pix_colors = pix_colors_unfocused;
#endif
}
/* ------------------------------------------------------------------------- *
- * CHILD PROCESS OPERATIONS *
- * ------------------------------------------------------------------------- */
-/*
- * The only open file descriptor is the slave tty - so no error messages.
- * returns are fatal
- */
-int
-rxvt_term::run_child (const char *const *argv)
-{
- char *login;
-
- SET_TTYMODE (STDIN_FILENO, & (tio)); /* init terminal attributes */
-
- if (Options & Opt_console)
- { /* be virtual console, fail silently */
-#ifdef TIOCCONS
- unsigned int on = 1;
-
- ioctl (STDIN_FILENO, TIOCCONS, &on);
-#elif defined (SRIOCSREDIR)
- int fd;
-
- fd = open (CONSOLE, O_WRONLY, 0);
- if (fd >= 0)
- if (ioctl (fd, SRIOCSREDIR, NULL) < 0)
- close (fd);
-#endif /* SRIOCSREDIR */
-
- }
-
- /* reset signals and spin off the command interpreter */
- signal (SIGINT, SIG_DFL);
- signal (SIGQUIT, SIG_DFL);
- signal (SIGCHLD, SIG_DFL);
- /*
- * mimick login's behavior by disabling the job control signals
- * a shell that wants them can turn them back on
- */
-#ifdef SIGTSTP
- signal (SIGTSTP, SIG_IGN);
- signal (SIGTTIN, SIG_IGN);
- signal (SIGTTOU, SIG_IGN);
-#endif /* SIGTSTP */
-
- /* set window size */
- struct winsize ws;
-
- ws.ws_col = TermWin.ncol;
- ws.ws_row = TermWin.nrow;
- ws.ws_xpixel = ws.ws_ypixel = 0;
- (void)ioctl (STDIN_FILENO, TIOCSWINSZ, &ws);
-
- // unblock signals (signals are blocked by iom.C
- sigset_t ss;
- sigemptyset (&ss);
- sigprocmask (SIG_SETMASK, &ss, 0);
-
-#ifndef __QNX__
- /* command interpreter path */
- if (argv != NULL)
- {
-# ifdef DEBUG_CMD
- int i;
-
- for (i = 0; argv[i]; i++)
- fprintf (stderr, "argv [%d] = \"%s\"\n", i, argv[i]);
-# endif
-
- execvp (argv[0], (char *const *)argv);
- /* no error message: STDERR is closed! */
- }
- else
- {
- const char *argv0, *shell;
-
- if ((shell = getenv ("SHELL")) == NULL || *shell == '\0')
- shell = "/bin/sh";
-
- argv0 = (const char *)rxvt_r_basename (shell);
- if (Options & Opt_loginShell)
- {
- login = (char *)rxvt_malloc ((STRLEN (argv0) + 2) * sizeof (char));
-
- login[0] = '-';
- STRCPY (&login[1], argv0);
- argv0 = login;
- }
- execlp (shell, argv0, NULL);
- /* no error message: STDERR is closed! */
- }
-
-#else /* __QNX__ uses qnxspawn () */
-
- char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
- char *command = NULL, fullcommand[_MAX_PATH];
- char **arg_v, *arg_a[2] = { NULL, NULL };
-
- if (argv != NULL)
- {
- if (access (argv[0], X_OK) == -1)
- {
- if (STRCHR (argv[0], '/') == NULL)
- {
- searchenv (argv[0], "PATH", fullcommand);
- if (fullcommand[0] != '\0')
- command = fullcommand;
- }
- if (access (command, X_OK) == -1)
- return -1;
- }
- else
- command = argv[0];
- arg_v = argv;
- }
- else
- {
- if ((command = getenv ("SHELL")) == NULL || *command == '\0')
- command = "/bin/sh";
-
- arg_a[0] = my_basename (command);
- if (Options & Opt_loginShell)
- {
- login = rxvt_malloc ((STRLEN (arg_a[0]) + 2) * sizeof (char));
-
- login[0] = '-';
- STRCPY (&login[1], arg_a[0]);
- arg_a[0] = login;
- }
- arg_v = arg_a;
- }
- iov_a[0] = iov_a[1] = iov_a[2] = tty_fd;
- cmd_pid = qnx_spawn (0, 0, 0, -1, -1,
- _SPAWN_SETSID | _SPAWN_TCSETPGRP,
- command, arg_v, environ, iov_a, 0);
- if (login)
- free (login);
-
- close (tty_fd);
- return cmd_fd;
-
-#endif
- return -1;
-}
-
-/* ------------------------------------------------------------------------- *
* GET TTY CURRENT STATE *
* ------------------------------------------------------------------------- */
-/* rxvt_get_ttymode () */
-/* EXTPROTO */
void
rxvt_get_ttymode (ttymode_t *tio, int erase)
{
#endif /* DEBUG_TTYMODE */
}
+/*----------------------------------------------------------------------*/
+/*
+ * Run the command in a subprocess and return a file descriptor for the
+ * master end of the pseudo-teletype pair with the command talking to
+ * the slave.
+ */
+void
+rxvt_term::run_command (const char *const *argv)
+{
+ int er;
+
+ if (!pty.get ())
+ rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
+
+#ifndef NO_BACKSPACE_KEY
+ if (key_backspace[0] && !key_backspace[1])
+ er = key_backspace[0];
+ else if (strcmp (key_backspace, "DEC") == 0)
+ er = '\177'; /* the initial state anyway */
+ else
+#endif
+ er = -1;
+
+ rxvt_get_ttymode (&tio, er);
+
+ /* set initial window size */
+ tt_winch ();
+
+#ifndef __QNX__
+ /* spin off the command interpreter */
+ switch (cmd_pid = fork ())
+ {
+ case -1:
+ rxvt_fatal ("can't fork, aborting.\n");
+ case 0:
+ init_env ();
+
+ if (!pty.make_controlling_tty ())
+ fprintf (stderr, "%s: could not obtain control of tty.", RESNAME);
+ else
+ {
+ /* Reopen stdin, stdout and stderr over the tty file descriptor */
+ dup2 (pty.tty, STDIN_FILENO);
+ dup2 (pty.tty, STDOUT_FILENO);
+ dup2 (pty.tty, STDERR_FILENO);
+
+ // close all our file handles that we do no longer need
+ for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
+ {
+ if ((*t)->pty.pty > 2) close ((*t)->pty.pty);
+ if ((*t)->pty.tty > 2) close ((*t)->pty.tty);
+ }
+
+ run_child (argv);
+ fprintf (stderr, "%s: unable to exec child.", RESNAME);
+ }
+
+ _exit (EXIT_FAILURE);
+
+ default:
+ {
+#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
+ int fdstdin;
+
+ fdstdin = dup (STDIN_FILENO);
+ dup2 (pty.tty, STDIN_FILENO);
+#endif
+
+#ifdef UTMP_SUPPORT
+ privileged_utmp (SAVE);
+#endif
+
+#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
+
+ dup2 (fdstdin, STDIN_FILENO);
+ close (fdstdin);
+#endif
+ }
+
+ pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */
+ break;
+ }
+#else /* __QNX__ uses qnxspawn () */
+ fchmod (pty.tty, 0622);
+ fcntl (pty.tty, F_SETFD, FD_CLOEXEC);
+ fcntl (pty.pty, F_SETFD, FD_CLOEXEC);
+
+ if (run_child (argv) == -1)
+ exit (EXIT_FAILURE);
+#endif
+}
+
+/* ------------------------------------------------------------------------- *
+ * CHILD PROCESS OPERATIONS *
+ * ------------------------------------------------------------------------- */
+/*
+ * The only open file descriptor is the slave tty - so no error messages.
+ * returns are fatal
+ */
+int
+rxvt_term::run_child (const char *const *argv)
+{
+ char *login;
+
+ SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */
+
+ if (options & Opt_console)
+ { /* be virtual console, fail silently */
+#ifdef TIOCCONS
+ unsigned int on = 1;
+
+ ioctl (STDIN_FILENO, TIOCCONS, &on);
+#elif defined (SRIOCSREDIR)
+ int fd;
+
+ fd = open (CONSOLE, O_WRONLY, 0);
+ if (fd >= 0)
+ if (ioctl (fd, SRIOCSREDIR, NULL) < 0)
+ close (fd);
+#endif /* SRIOCSREDIR */
+ }
+
+ /* reset signals and spin off the command interpreter */
+ signal (SIGINT, SIG_DFL);
+ signal (SIGQUIT, SIG_DFL);
+ signal (SIGCHLD, SIG_DFL);
+ signal (SIGHUP, SIG_DFL);
+ signal (SIGPIPE, SIG_DFL);
+ /*
+ * mimick login's behavior by disabling the job control signals
+ * a shell that wants them can turn them back on
+ */
+#ifdef SIGTSTP
+ signal (SIGTSTP, SIG_IGN);
+ signal (SIGTTIN, SIG_IGN);
+ signal (SIGTTOU, SIG_IGN);
+#endif /* SIGTSTP */
+
+ // unblock signals (signals are blocked by iom.C
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigprocmask (SIG_SETMASK, &ss, 0);
+
+#ifndef __QNX__
+ /* command interpreter path */
+ if (argv != NULL)
+ {
+# ifdef DEBUG_CMD
+ int i;
+
+ for (i = 0; argv[i]; i++)
+ fprintf (stderr, "argv [%d] = \"%s\"\n", i, argv[i]);
+# endif
+
+ execvp (argv[0], (char *const *)argv);
+ /* no error message: STDERR is closed! */
+ }
+ else
+ {
+ const char *argv0, *shell;
+
+ if ((shell = getenv ("SHELL")) == NULL || *shell == '\0')
+ shell = "/bin/sh";
+
+ argv0 = (const char *)rxvt_r_basename (shell);
+
+ if (options & Opt_loginShell)
+ {
+ login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char));
+
+ login[0] = '-';
+ strcpy (&login[1], argv0);
+ argv0 = login;
+ }
+ execlp (shell, argv0, NULL);
+ /* no error message: STDERR is closed! */
+ }
+
+#else /* __QNX__ uses qnxspawn () */
+
+ char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+ char *command = NULL, fullcommand[_MAX_PATH];
+ char **arg_v, *arg_a[2] = { NULL, NULL };
+
+ if (argv != NULL)
+ {
+ if (access (argv[0], X_OK) == -1)
+ {
+ if (strchr (argv[0], '/') == NULL)
+ {
+ searchenv (argv[0], "PATH", fullcommand);
+
+ if (fullcommand[0] != '\0')
+ command = fullcommand;
+ }
+
+ if (access (command, X_OK) == -1)
+ return -1;
+ }
+ else
+ command = argv[0];
+
+ arg_v = argv;
+ }
+ else
+ {
+ if ((command = getenv ("SHELL")) == NULL || *command == '\0')
+ command = "/bin/sh";
+
+ arg_a[0] = my_basename (command);
+
+ if (options & Opt_loginShell)
+ {
+ login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char));
+
+ login[0] = '-';
+ strcpy (&login[1], arg_a[0]);
+ arg_a[0] = login;
+ }
+
+ arg_v = arg_a;
+ }
+
+ iov_a[0] = iov_a[1] = iov_a[2] = pty.tty;
+ cmd_pid = qnx_spawn (0, 0, 0, -1, -1,
+ _SPAWN_SETSID | _SPAWN_TCSETPGRP,
+ command, arg_v, environ, iov_a, 0);
+ if (login)
+ free (login);
+
+ pty.close_tty ();
+ return pty.pty;
+#endif
+
+ return -1;
+}
+
/*----------------------- end-of-file (C source) -----------------------*/
char ut_id[5];
struct passwd *pwent = getpwuid (getuid ());
- if (!STRNCMP (pty, "/dev/", 5))
+ if (!strncmp (pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
- if (!STRNCMP (pty, "pty", 3) || !STRNCMP (pty, "tty", 3))
+ if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3))
{
- STRNCPY (ut_id, (pty + 3), sizeof (ut_id));
+ strncpy (ut_id, (pty + 3), sizeof (ut_id));
}
#ifdef HAVE_UTMP_PID
else if (sscanf (pty, "pts/%d", &i) == 1)
sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
#endif
- else if (STRNCMP (pty, "pty", 3) && STRNCMP (pty, "tty", 3))
+ else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3))
{
rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty);
return;
}
#ifdef HAVE_STRUCT_UTMP
- MEMSET (ut, 0, sizeof (struct utmp));
+ memset (ut, 0, sizeof (struct utmp));
# ifdef HAVE_UTMP_PID
setutent ();
- STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id));
+ strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
ut->ut_type = DEAD_PROCESS;
getutid (ut); /* position to entry in utmp file */
- STRNCPY (ut_id, ut_id, sizeof (ut_id));
+ strncpy (ut_id, ut_id, sizeof (ut_id));
# endif
#endif
#ifdef HAVE_STRUCT_UTMPX
- MEMSET (utx, 0, sizeof (struct utmpx));
+ memset (utx, 0, sizeof (struct utmpx));
setutxent ();
- STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id));
+ strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
utx->ut_type = DEAD_PROCESS;
getutxid (utx); /* position to entry in utmp file */
- STRNCPY (ut_id, ut_id, sizeof (ut_id));
+ strncpy (ut_id, ut_id, sizeof (ut_id));
#endif
#ifdef HAVE_STRUCT_UTMP
- STRNCPY (ut->ut_line, pty, sizeof (ut->ut_line));
+ strncpy (ut->ut_line, pty, sizeof (ut->ut_line));
ut->ut_time = time (NULL);
# ifdef HAVE_UTMP_PID
- STRNCPY (ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+ strncpy (ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
sizeof (ut->ut_user));
- STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id));
+ strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
ut->ut_time = time (NULL);
ut->ut_pid = cmd_pid;
# ifdef HAVE_UTMP_HOST
- STRNCPY (ut->ut_host, hostname, sizeof (ut->ut_host));
+ strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
# endif
ut->ut_type = USER_PROCESS;
pututline (ut);
endutent (); /* close the file */
utmp_pos = 0;
# else
- STRNCPY (ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+ strncpy (ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
sizeof (ut->ut_name));
# ifdef HAVE_UTMP_HOST
- STRNCPY (ut->ut_host, hostname, sizeof (ut->ut_host));
+ strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
# endif
# endif
#endif
#ifdef HAVE_STRUCT_UTMPX
- STRNCPY (utx->ut_line, pty, sizeof (utx->ut_line));
- STRNCPY (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
+ strncpy (utx->ut_line, pty, sizeof (utx->ut_line));
+ strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
sizeof (utx->ut_user));
- STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id));
+ strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
utx->ut_session = getsid (0);
utx->ut_tv.tv_sec = time (NULL);
utx->ut_tv.tv_usec = 0;
utx->ut_pid = cmd_pid;
# ifdef HAVE_UTMPX_HOST
- STRNCPY (utx->ut_host, hostname, sizeof (utx->ut_host));
+ strncpy (utx->ut_host, hostname, sizeof (utx->ut_host));
# if 0
{
char *colon;
- if ((colon = STRRCHR (ut->ut_host, ':')) != NULL)
+ if ((colon = strrchr (ut->ut_host, ':')) != NULL)
*colon = '\0';
}
# endif
{
if (*buf == '#' || sscanf (buf, "%s", name) != 1)
continue;
- if (!STRCMP (ut->ut_line, name))
+ if (!strcmp (ut->ut_line, name))
{
if (!rxvt_write_bsd_utmp (i, ut))
i = 0;
#ifdef WTMP_SUPPORT
# ifdef WTMP_ONLY_ON_LOGIN
- if (Options & Opt_loginShell)
+ if (options & Opt_loginShell)
# endif
{
# ifdef HAVE_STRUCT_UTMP
}
#endif
#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
- if (Options & Opt_loginShell)
+ if (options & Opt_loginShell)
rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
#endif
}
#ifdef HAVE_STRUCT_UTMP
# ifdef HAVE_UTMP_PID
- MEMSET (ut, 0, sizeof (struct utmp));
+ memset (ut, 0, sizeof (struct utmp));
setutent ();
- STRNCPY (ut->ut_id, ut_id, sizeof (ut->ut_id));
+ strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
ut->ut_type = USER_PROCESS;
{
struct utmp *tmput = getutid (ut);
}
ut->ut_type = DEAD_PROCESS;
# else
- MEMSET (ut->ut_name, 0, sizeof (ut->ut_name));
+ memset (ut->ut_name, 0, sizeof (ut->ut_name));
# ifdef HAVE_UTMP_HOST
- MEMSET (ut->ut_host, 0, sizeof (ut->ut_host));
+ memset (ut->ut_host, 0, sizeof (ut->ut_host));
# endif
# endif
ut->ut_time = time (NULL);
#endif
#ifdef HAVE_STRUCT_UTMPX
- MEMSET (utx, 0, sizeof (struct utmpx));
+ memset (utx, 0, sizeof (struct utmpx));
setutxent ();
- STRNCPY (utx->ut_id, ut_id, sizeof (utx->ut_id));
+ strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
utx->ut_type = USER_PROCESS;
if ((tmputx = getutxid (utx))) /* position to entry in utmp file */
utx = tmputx;
*/
#ifdef WTMP_SUPPORT
# ifdef WTMP_ONLY_ON_LOGIN
- if (Options & Opt_loginShell)
+ if (options & Opt_loginShell)
# endif
{
# ifdef HAVE_STRUCT_UTMP
pututline (ut);
endutent ();
# else
- MEMSET (ut, 0, sizeof (struct utmp));
+ memset (ut, 0, sizeof (struct utmp));
rxvt_write_bsd_utmp (utmp_pos, ut);
# endif
#endif
# endif
# ifdef HAVE_STRUCT_LASTLOGX
- MEMSET (&llx, 0, sizeof (llx));
+ memset (&llx, 0, sizeof (llx));
llx.ll_tv.tv_sec = time (NULL);
llx.ll_tv.tv_usec = 0;
- STRNCPY (llx.ll_line, pty, sizeof (llx.ll_line));
- STRNCPY (llx.ll_host, host, sizeof (llx.ll_host));
+ strncpy (llx.ll_line, pty, sizeof (llx.ll_line));
+ strncpy (llx.ll_host, host, sizeof (llx.ll_host));
updlastlogx (RXVT_LASTLOGX_FILE, getuid (), &llx);
# endif
return;
}
- MEMSET (&ll, 0, sizeof (ll));
+ memset (&ll, 0, sizeof (ll));
ll.ll_time = time (NULL);
- STRNCPY (ll.ll_line, pty, sizeof (ll.ll_line));
- STRNCPY (ll.ll_host, host, sizeof (ll.ll_host));
+ strncpy (ll.ll_line, pty, sizeof (ll.ll_line));
+ strncpy (ll.ll_host, host, sizeof (ll.ll_host));
# ifdef LASTLOG_IS_DIR
sprintf (lastlogfile, "%.*s/%.*s",
sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2, fname,
bool
rxvt_set_locale (const char *locale)
{
- if (!locale || !STRNCMP (locale, curlocale, 128))
+ if (!locale || !strncmp (locale, curlocale, 128))
return false;
- STRNCPY (curlocale, locale, 128);
+ strncpy (curlocale, locale, 128);
setlocale (LC_CTYPE, curlocale);
return true;
}
{
void *p = malloc (s);
- MEMSET (p, 0, s);
+ memset (p, 0, s);
return p;
}
{
termlist.erase (find (termlist.begin (), termlist.end(), this));
- if (cmd_fd >= 0)
- close (cmd_fd);
+ if (cmd_pid)
+ kill (-cmd_pid, SIGHUP);
+
+ pty.put ();
-#ifndef NO_SETOWNER_TTYDEV
- privileged_ttydev (RESTORE);
-#endif
#ifdef UTMP_SUPPORT
privileged_utmp (RESTORE);
#endif
im_destroy ();
#endif
#ifdef MENUBAR
- if (menubarGC) XFreeGC (display->display, menubarGC);
+ if (menubarGC) XFreeGC (display->display, menubarGC);
#endif
#ifdef XTERM_SCROLLBAR
if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
// TODO: free pixcolours, colours should become part of rxvt_display
- delete PixColorsFocused;
+ delete pix_colors_focused;
#ifdef OFF_FOCUS_FADING
- delete PixColorsUnFocused;
+ delete pix_colors_unfocused;
#endif
displays.put (display);
if (destroy_ev.active)
return;
+#if ENABLE_OVERLAY
+ scr_overlay_off ();
+#endif
+
if (display)
{
#if USE_XIM
if (!init_vars ())
return false;
- /*
- * Save and then give up any super-user privileges
- * If we need privileges in any area then we must specifically request it.
- * We should only need to be root in these cases:
- * 1. write utmp entries on some systems
- * 2. chown tty on some systems
- */
- privileges (SAVE);
- privileges (IGNORE);
-
init_secondary ();
const char **cmd_argv = init_resources (argc, argv);
menubar_read (rs[Rs_menu]);
#endif
#ifdef HAVE_SCROLLBARS
- if (Options & Opt_scrollBar)
+ if (options & Opt_scrollBar)
scrollBar.setIdle (); /* set existence for size calculations */
#endif
#endif
#ifdef HAVE_SCROLLBARS
- if (Options & Opt_scrollBar)
+ if (options & Opt_scrollBar)
resize_scrollbar (); /* create and map scrollbar */
#endif
#if (MENUBAR_MAX)
XMapWindow (display->display, menuBar.win);
#endif
#ifdef TRANSPARENT
- if (Options & Opt_transparent)
+ if (options & Opt_transparent)
{
XSelectInput (display->display, display->root, PropertyChangeMask);
check_our_parents ();
init_command (cmd_argv);
- pty_ev.start (cmd_fd, EVENT_READ);
+ pty_ev.start (pty.pty, EVENT_READ);
check_ev.start ();
static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
void
-rxvt_init_signals ()
+rxvt_init ()
{
/* install exit handler for cleanup */
#if 0
#else
#endif
#endif
+ /*
+ * Save and then give up any super-user privileges
+ * If we need privileges in any area then we must specifically request it.
+ * We should only need to be root in these cases:
+ * 1. write utmp entries on some systems
+ * 2. chown tty on some systems
+ */
+ rxvt_privileges (SAVE);
+ rxvt_privileges (IGNORE);
struct sigaction sa;
}
/* ARGSUSED */
-/* EXTPROTO */
+/* INTPROTO */
RETSIGTYPE
rxvt_Child_signal (int sig __attribute__ ((unused)))
{
/*
* Catch a fatal signal and tidy up before quitting
*/
-/* EXTPROTO */
+/* INTPROTO */
RETSIGTYPE
rxvt_Exit_signal (int sig)
{
* Exit gracefully, clearing the utmp entry and restoring tty attributes
* TODO: if debugging, this should free up any known resources if we can
*/
-/* EXTPROTO */
+/* INTPROTO */
void
rxvt_clean_exit ()
{
/* ------------------------------------------------------------------------- *
* MEMORY ALLOCATION WRAPPERS *
* ------------------------------------------------------------------------- */
-/* EXTPROTO */
+/* INTPROTO */
void *
rxvt_malloc (size_t size)
{
- void *p;
+ void *p;
p = malloc (size);
if (p)
return p;
- fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
- rxvt_clean_exit ();
- exit (EXIT_FAILURE);
+ rxvt_fatal ("memory allocation failure. aborting.\n");
/* NOTREACHED */
}
-/* EXTPROTO */
+/* INTPROTO */
void *
rxvt_calloc (size_t number, size_t size)
{
- void *p;
+ void *p;
p = calloc (number, size);
if (p)
return p;
- fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
- rxvt_clean_exit ();
- exit (EXIT_FAILURE);
+ rxvt_fatal ("memory allocation failure. aborting.\n");
/* NOTREACHED */
}
-/* EXTPROTO */
+/* INTPROTO */
void *
rxvt_realloc (void *ptr, size_t size)
{
p = realloc (ptr, size);
else
p = malloc (size);
+
if (p)
return p;
- fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
- rxvt_clean_exit ();
- exit (EXIT_FAILURE);
+ rxvt_fatal ("memory allocation failure. aborting.\n");
/* NOTREACHED */
}
* ------------------------------------------------------------------------- */
/* take care of suid/sgid super-user (root) privileges */
void
-rxvt_term::privileges (int mode)
+rxvt_privileges (rxvt_privaction action)
{
+#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
+ static uid_t euid;
+ static gid_t egid;
+#endif
+
#if ! defined(__CYGWIN32__)
# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
/* setreuid () is the poor man's setuid (), seteuid () */
# define HAVE_SETEUID
# endif
# ifdef HAVE_SETEUID
- switch (mode)
+ switch (action)
{
case IGNORE:
/*
break;
}
# else
- switch (mode)
+ switch (action)
{
case IGNORE:
setuid (getuid ());
#ifdef UTMP_SUPPORT
void
-rxvt_term::privileged_utmp (char action)
-{
- D_MAIN ((stderr, "rxvt_privileged_utmp (%c); waiting for: %c (pid: %d)",
- action, next_utmp_action, getpid ()));
- if (next_utmp_action != action || (action != SAVE && action != RESTORE)
- || (Options & Opt_utmpInhibit)
- || ttydev == NULL || *ttydev == '\0')
- return;
-
- privileges (RESTORE);
- if (action == SAVE)
- {
- next_utmp_action = RESTORE;
- makeutent (ttydev, rs[Rs_display_name]);
- }
- else
- { /* action == RESTORE */
- next_utmp_action = IGNORE;
- cleanutent ();
- }
- privileges (IGNORE);
-}
-#endif
-
-#ifndef NO_SETOWNER_TTYDEV
-void
-rxvt_term::privileged_ttydev (char action)
+rxvt_term::privileged_utmp (rxvt_privaction action)
{
- D_MAIN ((stderr,
- "privileged_ttydev (%c); waiting for: %c (pid: %d)",
- action, next_tty_action, getpid ()));
- if (next_tty_action != action || (action != SAVE && action != RESTORE)
- || ttydev == NULL || *ttydev == '\0')
+ if ((options & Opt_utmpInhibit)
+ || !pty.name || !*pty.name)
return;
- privileges (RESTORE);
+ rxvt_privileges (RESTORE);
if (action == SAVE)
- {
- next_tty_action = RESTORE;
-# ifndef RESET_TTY_TO_COMMON_DEFAULTS
- /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */
- if (lstat (ttydev, &ttyfd_stat) < 0) /* you lose out */
- next_tty_action = IGNORE;
- else
-# endif
-
- {
- chown (ttydev, getuid (), ttygid); /* fail silently */
- chmod (ttydev, ttymode);
-# ifdef HAVE_REVOKE
- revoke (ttydev);
-# endif
-
- }
- }
+ makeutent (pty.name, rs[Rs_display_name]);
else
- { /* action == RESTORE */
- next_tty_action = IGNORE;
-# ifndef RESET_TTY_TO_COMMON_DEFAULTS
- chmod (ttydev, ttyfd_stat.st_mode);
- chown (ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid);
-# else
- chmod (ttydev,
- (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
- chown (ttydev, 0, 0);
-# endif
+ cleanutent ();
- }
-
- privileges (IGNORE);
-
-# ifndef RESET_TTY_TO_COMMON_DEFAULTS
- D_MAIN ((stderr, "%s \"%s\": mode %03o, uid %d, gid %d",
- action == RESTORE ? "Restoring" : (action ==
- SAVE ? "Saving" :
- "UNKNOWN ERROR for"), ttydev,
- ttyfd_stat.st_mode, ttyfd_stat.st_uid,
- ttyfd_stat.st_gid));
-# endif
+ rxvt_privileges (IGNORE);
}
#endif
{
sb_w = scrollbar_TotalWidth ();
szHint.base_width += sb_w;
- if (!(Options & Opt_scrollBar_right))
+ if (!(options & Opt_scrollBar_right))
window_vt_x += sb_w;
}
szHint.height = szHint.base_height + TermWin.height;
}
- if (scrollbar_visible () && (Options & Opt_scrollBar_right))
+ if (scrollbar_visible () && (options & Opt_scrollBar_right))
window_sb_x = szHint.width - sb_w;
if (recalc_x)
void
rxvt_term::tt_winch ()
{
- struct winsize ws;
-
- if (cmd_fd < 0)
+ if (pty.pty < 0)
return;
+ struct winsize ws;
+
ws.ws_col = TermWin.ncol;
ws.ws_row = TermWin.nrow;
- ws.ws_xpixel = ws.ws_ypixel = 0;
-#ifndef DEBUG_SIZE
- (void)ioctl (cmd_fd, TIOCSWINSZ, &ws);
-#else
- if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0)
- D_SIZE ((stderr, "Failed to send TIOCSWINSZ to fd %d", fd));
-# ifdef SIGWINCH
- else if (cmd_pid) /* force through to the command */
+ ws.ws_xpixel = TermWin.width;
+ ws.ws_ypixel = TermWin.height;
+ (void)ioctl (pty.pty, TIOCSWINSZ, &ws);
+
+#if 0
+ // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
+ if (cmd_pid) /* force through to the command */
kill (cmd_pid, SIGWINCH);
-# endif
#endif
}
if (!XFetchName (display->display, TermWin.parent[0], &name))
name = NULL;
- if (name == NULL || STRCMP (name, str))
+ if (name == NULL || strcmp (name, str))
#endif
XStoreName (display->display, TermWin.parent[0], str);
if (!XGetIconName (display->display, TermWin.parent[0], &name))
name = NULL;
- if (name == NULL || STRCMP (name, str))
+ if (name == NULL || strcmp (name, str))
#endif
XSetIconName (display->display, TermWin.parent[0], str);
{ /* bright colors */
i -= 8;
# ifndef NO_BRIGHTCOLOR
- PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i];
+ pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
SET_PIXCOLOR (idx);
goto Done;
# endif
}
if (i >= 0 && i <= 7)
{ /* normal colors */
- PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i];
+ pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
SET_PIXCOLOR (idx);
goto Done;
}
*/
# if 0
for (i = Color_Black; i <= Color_White; i++)
- if (PixColors[idx] == PixColors[i])
+ if (pix_colors[idx] == pix_colors[i])
break;
if (i > Color_White)
{
- /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
- XFreeColors (display->display, display->cmap, (PixColors + idx), 1,
+ /* fprintf (stderr, "XFreeColors: pix_colors [%d] = %lu\n", idx, pix_colors [idx]); */
+ XFreeColors (display->display, display->cmap, (pix_colors + idx), 1,
DisplayPlanes (display->display, display->screen));
}
# endif
- PixColorsFocused[idx] = xcol;
+ pix_colors_focused[idx] = xcol;
SET_PIXCOLOR (idx);
/* XSetWindowAttributes attr; */
/* Cursor cursor; */
Done:
#ifdef OFF_FOCUS_FADING
- PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade]));
+ pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]));
#endif
- if (idx == Color_bg && ! (Options & Opt_transparent))
- XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
+ if (idx == Color_bg && ! (options & Opt_transparent))
+ XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]);
/* handle Color_BD, scrollbar background, etc. */
{
XColor xcol[2];
- xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColorsFocused[Color_pointer_fg] : PixColorsFocused[Color_fg];
- xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg];
+ xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? pix_colors_focused[Color_pointer_fg] : pix_colors_focused[Color_fg];
+ xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? pix_colors_focused[Color_pointer_bg] : pix_colors_focused[Color_bg];
XQueryColors (display->display, display->cmap, xcol, 2);
XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
}
env_colorfgbg =
(char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg") + 1);
- STRCPY (fstr, "default");
- STRCPY (bstr, "default");
+ strcpy (fstr, "default");
+ strcpy (bstr, "default");
for (i = Color_Black; i <= Color_White; i++)
- if (PixColors[Color_fg] == PixColors[i])
+ if (pix_colors[Color_fg] == pix_colors[i])
{
sprintf (fstr, "%d", (i - Color_Black));
break;
}
for (i = Color_Black; i <= Color_White; i++)
- if (PixColors[Color_bg] == PixColors[i])
+ if (pix_colors[Color_bg] == pix_colors[i])
{
sprintf (bstr, "%d", (i - Color_Black));
#ifdef XPM_BACKGROUND
colorfgbg = DEFAULT_RSTYLE;
for (i = minCOLOR; i <= maxCOLOR; i++)
{
- if (PixColors[Color_fg] == PixColors[i])
+ if (pix_colors[Color_fg] == pix_colors[i])
colorfgbg = SET_FGCOLOR (colorfgbg, i);
- if (PixColors[Color_bg] == PixColors[i])
+ if (pix_colors[Color_bg] == pix_colors[i])
colorfgbg = SET_BGCOLOR (colorfgbg, i);
}
#endif
#ifdef USE_XIM
void
-rxvt_term::im_set_size (XRectangle *size)
+rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg)
{
- size->x = TermWin.int_bwidth;
- size->y = TermWin.int_bwidth;
- size->width = Width2Pixel (TermWin.ncol);
- size->height = Height2Pixel (TermWin.nrow);
+ fg = pix_colors[Color_fg];
+ bg = pix_colors[Color_bg];
}
void
-rxvt_term::im_set_color (unsigned long *fg, unsigned long *bg)
+rxvt_term::im_set_size (XRectangle &size)
{
- *fg = PixColors[Color_fg];
- *bg = PixColors[Color_bg];
+ // the int_bwidth terms make no sense to me
+ size.x = TermWin.int_bwidth;
+ size.y = TermWin.int_bwidth;
+ size.width = Width2Pixel (TermWin.ncol) + TermWin.int_bwidth;
+ size.height = Height2Pixel (TermWin.nrow) + TermWin.int_bwidth;
+}
+
+void
+rxvt_term::im_set_preedit_area (XRectangle &preedit_rect,
+ XRectangle &status_rect,
+ const XRectangle &needed_rect)
+{
+ preedit_rect.x = needed_rect.width;
+ preedit_rect.y = 0;
+ preedit_rect.width = Width2Pixel (TermWin.ncol) - needed_rect.width + 1;
+ preedit_rect.height = TermWin.fheight;
+
+ status_rect.x = 0;
+ status_rect.y = 0;
+ status_rect.width = needed_rect.width ? needed_rect.width : Width2Pixel (TermWin.ncol) + 1;
+ status_rect.height = TermWin.fheight;
}
/* Checking whether input method is running. */
bool
rxvt_term::IMisRunning ()
{
- char *p;
- Atom atom;
- Window win;
- char server[IMBUFSIZ];
+ char *p;
+ Atom atom;
+ Window win;
+ char server[IMBUFSIZ];
/* get current locale modifier */
if ((p = XSetLocaleModifiers (NULL)) != NULL)
{
- STRCPY (server, "@server=");
- STRNCAT (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */
- if ((p = STRCHR (server + 1, '@')) != NULL) /* first one only */
+ strcpy (server, "@server=");
+ strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */
+
+ if ((p = strchr (server + 1, '@')) != NULL) /* first one only */
*p = '\0';
atom = XInternAtom (display->display, server, False);
win = XGetSelectionOwner (display->display, atom);
+
if (win != None)
return True;
}
+
return False;
}
void
rxvt_term::IMSendSpot ()
{
- XPoint spot;
- XVaNestedList preedit_attr;
+ XPoint spot;
+ XVaNestedList preedit_attr;
- if (Input_Context == NULL
- || !TermWin.focus || ! (input_style & XIMPreeditPosition)
- || ! (event_type == KeyPress
+ if (!Input_Context
+ || !TermWin.focus
+ || !(input_style & XIMPreeditPosition)
+#if 0
+ || !(event_type == KeyPress
|| event_type == Expose
|| event_type == NoExpose
|| event_type == SelectionNotify
|| event_type == ButtonRelease || event_type == FocusIn)
+#endif
|| !IMisRunning ())
return;
- im_set_position (&spot);
+ im_set_position (spot);
preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL);
}
void
-rxvt_term::im_set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect,
- XRectangle * needed_rect)
-{
- int mbh, vtx = 0;
-
- if (scrollbar_visible () && ! (Options & Opt_scrollBar_right))
- vtx = scrollbar_TotalWidth ();
-
- mbh = menubar_visible () ? menuBar_TotalHeight () : 0;
- mbh -= TermWin.lineSpace;
-
- preedit_rect->x = needed_rect->width + vtx;
- preedit_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh;
-
- preedit_rect->width = Width2Pixel (TermWin.ncol + 1) - needed_rect->width + vtx;
- preedit_rect->height = Height2Pixel (1);
-
- status_rect->x = vtx;
- status_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh;
-
- status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel (TermWin.ncol + 1);
- status_rect->height = Height2Pixel (1);
-}
-
-void
rxvt_term::im_destroy ()
{
if (Input_Context)
{
XDestroyIC (Input_Context);
- Input_Context = NULL;
+ Input_Context = 0;
}
if (input_method)
bool
rxvt_term::IM_get_IC (const char *modifiers)
{
- int i, j, found;
- XIM xim;
- XPoint spot;
- XRectangle rect, status_rect, needed_rect;
- unsigned long fg, bg;
- const char *p;
- char **s;
- XIMStyles *xim_styles;
- XVaNestedList preedit_attr, status_attr;
+ int i, j, found;
+ XIM xim;
+ XPoint spot;
+ XRectangle rect, status_rect, needed_rect;
+ unsigned long fg, bg;
+ const char *p;
+ char **s;
+ XIMStyles *xim_styles;
if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
return false;
if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
|| !xim_styles || !xim_styles->count_styles)
{
- display->put_xim (input_method);
+ im_destroy ();
return false;
}
p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root";
s = rxvt_splitcommastring (p);
+
for (i = found = 0; !found && s[i]; i++)
{
- if (!STRCMP (s[i], "OverTheSpot"))
+ if (!strcmp (s[i], "OverTheSpot"))
input_style = (XIMPreeditPosition | XIMStatusNothing);
- else if (!STRCMP (s[i], "OffTheSpot"))
+ else if (!strcmp (s[i], "OffTheSpot"))
input_style = (XIMPreeditArea | XIMStatusArea);
- else if (!STRCMP (s[i], "Root"))
+ else if (!strcmp (s[i], "Root"))
input_style = (XIMPreeditNothing | XIMStatusNothing);
for (j = 0; j < xim_styles->count_styles; j++)
if (!found)
{
- display->put_xim (input_method);
+ im_destroy ();
return false;
}
- preedit_attr = status_attr = NULL;
+ XFontSet fs = 0;
+ XVaNestedList preedit_attr = 0, status_attr = 0;
+
+ if (input_style & (XIMPreeditPosition | XIMPreeditArea))
+ {
+ // fake us a font-set, please
+ char **missing_charset_list;
+ int missing_charset_count;
+ char *def_string;
+ char pat[512];
+
+ sprintf (pat,
+ "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
+ "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
+ "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
+ "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
+ "-*-*-*-R-*-*-%d-*-*-*-*-*-*,"
+ "*",
+ TermWin.fheight,
+ TermWin.fheight + 1, TermWin.fheight - 1,
+ TermWin.fheight - 2, TermWin.fheight + 2);
+
+ fs = XCreateFontSet (display->display, pat,
+ &missing_charset_list, &missing_charset_count, &def_string);
+
+ if (missing_charset_list)
+ XFreeStringList (missing_charset_list);
+
+ if (!fs)
+ {
+ input_style &= ~(XIMPreeditPosition | XIMPreeditArea);
+ rxvt_warn ("unable to create fontset for input method, try \"-pt Root\". Continuing.\n");
+ }
+ }
if (input_style & XIMPreeditPosition)
{
- im_set_size (&rect);
- im_set_position (&spot);
- im_set_color (&fg, &bg);
-
- preedit_attr = XVaCreateNestedList (0, XNArea, &rect,
- XNSpotLocation, &spot,
- XNForeground, fg, XNBackground, bg,
- //XNFontSet, TermWin.fontset,
- NULL);
+ im_set_size (rect);
+ im_set_position (spot);
+ im_set_color (fg, bg);
+
+ preedit_attr = XVaCreateNestedList (0,
+ XNForeground, fg,
+ XNBackground, bg,
+ XNArea, &rect,
+ XNSpotLocation, &spot,
+ XNFontSet, fs,
+ NULL);
}
else if (input_style & XIMPreeditArea)
{
- im_set_color (&fg, &bg);
+ im_set_color (fg, bg);
/*
* The necessary width of preedit area is unknown
* until create input context.
*/
needed_rect.width = 0;
-
- im_set_preedit_area (&rect, &status_rect, &needed_rect);
-
- preedit_attr = XVaCreateNestedList (0, XNArea, &rect,
- XNForeground, fg, XNBackground, bg,
- //XNFontSet, TermWin.fontset,
+ im_set_preedit_area (rect, status_rect, needed_rect);
+
+ preedit_attr = XVaCreateNestedList (0,
+ XNForeground, fg,
+ XNBackground, bg,
+ XNArea, &rect,
+ XNFontSet, fs,
+ NULL);
+ status_attr = XVaCreateNestedList (0,
+ XNForeground, fg,
+ XNBackground, bg,
+ XNArea, &status_rect,
+ XNFontSet, fs,
NULL);
- status_attr = XVaCreateNestedList (0, XNArea, &status_rect,
- XNForeground, fg, XNBackground, bg,
- //XNFontSet, TermWin.fontset,
- NULL);
}
- Input_Context = XCreateIC (xim, XNInputStyle, input_style,
- XNClientWindow, TermWin.parent[0],
- XNFocusWindow, TermWin.parent[0],
- preedit_attr ? XNPreeditAttributes : NULL,
- preedit_attr,
- status_attr ? XNStatusAttributes : NULL,
- status_attr, NULL);
+ Input_Context = XCreateIC (xim,
+ XNInputStyle, input_style,
+ XNClientWindow, TermWin.vt,
+ XNFocusWindow, TermWin.parent[0],
+ preedit_attr ? XNPreeditAttributes : NULL,
+ preedit_attr,
+ status_attr ? XNStatusAttributes : NULL,
+ status_attr, NULL);
+
if (preedit_attr) XFree (preedit_attr);
if (status_attr) XFree (status_attr);
+ if (fs) XFreeFontSet (display->display, fs);
if (Input_Context == NULL)
{
rxvt_warn ("failed to create input context, continuing without XIM.\n");
- display->put_xim (input_method);
+ im_destroy ();
return false;
}
{
if (*s[i])
{
- STRCPY (buf, "@im=");
- STRNCAT (buf, s[i], IMBUFSIZ - 5);
+ strcpy (buf, "@im=");
+ strncat (buf, s[i], IMBUFSIZ - 5);
if (IM_get_IC (buf))
{
found = true;
void
rxvt_term::IMSetStatusPosition ()
{
- XRectangle preedit_rect, status_rect, *needed_rect;
- XVaNestedList preedit_attr, status_attr;
+ XRectangle preedit_rect, status_rect, *needed_rect;
+ XVaNestedList preedit_attr, status_attr;
- if (Input_Context == NULL
- || !TermWin.focus || ! (input_style & XIMPreeditArea)
+ if (!Input_Context
+ || !TermWin.focus
+ || !(input_style & XIMPreeditArea)
|| !IMisRunning ())
return;
XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL);
XFree (status_attr);
- im_set_preedit_area (&preedit_rect, &status_rect, needed_rect);
+ im_set_preedit_area (preedit_rect, status_rect, *needed_rect);
+ XFree (needed_rect);
preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL);
status_attr = XVaCreateNestedList (0, XNArea, &status_rect, NULL);
XSetICValues (Input_Context,
- XNPreeditAttributes, preedit_attr,
- XNStatusAttributes, status_attr, NULL);
+ XNPreeditAttributes, preedit_attr,
+ XNStatusAttributes, status_attr, NULL);
XFree (preedit_attr);
XFree (status_attr);
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
-#include "scrollbar-plain.intpro" /* PROTOS for internal routines */
/*----------------------------------------------------------------------*/
#if defined(PLAIN_SCROLLBAR)
XGCValues gcvalue;
scrollBar.init |= R_SB_PLAIN;
- gcvalue.foreground = PixColors[Color_fg];
- gcvalue.background = PixColors[Color_bg];
+ gcvalue.foreground = pix_colors[Color_fg];
+ gcvalue.background = pix_colors[Color_bg];
pscrollbarGC = XCreateGC (display->display, scrollBar.win,
GCForeground | GCBackground, &gcvalue);
}
/* instead of XClearWindow (display->display, scrollBar.win); */
- xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
+ xsb = (options & Opt_scrollBar_right) ? 1 : 0;
if (last_top < scrollBar.top)
XClearArea (display->display, scrollBar.win,
sb_shadow + xsb, last_top,
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
-#include "scrollbar-rxvt.intpro" /* PROTOS for internal routines */
/*----------------------------------------------------------------------*/
#if defined(RXVT_SCROLLBAR)
scrollBar.init |= R_SB_RXVT;
if (sbshadow)
{
- XSetWindowBackground (display->display, scrollBar.win, PixColors[Color_trough]);
+ XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_trough]);
XClearWindow (display->display, scrollBar.win);
}
}
{
int xofs;
- if (Options & Opt_scrollBar_right)
+ if (options & Opt_scrollBar_right)
xofs = 0;
else
xofs = sbshadow ? sbwidth : sbwidth - 1;
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
-#include "scrollbar-xterm.intpro" /* PROTOS for internal routines */
/*----------------------------------------------------------------------*/
#if defined(XTERM_SCROLLBAR)
(char *)x_stp_bits, x_stp_width,
x_stp_height);
if (!gcvalue.stipple)
- rxvt_fatal ("can't create bitmap");
+ rxvt_fatal ("can't create bitmap\n");
gcvalue.fill_style = FillOpaqueStippled;
- gcvalue.foreground = PixColors[Color_fg];
- gcvalue.background = PixColors[Color_bg];
+ gcvalue.foreground = pix_colors[Color_fg];
+ gcvalue.background = pix_colors[Color_bg];
xscrollbarGC = XCreateGC (display->display, scrollBar.win,
GCForeground | GCBackground
| GCFillStyle | GCStipple, &gcvalue);
- gcvalue.foreground = PixColors[Color_border];
+ gcvalue.foreground = pix_colors[Color_border];
ShadowGC = XCreateGC (display->display, scrollBar.win, GCForeground, &gcvalue);
}
/* instead of XClearWindow (display->display, scrollBar.win); */
- xsb = (Options & Opt_scrollBar_right) ? 1 : 0;
+ xsb = (options & Opt_scrollBar_right) ? 1 : 0;
if (last_top < scrollBar.top)
XClearArea (display->display, scrollBar.win,
sb_shadow + xsb, last_top,
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
-#include "scrollbar.intpro" /* PROTOS for internal routines */
/*----------------------------------------------------------------------*/
scrollbar_TotalWidth (),
szHint.height,
0,
- PixColors[Color_fg],
- PixColors[Color_bg]);
+ pix_colors[Color_fg],
+ pix_colors[Color_bg]);
#ifdef DEBUG_X
XStoreName (display->display, scrollBar.win, "scrollbar");
#endif
if (scrollstyle)
{
# ifdef NEXT_SCROLLBAR
- if (STRNCASECMP (scrollstyle, "next", 4) == 0)
+ if (strncasecmp (scrollstyle, "next", 4) == 0)
style = R_SB_NEXT;
# endif
# ifdef XTERM_SCROLLBAR
- if (STRNCASECMP (scrollstyle, "xterm", 5) == 0)
+ if (strncasecmp (scrollstyle, "xterm", 5) == 0)
style = R_SB_XTERM;
# endif
# ifdef PLAIN_SCROLLBAR
- if (STRNCASECMP (scrollstyle, "plain", 5) == 0)
+ if (strncasecmp (scrollstyle, "plain", 5) == 0)
style = R_SB_PLAIN;
# endif
width = min (i, SB_WIDTH_MAXIMUM);
# if defined(RXVT_SCROLLBAR)
- if (! (Options & Opt_scrollBar_floating) && style == R_SB_RXVT)
+ if (! (options & Opt_scrollBar_floating) && style == R_SB_RXVT)
sb_shadow = SHADOW;
# endif
/* scrollbar_align = R_SB_ALIGN_CENTRE; */
if (scrollalign)
{
- if (STRNCASECMP (scrollalign, "top", 3) == 0)
+ if (strncasecmp (scrollalign, "top", 3) == 0)
scrollbar_align = R_SB_ALIGN_TOP;
- else if (STRNCASECMP (scrollalign, "bottom", 6) == 0)
+ else if (strncasecmp (scrollalign, "bottom", 6) == 0)
scrollbar_align = R_SB_ALIGN_BOTTOM;
}
#endif
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
#include "version.h"
-#include "xdefaults.intpro" /* PROTOS for internal routines */
/* #define DEBUG_RESOURCES */
/* convenient macros */
#define optList_strlen(i) \
- (optList[i].flag ? 0 : (optList[i].arg ? STRLEN (optList[i].arg) : 1))
+ (optList[i].flag ? 0 : (optList[i].arg ? strlen (optList[i].arg) : 1))
#define optList_isBool(i) \
(optList[i].flag & Opt_Boolean)
#define optList_isReverse(i) \
#ifdef MOUSE_WHEEL
BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL),
#endif
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"),
BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"),
#endif
STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"),
STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"),
STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"),
-#ifndef NO_FRILLS
+#if ENABLE_FRILLS
STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"),
STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL),
STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL),
/*}}} */
static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n";
-static const char optionsstring[] = "Options: "
+static const char optionsstring[] = "options: "
#if XFT
"xft,"
#endif
#if !defined(NO_STRINGS)
"strings,"
#endif
-#if !defined(NO_FRILLS)
+#if defined(ENABLE_FRILLS)
"frills,"
#endif
#if !defined(NO_LINESPACE)
#ifdef DEBUG_STRICT
assert (optList[i].opt != NULL);
#endif
- len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0);
+ len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0);
col += len;
if (col > 79)
{ /* assume regular width */
#endif
rxvt_log (" %s%s %-*s%s%s\n",
(optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
- (INDENT - STRLEN (optList[i].opt)
+ (INDENT - strlen (optList[i].opt)
+ (optList_isBool (i) ? 0 : 2)),
(optList[i].arg ? optList[i].arg : ""),
(optList_isBool (i) ? "turn on/off " : ""),
if (optList[i].kw != NULL)
rxvt_log (" %s: %*s%s\n",
optList[i].kw,
- (INDENT - STRLEN (optList[i].kw)), "", /* XXX */
+ (INDENT - strlen (optList[i].kw)), "", /* XXX */
(optList_isBool (i) ? "boolean" : optList[i].arg));
#ifdef KEYSYM_RESOURCE
rxvt_log (" " "keysym.sym" ": %*s%s\n",
continue;
}
- if (!STRCMP (opt, "help"))
+ if (!strcmp (opt, "help"))
rxvt_usage (longopt ? 2 : 1);
- if (!STRCMP (opt, "h"))
+ if (!strcmp (opt, "h"))
rxvt_usage (0);
/* feature: always try to match long-options */
for (entry = 0; entry < optList_size (); entry++)
- if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw))
+ if ((optList[entry].kw && !strcmp (opt, optList[entry].kw))
|| (!longopt
- && optList[entry].opt && !STRCMP (opt, optList[entry].opt)))
+ && optList[entry].opt && !strcmp (opt, optList[entry].opt)))
break;
if (entry < optList_size ())
optList[entry].opt, optList[entry].kw, flag);
#endif
if (flag == On)
- Options |= (optList[entry].flag);
+ options |= (optList[entry].flag);
else
- Options &= ~ (optList[entry].flag);
+ options &= ~ (optList[entry].flag);
if (optList[entry].doff != -1)
rs[optList[entry].doff] = flag;
}
else
#ifdef KEYSYM_RESOURCE
- /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */
+ /* if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) */
if (rxvt_Str_match (opt, "keysym."))
{
const char *str = argv[++i];
str += 2;
if (arg)
{
- if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1)
+ if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1)
return -1;
}
else
return -1;
/* cue to ':', it's there since sscanf () worked */
- STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1);
+ strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1);
newargstr[NEWARGLIM - 1] = '\0';
newarg = newargstr;
}
/*
* convert keysym name to keysym number
*/
- STRNCPY (newargstr, str, NEWARGLIM - 1);
+ strncpy (newargstr, str, NEWARGLIM - 1);
newargstr[NEWARGLIM - 1] = '\0';
if (arg == NULL)
{
- if ((newarg = STRCHR (newargstr, ':')) == NULL)
+ if ((newarg = strchr (newargstr, ':')) == NULL)
return -1;
*newarg++ = '\0'; /* terminate keysym name */
}
if (newarg == NULL)
{
- STRNCPY (newargstr, arg, NEWARGLIM - 1);
+ strncpy (newargstr, arg, NEWARGLIM - 1);
newargstr[NEWARGLIM - 1] = '\0';
newarg = newargstr;
}
key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char));
key_string[0] = n;
- STRNCPY (key_string + 1, newarg, n);
+ strncpy (key_string + 1, newarg, n);
Keysym_map[sym] = (unsigned char *)key_string;
return 1;
if (stream == NULL)
return;
- len = STRLEN (name);
+ len = strlen (name);
while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
{
unsigned int entry, n;
str++; /* leading whitespace */
if ((str[len] != '*' && str[len] != '.')
- || (len && STRNCMP (str, name, len)))
+ || (len && strncmp (str, name, len)))
continue;
str += (len + 1); /* skip `name*' or `name.' */
if (kw == NULL)
continue;
- n = STRLEN (kw);
+ n = strlen (kw);
if (str[n] == ':' && rxvt_Str_match (str, kw))
{
/* skip `keyword:' */
str += n + 1;
rxvt_Str_trim (str);
- n = STRLEN (str);
+ n = strlen (str);
if (n && rs[optList[entry].doff] == NULL)
{
/* not already set */
for (int o = 0;;)
{
p = (char *)rxvt_realloc (p, o + n + 1);
- MEMCPY (p + o, str, n);
+ memcpy (p + o, str, n);
o += n;
p[o] = 0;
break;
rxvt_Str_trim (str);
- n = STRLEN (str);
+ n = strlen (str);
}
rs[optList[entry].doff] = p;
if (optList_isBool (entry))
{
- s = STRCASECMP (str, "TRUE") == 0
- || STRCASECMP (str, "YES") == 0
- || STRCASECMP (str, "ON") == 0
- || STRCASECMP (str, "1") == 0;
+ s = strcasecmp (str, "TRUE") == 0
+ || strcasecmp (str, "YES") == 0
+ || strcasecmp (str, "ON") == 0
+ || strcasecmp (str, "1") == 0;
if (optList_isReverse (entry))
s = !s;
if (s)
- Options |= optList[entry].flag;
+ options |= optList[entry].flag;
else
- Options &= ~optList[entry].flag;
+ options &= ~optList[entry].flag;
}
}
for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++)
{
- sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2,
+ sprintf (fname, "%-.*s/%s", sizeof (fname) - strlen (xnames[i]) - 2,
ptr, xnames[i]);
if ((rdb1 = XrmGetFileDatabase (fname)))
{
p = XGetDefault (display, name, kw);
p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
- if (p == NULL || (p0 && STRCMP (p, p0) == 0))
+ if (p == NULL || (p0 && strcmp (p, p0) == 0))
{
p = XGetDefault (display, RESCLASS, kw);
#ifdef RESFALLBACK
- if (p == NULL || (p0 && STRCMP (p, p0) == 0))
+ if (p == NULL || (p0 && strcmp (p, p0) == 0))
p = XGetDefault (display, RESFALLBACK, kw);
#endif
}
if (optList_isBool (entry))
{
- s = STRCASECMP (p, "TRUE") == 0
- || STRCASECMP (p, "YES") == 0
- || STRCASECMP (p, "ON") == 0
- || STRCASECMP (p, "1") == 0;
+ s = strcasecmp (p, "TRUE") == 0
+ || strcasecmp (p, "YES") == 0
+ || strcasecmp (p, "ON") == 0
+ || strcasecmp (p, "1") == 0;
if (optList_isReverse (entry))
s = !s;
if (s)
- Options |= (optList[entry].flag);
+ options |= (optList[entry].flag);
else
- Options &= ~ (optList[entry].flag);
+ options &= ~ (optList[entry].flag);
}
}
}
if ((home = getenv ("HOME")) != NULL)
{
- unsigned int i, len = STRLEN (home) + 2;
+ unsigned int i, len = strlen (home) + 2;
char *f = NULL;
for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++)
{
- f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char));
+ f = (char *)rxvt_realloc (f, (len + strlen (xnames[i])) * sizeof (char));
sprintf (f, "%s/%s", home, xnames[i]);
if (geom == NULL)
return 0;
str = (char *)rxvt_malloc (MAXLEN_GEOM + 1);
- if (!STRCMP (geom, "?"))
+ if (!strcmp (geom, "?"))
{
sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
min (bgpixmap->w, 9999), min (bgpixmap->h, 9999),
return 0;
}
- if ((p = STRCHR (geom, ';')) == NULL)
- p = STRCHR (geom, '\0');
+ if ((p = strchr (geom, ';')) == NULL)
+ p = strchr (geom, '\0');
n = (p - geom);
if (n <= MAXLEN_GEOM)
{
- STRNCPY (str, geom, n);
+ strncpy (str, geom, n);
str[n] = '\0';
flags = XParseGeometry (str, &x, &y, &w, &h);
if (bgPixmap.pixmap == None)
{ /* So be it: I'm not using pixmaps */
TermWin.pixmap = None;
- if (! (Options & Opt_transparent) || am_transparent == 0)
+ if (! (options & Opt_transparent) || am_transparent == 0)
XSetWindowBackground (display->display, TermWin.vt,
- PixColors[Color_bg]);
+ pix_colors[Color_bg]);
return;
}
- gcvalue.foreground = PixColors[Color_bg];
+ gcvalue.foreground = pix_colors[Color_bg];
gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
if (bgPixmap.pixmap != None)
XFreePixmap (display->display, bgPixmap.pixmap);
bgPixmap.pixmap = None;
}
- XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
+ XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]);
if (*file != '\0')
{
char *p;
/* semi-colon delimited */
- if ((p = STRCHR (file, ';')) == NULL)
- p = STRCHR (file, '\0');
+ if ((p = strchr (file, ';')) == NULL)
+ p = strchr (file, '\0');
rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.", (p - file), file);
}