Diff
Not logged in

Differences From Artifact [5e793bcdfb]:

To Artifact [bbab874571]:


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.13.4.40 2010/12/06 15:03:03 dgp Exp $
 * RCS: @(#) $Id: tclBinary.c,v 1.13.4.41 2010/12/30 14:42:02 dgp Exp $
 */

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

#include <math.h>

686
687
688
689
690
691
692




















693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717



















718
719
720
721
722
723
724







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







 *	A command token for the new command.
 *
 * Side effects:
 *	Creates a new binary command as a mapped ensemble.
 *
 *----------------------------------------------------------------------
 */

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

Tcl_Command
TclInitBinaryCmd(
    Tcl_Interp *interp)
{
    const EnsembleImplMap binaryMap[] = {
	{ "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 }
    };
    const EnsembleImplMap decodeMap[] = {
	{ "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;
}