PageRenderTime 4237ms CodeModel.GetById 36ms RepoModel.GetById 109ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/editline/sysunix.c

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C | 182 lines | 102 code | 20 blank | 60 comment | 8 complexity | 0463c94c19ef65b00f7b1a690aa9fffb MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is Mozilla Communicator client code, released
  17. * March 31, 1998.
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Simmule Turner and Rich Salz.
  21. * Portions created by the Initial Developer are Copyright (C) 1998
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. /*
  40. * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
  41. *
  42. * This software is not subject to any license of the American Telephone
  43. * and Telegraph Company or of the Regents of the University of California.
  44. *
  45. * Permission is granted to anyone to use this software for any purpose on
  46. * any computer system, and to alter it and redistribute it freely, subject
  47. * to the following restrictions:
  48. * 1. The authors are not responsible for the consequences of use of this
  49. * software, no matter how awful, even if they arise from flaws in it.
  50. * 2. The origin of this software must not be misrepresented, either by
  51. * explicit claim or by omission. Since few users ever read sources,
  52. * credits must appear in the documentation.
  53. * 3. Altered versions must be plainly marked as such, and must not be
  54. * misrepresented as being the original software. Since few users
  55. * ever read sources, credits must appear in the documentation.
  56. * 4. This notice may not be removed or altered.
  57. */
  58. /*
  59. ** Unix system-dependant routines for editline library.
  60. */
  61. #include "editline.h"
  62. #if defined(HAVE_TCGETATTR)
  63. #include <termios.h>
  64. void
  65. rl_ttyset(Reset)
  66. int Reset;
  67. {
  68. static struct termios old;
  69. struct termios new;
  70. if (Reset == 0) {
  71. (void)tcgetattr(0, &old);
  72. rl_erase = old.c_cc[VERASE];
  73. rl_kill = old.c_cc[VKILL];
  74. rl_eof = old.c_cc[VEOF];
  75. rl_intr = old.c_cc[VINTR];
  76. rl_quit = old.c_cc[VQUIT];
  77. new = old;
  78. new.c_cc[VINTR] = -1;
  79. new.c_cc[VQUIT] = -1;
  80. new.c_lflag &= ~(ECHO | ICANON);
  81. new.c_iflag &= ~(ISTRIP | INPCK);
  82. new.c_cc[VMIN] = 1;
  83. new.c_cc[VTIME] = 0;
  84. (void)tcsetattr(0, TCSADRAIN, &new);
  85. }
  86. else
  87. (void)tcsetattr(0, TCSADRAIN, &old);
  88. }
  89. #else
  90. #if defined(HAVE_TERMIO)
  91. #include <termio.h>
  92. void
  93. rl_ttyset(Reset)
  94. int Reset;
  95. {
  96. static struct termio old;
  97. struct termio new;
  98. if (Reset == 0) {
  99. (void)ioctl(0, TCGETA, &old);
  100. rl_erase = old.c_cc[VERASE];
  101. rl_kill = old.c_cc[VKILL];
  102. rl_eof = old.c_cc[VEOF];
  103. rl_intr = old.c_cc[VINTR];
  104. rl_quit = old.c_cc[VQUIT];
  105. new = old;
  106. new.c_cc[VINTR] = -1;
  107. new.c_cc[VQUIT] = -1;
  108. new.c_lflag &= ~(ECHO | ICANON);
  109. new.c_iflag &= ~(ISTRIP | INPCK);
  110. new.c_cc[VMIN] = 1;
  111. new.c_cc[VTIME] = 0;
  112. (void)ioctl(0, TCSETAW, &new);
  113. }
  114. else
  115. (void)ioctl(0, TCSETAW, &old);
  116. }
  117. #else
  118. #include <sgtty.h>
  119. void
  120. rl_ttyset(Reset)
  121. int Reset;
  122. {
  123. static struct sgttyb old_sgttyb;
  124. static struct tchars old_tchars;
  125. struct sgttyb new_sgttyb;
  126. struct tchars new_tchars;
  127. if (Reset == 0) {
  128. (void)ioctl(0, TIOCGETP, &old_sgttyb);
  129. rl_erase = old_sgttyb.sg_erase;
  130. rl_kill = old_sgttyb.sg_kill;
  131. (void)ioctl(0, TIOCGETC, &old_tchars);
  132. rl_eof = old_tchars.t_eofc;
  133. rl_intr = old_tchars.t_intrc;
  134. rl_quit = old_tchars.t_quitc;
  135. new_sgttyb = old_sgttyb;
  136. new_sgttyb.sg_flags &= ~ECHO;
  137. new_sgttyb.sg_flags |= RAW;
  138. #if defined(PASS8)
  139. new_sgttyb.sg_flags |= PASS8;
  140. #endif /* defined(PASS8) */
  141. (void)ioctl(0, TIOCSETP, &new_sgttyb);
  142. new_tchars = old_tchars;
  143. new_tchars.t_intrc = -1;
  144. new_tchars.t_quitc = -1;
  145. (void)ioctl(0, TIOCSETC, &new_tchars);
  146. }
  147. else {
  148. (void)ioctl(0, TIOCSETP, &old_sgttyb);
  149. (void)ioctl(0, TIOCSETC, &old_tchars);
  150. }
  151. }
  152. #endif /* defined(HAVE_TERMIO) */
  153. #endif /* defined(HAVE_TCGETATTR) */
  154. void
  155. rl_add_slash(path, p)
  156. char *path;
  157. char *p;
  158. {
  159. struct stat Sb;
  160. if (stat(path, &Sb) >= 0)
  161. (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
  162. }