| File: | obj/gnu/usr.bin/perl/cpan/Term-ReadKey/ReadKey.c |
| Warning: | line 854, column 3 Value stored to 'oldmode' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * This file was generated automatically by ExtUtils::ParseXS version 3.40 from the |
| 3 | * contents of ReadKey.xs. Do not edit this file, edit ReadKey.xs instead. |
| 4 | * |
| 5 | * ANY CHANGES MADE HERE WILL BE LOST! |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #line 1 "ReadKey.xs" |
| 10 | /* -*-C-*- */ |
| 11 | |
| 12 | #define PERL_NO_GET_CONTEXT /* we want efficiency */ |
| 13 | #include "EXTERN.h" |
| 14 | #include "perl.h" |
| 15 | #include "XSUB.h" |
| 16 | #include "ppport.h" |
| 17 | |
| 18 | #define InputStreamPerlIO * PerlIOPerlIO * |
| 19 | |
| 20 | /******************************************************************* |
| 21 | |
| 22 | Copyright (C) 1994,1995,1996,1997 Kenneth Albanowski. Unlimited |
| 23 | distribution and/or modification is allowed as long as this copyright |
| 24 | notice remains intact. |
| 25 | |
| 26 | Written by Kenneth Albanowski on Thu Oct 6 11:42:20 EDT 1994 |
| 27 | Contact at kjahds@kjahds.com or CIS:70705,126 |
| 28 | |
| 29 | Maintained by Jonathan Stowe <jns@gellyfish.co.uk> |
| 30 | |
| 31 | The below captures the history prior to it being in full time version |
| 32 | control: |
| 33 | |
| 34 | $Id: ReadKey.xs,v 2.22 2005/01/11 21:15:17 jonathan Exp $ |
| 35 | |
| 36 | Version 2.21, Sun Jul 28 12:57:56 BST 2002 |
| 37 | Fix to improve the chances of automated testing succeeding |
| 38 | |
| 39 | Version 2.20, Tue May 21 07:52:47 BST 2002 |
| 40 | Patch from Autrijus Tang fixing Win32 Breakage with bleadperl |
| 41 | |
| 42 | Version 2.19, Thu Mar 21 07:25:31 GMT 2002 |
| 43 | Added check for definedness of $_[0] in comparisons in ReadKey, ReadLine |
| 44 | after reports of warnings. |
| 45 | |
| 46 | Version 2.18, Sun Feb 10 13:06:57 GMT 2002 |
| 47 | Altered prototyping style after reports of compile failures on |
| 48 | Windows. |
| 49 | |
| 50 | Version 2.17, Fri Jan 25 06:58:47 GMT 2002 |
| 51 | The '_' macro for non-ANSI compatibility was removed in 5.7.2 |
| 52 | |
| 53 | Version 2.16, Thu Nov 29 21:19:03 GMT 2001 |
| 54 | It appears that the genchars.pl bit of the patch didnt apply |
| 55 | Applied the new ppport.h from Devel::PPPort |
| 56 | |
| 57 | Version 2.15, Sun Nov 4 15:02:37 GMT 2001 (jns) |
| 58 | Applied the patch in |
| 59 | http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-01/msg01588.html |
| 60 | for PerlIO compatibility. |
| 61 | |
| 62 | Version 2.14, Sun Mar 28 23:26:13 EST 1999 |
| 63 | ppport.h 1.007 fixed for 5.005_55. |
| 64 | |
| 65 | Version 2.13, Wed Mar 24 20:46:06 EST 1999 |
| 66 | Adapted to ppport.h 1.006. |
| 67 | |
| 68 | Version 2.12, Wed Jan 7 10:33:11 EST 1998 |
| 69 | Slightly modified test and error reporting for Win32. |
| 70 | |
| 71 | Version 2.11, Sun Dec 14 00:39:12 EST 1997 |
| 72 | First attempt at Win32 support. |
| 73 | |
| 74 | Version 2.10, skipped |
| 75 | |
| 76 | Version 2.09, Tue Oct 7 13:07:43 EDT 1997 |
| 77 | Grr. Added explicit detection of sys/poll.h and poll.h. |
| 78 | |
| 79 | Version 2.08, Mon Oct 6 16:07:44 EDT 1997 |
| 80 | Changed poll.h to sys/poll.h. |
| 81 | |
| 82 | Version 2.07, Sun Jan 26 19:11:56 EST 1997 |
| 83 | Added $VERSION to .pm. |
| 84 | |
| 85 | Version 2.06, Tue Nov 26 01:47:09 EST 1996 |
| 86 | Added PERLIO support and removed duplicate declaration in .pm. |
| 87 | |
| 88 | Version 2.05, Tue Mar 12 19:08:33 EST 1996 |
| 89 | Changed poll support so it works. Cleaned up .pm a little. |
| 90 | |
| 91 | Version 2.04, Tue Oct 10 05:35:48 EDT 1995 |
| 92 | Whoops. Changed GetTermSize back so that GSIZE code won't be |
| 93 | compiled if GWINSZ is being used. Also took ts_xxx and ts_yyy |
| 94 | out of GSIZE. |
| 95 | |
| 96 | Version 2.03, Thu Sep 21 21:53:16 EDT 1995 |
| 97 | Fixed up debugging info in Readkey.pm, and changed TermSizeVIO |
| 98 | to use _scrsize(). Hopefully this is GO for both Solaris and OS/2. |
| 99 | |
| 100 | Version 2.02, Mon Sep 18 22:17:57 EDT 1995 |
| 101 | Workaround for Solaris bug wasn't sufficient. Modularlized |
| 102 | GetTermSize into perl code, and added support for the |
| 103 | `resize` executable. Hard coded path for Solaris machines. |
| 104 | |
| 105 | Version 2.01, Wed Sep 13 22:22:23 EDT 1995 |
| 106 | Change error reporting around in getscreensize so that if |
| 107 | an ioctl fails but getenv succeeds, no warning will be |
| 108 | printed. This is an attempt to work around a Solaris bug where |
| 109 | TIOCGWINSZ fails in telnet sessions. |
| 110 | |
| 111 | Version 2.00, Mon Sep 4 06:37:24 EDT 1995 |
| 112 | Added timeouts to select/poll, added USE_STDIO_PTR support |
| 113 | (required for recent perl revisions), and fixed up compilation |
| 114 | under OS/2. |
| 115 | |
| 116 | Version 1.99, Fri Aug 11 20:18:11 EDT 1995 |
| 117 | Add file handles to ReadMode. |
| 118 | |
| 119 | Version 1.97, Mon Apr 10 21:41:52 EDT 1995 |
| 120 | Changed mode 5 to disable UC & delays. Added more ECHO flags. |
| 121 | Tested termio[s] & sgtty. |
| 122 | Added termoptions so test.pl can give more info. |
| 123 | |
| 124 | Version 1.96, |
| 125 | Mucked with filehandle selection in ReadKey.pm. |
| 126 | |
| 127 | Version 1.95, |
| 128 | Cleaning up for distribution. |
| 129 | |
| 130 | Version 1.94, |
| 131 | Dealt with get/settermsize sillyness. |
| 132 | |
| 133 | Version 1.91, Sat Mar 11 23:47:04 EST 1995: |
| 134 | Andy's patches, and a bit of termsize finesse. |
| 135 | |
| 136 | Version 1.9, Thu Mar 9 14:11:49 EST 1995: |
| 137 | Modifying for portability. Prototypes, singed chars, etc. |
| 138 | |
| 139 | Version 1.8, Mon Jan 9 23:18:14 EST 1995: |
| 140 | Added use of Configure.pm. No changes to ReadKey. |
| 141 | |
| 142 | Version 1.7, Fri Dec 16 13:48:14 EST 1994: |
| 143 | Getting closer to release. Added new readmode 2. Had to bump up other |
| 144 | modes, unfortunately. This is the _last_ time I do that. If I have to |
| 145 | bump up the modes again, I'm switching to a different scheme. |
| 146 | |
| 147 | Version 1.6, Wed Dec 14 17:36:59 EST 1994: |
| 148 | Completly reorganized the control-char support (twice!) so that |
| 149 | it is automatically ported by the preproccessor for termio[s], or |
| 150 | by an included script for sgtty. Logical defaults for sgtty are included |
| 151 | too. Added Sun TermSize support. (Hope I got it right.) |
| 152 | |
| 153 | Version 1.5, Fri Dec 9 16:07:49 EST 1994: |
| 154 | Added SetTermSize, GetSpeeds, Get/SetControlChars, PerlIO support. |
| 155 | |
| 156 | Version 1.01, Thu Oct 20 23:32:39 EDT 1994: |
| 157 | Added Select_fd_set_t casts to select() call. |
| 158 | |
| 159 | Version 1.0: First "real" release. Everything seems cool. |
| 160 | |
| 161 | |
| 162 | *******************************************************************/ |
| 163 | |
| 164 | /*** |
| 165 | |
| 166 | Things to do: |
| 167 | |
| 168 | Make sure the GetSpeed function is doing it's best to separate ispeed |
| 169 | from ospeed. |
| 170 | |
| 171 | Separate the stty stuff from ReadMode, so that stty -a can be easily |
| 172 | used, among other things. |
| 173 | |
| 174 | ***/ |
| 175 | |
| 176 | |
| 177 | |
| 178 | /* Using these defines, you can elide anything you know |
| 179 | won't work properly */ |
| 180 | |
| 181 | /* Methods of doing non-blocking reads */ |
| 182 | |
| 183 | /*#define DONT_USE_SELECT*/ |
| 184 | /*#define DONT_USE_POLL*/ |
| 185 | /*#define DONT_USE_NODELAY*/ |
| 186 | |
| 187 | |
| 188 | /* Terminal I/O packages */ |
| 189 | |
| 190 | /*#define DONT_USE_TERMIOS*/ |
| 191 | /*#define DONT_USE_TERMIO*/ |
| 192 | /*#define DONT_USE_SGTTY*/ |
| 193 | |
| 194 | /* IOCTLs that can be used for GetTerminalSize */ |
| 195 | |
| 196 | /*#define DONT_USE_GWINSZ*/ |
| 197 | /*#define DONT_USE_GSIZE*/ |
| 198 | |
| 199 | /* IOCTLs that can be used for SetTerminalSize */ |
| 200 | |
| 201 | /*#define DONT_USE_SWINSZ*/ |
| 202 | /*#define DONT_USE_SSIZE*/ |
| 203 | |
| 204 | |
| 205 | /* This bit is for OS/2 */ |
| 206 | |
| 207 | #ifdef OS2 |
| 208 | # define I_FCNTL |
| 209 | # define HAS_FCNTL |
| 210 | |
| 211 | # define O_NODELAY0x0004 O_NDELAY0x0004 |
| 212 | |
| 213 | # define DONT_USE_SELECT |
| 214 | # define DONT_USE_POLL |
| 215 | |
| 216 | # define DONT_USE_TERMIOS |
| 217 | # define DONT_USE_SGTTY |
| 218 | # define I_TERMIO |
| 219 | # define CC_TERMIO |
| 220 | |
| 221 | /* This flag should be off in the lflags when we enable termio mode */ |
| 222 | # define TRK_IDEFAULT0 IDEFAULT |
| 223 | |
| 224 | # define INCL_SUB |
| 225 | # define INCL_DOS |
| 226 | |
| 227 | # include <os2.h> |
| 228 | # include <stdlib.h> |
| 229 | |
| 230 | # define VIOMODE |
| 231 | #else |
| 232 | /* no os2 */ |
| 233 | #endif |
| 234 | |
| 235 | /* This bit is for Windows 95/NT */ |
| 236 | |
| 237 | #ifdef WIN32 |
| 238 | # define DONT_USE_TERMIO |
| 239 | # define DONT_USE_TERMIOS |
| 240 | # define DONT_USE_SGTTY |
| 241 | # define DONT_USE_POLL |
| 242 | # define DONT_USE_SELECT |
| 243 | # define DONT_USE_NODELAY |
| 244 | # define USE_WIN32 |
| 245 | # include <io.h> |
| 246 | # if defined(_get_osfhandle) && (PERL_VERSION32 == 4) && (PERL_SUBVERSION1 < 5) |
| 247 | # undef _get_osfhandle |
| 248 | # if defined(_MSC_VER) |
| 249 | # define level _cnt |
| 250 | # endif |
| 251 | # endif |
| 252 | #endif |
| 253 | |
| 254 | /* This bit for NeXT */ |
| 255 | |
| 256 | #ifdef _NEXT_SOURCE |
| 257 | /* fcntl with O_NDELAY (FNDELAY, actually) is broken on NeXT */ |
| 258 | # define DONT_USE_NODELAY |
| 259 | #endif |
| 260 | |
| 261 | #if !defined(DONT_USE_NODELAY) |
| 262 | # ifdef HAS_FCNTL |
| 263 | # define Have_nodelay |
| 264 | # ifdef I_FCNTL |
| 265 | # include <fcntl.h> |
| 266 | # endif |
| 267 | # ifdef I_SYS_FILE |
| 268 | # include <sys/file.h> |
| 269 | # endif |
| 270 | # ifdef I_UNISTD |
| 271 | # include <unistd.h> |
| 272 | # endif |
| 273 | |
| 274 | /* If any other headers are needed for fcntl or O_NODELAY, they need to get |
| 275 | included right here */ |
| 276 | |
| 277 | # if !defined(O_NODELAY0x0004) |
| 278 | # if !defined(FNDELAY0x0004) |
| 279 | # undef Have_nodelay |
| 280 | # else |
| 281 | # define O_NODELAY0x0004 FNDELAY0x0004 |
| 282 | # endif |
| 283 | # else |
| 284 | # define O_NODELAY0x0004 O_NDELAY0x0004 |
| 285 | # endif |
| 286 | # endif |
| 287 | #endif |
| 288 | |
| 289 | #if !defined(DONT_USE_SELECT) |
| 290 | # ifdef HAS_SELECT |
| 291 | # ifdef I_SYS_SELECT |
| 292 | # include <sys/select.h> |
| 293 | # endif |
| 294 | |
| 295 | /* If any other headers are likely to be needed for select, they need to be |
| 296 | included right here */ |
| 297 | |
| 298 | # define Have_select |
| 299 | # endif |
| 300 | #endif |
| 301 | |
| 302 | #if !defined(DONT_USE_POLL) |
| 303 | # ifdef HAS_POLL |
| 304 | # ifdef HAVE_POLL_H |
| 305 | # include <poll.h> |
| 306 | # define Have_poll |
| 307 | # endif |
| 308 | # ifdef HAVE_SYS_POLL_H |
| 309 | # include <sys/poll.h> |
| 310 | # define Have_poll |
| 311 | # endif |
| 312 | # endif |
| 313 | #endif |
| 314 | |
| 315 | #ifdef DONT_USE_TERMIOS |
| 316 | # ifdef I_TERMIOS |
| 317 | # undef I_TERMIOS |
| 318 | # endif |
| 319 | #endif |
| 320 | #ifdef DONT_USE_TERMIO |
| 321 | # ifdef I_TERMIO |
| 322 | # undef I_TERMIO |
| 323 | # endif |
| 324 | #endif |
| 325 | #ifdef DONT_USE_SGTTY |
| 326 | # ifdef I_SGTTY |
| 327 | # undef I_SGTTY |
| 328 | # endif |
| 329 | #endif |
| 330 | |
| 331 | /* Pre-POSIX SVR3 systems sometimes define struct winsize in |
| 332 | sys/ptem.h. However, sys/ptem.h needs a type mblk_t (?) which |
| 333 | is defined in <sys/stream.h>. |
| 334 | No, Configure (dist3.051) doesn't know how to check for this. |
| 335 | */ |
| 336 | #ifdef I_SYS_STREAM |
| 337 | # include <sys/stream.h> |
| 338 | #endif |
| 339 | #ifdef I_SYS_PTEM |
| 340 | # include <sys/ptem.h> |
| 341 | #endif |
| 342 | |
| 343 | #ifdef I_TERMIOS |
| 344 | # include <termios.h> |
| 345 | #else |
| 346 | # ifdef I_TERMIO |
| 347 | # include <termio.h> |
| 348 | # else |
| 349 | # ifdef I_SGTTY |
| 350 | # include <sgtty.h> |
| 351 | # endif |
| 352 | # endif |
| 353 | #endif |
| 354 | |
| 355 | #ifdef I_TERMIOS |
| 356 | # define CC_TERMIOS |
| 357 | #else |
| 358 | # ifdef I_TERMIO |
| 359 | # define CC_TERMIO |
| 360 | # else |
| 361 | # ifdef I_SGTTY |
| 362 | # define CC_SGTTY |
| 363 | # endif |
| 364 | # endif |
| 365 | #endif |
| 366 | |
| 367 | #ifndef TRK_IDEFAULT0 |
| 368 | /* This flag should be off in the lflags when we enable termio mode */ |
| 369 | # define TRK_IDEFAULT0 0 |
| 370 | #endif |
| 371 | |
| 372 | /* Fix up the disappearance of the '_' macro in Perl 5.7.2 */ |
| 373 | |
| 374 | #ifndef _ |
| 375 | # ifdef CAN_PROTOTYPE |
| 376 | # define _(args)args args |
| 377 | # else |
| 378 | # define _(args)args () |
| 379 | # endif |
| 380 | #endif |
| 381 | |
| 382 | #define DisableFlush(1) (1) /* Should flushing mode changes be enabled? |
| 383 | I think not for now. */ |
| 384 | |
| 385 | |
| 386 | #define STDINPerl_PerlIO_stdin() PerlIO_stdin()Perl_PerlIO_stdin() |
| 387 | |
| 388 | #include "cchars.h" |
| 389 | |
| 390 | |
| 391 | STATICstatic int GetTermSizeVIO _((pTHX_ PerlIO * file,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 392 | int * retwidth, int * retheight,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 393 | int * xpix, int * ypix))( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix); |
| 394 | |
| 395 | STATICstatic int GetTermSizeGWINSZ _((pTHX_ PerlIO * file,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 396 | int * retwidth, int * retheight,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 397 | int * xpix, int * ypix))( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix); |
| 398 | |
| 399 | STATICstatic int GetTermSizeGSIZE _((pTHX_ PerlIO * file,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 400 | int * retwidth, int * retheight,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 401 | int * xpix, int * ypix))( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix); |
| 402 | |
| 403 | STATICstatic int GetTermSizeWin32 _((pTHX_ PerlIO * file,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 404 | int * retwidth, int * retheight,( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix) |
| 405 | int * xpix, int * ypix))( PerlIO * file, int * retwidth, int * retheight, int * xpix, int * ypix); |
| 406 | |
| 407 | STATICstatic int SetTerminalSize _((pTHX_ PerlIO * file,( PerlIO * file, int width, int height, int xpix, int ypix) |
| 408 | int width, int height,( PerlIO * file, int width, int height, int xpix, int ypix) |
| 409 | int xpix, int ypix))( PerlIO * file, int width, int height, int xpix, int ypix); |
| 410 | |
| 411 | STATICstatic void ReadMode _((pTHX_ PerlIO * file,int mode))( PerlIO * file,int mode); |
| 412 | |
| 413 | STATICstatic int pollfile _((pTHX_ PerlIO * file, double delay))( PerlIO * file, double delay); |
| 414 | |
| 415 | STATICstatic int setnodelay _((pTHX_ PerlIO * file, int mode))( PerlIO * file, int mode); |
| 416 | |
| 417 | STATICstatic int selectfile _((pTHX_ PerlIO * file, double delay))( PerlIO * file, double delay); |
| 418 | |
| 419 | STATICstatic int Win32PeekChar _((pTHX_ PerlIO * file, double delay, char * key))( PerlIO * file, double delay, char * key); |
| 420 | |
| 421 | STATICstatic int getspeed _((pTHX_ PerlIO * file, I32 *in, I32 * out ))( PerlIO * file, I32 *in, I32 * out ); |
| 422 | |
| 423 | |
| 424 | #ifdef VIOMODE |
| 425 | int GetTermSizeVIO(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 426 | { |
| 427 | /*int handle=PerlIO_fileno(file); |
| 428 | |
| 429 | static VIOMODEINFO *modeinfo = NULL; |
| 430 | |
| 431 | if (modeinfo == NULL) |
| 432 | modeinfo = (VIOMODEINFO *)malloc(sizeof(VIOMODEINFO)); |
| 433 | |
| 434 | VioGetMode(modeinfo,0); |
| 435 | *retheight = modeinfo->row ?: 25; |
| 436 | *retwidth = modeinfo->col ?: 80;*/ |
| 437 | int buf[2]; |
| 438 | |
| 439 | _scrsize(&buf[0]); |
| 440 | |
| 441 | *retwidth = buf[0]; *retheight = buf[1]; |
| 442 | |
| 443 | *xpix = *ypix = 0; |
| 444 | return 0; |
| 445 | } |
| 446 | #else |
| 447 | int GetTermSizeVIO(pTHX_ PerlIOPerlIO *file,int * retwidth,int *retheight, int *xpix,int *ypix) |
| 448 | { |
| 449 | croakPerl_croak("TermSizeVIO is not implemented on this architecture"); |
| 450 | return 0; |
| 451 | } |
| 452 | #endif |
| 453 | |
| 454 | |
| 455 | #if defined(TIOCGWINSZ((unsigned long)0x40000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((104)))) && !defined(DONT_USE_GWINSZ) |
| 456 | int GetTermSizeGWINSZ(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 457 | { |
| 458 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 459 | struct winsize w; |
| 460 | |
| 461 | if (ioctl (handle, TIOCGWINSZ((unsigned long)0x40000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((104))), &w) == 0) { |
| 462 | *retwidth=w.ws_col; *retheight=w.ws_row; |
| 463 | *xpix=w.ws_xpixel; *ypix=w.ws_ypixel; return 0; |
| 464 | } |
| 465 | else { |
| 466 | return -1; /* failure */ |
| 467 | } |
| 468 | |
| 469 | } |
| 470 | #else |
| 471 | int GetTermSizeGWINSZ(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 472 | { |
| 473 | croakPerl_croak("TermSizeGWINSZ is not implemented on this architecture"); |
| 474 | return 0; |
| 475 | } |
| 476 | #endif |
| 477 | |
| 478 | #if (!defined(TIOCGWINSZ((unsigned long)0x40000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((104)))) || defined(DONT_USE_GWINSZ)) && (defined(TIOCGSIZE) && !defined(DONT_USE_GSIZE)) |
| 479 | int GetTermSizeGSIZE(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 480 | { |
| 481 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 482 | |
| 483 | struct ttysize w; |
| 484 | |
| 485 | if (ioctl (handle, TIOCGSIZE, &w) == 0) { |
| 486 | *retwidth=w.ts_cols; *retheight=w.ts_lines; |
| 487 | *xpix=0/*w.ts_xxx*/; *ypix=0/*w.ts_yyy*/; return 0; |
| 488 | } |
| 489 | else { |
| 490 | return -1; /* failure */ |
| 491 | } |
| 492 | } |
| 493 | #else |
| 494 | int GetTermSizeGSIZE(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 495 | { |
| 496 | croakPerl_croak("TermSizeGSIZE is not implemented on this architecture"); |
| 497 | return 0; |
| 498 | } |
| 499 | #endif |
| 500 | |
| 501 | #ifdef USE_WIN32 |
| 502 | int GetTermSizeWin32(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 503 | { |
| 504 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 505 | HANDLE whnd = (HANDLE)_get_osfhandle(handle); |
| 506 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 507 | |
| 508 | if (GetConsoleScreenBufferInfo(whnd, &info)) { |
| 509 | /* Logic: return maximum possible screen width, but return |
| 510 | only currently selected height */ |
| 511 | if (retwidth) |
| 512 | *retwidth = info.dwMaximumWindowSize.X; |
| 513 | /*info.srWindow.Right - info.srWindow.Left;*/ |
| 514 | if (retheight) |
| 515 | *retheight = info.srWindow.Bottom - info.srWindow.Top; |
| 516 | if (xpix) |
| 517 | *xpix = 0; |
| 518 | if (ypix) |
| 519 | *ypix = 0; |
| 520 | return 0; |
| 521 | } else |
| 522 | return -1; |
| 523 | } |
| 524 | #else |
| 525 | int GetTermSizeWin32(pTHX_ PerlIOPerlIO *file,int *retwidth,int *retheight,int *xpix,int *ypix) |
| 526 | { |
| 527 | croakPerl_croak("TermSizeWin32 is not implemented on this architecture"); |
| 528 | return 0; |
| 529 | } |
| 530 | #endif /* USE_WIN32 */ |
| 531 | |
| 532 | |
| 533 | STATICstatic int termsizeoptions() { |
| 534 | return 0 |
| 535 | #ifdef VIOMODE |
| 536 | | 1 |
| 537 | #endif |
| 538 | #if defined(TIOCGWINSZ((unsigned long)0x40000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((104)))) && !defined(DONT_USE_GWINSZ) |
| 539 | | 2 |
| 540 | #endif |
| 541 | #if defined(TIOCGSIZE) && !defined(DONT_USE_GSIZE) |
| 542 | | 4 |
| 543 | #endif |
| 544 | #if defined(USE_WIN32) |
| 545 | | 8 |
| 546 | #endif |
| 547 | ; |
| 548 | } |
| 549 | |
| 550 | |
| 551 | int SetTerminalSize(pTHX_ PerlIOPerlIO *file,int width,int height,int xpix,int ypix) |
| 552 | { |
| 553 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 554 | |
| 555 | #ifdef VIOMODE |
| 556 | return -1; |
| 557 | #else |
| 558 | |
| 559 | #if defined(TIOCSWINSZ((unsigned long)0x80000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((103)))) && !defined(DONT_USE_SWINSZ) |
| 560 | char buffer[10]; |
| 561 | struct winsize w; |
| 562 | |
| 563 | w.ws_col=width; |
| 564 | w.ws_row=height; |
| 565 | w.ws_xpixel=xpix; |
| 566 | w.ws_ypixel=ypix; |
| 567 | if (ioctl (handle, TIOCSWINSZ((unsigned long)0x80000000 | ((sizeof(struct winsize) & 0x1fff ) << 16) | ((('t')) << 8) | ((103))), &w) == 0) { |
| 568 | sprintf(buffer,"%d",width); /* Be polite to our children */ |
| 569 | my_setenv("COLUMNS",buffer)Perl_my_setenv( "COLUMNS",buffer); |
| 570 | sprintf(buffer,"%d",height); |
| 571 | my_setenv("LINES",buffer)Perl_my_setenv( "LINES",buffer); |
| 572 | return 0; |
| 573 | } |
| 574 | else { |
| 575 | croakPerl_croak("TIOCSWINSZ ioctl call to set terminal size failed: %s",Strerror(errno)strerror((*__errno()))); |
| 576 | return -1; |
| 577 | } |
| 578 | #else |
| 579 | # if defined(TIOCSSIZE) && !defined(DONT_USE_SSIZE) |
| 580 | char buffer[10]; |
| 581 | struct ttysize w; |
| 582 | |
| 583 | w.ts_lines=height; |
| 584 | w.ts_cols=width; |
| 585 | w.ts_xxx=xpix; |
| 586 | w.ts_yyy=ypix; |
| 587 | if (ioctl (handle, TIOCSSIZE, &w) == 0) { |
| 588 | sprintf(buffer,"%d",width); |
| 589 | my_setenv("COLUMNS",buffer)Perl_my_setenv( "COLUMNS",buffer); |
| 590 | sprintf(buffer,"%d",height); |
| 591 | my_setenv("LINES",buffer)Perl_my_setenv( "LINES",buffer); |
| 592 | return 0; |
| 593 | } |
| 594 | else { |
| 595 | croakPerl_croak("TIOCSSIZE ioctl call to set terminal size failed: %s",Strerror(errno)strerror((*__errno()))); |
| 596 | return -1; |
| 597 | } |
| 598 | # else |
| 599 | /*sprintf(buffer,"%d",width) * Should we could do this and then * |
| 600 | my_setenv("COLUMNS",buffer) * said we succeeded? * |
| 601 | sprintf(buffer,"%d",height); |
| 602 | my_setenv("LINES",buffer)*/ |
| 603 | |
| 604 | return -1; /* Fail */ |
| 605 | # endif |
| 606 | #endif |
| 607 | #endif |
| 608 | |
| 609 | } |
| 610 | |
| 611 | STATICstatic const I32 terminal_speeds[] = { |
| 612 | #ifdef B5050 |
| 613 | 50, B5050, |
| 614 | #endif |
| 615 | #ifdef B7575 |
| 616 | 75, B7575, |
| 617 | #endif |
| 618 | #ifdef B110110 |
| 619 | 110, B110110, |
| 620 | #endif |
| 621 | #ifdef B134134 |
| 622 | 134, B134134, |
| 623 | #endif |
| 624 | #ifdef B150150 |
| 625 | 150, B150150, |
| 626 | #endif |
| 627 | #ifdef B200200 |
| 628 | 200, B200200, |
| 629 | #endif |
| 630 | #ifdef B300300 |
| 631 | 300, B300300, |
| 632 | #endif |
| 633 | #ifdef B600600 |
| 634 | 600, B600600, |
| 635 | #endif |
| 636 | #ifdef B12001200 |
| 637 | 1200, B12001200, |
| 638 | #endif |
| 639 | #ifdef B18001800 |
| 640 | 1800, B18001800, |
| 641 | #endif |
| 642 | #ifdef B24002400 |
| 643 | 2400, B24002400, |
| 644 | #endif |
| 645 | #ifdef B48004800 |
| 646 | 4800, B48004800, |
| 647 | #endif |
| 648 | #ifdef B96009600 |
| 649 | 9600, B96009600, |
| 650 | #endif |
| 651 | #ifdef B1920019200 |
| 652 | 19200, B1920019200, |
| 653 | #endif |
| 654 | #ifdef B3840038400 |
| 655 | 38400, B3840038400, |
| 656 | #endif |
| 657 | #ifdef B5760057600 |
| 658 | 57600, B5760057600, |
| 659 | #endif |
| 660 | #ifdef B115200115200 |
| 661 | 115200, B115200115200, |
| 662 | #endif |
| 663 | #ifdef EXTA19200 |
| 664 | 19200, EXTA19200, |
| 665 | #endif |
| 666 | #ifdef EXTB38400 |
| 667 | 38400, EXTB38400, |
| 668 | #endif |
| 669 | #ifdef B00 |
| 670 | 0, B00, |
| 671 | #endif |
| 672 | -1,-1 |
| 673 | }; |
| 674 | |
| 675 | int getspeed(pTHX_ PerlIOPerlIO *file,I32 *in, I32 *out) |
| 676 | { |
| 677 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 678 | #if defined(I_TERMIOS) || defined(I_TERMIO) || defined(I_SGTTY) |
| 679 | int i; |
| 680 | #endif |
| 681 | # ifdef I_TERMIOS |
| 682 | /* Posixy stuff */ |
| 683 | |
| 684 | struct termios buf; |
| 685 | tcgetattr(handle,&buf); |
| 686 | |
| 687 | *in = *out = -1; |
| 688 | *in = cfgetispeed(&buf); |
| 689 | *out = cfgetospeed(&buf); |
| 690 | for(i=0;terminal_speeds[i]!=-1;i+=2) { |
| 691 | if(*in == terminal_speeds[i+1]) |
| 692 | { *in = terminal_speeds[i]; break; } |
| 693 | } |
| 694 | for(i=0;terminal_speeds[i]!=-1;i+=2) { |
| 695 | if(*out == terminal_speeds[i+1]) |
| 696 | { *out = terminal_speeds[i]; break; } |
| 697 | } |
| 698 | return 0; |
| 699 | |
| 700 | # else |
| 701 | # ifdef I_TERMIO |
| 702 | /* SysV stuff */ |
| 703 | struct termio buf; |
| 704 | |
| 705 | ioctl(handle,TCGETA,&buf); |
| 706 | |
| 707 | *in=*out=-1; |
| 708 | for(i=0;terminal_speeds[i]!=-1;i+=2) { |
| 709 | if((buf.c_cflag & CBAUD) == terminal_speeds[i+1]) |
| 710 | { *in=*out=terminal_speeds[i]; break; } |
| 711 | } |
| 712 | return 0; |
| 713 | |
| 714 | # else |
| 715 | # ifdef I_SGTTY |
| 716 | /* BSD stuff */ |
| 717 | struct sgttyb buf; |
| 718 | |
| 719 | ioctl(handle,TIOCGETP,&buf); |
| 720 | |
| 721 | *in=*out=-1; |
| 722 | |
| 723 | for(i=0;terminal_speeds[i]!=-1;i+=2) |
| 724 | if(buf.sg_ospeed == terminal_speeds[i+1]) |
| 725 | { *out = terminal_speeds[i]; break; } |
| 726 | |
| 727 | for(i=0;terminal_speeds[i]!=-1;i+=2) |
| 728 | if(buf.sg_ispeed == terminal_speeds[i+1]) |
| 729 | { *in = terminal_speeds[i]; break; } |
| 730 | |
| 731 | return 0; |
| 732 | |
| 733 | |
| 734 | # else |
| 735 | |
| 736 | /* No termio, termios or sgtty. I suppose we can try stty, |
| 737 | but it would be nice if you could get a better OS */ |
| 738 | |
| 739 | return -1; |
| 740 | |
| 741 | # endif |
| 742 | # endif |
| 743 | # endif |
| 744 | } |
| 745 | |
| 746 | #ifdef WIN32 |
| 747 | struct tbuffertermios { DWORD Mode; }; |
| 748 | #else |
| 749 | #ifdef I_TERMIOS |
| 750 | #define USE_TERMIOS |
| 751 | #define tbuffertermios termios |
| 752 | #else |
| 753 | #ifdef I_TERMIO |
| 754 | #define USE_TERMIO |
| 755 | #define tbuffertermios termio |
| 756 | #else |
| 757 | #ifdef I_SGTTY |
| 758 | #define USE_SGTTY |
| 759 | struct tbuffertermios { |
| 760 | struct sgttyb buf; |
| 761 | #if defined(TIOCGETC) |
| 762 | struct tchars tchar; |
| 763 | #endif |
| 764 | #if defined(TIOCGLTC) |
| 765 | struct ltchars ltchar; |
| 766 | #endif |
| 767 | #if defined(TIOCLGET) |
| 768 | int local; |
| 769 | #endif |
| 770 | }; |
| 771 | #else |
| 772 | #define USE_STTY |
| 773 | struct tbuffertermios { |
| 774 | int dummy; |
| 775 | }; |
| 776 | #endif |
| 777 | #endif |
| 778 | #endif |
| 779 | #endif |
| 780 | |
| 781 | static HV * filehash; /* Used to store the original terminal settings for each handle*/ |
| 782 | static HV * modehash; /* Used to record the current terminal "mode" for each handle*/ |
| 783 | |
| 784 | void ReadMode(pTHX_ PerlIOPerlIO *file,int mode) |
| 785 | { |
| 786 | dTHRstruct Perl___notused_struct; |
| 787 | int handle; |
| 788 | int firsttime; |
| 789 | int oldmode; |
| 790 | struct tbuffertermios work; |
| 791 | struct tbuffertermios savebuf; |
| 792 | |
| 793 | |
| 794 | handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 795 | |
| 796 | firsttime=!hv_exists(filehash, (char*)&handle, sizeof(int))((Perl_hv_common_key_len( (filehash),((char*)&handle),(sizeof (int)),0x08,((void*)0),0)) ? (_Bool)1 : (_Bool)0); |
| 797 | |
| 798 | |
| 799 | # ifdef WIN32 |
| 800 | |
| 801 | if (!GetConsoleMode((HANDLE)_get_osfhandle(handle), &work.Mode)) |
| 802 | croakPerl_croak("GetConsoleMode failed, LastError=|%d|",GetLastError()); |
| 803 | |
| 804 | # endif /* WIN32 */ |
| 805 | |
| 806 | # ifdef USE_TERMIOS |
| 807 | /* Posixy stuff */ |
| 808 | |
| 809 | tcgetattr(handle,&work); |
| 810 | |
| 811 | |
| 812 | |
| 813 | #endif |
| 814 | #ifdef USE_TERMIO |
| 815 | /* SysV stuff */ |
| 816 | |
| 817 | ioctl(handle,TCGETA,&work); |
| 818 | |
| 819 | |
| 820 | #endif |
| 821 | #ifdef USE_SGTTY |
| 822 | /* BSD stuff */ |
| 823 | |
| 824 | ioctl(handle,TIOCGETP,&work.buf); |
| 825 | # if defined(TIOCGETC) |
| 826 | ioctl(handle,TIOCGETC,&work.tchar); |
| 827 | # endif |
| 828 | # if defined(TIOCLGET) |
| 829 | ioctl(handle,TIOCLGET,&work.local); |
| 830 | # endif |
| 831 | # if defined(TIOCGLTC) |
| 832 | ioctl(handle,TIOCGLTC,&work.ltchar); |
| 833 | # endif |
| 834 | |
| 835 | |
| 836 | #endif |
| 837 | |
| 838 | |
| 839 | if(firsttime) { |
| 840 | firsttime=0; |
| 841 | memcpy((void*)&savebuf,(void*)&work,sizeof(struct tbuffertermios)); |
| 842 | if(!hv_store(filehash,(char*)&handle,sizeof(int),((SV**) Perl_hv_common_key_len( (filehash),((char*)&handle ),(sizeof(int)),(0x04|0x20),(Perl_newSVpv( (char*)&savebuf ,sizeof(struct termios))),(0))) |
| 843 | newSVpv((char*)&savebuf,sizeof(struct tbuffer)),0)((SV**) Perl_hv_common_key_len( (filehash),((char*)&handle ),(sizeof(int)),(0x04|0x20),(Perl_newSVpv( (char*)&savebuf ,sizeof(struct termios))),(0)))) |
| 844 | croakPerl_croak("Unable to stash terminal settings.\n"); |
| 845 | if(!hv_store(modehash,(char*)&handle,sizeof(int),newSViv(0),0)((SV**) Perl_hv_common_key_len( (modehash),((char*)&handle ),(sizeof(int)),(0x04|0x20),(Perl_newSViv( 0)),(0)))) |
| 846 | croakPerl_croak("Unable to stash terminal settings.\n"); |
| 847 | } else { |
| 848 | SV ** temp; |
| 849 | if(!(temp=hv_fetch(filehash,(char*)&handle,sizeof(int),0)((SV**) Perl_hv_common_key_len( (filehash),((char*)&handle ),(sizeof(int)),(0) ? (0x20 | 0x10) : 0x20,((void*)0),0)))) |
| 850 | croakPerl_croak("Unable to retrieve stashed terminal settings.\n"); |
| 851 | memcpy(&savebuf,SvPV(*temp,PL_na)((((*temp)->sv_flags & (0x00000400|0x00200000)) == 0x00000400 ) ? ((PL_na = ((XPV*) (*temp)->sv_any)->xpv_cur), ((*temp )->sv_u.svu_pv)) : Perl_sv_2pv_flags( *temp,&PL_na,2)),sizeof(struct tbuffertermios)); |
| 852 | if(!(temp=hv_fetch(modehash,(char*)&handle,sizeof(int),0)((SV**) Perl_hv_common_key_len( (modehash),((char*)&handle ),(sizeof(int)),(0) ? (0x20 | 0x10) : 0x20,((void*)0),0)))) |
| 853 | croakPerl_croak("Unable to retrieve stashed terminal mode.\n"); |
| 854 | oldmode=SvIV(*temp)((((*temp)->sv_flags & (0x00000100|0x00200000)) == 0x00000100 ) ? ((XPVIV*) (*temp)->sv_any)->xiv_u.xivu_iv : Perl_sv_2iv_flags ( *temp,2)); |
Value stored to 'oldmode' is never read | |
| 855 | } |
| 856 | |
| 857 | #ifdef WIN32 |
| 858 | |
| 859 | switch (mode) { |
| 860 | case 5: |
| 861 | /* Should 5 disable ENABLE_WRAP_AT_EOL_OUTPUT? */ |
| 862 | case 4: |
| 863 | work.Mode &= ~(ENABLE_ECHO_INPUT|ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_PROCESSED_OUTPUT); |
| 864 | work.Mode |= 0; |
| 865 | break; |
| 866 | case 3: |
| 867 | work.Mode &= ~(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT); |
| 868 | work.Mode |= ENABLE_PROCESSED_INPUT|ENABLE_PROCESSED_OUTPUT; |
| 869 | break; |
| 870 | case 2: |
| 871 | work.Mode &= ~(ENABLE_ECHO_INPUT); |
| 872 | work.Mode |= ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT|ENABLE_PROCESSED_OUTPUT; |
| 873 | break; |
| 874 | case 1: |
| 875 | work.Mode &= ~(0); |
| 876 | work.Mode |= ENABLE_ECHO_INPUT|ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT|ENABLE_PROCESSED_OUTPUT; |
| 877 | break; |
| 878 | case 0: |
| 879 | work = savebuf; |
| 880 | firsttime = 1; |
| 881 | break; |
| 882 | } |
| 883 | |
| 884 | if (!SetConsoleMode((HANDLE)_get_osfhandle(handle), work.Mode)) |
| 885 | croakPerl_croak("SetConsoleMode failed, LastError=|%d|",GetLastError()); |
| 886 | |
| 887 | #endif /* WIN32 */ |
| 888 | |
| 889 | |
| 890 | #ifdef USE_TERMIOS |
| 891 | |
| 892 | |
| 893 | /* What, me worry about standards? */ |
| 894 | |
| 895 | # if !defined (VMIN16) |
| 896 | # define VMIN16 VEOF0 |
| 897 | # endif |
| 898 | |
| 899 | # if !defined (VTIME17) |
| 900 | # define VTIME17 VEOL1 |
| 901 | # endif |
| 902 | |
| 903 | # if !defined (IXANY0x00000800) |
| 904 | # define IXANY0x00000800 (0) |
| 905 | # endif |
| 906 | |
| 907 | #ifndef IEXTEN0x00000400 |
| 908 | #ifdef IDEFAULT |
| 909 | #define IEXTEN0x00000400 IDEFAULT |
| 910 | #endif |
| 911 | #endif |
| 912 | |
| 913 | /* XXX Is ONLCR in POSIX?. The value of '4' seems to be the same for |
| 914 | both SysV and Sun, so it's probably rather general, and I'm not |
| 915 | aware of a POSIX way to do this otherwise. |
| 916 | */ |
| 917 | #ifndef ONLCR0x00000002 |
| 918 | # define ONLCR0x00000002 4 |
| 919 | #endif |
| 920 | |
| 921 | #ifndef IMAXBEL0x00002000 |
| 922 | #define IMAXBEL0x00002000 0 |
| 923 | #endif |
| 924 | #ifndef ECHOE0x00000002 |
| 925 | #define ECHOE0x00000002 0 |
| 926 | #endif |
| 927 | #ifndef ECHOK0x00000004 |
| 928 | #define ECHOK0x00000004 0 |
| 929 | #endif |
| 930 | #ifndef ECHONL0x00000010 |
| 931 | #define ECHONL0x00000010 0 |
| 932 | #endif |
| 933 | #ifndef ECHOPRT0x00000020 |
| 934 | #define ECHOPRT0x00000020 0 |
| 935 | #endif |
| 936 | #ifndef FLUSHO0x00800000 |
| 937 | #define FLUSHO0x00800000 0 |
| 938 | #endif |
| 939 | #ifndef PENDIN0x20000000 |
| 940 | #define PENDIN0x20000000 0 |
| 941 | #endif |
| 942 | #ifndef ECHOKE0x00000001 |
| 943 | #define ECHOKE0x00000001 0 |
| 944 | #endif |
| 945 | #ifndef ONLCR0x00000002 |
| 946 | #define ONLCR0x00000002 0 |
| 947 | #endif |
| 948 | #ifndef OCRNL0x00000010 |
| 949 | #define OCRNL0x00000010 0 |
| 950 | #endif |
| 951 | #ifndef ONLRET0x00000080 |
| 952 | #define ONLRET0x00000080 0 |
| 953 | #endif |
| 954 | #ifndef IUCLC0x00001000 |
| 955 | #define IUCLC0x00001000 0 |
| 956 | #endif |
| 957 | #ifndef OPOST0x00000001 |
| 958 | #define OPOST0x00000001 0 |
| 959 | #endif |
| 960 | #ifndef OLCUC0x00000020 |
| 961 | #define OLCUC0x00000020 0 |
| 962 | #endif |
| 963 | #ifndef ECHOCTL0x00000040 |
| 964 | #define ECHOCTL0x00000040 0 |
| 965 | #endif |
| 966 | #ifndef XCASE0x01000000 |
| 967 | #define XCASE0x01000000 0 |
| 968 | #endif |
| 969 | #ifndef BRKINT0x00000002 |
| 970 | #define BRKINT0x00000002 0 |
| 971 | #endif |
| 972 | |
| 973 | |
| 974 | if(mode==5) { |
| 975 | /*\ |
| 976 | * Disable everything except parity if needed. |
| 977 | \*/ |
| 978 | |
| 979 | /* Hopefully, this should put the tty into unbuffered mode |
| 980 | with signals and control characters (both posixy and normal) |
| 981 | disabled, along with flow control. Echo should be off. |
| 982 | CR/LF is not translated, along with 8-bit/parity */ |
| 983 | |
| 984 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 985 | |
| 986 | work.c_lflag &= ~(ICANON0x00000100|ISIG0x00000080|IEXTEN0x00000400 ); |
| 987 | work.c_lflag &= ~(ECHO0x00000008|ECHOE0x00000002|ECHOK0x00000004|ECHONL0x00000010|ECHOCTL0x00000040); |
| 988 | work.c_lflag &= ~(ECHOPRT0x00000020|ECHOKE0x00000001|FLUSHO0x00800000|PENDIN0x20000000|XCASE0x01000000); |
| 989 | work.c_lflag |= NOFLSH0x80000000; |
| 990 | work.c_iflag &= ~(IXOFF0x00000400|IXON0x00000200|IXANY0x00000800|ICRNL0x00000100|IMAXBEL0x00002000|BRKINT0x00000002); |
| 991 | |
| 992 | if(((work.c_iflag & INPCK0x00000010) != INPCK0x00000010) || |
| 993 | ((work.c_cflag & PARENB0x00001000) != PARENB0x00001000)) { |
| 994 | work.c_iflag &= ~ISTRIP0x00000020; |
| 995 | work.c_iflag |= IGNPAR0x00000004; |
| 996 | work.c_iflag &= ~PARMRK0x00000008; |
| 997 | } |
| 998 | work.c_oflag &= ~(OPOST0x00000001 |ONLCR0x00000002|OCRNL0x00000010|ONLRET0x00000080); |
| 999 | |
| 1000 | work.c_cc[VTIME17] = 0; |
| 1001 | work.c_cc[VMIN16] = 1; |
| 1002 | } |
| 1003 | else if(mode==4) { |
| 1004 | /* Hopefully, this should put the tty into unbuffered mode |
| 1005 | with signals and control characters (both posixy and normal) |
| 1006 | disabled, along with flow control. Echo should be off. |
| 1007 | About the only thing left unchanged is 8-bit/parity */ |
| 1008 | |
| 1009 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1010 | |
| 1011 | /*work.c_iflag = savebuf.c_iflag;*/ |
| 1012 | work.c_lflag &= ~(ICANON0x00000100 | ISIG0x00000080 | IEXTEN0x00000400 | ECHO0x00000008); |
| 1013 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010|ECHOCTL0x00000040|ECHOPRT0x00000020|ECHOKE0x00000001); |
| 1014 | work.c_iflag &= ~(IXON0x00000200 | IXANY0x00000800 | BRKINT0x00000002); |
| 1015 | work.c_oflag = savebuf.c_oflag; |
| 1016 | work.c_cc[VTIME17] = 0; |
| 1017 | work.c_cc[VMIN16] = 1; |
| 1018 | } |
| 1019 | else if(mode==3) |
| 1020 | { |
| 1021 | /* This should be an unbuffered mode with signals and control |
| 1022 | characters enabled, as should be flow control. Echo should |
| 1023 | still be off */ |
| 1024 | |
| 1025 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1026 | |
| 1027 | work.c_iflag = savebuf.c_iflag; |
| 1028 | work.c_lflag &= ~(ICANON0x00000100 | ECHO0x00000008); |
| 1029 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010|ECHOCTL0x00000040|ECHOPRT0x00000020|ECHOKE0x00000001); |
| 1030 | work.c_lflag |= ISIG0x00000080 | IEXTEN0x00000400; |
| 1031 | /*work.c_iflag &= ~(IXON | IXOFF | IXANY); |
| 1032 | work.c_iflag |= savebuf.c_iflag & (IXON|IXOFF|IXANY); |
| 1033 | work.c_oflag = savebuf.c_oflag;*/ |
| 1034 | work.c_cc[VTIME17] = 0; |
| 1035 | work.c_cc[VMIN16] = 1; |
| 1036 | } |
| 1037 | else if(mode==2) |
| 1038 | { |
| 1039 | /* This should be an unbuffered mode with signals and control |
| 1040 | characters enabled, as should be flow control. Echo should |
| 1041 | still be off */ |
| 1042 | |
| 1043 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1044 | |
| 1045 | work.c_iflag = savebuf.c_iflag; |
| 1046 | work.c_lflag |= ICANON0x00000100|ISIG0x00000080|IEXTEN0x00000400; |
| 1047 | work.c_lflag &= ~ECHO0x00000008; |
| 1048 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010|ECHOCTL0x00000040|ECHOPRT0x00000020|ECHOKE0x00000001); |
| 1049 | /*work.c_iflag &= ~(IXON |IXOFF|IXANY); |
| 1050 | work.c_iflag |= savebuf.c_iflag & (IXON|IXOFF|IXANY); |
| 1051 | work.c_oflag = savebuf.c_oflag; |
| 1052 | work.c_cc[VTIME] = savebuf.c_cc[VTIME]; |
| 1053 | work.c_cc[VMIN] = savebuf.c_cc[VMIN];*/ |
| 1054 | } |
| 1055 | else if(mode==1) |
| 1056 | { |
| 1057 | /* This should be an unbuffered mode with signals and control |
| 1058 | characters enabled, as should be flow control. Echo should |
| 1059 | still be off */ |
| 1060 | |
| 1061 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1062 | |
| 1063 | work.c_iflag = savebuf.c_iflag; |
| 1064 | work.c_lflag |= ICANON0x00000100|ECHO0x00000008|ISIG0x00000080|IEXTEN0x00000400; |
| 1065 | /*work.c_iflag &= ~(IXON |IXOFF|IXANY); |
| 1066 | work.c_iflag |= savebuf.c_iflag & (IXON|IXOFF|IXANY); |
| 1067 | work.c_oflag = savebuf.c_oflag; |
| 1068 | work.c_cc[VTIME] = savebuf.c_cc[VTIME]; |
| 1069 | work.c_cc[VMIN] = savebuf.c_cc[VMIN];*/ |
| 1070 | } |
| 1071 | else if(mode==0){ |
| 1072 | /*work.c_lflag &= ~BITMASK; |
| 1073 | work.c_lflag |= savebuf.c_lflag & BITMASK; |
| 1074 | work.c_oflag = savebuf.c_oflag; |
| 1075 | work.c_cc[VTIME] = savebuf.c_cc[VTIME]; |
| 1076 | work.c_cc[VMIN] = savebuf.c_cc[VMIN]; |
| 1077 | work.c_iflag = savebuf.c_iflag; |
| 1078 | work.c_iflag &= ~(IXON|IXOFF|IXANY); |
| 1079 | work.c_iflag |= savebuf.c_iflag & (IXON|IXOFF|IXANY);*/ |
| 1080 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1081 | /*Copy(&work,&savebuf,1,sizeof(struct tbuffer));*/ |
| 1082 | |
| 1083 | firsttime=1; |
| 1084 | } |
| 1085 | else |
| 1086 | { |
| 1087 | croakPerl_croak("ReadMode %d is not implemented on this architecture.",mode); |
| 1088 | return; |
| 1089 | } |
| 1090 | |
| 1091 | |
| 1092 | /* If switching from a "lower power" mode to a higher one, keep the |
| 1093 | data that may be in the queue, as it can easily be type-ahead. On |
| 1094 | switching to a lower mode from a higher one, however, flush the queue |
| 1095 | so that raw keystrokes won't hit an unexpecting program */ |
| 1096 | |
| 1097 | if(DisableFlush(1) || oldmode<=mode) |
| 1098 | tcsetattr(handle,TCSANOW0,&work); |
| 1099 | else |
| 1100 | tcsetattr(handle,TCSAFLUSH2,&work); |
| 1101 | |
| 1102 | /*tcsetattr(handle,TCSANOW,&work);*/ /* It might be better to FLUSH |
| 1103 | when changing gears to a lower mode, |
| 1104 | and only use NOW for higher modes. |
| 1105 | */ |
| 1106 | |
| 1107 | |
| 1108 | #endif |
| 1109 | #ifdef USE_TERMIO |
| 1110 | |
| 1111 | /* What, me worry about standards? */ |
| 1112 | |
| 1113 | # if !defined (IXANY0x00000800) |
| 1114 | # define IXANY0x00000800 (0) |
| 1115 | # endif |
| 1116 | |
| 1117 | #ifndef ECHOE0x00000002 |
| 1118 | #define ECHOE0x00000002 0 |
| 1119 | #endif |
| 1120 | #ifndef ECHOK0x00000004 |
| 1121 | #define ECHOK0x00000004 0 |
| 1122 | #endif |
| 1123 | #ifndef ECHONL0x00000010 |
| 1124 | #define ECHONL0x00000010 0 |
| 1125 | #endif |
| 1126 | #ifndef XCASE0x01000000 |
| 1127 | #define XCASE0x01000000 0 |
| 1128 | #endif |
| 1129 | #ifndef BRKINT0x00000002 |
| 1130 | #define BRKINT0x00000002 0 |
| 1131 | #endif |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | if(mode==5) { |
| 1136 | /* This mode should be echo disabled, signals disabled, |
| 1137 | flow control disabled, and unbuffered. CR/LF translation |
| 1138 | is off, and 8 bits if possible */ |
| 1139 | |
| 1140 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1141 | |
| 1142 | work.c_lflag &= ~(ECHO0x00000008 | ISIG0x00000080 | ICANON0x00000100 | XCASE0x01000000); |
| 1143 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010 | TRK_IDEFAULT0); |
| 1144 | work.c_iflag &= ~(IXON0x00000200 | IXOFF0x00000400 | IXANY0x00000800 | ICRNL0x00000100 | BRKINT0x00000002); |
| 1145 | if((work.c_cflag | PARENB0x00001000)!=PARENB0x00001000 ) { |
| 1146 | work.c_iflag &= ~(ISTRIP0x00000020|INPCK0x00000010); |
| 1147 | work.c_iflag |= IGNPAR0x00000004; |
| 1148 | } |
| 1149 | work.c_oflag &= ~(OPOST0x00000001|ONLCR0x00000002); |
| 1150 | work.c_cc[VMIN16] = 1; |
| 1151 | work.c_cc[VTIME17] = 1; |
| 1152 | } |
| 1153 | else if(mode==4) { |
| 1154 | /* This mode should be echo disabled, signals disabled, |
| 1155 | flow control disabled, and unbuffered. Parity is not |
| 1156 | touched. */ |
| 1157 | |
| 1158 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1159 | |
| 1160 | work.c_lflag &= ~(ECHO0x00000008 | ISIG0x00000080 | ICANON0x00000100); |
| 1161 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010 TRK_IDEFAULT0); |
| 1162 | work.c_iflag = savebuf.c_iflag; |
| 1163 | work.c_iflag &= ~(IXON0x00000200 | IXOFF0x00000400 | IXANY0x00000800 | BRKINT0x00000002); |
| 1164 | work.c_oflag = savebuf.c_oflag; |
| 1165 | work.c_cc[VMIN16] = 1; |
| 1166 | work.c_cc[VTIME17] = 1; |
| 1167 | } |
| 1168 | else if(mode==3) { |
| 1169 | /* This mode tries to have echo off, signals enabled, |
| 1170 | flow control as per the original setting, and unbuffered. */ |
| 1171 | |
| 1172 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1173 | |
| 1174 | work.c_lflag &= ~(ECHO0x00000008 | ICANON0x00000100); |
| 1175 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010 | TRK_IDEFAULT0); |
| 1176 | work.c_lflag |= ISIG0x00000080; |
| 1177 | work.c_iflag = savebuf.c_iflag; |
| 1178 | work.c_iflag &= ~(IXON0x00000200 | IXOFF0x00000400 | IXANY0x00000800); |
| 1179 | work.c_iflag |= savebuf.c_iflag & (IXON0x00000200|IXOFF0x00000400|IXANY0x00000800); |
| 1180 | work.c_oflag = savebuf.c_oflag; |
| 1181 | work.c_cc[VMIN16] = 1; |
| 1182 | work.c_cc[VTIME17] = 1; |
| 1183 | } |
| 1184 | else if(mode==2) { |
| 1185 | /* This mode tries to set echo on, signals on, and buffering |
| 1186 | on, with flow control set to whatever it was originally. */ |
| 1187 | |
| 1188 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1189 | |
| 1190 | work.c_lflag |= (ISIG0x00000080 | ICANON0x00000100); |
| 1191 | work.c_lflag &= ~ECHO0x00000008; |
| 1192 | work.c_lflag &= ~(ECHOE0x00000002 | ECHOK0x00000004 | ECHONL0x00000010 | TRK_IDEFAULT0); |
| 1193 | work.c_iflag = savebuf.c_iflag; |
| 1194 | work.c_iflag &= ~(IXON0x00000200 | IXOFF0x00000400 | IXANY0x00000800); |
| 1195 | work.c_iflag |= savebuf.c_iflag & (IXON0x00000200|IXOFF0x00000400|IXANY0x00000800); |
| 1196 | work.c_oflag = savebuf.c_oflag; |
| 1197 | work.c_cc[VMIN16] = savebuf.c_cc[VMIN16]; |
| 1198 | work.c_cc[VTIME17] = savebuf.c_cc[VTIME17]; |
| 1199 | |
| 1200 | /* This assumes turning ECHO and ICANON back on is |
| 1201 | sufficient to re-enable cooked mode. If this is a |
| 1202 | problem, complain to me */ |
| 1203 | |
| 1204 | /* What the heck. We're already saving the entire buf, so |
| 1205 | I'm now going to reset VMIN and VTIME too. Hope this works |
| 1206 | properly */ |
| 1207 | |
| 1208 | } |
| 1209 | else if(mode==1) { |
| 1210 | /* This mode tries to set echo on, signals on, and buffering |
| 1211 | on, with flow control set to whatever it was originally. */ |
| 1212 | |
| 1213 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1214 | |
| 1215 | work.c_lflag |= (ECHO0x00000008 | ISIG0x00000080 | ICANON0x00000100); |
| 1216 | work.c_iflag &= ~TRK_IDEFAULT0; |
| 1217 | work.c_iflag = savebuf.c_iflag; |
| 1218 | work.c_iflag &= ~(IXON0x00000200 | IXOFF0x00000400 | IXANY0x00000800); |
| 1219 | work.c_iflag |= savebuf.c_iflag & (IXON0x00000200|IXOFF0x00000400|IXANY0x00000800); |
| 1220 | work.c_oflag = savebuf.c_oflag; |
| 1221 | work.c_cc[VMIN16] = savebuf.c_cc[VMIN16]; |
| 1222 | work.c_cc[VTIME17] = savebuf.c_cc[VTIME17]; |
| 1223 | |
| 1224 | /* This assumes turning ECHO and ICANON back on is |
| 1225 | sufficient to re-enable cooked mode. If this is a |
| 1226 | problem, complain to me */ |
| 1227 | |
| 1228 | /* What the heck. We're already saving the entire buf, so |
| 1229 | I'm now going to reset VMIN and VTIME too. Hope this works |
| 1230 | properly */ |
| 1231 | } |
| 1232 | else if(mode==0) { |
| 1233 | /* Put things back the way they were */ |
| 1234 | |
| 1235 | /*work.c_lflag = savebuf.c_lflag; |
| 1236 | work.c_iflag = savebuf.c_iflag; |
| 1237 | work.c_oflag = savebuf.c_oflag; |
| 1238 | work.c_cc[VMIN] = savebuf.c_cc[VMIN]; |
| 1239 | work.c_cc[VTIME] = savebuf.c_cc[VTIME];*/ |
| 1240 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1241 | firsttime=1; |
| 1242 | } |
| 1243 | else |
| 1244 | { |
| 1245 | croakPerl_croak("ReadMode %d is not implemented on this architecture.",mode); |
| 1246 | return; |
| 1247 | } |
| 1248 | |
| 1249 | |
| 1250 | if(DisableFlush(1) || oldmode<=mode) |
| 1251 | ioctl(handle,TCSETA,&work); |
| 1252 | else |
| 1253 | ioctl(handle,TCSETAF,&work); |
| 1254 | |
| 1255 | #endif |
| 1256 | #ifdef USE_SGTTY |
| 1257 | |
| 1258 | |
| 1259 | if(mode==5) { |
| 1260 | /* Unbuffered, echo off, signals off, flow control off */ |
| 1261 | /* CR-CR/LF mode off too, and 8-bit path enabled. */ |
| 1262 | # if defined(TIOCLGET) && defined(LPASS8) |
| 1263 | if((work.buf.sg_flags & (EVENP|ODDP))==0 || |
| 1264 | (work.buf.sg_flags & (EVENP|ODDP))==(EVENP|ODDP)) |
| 1265 | work.local |= LPASS8; /* If parity isn't being used, use 8 bits */ |
| 1266 | # endif |
| 1267 | work.buf.sg_flags &= ~(ECHO0x00000008|CRMOD); |
| 1268 | work.buf.sg_flags |= (RAW|CBREAK); |
| 1269 | # if defined(TIOCGETC) |
| 1270 | work.tchar.t_intrc = -1; |
| 1271 | work.tchar.t_quitc = -1; |
| 1272 | work.tchar.t_startc= -1; |
| 1273 | work.tchar.t_stopc = -1; |
| 1274 | work.tchar.t_eofc = -1; |
| 1275 | work.tchar.t_brkc = -1; |
| 1276 | # endif |
| 1277 | # if defined(TIOCGLTC) |
| 1278 | work.ltchar.t_suspc= -1; |
| 1279 | work.ltchar.t_dsuspc= -1; |
| 1280 | work.ltchar.t_rprntc= -1; |
| 1281 | work.ltchar.t_flushc= -1; |
| 1282 | work.ltchar.t_werasc= -1; |
| 1283 | work.ltchar.t_lnextc= -1; |
| 1284 | # endif |
| 1285 | } |
| 1286 | else if(mode==4) { |
| 1287 | /* Unbuffered, echo off, signals off, flow control off */ |
| 1288 | work.buf.sg_flags &= ~(ECHO0x00000008|RAW); |
| 1289 | work.buf.sg_flags |= (CBREAK|CRMOD); |
| 1290 | # if defined(TIOCLGET) |
| 1291 | work.local=savebuf.local; |
| 1292 | # endif |
| 1293 | # if defined(TIOCGETC) |
| 1294 | work.tchar.t_intrc = -1; |
| 1295 | work.tchar.t_quitc = -1; |
| 1296 | work.tchar.t_startc= -1; |
| 1297 | work.tchar.t_stopc = -1; |
| 1298 | work.tchar.t_eofc = -1; |
| 1299 | work.tchar.t_brkc = -1; |
| 1300 | # endif |
| 1301 | # if defined(TIOCGLTC) |
| 1302 | work.ltchar.t_suspc= -1; |
| 1303 | work.ltchar.t_dsuspc= -1; |
| 1304 | work.ltchar.t_rprntc= -1; |
| 1305 | work.ltchar.t_flushc= -1; |
| 1306 | work.ltchar.t_werasc= -1; |
| 1307 | work.ltchar.t_lnextc= -1; |
| 1308 | # endif |
| 1309 | } |
| 1310 | else if(mode==3) { |
| 1311 | /* Unbuffered, echo off, signals on, flow control on */ |
| 1312 | work.buf.sg_flags &= ~(RAW|ECHO0x00000008); |
| 1313 | work.buf.sg_flags |= CBREAK|CRMOD; |
| 1314 | # if defined(TIOCLGET) |
| 1315 | work.local=savebuf.local; |
| 1316 | # endif |
| 1317 | # if defined(TIOCGLTC) |
| 1318 | work.tchar = savebuf.tchar; |
| 1319 | # endif |
| 1320 | # if defined(TIOCGLTC) |
| 1321 | work.ltchar = savebuf.ltchar; |
| 1322 | # endif |
| 1323 | } |
| 1324 | else if(mode==2) { |
| 1325 | /* Buffered, echo on, signals on, flow control on */ |
| 1326 | work.buf.sg_flags &= ~(RAW|CBREAK); |
| 1327 | work.buf.sg_flags |= CRMOD; |
| 1328 | work.buf.sg_flags &= ~ECHO0x00000008; |
| 1329 | # if defined(TIOCLGET) |
| 1330 | work.local=savebuf.local; |
| 1331 | # endif |
| 1332 | # if defined(TIOCGLTC) |
| 1333 | work.tchar = savebuf.tchar; |
| 1334 | # endif |
| 1335 | # if defined(TIOCGLTC) |
| 1336 | work.ltchar = savebuf.ltchar; |
| 1337 | # endif |
| 1338 | } |
| 1339 | else if(mode==1) { |
| 1340 | /* Buffered, echo on, signals on, flow control on */ |
| 1341 | work.buf.sg_flags &= ~(RAW|CBREAK); |
| 1342 | work.buf.sg_flags |= ECHO0x00000008|CRMOD; |
| 1343 | # if defined(TIOCLGET) |
| 1344 | work.local=savebuf.local; |
| 1345 | # endif |
| 1346 | # if defined(TIOCGLTC) |
| 1347 | work.tchar = savebuf.tchar; |
| 1348 | # endif |
| 1349 | # if defined(TIOCGLTC) |
| 1350 | work.ltchar = savebuf.ltchar; |
| 1351 | # endif |
| 1352 | } |
| 1353 | else if(mode==0){ |
| 1354 | /* Original settings */ |
| 1355 | #if 0 |
| 1356 | work.buf.sg_flags &= ~(RAW|CBREAK|ECHO0x00000008|CRMOD); |
| 1357 | work.buf.sg_flags |= savebuf.sg_flags & (RAW|CBREAK|ECHO0x00000008|CRMOD); |
| 1358 | # if defined(TIOCLGET) |
| 1359 | work.local=savebuf.local; |
| 1360 | # endif |
| 1361 | # if defined(TIOCGLTC) |
| 1362 | work.tchar = savebuf.tchar; |
| 1363 | # endif |
| 1364 | # if defined(TIOCGLTC) |
| 1365 | work.ltchar = savebuf.ltchar; |
| 1366 | # endif |
| 1367 | #endif |
| 1368 | memcpy((void*)&work,(void*)&savebuf,sizeof(struct tbuffertermios)); |
| 1369 | firsttime=1; |
| 1370 | } |
| 1371 | else |
| 1372 | { |
| 1373 | croakPerl_croak("ReadMode %d is not implemented on this architecture.",mode); |
| 1374 | return; |
| 1375 | } |
| 1376 | #if defined(TIOCLSET) |
| 1377 | ioctl(handle,TIOCLSET,&work.local); |
| 1378 | #endif |
| 1379 | #if defined(TIOCSETC) |
| 1380 | ioctl(handle,TIOCSETC,&work.tchar); |
| 1381 | #endif |
| 1382 | # if defined(TIOCGLTC) |
| 1383 | ioctl(handle,TIOCSLTC,&work.ltchar); |
| 1384 | # endif |
| 1385 | if(DisableFlush(1) || oldmode<=mode) |
| 1386 | ioctl(handle,TIOCSETN,&work.buf); |
| 1387 | else |
| 1388 | ioctl(handle,TIOCSETP,&work.buf); |
| 1389 | #endif |
| 1390 | #ifdef USE_STTY |
| 1391 | |
| 1392 | /* No termio, termios or sgtty. I suppose we can try stty, |
| 1393 | but it would be nice if you could get a better OS */ |
| 1394 | |
| 1395 | if(mode==5) |
| 1396 | system("/bin/stty raw -cbreak -isig -echo -ixon -onlcr -icrnl -brkint"); |
| 1397 | else if(mode==4) |
| 1398 | system("/bin/stty -raw cbreak -isig -echo -ixon onlcr icrnl -brkint"); |
| 1399 | else if(mode==3) |
| 1400 | system("/bin/stty -raw cbreak isig -echo ixon onlcr icrnl brkint"); |
| 1401 | else if(mode==2) |
| 1402 | system("/bin/stty -raw -cbreak isig echo ixon onlcr icrnl brkint"); |
| 1403 | else if(mode==1) |
| 1404 | system("/bin/stty -raw -cbreak isig -echo ixon onlcr icrnl brkint"); |
| 1405 | else if(mode==0) |
| 1406 | system("/bin/stty -raw -cbreak isig echo ixon onlcr icrnl brkint"); |
| 1407 | |
| 1408 | /* Those probably won't work, but they couldn't hurt |
| 1409 | at this point */ |
| 1410 | |
| 1411 | #endif |
| 1412 | |
| 1413 | /*warn("Mode set to %d.\n",mode);*/ |
| 1414 | |
| 1415 | if( firsttime ) { |
| 1416 | (void)hv_delete(filehash,(char*)&handle,sizeof(int),0)(((SV *)({ void *_p = (Perl_hv_common_key_len( (filehash),((char *)&handle),(sizeof(int)),(0) | 0x40,((void*)0),0)); _p; } ))); |
| 1417 | (void)hv_delete(modehash,(char*)&handle,sizeof(int),0)(((SV *)({ void *_p = (Perl_hv_common_key_len( (modehash),((char *)&handle),(sizeof(int)),(0) | 0x40,((void*)0),0)); _p; } ))); |
| 1418 | } else { |
| 1419 | if(!hv_store(modehash,(char*)&handle,sizeof(int),((SV**) Perl_hv_common_key_len( (modehash),((char*)&handle ),(sizeof(int)),(0x04|0x20),(Perl_newSViv( mode)),(0))) |
| 1420 | newSViv(mode),0)((SV**) Perl_hv_common_key_len( (modehash),((char*)&handle ),(sizeof(int)),(0x04|0x20),(Perl_newSViv( mode)),(0)))) |
| 1421 | croakPerl_croak("Unable to stash terminal settings.\n"); |
| 1422 | } |
| 1423 | |
| 1424 | } |
| 1425 | |
| 1426 | #ifdef USE_PERLIO |
| 1427 | |
| 1428 | /* Make use of a recent addition to Perl, if possible */ |
| 1429 | # define FCOUNT(f)Perl_PerlIO_get_cnt( f) PerlIO_get_cnt(f)Perl_PerlIO_get_cnt( f) |
| 1430 | #else |
| 1431 | |
| 1432 | /* Make use of a recent addition to Configure, if possible */ |
| 1433 | # ifdef USE_STDIO_PTR |
| 1434 | # define FCOUNT(f)Perl_PerlIO_get_cnt( f) PerlIO_get_cnt(f)Perl_PerlIO_get_cnt( f) |
| 1435 | # else |
| 1436 | /* This bit borrowed from pp_sys.c. Complain to Larry if it's broken. */ |
| 1437 | /* If any of this works PerlIO_get_cnt() will too ... NI-S */ |
| 1438 | # if defined(USE_STD_STDIO) || defined(atarist) /* this will work with atariST */ |
| 1439 | # define FBASE(f) ((f)->_base) |
| 1440 | # define FSIZE(f) ((f)->_cnt + ((f)->_ptr - (f)->_base)) |
| 1441 | # define FPTR(f) ((f)->_ptr) |
| 1442 | # define FCOUNT(f)Perl_PerlIO_get_cnt( f) ((f)->_cnt) |
| 1443 | # else |
| 1444 | # if defined(USE_LINUX_STDIO) |
| 1445 | # define FBASE(f) ((f)->_IO_read_base) |
| 1446 | # define FSIZE(f) ((f)->_IO_read_end - FBASE(f)) |
| 1447 | # define FPTR(f) ((f)->_IO_read_ptr) |
| 1448 | # define FCOUNT(f)Perl_PerlIO_get_cnt( f) ((f)->_IO_read_end - FPTR(f)) |
| 1449 | # endif |
| 1450 | # endif |
| 1451 | # endif |
| 1452 | #endif |
| 1453 | |
| 1454 | /* This is for the best, I'm afraid. */ |
| 1455 | #if !defined(FCOUNT) |
| 1456 | # ifdef Have_select |
| 1457 | # undef Have_select |
| 1458 | # endif |
| 1459 | # ifdef Have_poll |
| 1460 | # undef Have_poll |
| 1461 | # endif |
| 1462 | #endif |
| 1463 | |
| 1464 | /* Note! If your machine has a bolixed up select() call that doesn't |
| 1465 | understand this syntax, either fix the checkwaiting call below, or define |
| 1466 | DONT_USE_SELECT. */ |
| 1467 | |
| 1468 | #ifdef Have_select |
| 1469 | int selectfile(pTHX_ PerlIOPerlIO *file,double delay) |
| 1470 | { |
| 1471 | struct timeval t; |
| 1472 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 1473 | |
| 1474 | /*char buf[32]; |
| 1475 | Select_fd_set_t fd=(Select_fd_set_t)&buf[0];*/ |
| 1476 | |
| 1477 | fd_set fd; |
| 1478 | if (PerlIO_fast_gets(file) && PerlIO_get_cnt(file)Perl_PerlIO_get_cnt( file) > 0) |
| 1479 | return 1; |
| 1480 | |
| 1481 | /*t.tv_sec=t.tv_usec=0;*/ |
| 1482 | |
| 1483 | if (delay < 0.0) |
| 1484 | delay = 0.0; |
| 1485 | t.tv_sec = (long)delay; |
| 1486 | delay -= (double)t.tv_sec; |
| 1487 | t.tv_usec = (long)(delay * 1000000.0); |
| 1488 | |
| 1489 | FD_ZERO(&fd)do { fd_set *_p = (&fd); __size_t _n = (((1024) + ((((unsigned )(sizeof(__fd_mask) * 8))) - 1)) / (((unsigned)(sizeof(__fd_mask ) * 8)))); while (_n > 0) _p->fds_bits[--_n] = 0; } while (0); |
| 1490 | FD_SET(handle,&fd)__fd_set((handle), (&fd)); |
| 1491 | if(select(handle+1,(Select_fd_set_tfd_set *)&fd, |
| 1492 | (Select_fd_set_tfd_set *)0, |
| 1493 | (Select_fd_set_tfd_set *)&fd, &t)) return -1; |
| 1494 | else return 0; |
| 1495 | } |
| 1496 | |
| 1497 | #else |
| 1498 | int selectfile(pTHX_ PerlIOPerlIO *file, double delay) |
| 1499 | { |
| 1500 | croakPerl_croak("select is not supported on this architecture"); |
| 1501 | return 0; |
| 1502 | } |
| 1503 | #endif |
| 1504 | |
| 1505 | #ifdef Have_nodelay |
| 1506 | int setnodelay(pTHX_ PerlIOPerlIO *file, int mode) |
| 1507 | { |
| 1508 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 1509 | int flags; |
| 1510 | flags=fcntl(handle,F_GETFL3,0); |
| 1511 | if(mode) |
| 1512 | flags|=O_NODELAY0x0004; |
| 1513 | else |
| 1514 | flags&=~O_NODELAY0x0004; |
| 1515 | fcntl(handle,F_SETFL4,flags); |
| 1516 | return 0; |
| 1517 | } |
| 1518 | |
| 1519 | #else |
| 1520 | int setnodelay(pTHX_ PerlIOPerlIO *file, int mode) |
| 1521 | { |
| 1522 | croakPerl_croak("setnodelay is not supported on this architecture"); |
| 1523 | return 0; |
| 1524 | } |
| 1525 | #endif |
| 1526 | |
| 1527 | #ifdef Have_poll |
| 1528 | int pollfile(pTHX_ pTHX_ PerlIOPerlIO *file,double delay) |
| 1529 | { |
| 1530 | int handle=PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 1531 | struct pollfd fds; |
| 1532 | if (PerlIO_fast_gets(f) && PerlIO_get_cnt(f)Perl_PerlIO_get_cnt( f) > 0) |
| 1533 | return 1; |
| 1534 | if(delay<0.0) delay = 0.0; |
| 1535 | fds.fd=handle; |
| 1536 | fds.events=POLLIN; |
| 1537 | fds.revents=0; |
| 1538 | return (poll(&fds,1,(long)(delay * 1000.0))>0); |
| 1539 | } |
| 1540 | #else |
| 1541 | int pollfile(pTHX_ PerlIOPerlIO *file,double delay) |
| 1542 | { |
| 1543 | croakPerl_croak("pollfile is not supported on this architecture"); |
| 1544 | return 0; |
| 1545 | } |
| 1546 | #endif |
| 1547 | |
| 1548 | #ifdef WIN32 |
| 1549 | |
| 1550 | /* |
| 1551 | |
| 1552 | This portion of the Win32 code is partially borrowed from a version of PDCurses. |
| 1553 | |
| 1554 | */ |
| 1555 | |
| 1556 | typedef struct { |
| 1557 | int repeatCount; |
| 1558 | int vKey; |
| 1559 | int vScan; |
| 1560 | int ascii; |
| 1561 | int control; |
| 1562 | } win32_key_event_t; |
| 1563 | |
| 1564 | #define KEY_PUSH(I, K) { events[I].repeatCount = 1; events[I].ascii = K; } |
| 1565 | #define KEY_PUSH3(K1, K2, K3) \ |
| 1566 | do { \ |
| 1567 | eventCount = 0; \ |
| 1568 | KEY_PUSH(2, K1); \ |
| 1569 | KEY_PUSH(1, K2); \ |
| 1570 | KEY_PUSH(0, K3); \ |
| 1571 | eventCount = 3; \ |
| 1572 | goto again; \ |
| 1573 | } while (0) |
| 1574 | |
| 1575 | #define KEY_PUSH4(K1, K2, K3, K4) \ |
| 1576 | do { \ |
| 1577 | eventCount = 0; \ |
| 1578 | KEY_PUSH(3, K1); \ |
| 1579 | KEY_PUSH(2, K2); \ |
| 1580 | KEY_PUSH(1, K3); \ |
| 1581 | KEY_PUSH(0, K4); \ |
| 1582 | eventCount = 4; \ |
| 1583 | goto again; \ |
| 1584 | } while (0) |
| 1585 | |
| 1586 | int Win32PeekChar(pTHX_ PerlIOPerlIO *file,double delay,char *key) |
| 1587 | { |
| 1588 | int handle; |
| 1589 | HANDLE whnd; |
| 1590 | INPUT_RECORD record; |
| 1591 | DWORD readRecords; |
| 1592 | |
| 1593 | #if 0 |
| 1594 | static int keyCount = 0; |
| 1595 | static char lastKey = 0; |
| 1596 | #endif |
| 1597 | |
| 1598 | #define MAX_EVENTS 4 |
| 1599 | static int eventCount = 0; |
| 1600 | static win32_key_event_t events[MAX_EVENTS]; |
| 1601 | int keyCount; |
| 1602 | |
| 1603 | file = STDINPerl_PerlIO_stdin(); |
| 1604 | |
| 1605 | handle = PerlIO_fileno(file)Perl_PerlIO_fileno( file); |
| 1606 | whnd = /*GetStdHandle(STD_INPUT_HANDLE)*/(HANDLE)_get_osfhandle(handle); |
| 1607 | |
| 1608 | |
| 1609 | again: |
| 1610 | #if 0 |
| 1611 | if (keyCount > 0) { |
| 1612 | keyCount--; |
| 1613 | *key = lastKey; |
| 1614 | return TRUE(1); |
| 1615 | } |
| 1616 | #endif |
| 1617 | |
| 1618 | /* printf("eventCount: %d\n", eventCount); */ |
| 1619 | if (eventCount) { |
| 1620 | /* printf("key %d; repeatCount %d\n", *key, events[eventCount - 1].repeatCount); */ |
| 1621 | *key = events[eventCount - 1].ascii; |
| 1622 | events[eventCount - 1].repeatCount--; |
| 1623 | if (events[eventCount - 1].repeatCount <= 0) { |
| 1624 | eventCount--; |
| 1625 | } |
| 1626 | return TRUE(1); |
| 1627 | } |
| 1628 | |
| 1629 | if (delay > 0) { |
| 1630 | if (WaitForSingleObject(whnd, delay * 1000) != WAIT_OBJECT_0) |
| 1631 | { |
| 1632 | return FALSE(0); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | if (delay != 0) { |
| 1637 | PeekConsoleInput(whnd, &record, 1, &readRecords); |
| 1638 | if (readRecords == 0) { |
| 1639 | return(FALSE(0)); |
| 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | ReadConsoleInput(whnd, &record, 1, &readRecords); |
| 1644 | switch(record.EventType) |
| 1645 | { |
| 1646 | case KEY_EVENT: |
| 1647 | /* printf("\nkeyDown = %d, repeat = %d, vKey = %d, vScan = %d, ASCII = %d, Control = %d\n", |
| 1648 | record.Event.KeyEvent.bKeyDown, |
| 1649 | record.Event.KeyEvent.wRepeatCount, |
| 1650 | record.Event.KeyEvent.wVirtualKeyCode, |
| 1651 | record.Event.KeyEvent.wVirtualScanCode, |
| 1652 | record.Event.KeyEvent.uChar.AsciiChar, |
| 1653 | record.Event.KeyEvent.dwControlKeyState); */ |
| 1654 | |
| 1655 | if (record.Event.KeyEvent.bKeyDown == FALSE(0)) |
| 1656 | goto again; /* throw away KeyUp events */ |
| 1657 | |
| 1658 | if (record.Event.KeyEvent.wVirtualKeyCode == 38) { /* up */ |
| 1659 | KEY_PUSH3(27, 91, 65); |
| 1660 | } |
| 1661 | if (record.Event.KeyEvent.wVirtualKeyCode == 40) { /* down */ |
| 1662 | KEY_PUSH3(27, 91, 66); |
| 1663 | } |
| 1664 | if (record.Event.KeyEvent.wVirtualKeyCode == 39) { /* right */ |
| 1665 | KEY_PUSH3(27, 91, 67); |
| 1666 | } |
| 1667 | if (record.Event.KeyEvent.wVirtualKeyCode == 37) { /* left */ |
| 1668 | KEY_PUSH3(27, 91, 68); |
| 1669 | } |
| 1670 | if (record.Event.KeyEvent.wVirtualKeyCode == 33) { /* page up */ |
| 1671 | KEY_PUSH3(27, 79, 121); |
| 1672 | } |
| 1673 | if (record.Event.KeyEvent.wVirtualKeyCode == 34) { /* page down */ |
| 1674 | KEY_PUSH3(27, 79, 115); |
| 1675 | } |
| 1676 | if (record.Event.KeyEvent.wVirtualKeyCode == 36) { /* home */ |
| 1677 | KEY_PUSH4(27, 91, 49, 126); |
| 1678 | } |
| 1679 | if (record.Event.KeyEvent.wVirtualKeyCode == 35) { /* end */ |
| 1680 | KEY_PUSH4(27, 91, 52, 126); |
| 1681 | } |
| 1682 | if (record.Event.KeyEvent.wVirtualKeyCode == 45) { /* insert */ |
| 1683 | KEY_PUSH4(27, 91, 50, 126); |
| 1684 | } |
| 1685 | if (record.Event.KeyEvent.wVirtualKeyCode == 46) { /* delete */ |
| 1686 | KEY_PUSH4(27, 91, 51, 126); |
| 1687 | } |
| 1688 | |
| 1689 | if (record.Event.KeyEvent.wVirtualKeyCode == 16 |
| 1690 | || record.Event.KeyEvent.wVirtualKeyCode == 17 |
| 1691 | || record.Event.KeyEvent.wVirtualKeyCode == 18 |
| 1692 | || record.Event.KeyEvent.wVirtualKeyCode == 20 |
| 1693 | || record.Event.KeyEvent.wVirtualKeyCode == 144 |
| 1694 | || record.Event.KeyEvent.wVirtualKeyCode == 145) |
| 1695 | goto again; /* throw away shift/alt/ctrl key only key events */ |
| 1696 | keyCount = record.Event.KeyEvent.wRepeatCount; |
| 1697 | break; |
| 1698 | default: |
| 1699 | keyCount = 0; |
| 1700 | goto again; |
| 1701 | break; |
| 1702 | } |
| 1703 | |
| 1704 | *key = record.Event.KeyEvent.uChar.AsciiChar; |
| 1705 | keyCount--; |
| 1706 | |
| 1707 | if (keyCount) { |
| 1708 | events[0].repeatCount = keyCount; |
| 1709 | events[0].ascii = *key; |
| 1710 | eventCount = 1; |
| 1711 | } |
| 1712 | |
| 1713 | return(TRUE(1)); |
| 1714 | |
| 1715 | /* again: |
| 1716 | return (FALSE); |
| 1717 | */ |
| 1718 | |
| 1719 | |
| 1720 | } |
| 1721 | #else |
| 1722 | int Win32PeekChar(pTHX_ PerlIOPerlIO *file, double delay,char *key) |
| 1723 | { |
| 1724 | croakPerl_croak("Win32PeekChar is not supported on this architecture"); |
| 1725 | return 0; |
| 1726 | } |
| 1727 | #endif |
| 1728 | |
| 1729 | |
| 1730 | STATICstatic int blockoptions() { |
| 1731 | return 0 |
| 1732 | #ifdef Have_nodelay |
| 1733 | | 1 |
| 1734 | #endif |
| 1735 | #ifdef Have_poll |
| 1736 | | 2 |
| 1737 | #endif |
| 1738 | #ifdef Have_select |
| 1739 | | 4 |
| 1740 | #endif |
| 1741 | #ifdef USE_WIN32 |
| 1742 | | 8 |
| 1743 | #endif |
| 1744 | ; |
| 1745 | } |
| 1746 | |
| 1747 | STATICstatic int termoptions() { |
| 1748 | int i=0; |
| 1749 | #ifdef USE_TERMIOS |
| 1750 | i=1; |
| 1751 | #endif |
| 1752 | #ifdef USE_TERMIO |
| 1753 | i=2; |
| 1754 | #endif |
| 1755 | #ifdef USE_SGTTY |
| 1756 | i=3; |
| 1757 | #endif |
| 1758 | #ifdef USE_STTY |
| 1759 | i=4; |
| 1760 | #endif |
| 1761 | #ifdef USE_WIN32 |
| 1762 | i=5; |
| 1763 | #endif |
| 1764 | return i; |
| 1765 | } |
| 1766 | |
| 1767 | |
| 1768 | |
| 1769 | #line 1770 "ReadKey.c" |
| 1770 | #ifndef PERL_UNUSED_VAR |
| 1771 | # define PERL_UNUSED_VAR(var)((void)sizeof(var)) if (0) var = var |
| 1772 | #endif |
| 1773 | |
| 1774 | #ifndef dVARstruct Perl___notused_struct |
| 1775 | # define dVARstruct Perl___notused_struct dNOOPstruct Perl___notused_struct |
| 1776 | #endif |
| 1777 | |
| 1778 | |
| 1779 | /* This stuff is not part of the API! You have been warned. */ |
| 1780 | #ifndef PERL_VERSION_DECIMAL |
| 1781 | # define PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s) (r*1000000 + v*1000 + s) |
| 1782 | #endif |
| 1783 | #ifndef PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) |
| 1784 | # define PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) \ |
| 1785 | PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)(5*1000000 + 32*1000 + 1) |
| 1786 | #endif |
| 1787 | #ifndef PERL_VERSION_GE |
| 1788 | # define PERL_VERSION_GE(r,v,s)((5*1000000 + 32*1000 + 1) >= (r*1000000 + v*1000 + s)) \ |
| 1789 | (PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) >= PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s)) |
| 1790 | #endif |
| 1791 | #ifndef PERL_VERSION_LE |
| 1792 | # define PERL_VERSION_LE(r,v,s)((5*1000000 + 32*1000 + 1) <= (r*1000000 + v*1000 + s)) \ |
| 1793 | (PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) <= PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s)) |
| 1794 | #endif |
| 1795 | |
| 1796 | /* XS_INTERNAL is the explicit static-linkage variant of the default |
| 1797 | * XS macro. |
| 1798 | * |
| 1799 | * XS_EXTERNAL is the same as XS_INTERNAL except it does not include |
| 1800 | * "STATIC", ie. it exports XSUB symbols. You probably don't want that |
| 1801 | * for anything but the BOOT XSUB. |
| 1802 | * |
| 1803 | * See XSUB.h in core! |
| 1804 | */ |
| 1805 | |
| 1806 | |
| 1807 | /* TODO: This might be compatible further back than 5.10.0. */ |
| 1808 | #if PERL_VERSION_GE(5, 10, 0)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 10*1000 + 0)) && PERL_VERSION_LE(5, 15, 1)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 15*1000 + 1)) |
| 1809 | # undef XS_EXTERNAL |
| 1810 | # undef XS_INTERNAL |
| 1811 | # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
| 1812 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) __declspec(dllexport) XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1813 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1814 | # endif |
| 1815 | # if defined(__SYMBIAN32__) |
| 1816 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) EXPORT_C XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1817 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) EXPORT_C STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1818 | # endif |
| 1819 | # ifndef XS_EXTERNAL |
| 1820 | # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
| 1821 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) void name(pTHX_ CV* cv __attribute__unused____attribute__((unused))) |
| 1822 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic void name(pTHX_ CV* cv __attribute__unused____attribute__((unused))) |
| 1823 | # else |
| 1824 | # ifdef __cplusplus |
| 1825 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) extern "C" XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1826 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) static XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1827 | # else |
| 1828 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1829 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
| 1830 | # endif |
| 1831 | # endif |
| 1832 | # endif |
| 1833 | #endif |
| 1834 | |
| 1835 | /* perl >= 5.10.0 && perl <= 5.15.1 */ |
| 1836 | |
| 1837 | |
| 1838 | /* The XS_EXTERNAL macro is used for functions that must not be static |
| 1839 | * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL |
| 1840 | * macro defined, the best we can do is assume XS is the same. |
| 1841 | * Dito for XS_INTERNAL. |
| 1842 | */ |
| 1843 | #ifndef XS_EXTERNAL |
| 1844 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) XS(name)void name( CV* cv __attribute__((unused))) |
| 1845 | #endif |
| 1846 | #ifndef XS_INTERNAL |
| 1847 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) XS(name)void name( CV* cv __attribute__((unused))) |
| 1848 | #endif |
| 1849 | |
| 1850 | /* Now, finally, after all this mess, we want an ExtUtils::ParseXS |
| 1851 | * internal macro that we're free to redefine for varying linkage due |
| 1852 | * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use |
| 1853 | * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to! |
| 1854 | */ |
| 1855 | |
| 1856 | #undef XS_EUPXS |
| 1857 | #if defined(PERL_EUPXS_ALWAYS_EXPORT) |
| 1858 | # define XS_EUPXS(name)static void name( CV* cv __attribute__((unused))) XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) |
| 1859 | #else |
| 1860 | /* default to internal */ |
| 1861 | # define XS_EUPXS(name)static void name( CV* cv __attribute__((unused))) XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) |
| 1862 | #endif |
| 1863 | |
| 1864 | #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) |
| 1865 | #define PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) assert(cv)((void)0); assert(params)((void)0) |
| 1866 | |
| 1867 | /* prototype to pass -Wmissing-prototypes */ |
| 1868 | STATICstatic void |
| 1869 | S_croak_xs_usage(const CV *const cv, const char *const params); |
| 1870 | |
| 1871 | STATICstatic void |
| 1872 | S_croak_xs_usage(const CV *const cv, const char *const params) |
| 1873 | { |
| 1874 | const GV *const gv = CvGV(cv)Perl_CvGV( (CV *)(cv)); |
| 1875 | |
| 1876 | PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0); |
| 1877 | |
| 1878 | if (gv) { |
| 1879 | const char *const gvname = GvNAME(gv)((((XPVGV*)(gv)->sv_any)->xiv_u.xivu_namehek))->hek_key; |
| 1880 | const HV *const stash = GvSTASH(gv)(((XPVGV*)(gv)->sv_any)->xnv_u.xgv_stash); |
| 1881 | const char *const hvname = stash ? HvNAME(stash)((((stash)->sv_flags & 0x02000000) && ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV*) (stash )->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name && ( ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_count ? * ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_names : ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name )) ? (( ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash )[((XPVHV*) (stash)->sv_any)->xhv_max+1]))->xhv_name_count ? *((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_names : ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name ))->hek_key : ((void*)0)) : NULL((void*)0); |
| 1882 | |
| 1883 | if (hvname) |
| 1884 | Perl_croak_nocontextPerl_croak("Usage: %s::%s(%s)", hvname, gvname, params); |
| 1885 | else |
| 1886 | Perl_croak_nocontextPerl_croak("Usage: %s(%s)", gvname, params); |
| 1887 | } else { |
| 1888 | /* Pants. I don't think that it should be possible to get here. */ |
| 1889 | Perl_croak_nocontextPerl_croak("Usage: CODE(0x%" UVxf"lx" ")(%s)", PTR2UV(cv)(UV)(cv), params); |
| 1890 | } |
| 1891 | } |
| 1892 | #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) |
| 1893 | |
| 1894 | #define croak_xs_usagePerl_croak_xs_usage S_croak_xs_usage |
| 1895 | |
| 1896 | #endif |
| 1897 | |
| 1898 | /* NOTE: the prototype of newXSproto() is different in versions of perls, |
| 1899 | * so we define a portable version of newXSproto() |
| 1900 | */ |
| 1901 | #ifdef newXS_flags |
| 1902 | #define newXSproto_portable(name, c_impl, file, proto)Perl_newXS_flags( name,c_impl,file,proto,0) newXS_flags(name, c_impl, file, proto, 0)Perl_newXS_flags( name,c_impl,file,proto,0) |
| 1903 | #else |
| 1904 | #define newXSproto_portable(name, c_impl, file, proto)Perl_newXS_flags( name,c_impl,file,proto,0) (PL_Sv=(SV*)newXS(name, c_impl, file)Perl_newXS( name,c_impl,file), sv_setpv(PL_Sv, proto)Perl_sv_setpv( PL_Sv,proto), (CV*)PL_Sv) |
| 1905 | #endif /* !defined(newXS_flags) */ |
| 1906 | |
| 1907 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
| 1908 | # define newXS_deffile(a,b)Perl_newXS_deffile( a,b) Perl_newXS(aTHX_ a,b,file) |
| 1909 | #else |
| 1910 | # define newXS_deffile(a,b)Perl_newXS_deffile( a,b) Perl_newXS_deffile(aTHX_ a,b) |
| 1911 | #endif |
| 1912 | |
| 1913 | #line 1914 "ReadKey.c" |
| 1914 | |
| 1915 | XS_EUPXS(XS_Term__ReadKey_selectfile)static void XS_Term__ReadKey_selectfile( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 1916 | XS_EUPXS(XS_Term__ReadKey_selectfile)static void XS_Term__ReadKey_selectfile( CV* cv __attribute__ ((unused))) |
| 1917 | { |
| 1918 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 1919 | if (items != 2) |
| 1920 | croak_xs_usagePerl_croak_xs_usage(cv, "file, delay"); |
| 1921 | { |
| 1922 | InputStreamPerlIO * file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 1923 | ; |
| 1924 | double delay = (double)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
| 1925 | ; |
| 1926 | int RETVAL; |
| 1927 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 1928 | #line 1767 "ReadKey.xs" |
| 1929 | RETVAL = selectfile(aTHX_ file, delay); |
| 1930 | #line 1931 "ReadKey.c" |
| 1931 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 1932 | } |
| 1933 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 1934 | } |
| 1935 | |
| 1936 | |
| 1937 | XS_EUPXS(XS_Term__ReadKey_SetReadMode)static void XS_Term__ReadKey_SetReadMode( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 1938 | XS_EUPXS(XS_Term__ReadKey_SetReadMode)static void XS_Term__ReadKey_SetReadMode( CV* cv __attribute__ ((unused))) |
| 1939 | { |
| 1940 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 1941 | if (items < 1 || items > 2) |
| 1942 | croak_xs_usagePerl_croak_xs_usage(cv, "mode, file=STDIN"); |
| 1943 | { |
| 1944 | int mode = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
| 1945 | ; |
| 1946 | InputStreamPerlIO * file; |
| 1947 | |
| 1948 | if (items < 2) |
| 1949 | file = STDINPerl_PerlIO_stdin(); |
| 1950 | else { |
| 1951 | file = IoIFP(sv_2io(ST(1)))(Perl_sv_2io( PL_stack_base[ax + (1)]))->sv_u.svu_fp |
| 1952 | ; |
| 1953 | } |
| 1954 | #line 1777 "ReadKey.xs" |
| 1955 | { |
| 1956 | ReadMode(aTHX_ file,mode); |
| 1957 | } |
| 1958 | #line 1959 "ReadKey.c" |
| 1959 | } |
| 1960 | XSRETURN_EMPTY(void)( { (void)( { const IV tmpXSoff = (0); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); } ); |
| 1961 | } |
| 1962 | |
| 1963 | |
| 1964 | XS_EUPXS(XS_Term__ReadKey_setnodelay)static void XS_Term__ReadKey_setnodelay( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 1965 | XS_EUPXS(XS_Term__ReadKey_setnodelay)static void XS_Term__ReadKey_setnodelay( CV* cv __attribute__ ((unused))) |
| 1966 | { |
| 1967 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 1968 | if (items != 2) |
| 1969 | croak_xs_usagePerl_croak_xs_usage(cv, "file, mode"); |
| 1970 | { |
| 1971 | InputStreamPerlIO * file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 1972 | ; |
| 1973 | int mode = (int)SvIV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (1)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 1)],2)) |
| 1974 | ; |
| 1975 | int RETVAL; |
| 1976 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 1977 | #line 1786 "ReadKey.xs" |
| 1978 | RETVAL = setnodelay(aTHX_ file, mode); |
| 1979 | #line 1980 "ReadKey.c" |
| 1980 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 1981 | } |
| 1982 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 1983 | } |
| 1984 | |
| 1985 | |
| 1986 | XS_EUPXS(XS_Term__ReadKey_pollfile)static void XS_Term__ReadKey_pollfile( CV* cv __attribute__(( unused))); /* prototype to pass -Wmissing-prototypes */ |
| 1987 | XS_EUPXS(XS_Term__ReadKey_pollfile)static void XS_Term__ReadKey_pollfile( CV* cv __attribute__(( unused))) |
| 1988 | { |
| 1989 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 1990 | if (items != 2) |
| 1991 | croak_xs_usagePerl_croak_xs_usage(cv, "file, delay"); |
| 1992 | { |
| 1993 | InputStreamPerlIO * file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 1994 | ; |
| 1995 | double delay = (double)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
| 1996 | ; |
| 1997 | int RETVAL; |
| 1998 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 1999 | #line 1795 "ReadKey.xs" |
| 2000 | RETVAL = pollfile(aTHX_ file, delay); |
| 2001 | #line 2002 "ReadKey.c" |
| 2002 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 2003 | } |
| 2004 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2005 | } |
| 2006 | |
| 2007 | |
| 2008 | XS_EUPXS(XS_Term__ReadKey_Win32PeekChar)static void XS_Term__ReadKey_Win32PeekChar( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2009 | XS_EUPXS(XS_Term__ReadKey_Win32PeekChar)static void XS_Term__ReadKey_Win32PeekChar( CV* cv __attribute__ ((unused))) |
| 2010 | { |
| 2011 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2012 | if (items != 2) |
| 2013 | croak_xs_usagePerl_croak_xs_usage(cv, "file, delay"); |
| 2014 | { |
| 2015 | InputStreamPerlIO * file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2016 | ; |
| 2017 | double delay = (double)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
| 2018 | ; |
| 2019 | SV * RETVAL; |
| 2020 | #line 1804 "ReadKey.xs" |
| 2021 | { |
| 2022 | char key; |
| 2023 | if (Win32PeekChar(aTHX_ file, delay, &key)) |
| 2024 | RETVAL = newSVpv(&key, 1)Perl_newSVpv( &key,1); |
| 2025 | else |
| 2026 | RETVAL = newSVsv(&PL_sv_undef)Perl_newSVsv_flags( (&(PL_sv_immortals[1])),2|16); |
| 2027 | } |
| 2028 | #line 2029 "ReadKey.c" |
| 2029 | RETVAL = sv_2mortal(RETVAL)Perl_sv_2mortal( RETVAL); |
| 2030 | ST(0)PL_stack_base[ax + (0)] = RETVAL; |
| 2031 | } |
| 2032 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2033 | } |
| 2034 | |
| 2035 | |
| 2036 | XS_EUPXS(XS_Term__ReadKey_blockoptions)static void XS_Term__ReadKey_blockoptions( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2037 | XS_EUPXS(XS_Term__ReadKey_blockoptions)static void XS_Term__ReadKey_blockoptions( CV* cv __attribute__ ((unused))) |
| 2038 | { |
| 2039 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2040 | if (items != 0) |
| 2041 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
| 2042 | { |
| 2043 | int RETVAL; |
| 2044 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 2045 | |
| 2046 | RETVAL = blockoptions(); |
| 2047 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 2048 | } |
| 2049 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2050 | } |
| 2051 | |
| 2052 | |
| 2053 | XS_EUPXS(XS_Term__ReadKey_termoptions)static void XS_Term__ReadKey_termoptions( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2054 | XS_EUPXS(XS_Term__ReadKey_termoptions)static void XS_Term__ReadKey_termoptions( CV* cv __attribute__ ((unused))) |
| 2055 | { |
| 2056 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2057 | if (items != 0) |
| 2058 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
| 2059 | { |
| 2060 | int RETVAL; |
| 2061 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 2062 | |
| 2063 | RETVAL = termoptions(); |
| 2064 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 2065 | } |
| 2066 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2067 | } |
| 2068 | |
| 2069 | |
| 2070 | XS_EUPXS(XS_Term__ReadKey_termsizeoptions)static void XS_Term__ReadKey_termsizeoptions( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2071 | XS_EUPXS(XS_Term__ReadKey_termsizeoptions)static void XS_Term__ReadKey_termsizeoptions( CV* cv __attribute__ ((unused))) |
| 2072 | { |
| 2073 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2074 | if (items != 0) |
| 2075 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
| 2076 | { |
| 2077 | int RETVAL; |
| 2078 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 2079 | |
| 2080 | RETVAL = termsizeoptions(); |
| 2081 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 2082 | } |
| 2083 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2084 | } |
| 2085 | |
| 2086 | |
| 2087 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeWin32)static void XS_Term__ReadKey_GetTermSizeWin32( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2088 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeWin32)static void XS_Term__ReadKey_GetTermSizeWin32( CV* cv __attribute__ ((unused))) |
| 2089 | { |
| 2090 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2091 | if (items < 0 || items > 1) |
| 2092 | croak_xs_usagePerl_croak_xs_usage(cv, "file=STDIN"); |
| 2093 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
| 2094 | SPsp -= items; |
| 2095 | { |
| 2096 | InputStreamPerlIO * file; |
| 2097 | |
| 2098 | if (items < 1) |
| 2099 | file = STDINPerl_PerlIO_stdin(); |
| 2100 | else { |
| 2101 | file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2102 | ; |
| 2103 | } |
| 2104 | #line 1827 "ReadKey.xs" |
| 2105 | { |
| 2106 | int x,y,xpix,ypix; |
| 2107 | if( GetTermSizeWin32(aTHX_ file,&x,&y,&xpix,&ypix)==0) |
| 2108 | { |
| 2109 | EXTEND(sp, 4)(void)( { (void)0; if (__builtin_expect(((((4) < 0 || PL_stack_max - (sp) < (4))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(4) > sizeof(ssize_t) && ((ssize_t) (4) != (4)) ? -1 : (4))); ((void)sizeof(sp)); } } ); |
| 2110 | PUSHs(sv_2mortal(newSViv((IV)x)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)x)))); |
| 2111 | PUSHs(sv_2mortal(newSViv((IV)y)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)y)))); |
| 2112 | PUSHs(sv_2mortal(newSViv((IV)xpix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)xpix)))); |
| 2113 | PUSHs(sv_2mortal(newSViv((IV)ypix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)ypix)))); |
| 2114 | } |
| 2115 | else |
| 2116 | { |
| 2117 | ST(0)PL_stack_base[ax + (0)] = sv_newmortal()Perl_sv_newmortal(); |
| 2118 | } |
| 2119 | } |
| 2120 | #line 2121 "ReadKey.c" |
| 2121 | PUTBACKPL_stack_sp = sp; |
| 2122 | return; |
| 2123 | } |
| 2124 | } |
| 2125 | |
| 2126 | |
| 2127 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeVIO)static void XS_Term__ReadKey_GetTermSizeVIO( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2128 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeVIO)static void XS_Term__ReadKey_GetTermSizeVIO( CV* cv __attribute__ ((unused))) |
| 2129 | { |
| 2130 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2131 | if (items < 0 || items > 1) |
| 2132 | croak_xs_usagePerl_croak_xs_usage(cv, "file=STDIN"); |
| 2133 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
| 2134 | SPsp -= items; |
| 2135 | { |
| 2136 | InputStreamPerlIO * file; |
| 2137 | |
| 2138 | if (items < 1) |
| 2139 | file = STDINPerl_PerlIO_stdin(); |
| 2140 | else { |
| 2141 | file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2142 | ; |
| 2143 | } |
| 2144 | #line 1847 "ReadKey.xs" |
| 2145 | { |
| 2146 | int x,y,xpix,ypix; |
| 2147 | if( GetTermSizeVIO(aTHX_ file,&x,&y,&xpix,&ypix)==0) |
| 2148 | { |
| 2149 | EXTEND(sp, 4)(void)( { (void)0; if (__builtin_expect(((((4) < 0 || PL_stack_max - (sp) < (4))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(4) > sizeof(ssize_t) && ((ssize_t) (4) != (4)) ? -1 : (4))); ((void)sizeof(sp)); } } ); |
| 2150 | PUSHs(sv_2mortal(newSViv((IV)x)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)x)))); |
| 2151 | PUSHs(sv_2mortal(newSViv((IV)y)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)y)))); |
| 2152 | PUSHs(sv_2mortal(newSViv((IV)xpix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)xpix)))); |
| 2153 | PUSHs(sv_2mortal(newSViv((IV)ypix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)ypix)))); |
| 2154 | } |
| 2155 | else |
| 2156 | { |
| 2157 | ST(0)PL_stack_base[ax + (0)] = sv_newmortal()Perl_sv_newmortal(); |
| 2158 | } |
| 2159 | } |
| 2160 | #line 2161 "ReadKey.c" |
| 2161 | PUTBACKPL_stack_sp = sp; |
| 2162 | return; |
| 2163 | } |
| 2164 | } |
| 2165 | |
| 2166 | |
| 2167 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeGWINSZ)static void XS_Term__ReadKey_GetTermSizeGWINSZ( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2168 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeGWINSZ)static void XS_Term__ReadKey_GetTermSizeGWINSZ( CV* cv __attribute__ ((unused))) |
| 2169 | { |
| 2170 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2171 | if (items < 0 || items > 1) |
| 2172 | croak_xs_usagePerl_croak_xs_usage(cv, "file=STDIN"); |
| 2173 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
| 2174 | SPsp -= items; |
| 2175 | { |
| 2176 | InputStreamPerlIO * file; |
| 2177 | |
| 2178 | if (items < 1) |
| 2179 | file = STDINPerl_PerlIO_stdin(); |
| 2180 | else { |
| 2181 | file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2182 | ; |
| 2183 | } |
| 2184 | #line 1867 "ReadKey.xs" |
| 2185 | { |
| 2186 | int x,y,xpix,ypix; |
| 2187 | if( GetTermSizeGWINSZ(aTHX_ file,&x,&y,&xpix,&ypix)==0) |
| 2188 | { |
| 2189 | EXTEND(sp, 4)(void)( { (void)0; if (__builtin_expect(((((4) < 0 || PL_stack_max - (sp) < (4))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(4) > sizeof(ssize_t) && ((ssize_t) (4) != (4)) ? -1 : (4))); ((void)sizeof(sp)); } } ); |
| 2190 | PUSHs(sv_2mortal(newSViv((IV)x)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)x)))); |
| 2191 | PUSHs(sv_2mortal(newSViv((IV)y)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)y)))); |
| 2192 | PUSHs(sv_2mortal(newSViv((IV)xpix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)xpix)))); |
| 2193 | PUSHs(sv_2mortal(newSViv((IV)ypix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)ypix)))); |
| 2194 | } |
| 2195 | else |
| 2196 | { |
| 2197 | ST(0)PL_stack_base[ax + (0)] = sv_newmortal()Perl_sv_newmortal(); |
| 2198 | } |
| 2199 | } |
| 2200 | #line 2201 "ReadKey.c" |
| 2201 | PUTBACKPL_stack_sp = sp; |
| 2202 | return; |
| 2203 | } |
| 2204 | } |
| 2205 | |
| 2206 | |
| 2207 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeGSIZE)static void XS_Term__ReadKey_GetTermSizeGSIZE( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2208 | XS_EUPXS(XS_Term__ReadKey_GetTermSizeGSIZE)static void XS_Term__ReadKey_GetTermSizeGSIZE( CV* cv __attribute__ ((unused))) |
| 2209 | { |
| 2210 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2211 | if (items < 0 || items > 1) |
| 2212 | croak_xs_usagePerl_croak_xs_usage(cv, "file=STDIN"); |
| 2213 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
| 2214 | SPsp -= items; |
| 2215 | { |
| 2216 | InputStreamPerlIO * file; |
| 2217 | |
| 2218 | if (items < 1) |
| 2219 | file = STDINPerl_PerlIO_stdin(); |
| 2220 | else { |
| 2221 | file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2222 | ; |
| 2223 | } |
| 2224 | #line 1887 "ReadKey.xs" |
| 2225 | { |
| 2226 | int x,y,xpix,ypix; |
| 2227 | if( GetTermSizeGSIZE(aTHX_ file,&x,&y,&xpix,&ypix)==0) |
| 2228 | { |
| 2229 | EXTEND(sp, 4)(void)( { (void)0; if (__builtin_expect(((((4) < 0 || PL_stack_max - (sp) < (4))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(4) > sizeof(ssize_t) && ((ssize_t) (4) != (4)) ? -1 : (4))); ((void)sizeof(sp)); } } ); |
| 2230 | PUSHs(sv_2mortal(newSViv((IV)x)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)x)))); |
| 2231 | PUSHs(sv_2mortal(newSViv((IV)y)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)y)))); |
| 2232 | PUSHs(sv_2mortal(newSViv((IV)xpix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)xpix)))); |
| 2233 | PUSHs(sv_2mortal(newSViv((IV)ypix)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)ypix)))); |
| 2234 | } |
| 2235 | else |
| 2236 | { |
| 2237 | ST(0)PL_stack_base[ax + (0)] = sv_newmortal()Perl_sv_newmortal(); |
| 2238 | } |
| 2239 | } |
| 2240 | #line 2241 "ReadKey.c" |
| 2241 | PUTBACKPL_stack_sp = sp; |
| 2242 | return; |
| 2243 | } |
| 2244 | } |
| 2245 | |
| 2246 | |
| 2247 | XS_EUPXS(XS_Term__ReadKey_SetTerminalSize)static void XS_Term__ReadKey_SetTerminalSize( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2248 | XS_EUPXS(XS_Term__ReadKey_SetTerminalSize)static void XS_Term__ReadKey_SetTerminalSize( CV* cv __attribute__ ((unused))) |
| 2249 | { |
| 2250 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2251 | if (items < 4 || items > 5) |
| 2252 | croak_xs_usagePerl_croak_xs_usage(cv, "width, height, xpix, ypix, file=STDIN"); |
| 2253 | { |
| 2254 | int width = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
| 2255 | ; |
| 2256 | int height = (int)SvIV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (1)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 1)],2)) |
| 2257 | ; |
| 2258 | int xpix = (int)SvIV(ST(2))((((PL_stack_base[ax + (2)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (2)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 2)],2)) |
| 2259 | ; |
| 2260 | int ypix = (int)SvIV(ST(3))((((PL_stack_base[ax + (3)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (3)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 3)],2)) |
| 2261 | ; |
| 2262 | InputStreamPerlIO * file; |
| 2263 | int RETVAL; |
| 2264 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
| 2265 | |
| 2266 | if (items < 5) |
| 2267 | file = STDINPerl_PerlIO_stdin(); |
| 2268 | else { |
| 2269 | file = IoIFP(sv_2io(ST(4)))(Perl_sv_2io( PL_stack_base[ax + (4)]))->sv_u.svu_fp |
| 2270 | ; |
| 2271 | } |
| 2272 | #line 1911 "ReadKey.xs" |
| 2273 | { |
| 2274 | RETVAL=SetTerminalSize(aTHX_ file,width,height,xpix,ypix); |
| 2275 | } |
| 2276 | #line 2277 "ReadKey.c" |
| 2277 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)(void)( { (void)( { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect ((((((targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } ); (*++sp = (targ)); } ); |
| 2278 | } |
| 2279 | XSRETURN(1)(void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); |
| 2280 | } |
| 2281 | |
| 2282 | |
| 2283 | XS_EUPXS(XS_Term__ReadKey_GetSpeed)static void XS_Term__ReadKey_GetSpeed( CV* cv __attribute__(( unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2284 | XS_EUPXS(XS_Term__ReadKey_GetSpeed)static void XS_Term__ReadKey_GetSpeed( CV* cv __attribute__(( unused))) |
| 2285 | { |
| 2286 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2287 | if (items < 0 || items > 1) |
| 2288 | croak_xs_usagePerl_croak_xs_usage(cv, "file=STDIN"); |
| 2289 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
| 2290 | SPsp -= items; |
| 2291 | { |
| 2292 | InputStreamPerlIO * file; |
| 2293 | |
| 2294 | if (items < 1) |
| 2295 | file = STDINPerl_PerlIO_stdin(); |
| 2296 | else { |
| 2297 | file = IoIFP(sv_2io(ST(0)))(Perl_sv_2io( PL_stack_base[ax + (0)]))->sv_u.svu_fp |
| 2298 | ; |
| 2299 | } |
| 2300 | #line 1921 "ReadKey.xs" |
| 2301 | { |
| 2302 | I32 in,out; |
| 2303 | /* |
| 2304 | * experimentally relaxed for |
| 2305 | * https://rt.cpan.org/Ticket/Display.html?id=88050 |
| 2306 | if(items!=0) { |
| 2307 | croak("Usage: Term::ReadKey::GetSpeed()"); |
| 2308 | } |
| 2309 | */ |
| 2310 | if(getspeed(aTHX_ file,&in,&out)) { |
| 2311 | /* Failure */ |
| 2312 | ST( 0)PL_stack_base[ax + (0)] = sv_newmortal()Perl_sv_newmortal(); |
| 2313 | } else { |
| 2314 | EXTEND(sp, 2)(void)( { (void)0; if (__builtin_expect(((((2) < 0 || PL_stack_max - (sp) < (2))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(2) > sizeof(ssize_t) && ((ssize_t) (2) != (2)) ? -1 : (2))); ((void)sizeof(sp)); } } ); |
| 2315 | PUSHs(sv_2mortal(newSViv((IV)in)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)in)))); |
| 2316 | PUSHs(sv_2mortal(newSViv((IV)out)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( (IV)out)))); |
| 2317 | } |
| 2318 | } |
| 2319 | #line 2320 "ReadKey.c" |
| 2320 | PUTBACKPL_stack_sp = sp; |
| 2321 | return; |
| 2322 | } |
| 2323 | } |
| 2324 | |
| 2325 | #ifdef __cplusplus |
| 2326 | extern "C" |
| 2327 | #endif |
| 2328 | XS_EXTERNAL(boot_Term__ReadKey)void boot_Term__ReadKey( CV* cv __attribute__((unused))); /* prototype to pass -Wmissing-prototypes */ |
| 2329 | XS_EXTERNAL(boot_Term__ReadKey)void boot_Term__ReadKey( CV* cv __attribute__((unused))) |
| 2330 | { |
| 2331 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
| 2332 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
| 2333 | #else |
| 2334 | dVARstruct Perl___notused_struct; dXSBOOTARGSXSAPIVERCHKI32 ax = Perl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter )) << 16) | ((sizeof("" "2.38" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "2.38" "")- 1) << 8) | ((((1)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | (((( 1)) ? (_Bool)1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "ReadKey.c", "v" "5" "." "32" "." "0", "2.38"); SV **mark = PL_stack_base + ax; SV **sp = PL_stack_sp; I32 items = (I32 )(sp - mark); |
| 2335 | #endif |
| 2336 | #if (PERL_REVISION5 == 5 && PERL_VERSION32 < 9) |
| 2337 | char* file = __FILE__"ReadKey.c"; |
| 2338 | #else |
| 2339 | const char* file = __FILE__"ReadKey.c"; |
| 2340 | #endif |
| 2341 | |
| 2342 | PERL_UNUSED_VAR(file)((void)sizeof(file)); |
| 2343 | |
| 2344 | PERL_UNUSED_VAR(cv)((void)sizeof(cv)); /* -W */ |
| 2345 | PERL_UNUSED_VAR(items)((void)sizeof(items)); /* -W */ |
| 2346 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
| 2347 | XS_VERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "2.38" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "2.38" "")- 1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | (((( 0)) ? (_Bool)1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "" "")-1))), cv, "ReadKey.c", items , ax, "2.38"); |
| 2348 | # ifdef XS_APIVERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "" "")-1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | (((( 0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | ((((0)) ? (_Bool )1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "ReadKey.c", items, ax, "v" "5" "." "32" "." "0") |
| 2349 | XS_APIVERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "" "")-1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | (((( 0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | ((((0)) ? (_Bool )1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "ReadKey.c", items, ax, "v" "5" "." "32" "." "0"); |
| 2350 | # endif |
| 2351 | #endif |
| 2352 | |
| 2353 | newXS_deffile("Term::ReadKey::selectfile", XS_Term__ReadKey_selectfile)Perl_newXS_deffile( "Term::ReadKey::selectfile",XS_Term__ReadKey_selectfile ); |
| 2354 | newXS_deffile("Term::ReadKey::SetReadMode", XS_Term__ReadKey_SetReadMode)Perl_newXS_deffile( "Term::ReadKey::SetReadMode",XS_Term__ReadKey_SetReadMode ); |
| 2355 | newXS_deffile("Term::ReadKey::setnodelay", XS_Term__ReadKey_setnodelay)Perl_newXS_deffile( "Term::ReadKey::setnodelay",XS_Term__ReadKey_setnodelay ); |
| 2356 | newXS_deffile("Term::ReadKey::pollfile", XS_Term__ReadKey_pollfile)Perl_newXS_deffile( "Term::ReadKey::pollfile",XS_Term__ReadKey_pollfile ); |
| 2357 | newXS_deffile("Term::ReadKey::Win32PeekChar", XS_Term__ReadKey_Win32PeekChar)Perl_newXS_deffile( "Term::ReadKey::Win32PeekChar",XS_Term__ReadKey_Win32PeekChar ); |
| 2358 | newXS_deffile("Term::ReadKey::blockoptions", XS_Term__ReadKey_blockoptions)Perl_newXS_deffile( "Term::ReadKey::blockoptions",XS_Term__ReadKey_blockoptions ); |
| 2359 | newXS_deffile("Term::ReadKey::termoptions", XS_Term__ReadKey_termoptions)Perl_newXS_deffile( "Term::ReadKey::termoptions",XS_Term__ReadKey_termoptions ); |
| 2360 | newXS_deffile("Term::ReadKey::termsizeoptions", XS_Term__ReadKey_termsizeoptions)Perl_newXS_deffile( "Term::ReadKey::termsizeoptions",XS_Term__ReadKey_termsizeoptions ); |
| 2361 | newXS_deffile("Term::ReadKey::GetTermSizeWin32", XS_Term__ReadKey_GetTermSizeWin32)Perl_newXS_deffile( "Term::ReadKey::GetTermSizeWin32",XS_Term__ReadKey_GetTermSizeWin32 ); |
| 2362 | newXS_deffile("Term::ReadKey::GetTermSizeVIO", XS_Term__ReadKey_GetTermSizeVIO)Perl_newXS_deffile( "Term::ReadKey::GetTermSizeVIO",XS_Term__ReadKey_GetTermSizeVIO ); |
| 2363 | newXS_deffile("Term::ReadKey::GetTermSizeGWINSZ", XS_Term__ReadKey_GetTermSizeGWINSZ)Perl_newXS_deffile( "Term::ReadKey::GetTermSizeGWINSZ",XS_Term__ReadKey_GetTermSizeGWINSZ ); |
| 2364 | newXS_deffile("Term::ReadKey::GetTermSizeGSIZE", XS_Term__ReadKey_GetTermSizeGSIZE)Perl_newXS_deffile( "Term::ReadKey::GetTermSizeGSIZE",XS_Term__ReadKey_GetTermSizeGSIZE ); |
| 2365 | newXS_deffile("Term::ReadKey::SetTerminalSize", XS_Term__ReadKey_SetTerminalSize)Perl_newXS_deffile( "Term::ReadKey::SetTerminalSize",XS_Term__ReadKey_SetTerminalSize ); |
| 2366 | newXS_deffile("Term::ReadKey::GetSpeed", XS_Term__ReadKey_GetSpeed)Perl_newXS_deffile( "Term::ReadKey::GetSpeed",XS_Term__ReadKey_GetSpeed ); |
| 2367 | |
| 2368 | /* Initialisation Section */ |
| 2369 | |
| 2370 | #line 1943 "ReadKey.xs" |
| 2371 | newXS("Term::ReadKey::GetControlChars", XS_Term__ReadKey_GetControlChars, file)Perl_newXS( "Term::ReadKey::GetControlChars",XS_Term__ReadKey_GetControlChars ,file); |
| 2372 | newXS("Term::ReadKey::SetControlChars", XS_Term__ReadKey_SetControlChars, file)Perl_newXS( "Term::ReadKey::SetControlChars",XS_Term__ReadKey_SetControlChars ,file); |
| 2373 | filehash=newHV()((HV *)({ void *_p = (Perl_newSV_type( SVt_PVHV)); _p; })); |
| 2374 | modehash=newHV()((HV *)({ void *_p = (Perl_newSV_type( SVt_PVHV)); _p; })); |
| 2375 | |
| 2376 | #line 2377 "ReadKey.c" |
| 2377 | |
| 2378 | /* End of Initialisation Section */ |
| 2379 | |
| 2380 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
| 2381 | # if PERL_VERSION_GE(5, 9, 0)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 9*1000 + 0)) |
| 2382 | if (PL_unitcheckav) |
| 2383 | call_list(PL_scopestack_ix, PL_unitcheckav)Perl_call_list( PL_scopestack_ix,PL_unitcheckav); |
| 2384 | # endif |
| 2385 | XSRETURN_YES(void)( { (PL_stack_base[ax + (0)] = &(PL_sv_immortals[0] ) ); (void)( { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } ); } ); |
| 2386 | #else |
| 2387 | Perl_xs_boot_epilog(aTHX_ ax); |
| 2388 | #endif |
| 2389 | } |
| 2390 |