js/src/editline/sysunix.c

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
michael@0 8 *
michael@0 9 * This software is not subject to any license of the American Telephone
michael@0 10 * and Telegraph Company or of the Regents of the University of California.
michael@0 11 *
michael@0 12 * Permission is granted to anyone to use this software for any purpose on
michael@0 13 * any computer system, and to alter it and redistribute it freely, subject
michael@0 14 * to the following restrictions:
michael@0 15 * 1. The authors are not responsible for the consequences of use of this
michael@0 16 * software, no matter how awful, even if they arise from flaws in it.
michael@0 17 * 2. The origin of this software must not be misrepresented, either by
michael@0 18 * explicit claim or by omission. Since few users ever read sources,
michael@0 19 * credits must appear in the documentation.
michael@0 20 * 3. Altered versions must be plainly marked as such, and must not be
michael@0 21 * misrepresented as being the original software. Since few users
michael@0 22 * ever read sources, credits must appear in the documentation.
michael@0 23 * 4. This notice may not be removed or altered.
michael@0 24 */
michael@0 25
michael@0 26
michael@0 27 /*
michael@0 28 ** Unix system-dependant routines for editline library.
michael@0 29 */
michael@0 30 #include "editline.h"
michael@0 31
michael@0 32 #if defined(HAVE_TCGETATTR)
michael@0 33 #include <termios.h>
michael@0 34
michael@0 35 void
michael@0 36 rl_ttyset(Reset)
michael@0 37 int Reset;
michael@0 38 {
michael@0 39 static struct termios old;
michael@0 40 struct termios new;
michael@0 41
michael@0 42 if (Reset == 0) {
michael@0 43 (void)tcgetattr(0, &old);
michael@0 44 rl_erase = old.c_cc[VERASE];
michael@0 45 rl_kill = old.c_cc[VKILL];
michael@0 46 rl_eof = old.c_cc[VEOF];
michael@0 47 rl_intr = old.c_cc[VINTR];
michael@0 48 rl_quit = old.c_cc[VQUIT];
michael@0 49
michael@0 50 new = old;
michael@0 51 new.c_cc[VINTR] = -1;
michael@0 52 new.c_cc[VQUIT] = -1;
michael@0 53 new.c_lflag &= ~(ECHO | ICANON);
michael@0 54 new.c_iflag &= ~(ISTRIP | INPCK);
michael@0 55 new.c_cc[VMIN] = 1;
michael@0 56 new.c_cc[VTIME] = 0;
michael@0 57 (void)tcsetattr(0, TCSADRAIN, &new);
michael@0 58 }
michael@0 59 else
michael@0 60 (void)tcsetattr(0, TCSADRAIN, &old);
michael@0 61 }
michael@0 62
michael@0 63 #else
michael@0 64 #if defined(HAVE_TERMIO)
michael@0 65 #include <termio.h>
michael@0 66
michael@0 67 void
michael@0 68 rl_ttyset(Reset)
michael@0 69 int Reset;
michael@0 70 {
michael@0 71 static struct termio old;
michael@0 72 struct termio new;
michael@0 73
michael@0 74 if (Reset == 0) {
michael@0 75 (void)ioctl(0, TCGETA, &old);
michael@0 76 rl_erase = old.c_cc[VERASE];
michael@0 77 rl_kill = old.c_cc[VKILL];
michael@0 78 rl_eof = old.c_cc[VEOF];
michael@0 79 rl_intr = old.c_cc[VINTR];
michael@0 80 rl_quit = old.c_cc[VQUIT];
michael@0 81
michael@0 82 new = old;
michael@0 83 new.c_cc[VINTR] = -1;
michael@0 84 new.c_cc[VQUIT] = -1;
michael@0 85 new.c_lflag &= ~(ECHO | ICANON);
michael@0 86 new.c_iflag &= ~(ISTRIP | INPCK);
michael@0 87 new.c_cc[VMIN] = 1;
michael@0 88 new.c_cc[VTIME] = 0;
michael@0 89 (void)ioctl(0, TCSETAW, &new);
michael@0 90 }
michael@0 91 else
michael@0 92 (void)ioctl(0, TCSETAW, &old);
michael@0 93 }
michael@0 94
michael@0 95 #else
michael@0 96 #include <sgtty.h>
michael@0 97
michael@0 98 void
michael@0 99 rl_ttyset(Reset)
michael@0 100 int Reset;
michael@0 101 {
michael@0 102 static struct sgttyb old_sgttyb;
michael@0 103 static struct tchars old_tchars;
michael@0 104 struct sgttyb new_sgttyb;
michael@0 105 struct tchars new_tchars;
michael@0 106
michael@0 107 if (Reset == 0) {
michael@0 108 (void)ioctl(0, TIOCGETP, &old_sgttyb);
michael@0 109 rl_erase = old_sgttyb.sg_erase;
michael@0 110 rl_kill = old_sgttyb.sg_kill;
michael@0 111
michael@0 112 (void)ioctl(0, TIOCGETC, &old_tchars);
michael@0 113 rl_eof = old_tchars.t_eofc;
michael@0 114 rl_intr = old_tchars.t_intrc;
michael@0 115 rl_quit = old_tchars.t_quitc;
michael@0 116
michael@0 117 new_sgttyb = old_sgttyb;
michael@0 118 new_sgttyb.sg_flags &= ~ECHO;
michael@0 119 new_sgttyb.sg_flags |= RAW;
michael@0 120 #if defined(PASS8)
michael@0 121 new_sgttyb.sg_flags |= PASS8;
michael@0 122 #endif /* defined(PASS8) */
michael@0 123 (void)ioctl(0, TIOCSETP, &new_sgttyb);
michael@0 124
michael@0 125 new_tchars = old_tchars;
michael@0 126 new_tchars.t_intrc = -1;
michael@0 127 new_tchars.t_quitc = -1;
michael@0 128 (void)ioctl(0, TIOCSETC, &new_tchars);
michael@0 129 }
michael@0 130 else {
michael@0 131 (void)ioctl(0, TIOCSETP, &old_sgttyb);
michael@0 132 (void)ioctl(0, TIOCSETC, &old_tchars);
michael@0 133 }
michael@0 134 }
michael@0 135 #endif /* defined(HAVE_TERMIO) */
michael@0 136 #endif /* defined(HAVE_TCGETATTR) */
michael@0 137
michael@0 138 void
michael@0 139 rl_add_slash(path, p)
michael@0 140 char *path;
michael@0 141 char *p;
michael@0 142 {
michael@0 143 struct stat Sb;
michael@0 144
michael@0 145 if (stat(path, &Sb) >= 0)
michael@0 146 (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
michael@0 147 }
michael@0 148

mercurial