Diff
Not logged in

Differences From Artifact [4300734207]:

To Artifact [3e89f04691]:


1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20












-
+







/*
 * tclBinary.c --
 *
 *	This file contains the implementation of the "binary" Tcl built-in
 *	command and the Tcl binary data object.
 *
 * Copyright (c) 1997 by Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclBinary.c,v 1.55 2009/07/16 21:24:39 dgp Exp $
 * RCS: @(#) $Id: tclBinary.c,v 1.56 2009/11/18 21:59:51 nijtmans Exp $
 */

#include "tclInt.h"
#include "tommath.h"

#include <math.h>

468
469
470
471
472
473
474

475
476
477
478
479
480
481
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482







+







 */

static void
FreeByteArrayInternalRep(
    Tcl_Obj *objPtr)		/* Object with internal rep to free. */
{
    ckfree((char *) GET_BYTEARRAY(objPtr));
    objPtr->typePtr = NULL;
}

/*
 *----------------------------------------------------------------------
 *
 * DupByteArrayInternalRep --
 *
591
592
593
594
595
596
597
598
599
600
601
602





603
604
605
606
607
608

609
610
611
612
613
614




615
616
617
618
619
620
621
592
593
594
595
596
597
598





599
600
601
602
603
604
605
606
607
608

609
610
611




612
613
614
615
616
617
618
619
620
621
622







-
-
-
-
-
+
+
+
+
+





-
+


-
-
-
-
+
+
+
+







 */

Tcl_Command
TclInitBinaryCmd(
    Tcl_Interp *interp)
{
    const EnsembleImplMap binaryMap[] = {
	{ "format", BinaryFormatCmd, NULL },
	{ "scan",   BinaryScanCmd,   NULL },
	{ "encode", NULL,	     NULL },
	{ "decode", NULL,	     NULL },
	{ NULL, NULL, NULL }
	{ "format", BinaryFormatCmd, NULL, NULL ,NULL },
	{ "scan",   BinaryScanCmd, NULL,NULL ,NULL },
	{ "encode", NULL, NULL, NULL, NULL },
	{ "decode", NULL, NULL, NULL, NULL },
	{ NULL, NULL, NULL, NULL, NULL }
    };
    const EnsembleImplMap encodeMap[] = {
	{ "hex",      BinaryEncodeHex, NULL, NULL, (ClientData)HexDigits },
	{ "uuencode", BinaryEncode64,  NULL, NULL, (ClientData)UueDigits },
	{ "base64",   BinaryEncode64,  NULL, NULL, (ClientData)B64Digits },
	{ NULL, NULL, NULL }
	{ NULL, NULL, NULL, NULL, NULL }
    };
    const EnsembleImplMap decodeMap[] = {
	{ "hex",      BinaryDecodeHex, NULL },
	{ "uuencode", BinaryDecodeUu,  NULL },
	{ "base64",   BinaryDecode64,  NULL },
	{ NULL, NULL, NULL }
	{ "hex",      BinaryDecodeHex, NULL, NULL, NULL },
	{ "uuencode", BinaryDecodeUu,  NULL, NULL, NULL },
	{ "base64",   BinaryDecode64,  NULL, NULL, NULL },
	{ NULL, NULL, NULL, NULL, NULL }
    };
    Tcl_Command binaryEnsemble;

    binaryEnsemble = TclMakeEnsemble(interp, "binary", binaryMap);
    TclMakeEnsemble(interp, "binary encode", encodeMap);
    TclMakeEnsemble(interp, "binary decode", decodeMap);
    return binaryEnsemble;