1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
|
/*
* tclExtdInt.h
*
* Standard internal include file for Extended Tcl.
*-----------------------------------------------------------------------------
* Copyright 1991-1999 Karl Lehenbauer and Mark Diekhans.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies. Karl Lehenbauer and
* Mark Diekhans make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*-----------------------------------------------------------------------------
* $Id: tclExtdInt.h,v 1.8 2008/12/15 20:00:27 andreas_kupries Exp $
*-----------------------------------------------------------------------------
*/
#ifndef TCLEXTDINT_H
#define TCLEXTDINT_H
#include "tclExtend.h"
/* Keep it before tcl*Port, otherwise a clash in TclpPanic.
*/
#include "tclInt.h"
#if defined(__WIN32__) || defined(_WIN32)
# include "tclXwinPort.h"
#else
# include "tclXunixPort.h"
#endif
/*
* Internal interp flags compatibility - removed in Tcl 8.5 sources.
*/
#ifndef ERR_IN_PROGRESS
#define ERR_IN_PROGRESS 2
#endif
#ifndef ERROR_CODE_SET
#define ERROR_CODE_SET 8
#endif
/*
* Assert macro for use in TclX. Some GCCs libraries are missing a function
* used by their macro, so we define our own.
*/
#ifdef TCLX_DEBUG
# define TclX_Assert(expr) ((expr) ? (void)0 : \
panic("TclX assertion failure: %s:%d \"%s\"\n",\
__FILE__, __LINE__, "expr"))
#else
# define TclX_Assert(expr)
#endif
/*
* Get ranges of integers and longs.
* If no MAXLONG, assume sizeof (long) == sizeof (int).
*/
#ifndef MAXINT
# ifdef INT_MAX /* POSIX */
# define MAXINT INT_MAX
# else
# define BITSPERBYTE 8
# define BITS(type) (BITSPERBYTE * (int)sizeof(type))
# define HIBITI (1 << BITS(int) - 1)
# define MAXINT (~HIBITI)
# endif
#endif
#ifndef MININT
# ifdef INT_MIN /* POSIX */
# define MININT INT_MIN
# else
# define MININT (-MAXINT)-1
# endif
#endif
#ifndef MAXLONG
# ifdef LONG_MAX /* POSIX */
# define MAXLONG LONG_MAX
# else
# define MAXLONG MAXINT
# endif
#endif
/*
* Boolean constants.
*/
#ifndef TRUE
# define TRUE (1)
# define FALSE (0)
#endif
/*
* Defines used by TclX_Get/SetChannelOption. Defines name TCLX_COPT_ are the
* options and the others are the value
*/
#define TCLX_COPT_BLOCKING 1
#define TCLX_MODE_BLOCKING 0
#define TCLX_MODE_NONBLOCKING 1
#define TCLX_COPT_BUFFERING 2
#define TCLX_BUFFERING_FULL 0
#define TCLX_BUFFERING_LINE 1
#define TCLX_BUFFERING_NONE 2
/*
* Two values are always returned for translation, one for the read side and
* one for the write. They are returned masked into one word.
*/
#define TCLX_COPT_TRANSLATION 3
#define TCLX_TRANSLATE_READ_SHIFT 8
#define TCLX_TRANSLATE_READ_MASK 0xFF00
#define TCLX_TRANSLATE_WRITE_MASK 0x00FF
#define TCLX_TRANSLATE_UNSPECIFIED 0 /* For only one direction specified */
#define TCLX_TRANSLATE_AUTO 1
#define TCLX_TRANSLATE_LF 2
#define TCLX_TRANSLATE_BINARY 2 /* same as LF */
#define TCLX_TRANSLATE_CR 3
#define TCLX_TRANSLATE_CRLF 4
#define TCLX_TRANSLATE_PLATFORM 5
/*
* Flags used by chown/chgrp.
*/
#define TCLX_CHOWN 0x1
#define TCLX_CHGRP 0x2
/*
* Structure use to pass file locking information. Parallels the Posix
* struct flock, but use to pass info from the generic code to the system
* dependent code.
*/
typedef struct {
Tcl_Channel channel; /* Channel to lock */
int access; /* TCL_READABLE and/or TCL_WRITABLE */
int block; /* Block if lock is not available */
off_t start; /* Starting offset */
off_t len; /* len = 0 means until end of file */
pid_t pid; /* Lock owner */
short whence; /* Type of start */
int gotLock; /* Succeeded? */
} TclX_FlockInfo;
/*
* Used to return argument messages by most commands.
* FIX: Should be internal, got thought TclX_WrongArgs.
*/
extern char *tclXWrongArgs;
extern Tcl_Obj *tclXWrongArgsObj;
/*
* Macros to do string compares. They pre-check the first character before
* checking of the strings are equal.
*/
#define STREQU(str1, str2) \
(((str1)[0] == (str2)[0]) && (strcmp(str1, str2) == 0))
#define STRNEQU(str1, str2, cnt) \
(((str1)[0] == (str2)[0]) && (strncmp(str1, str2, cnt) == 0))
#define OBJSTREQU(obj1, str1) \
(strcmp(Tcl_GetStringFromObj(obj1, NULL), str1) == 0)
#define OBJSTRNEQU(obj1, str1, cnt) \
(strncmp(Tcl_GetStringFromObj(obj1, NULL), str1, cnt) == 0)
/*
* Macro to do ctype functions with 8 bit character sets.
*/
#define ISSPACE(c) (isspace ((unsigned char) c))
#define ISDIGIT(c) (isdigit ((unsigned char) c))
#define ISLOWER(c) (islower ((unsigned char) c))
/*
* Macro that behaves like strdup, only uses ckalloc. Also macro that does the
* same with a string that might contain zero bytes,
*/
#define ckstrdup(sourceStr) \
(strcpy (ckalloc (strlen (sourceStr) + 1), sourceStr))
#define ckbinstrdup(sourceStr, length) \
((char *) memcpy (ckalloc (length + 1), sourceStr, length + 1))
/*
* Handle hiding of errorLine in 8.6
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)
#define ERRORLINE(interp) ((interp)->errorLine)
#else
#define ERRORLINE(interp) (Tcl_GetErrorLine(interp))
#endif
/*
* Callback type for walking directories.
*/
typedef int
(TclX_WalkDirProc) _ANSI_ARGS_((Tcl_Interp *interp,
char *path,
char *fileName,
int caseSensitive,
ClientData clientData));
/*
* Prototypes for utility procedures.
*/
extern int
TclX_CreateObjCommand _ANSI_ARGS_((Tcl_Interp* interp, char* cmdName,
Tcl_ObjCmdProc *proc, ClientData clientData,
Tcl_CmdDeleteProc *deleteProc, int flags));
extern void *
TclX_StructOffset _ANSI_ARGS_((void *nsPtr, size_t offset,
unsigned int offType));
/*
* Macro to use to fill in "offset" fields of a structure.
* Computes number of bytes from beginning of structure to a given field.
* Based off Tk_Offset
*/
#ifdef offsetof
#define TclX_Offset(type, field) ((size_t) offsetof(type, field))
#else
#define TclX_Offset(type, field) ((size_t) ((char *) &((type *) 0)->field))
#endif
/* Special flags for "TclX_CreateObjCommand".
*/
#define TCLX_CMD_NOPREFIX 1 /* don't define with "exp_" prefix */
#define TCLX_CMD_REDEFINE 2 /* stomp on old commands with same name */
/*
* UTF-8 compatibility handling
*/
#ifndef TCL_UTF_MAX
#define Tcl_WriteChars Tcl_Write
#endif
#define TclX_WriteNL(channel) (Tcl_Write (channel, "\n", 1))
extern int
TclX_StrToOffset _ANSI_ARGS_((CONST char *string,
int base,
off_t *offsetPtr));
int
TclX_GetUnsignedFromObj _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *objPtr,
unsigned *valuePtr));
extern int
TclX_GetChannelOption _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int option,
int *valuePtr));
extern Tcl_Obj *
TclXGetHostInfo _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int remoteHost));
extern Tcl_Channel
TclX_GetOpenChannel _ANSI_ARGS_((Tcl_Interp *interp,
char *handle,
int chanAccess));
extern Tcl_Channel
TclX_GetOpenChannelObj _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *handle,
int chanAccess));
extern int
TclX_GetOffsetFromObj _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *objPtr,
off_t *offsetPtr));
extern int
TclX_RelativeExpr _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *exprPtr,
int stringLen,
int *exprResultPtr));
extern int
TclX_SetChannelOption _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int option,
int value));
extern char *
TclX_JoinPath _ANSI_ARGS_((char *path1,
char *path2,
Tcl_DString *joinedPath));
extern int
TclX_WrongArgs _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *commandNameObj,
char *string));
extern int
TclX_IsNullObj _ANSI_ARGS_((Tcl_Obj *objPtr));
/*
* Definitions required to initialize all extended commands.
*/
extern void
TclX_BsearchInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_ChmodInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_CmdloopInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_DebugInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_DupInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_FcntlInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_FilecmdsInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_FstatInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_FlockInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_FilescanInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_GeneralInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_IdInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_KeyedListInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_LgetsInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_ListInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_MathInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_MsgCatInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_ProcessInit _ANSI_ARGS_((Tcl_Interp *interp));
void
TclX_ProfileInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_RestoreResultErrorInfo _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *saveObjPtr));
extern Tcl_Obj *
TclX_SaveResultErrorInfo _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_SelectInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_SignalInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_StringInit _ANSI_ARGS_((Tcl_Interp *interp));
extern int
TclX_LibraryInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_SocketInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_OsCmdsInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_PlatformCmdsInit _ANSI_ARGS_((Tcl_Interp *interp));
extern void
TclX_ServerInit _ANSI_ARGS_((Tcl_Interp *interp));
/*
* From TclXxxxDup.c
*/
Tcl_Channel
TclXOSDupChannel _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel srcChannel,
int mode,
char *targetChannelId));
Tcl_Channel
TclXOSBindOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
int fileNum));
/*
* from tclXxxxOS.c
*/
extern int
TclXNotAvailableError _ANSI_ARGS_((Tcl_Interp *interp,
char *funcName));
extern int
TclXNotAvailableObjError _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *obj));
extern clock_t
TclXOSTicksToMS _ANSI_ARGS_((clock_t numTicks));
extern int
TclXOSgetpriority _ANSI_ARGS_((Tcl_Interp *interp,
int *priority,
char *funcName));
extern int
TclXOSincrpriority _ANSI_ARGS_((Tcl_Interp *interp,
int priorityIncr,
int *priority,
char *funcName));
extern int
TclXOSpipe _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel *channels));
extern int
TclXOSsetitimer _ANSI_ARGS_((Tcl_Interp *interp,
double *seconds,
char *funcName));
extern void
TclXOSsleep _ANSI_ARGS_((unsigned seconds));
extern void
TclXOSsync _ANSI_ARGS_((void));
extern int
TclXOSfsync _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel));
extern int
TclXOSsystem _ANSI_ARGS_((Tcl_Interp *interp,
char *command,
int *exitCode));
extern int
TclX_OSlink _ANSI_ARGS_((Tcl_Interp *interp,
char *srcPath,
char *destPath,
char *funcName));
extern int
TclX_OSsymlink _ANSI_ARGS_((Tcl_Interp *interp,
char *srcPath,
char *destPath,
char *funcName));
extern void
TclXOSElapsedTime _ANSI_ARGS_((clock_t *realTime,
clock_t *cpuTime));
extern int
TclXOSkill _ANSI_ARGS_((Tcl_Interp *interp,
pid_t pid,
int signal,
char *funcName));
extern int
TclXOSFstat _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
struct stat *statBuf,
int *ttyDev));
extern int
TclXOSSeekable _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int *seekablePtr));
extern int
TclXOSWalkDir _ANSI_ARGS_((Tcl_Interp *interp,
char *path,
int hidden,
TclX_WalkDirProc *callback,
ClientData clientData));
extern int
TclXOSGetFileSize _ANSI_ARGS_((Tcl_Channel channel,
off_t *fileSize));
extern int
TclXOSftruncate _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
off_t newSize,
char *funcName));
extern int
TclXOSfork _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *funcNameObj));
extern int
TclXOSexecl _ANSI_ARGS_((Tcl_Interp *interp,
char *path,
char **argList));
extern int
TclXOSInetAtoN _ANSI_ARGS_((Tcl_Interp *interp,
char *strAddress,
struct in_addr *inAddress));
extern int
TclXOSgetpeername _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
void *sockaddr,
int sockaddrSize));
extern int
TclXOSgetsockname _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
void *sockaddr,
int sockaddrSize));
extern int
TclXOSgetsockopt _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int option,
int *valuePtr));
extern int
TclXOSsetsockopt _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int option,
int value));
extern int
TclXOSchmod _ANSI_ARGS_((Tcl_Interp *interp,
char *fileName,
int mode));
extern int
TclXOSfchmod _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int mode,
char *funcName));
extern int
TclXOSChangeOwnGrpObj _ANSI_ARGS_((Tcl_Interp *interp,
unsigned options,
char *ownerStr,
char *groupStr,
Tcl_Obj *fileList,
char *funcName));
extern int
TclXOSFChangeOwnGrpObj _ANSI_ARGS_((Tcl_Interp *interp,
unsigned options,
char *ownerStr,
char *groupStr,
Tcl_Obj *channelIdList,
char *funcName));
int
TclXOSGetSelectFnum _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int direction,
int *fnumPtr));
int
TclXOSHaveFlock _ANSI_ARGS_((void));
int
TclXOSFlock _ANSI_ARGS_((Tcl_Interp *interp,
TclX_FlockInfo *lockInfoPtr));
int
TclXOSFunlock _ANSI_ARGS_((Tcl_Interp *interp,
TclX_FlockInfo *lockInfoPtr));
int
TclXOSGetAppend _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int *valuePtr));
int
TclXOSSetAppend _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int value));
int
TclXOSGetCloseOnExec _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int *valuePtr));
int
TclXOSSetCloseOnExec _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Channel channel,
int value));
#endif
|