-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipherInit.c
More file actions
98 lines (82 loc) · 3.26 KB
/
Copy pathcipherInit.c
File metadata and controls
98 lines (82 loc) · 3.26 KB
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
/*
* cipherInit.c --
*
* This file contains the _Init routine for the Tcl package
* mechanism.
*
* Copyright (c) 1995-2000 Michael Thomas <wart@kobold.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <tcl.h>
#include <cipher.h>
#include <stat.h>
#include <perm.h>
#include <wordtree.h>
#include <score.h>
#include <hillclimb.h>
#include <keygen.h>
#include <crithmCmd.h>
#include <wordtreeCmd.h>
#include <morseCommand.h>
#include <cipherDebug.h>
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
EXTERN int Cipher_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Dictionary_Init _ANSI_ARGS_((Tcl_Interp *interp));
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
extern void InitCiphertypes(void);
extern ScoreItem *defaultScoreItem;
int
Cipher_Init(Tcl_Interp *interp)
{
CrithmInfo *cInfo;
TreeNode **tInfo;
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
return TCL_ERROR;
}
tInfo = (TreeNode **)ckalloc(sizeof(TreeNode *));
*tInfo = createWordTreeRoot();
cInfo = (CrithmInfo *)ckalloc(sizeof(CrithmInfo));
cInfo->base = 0;
cInfo->letterValue = (int *)NULL;
cInfo->iterationCmd = (char *)NULL;
Tcl_CreateCommand(interp, "cipher", CipherCmd, (ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "stat", StatCmd, (ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "permute", PermCmd, (ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "key", KeygenCmd, (ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "morse", MorseCmd, (ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "crithm", CrithmCmd, (ClientData)cInfo,
CrithmDelete);
Tcl_CreateCommand(interp, "wordtree", WordtreeCmd, (ClientData) tInfo,
WordtreeDelete);
InitCiphertypes();
if (InitScoreTypes(interp) != TCL_OK) {
return TCL_ERROR;
}
Tcl_CreateCommand(interp, "score", ScoreCmd, (ClientData)NULL, DeleteScoreCommand);
Tcl_CreateObjCommand(interp, "Hillclimb::generateSwapNeighborKeys", HillclimbGenerateSwapNeighborKeysObjCmd, (ClientData)NULL, NULL);
Tcl_CreateObjCommand(interp, "Hillclimb::swapKeysquareKey", HillclimbKeysquareSwapNeighborKeysObjCmd, (ClientData)NULL, NULL);
Tcl_CreateObjCommand(interp, "Hillclimb::swapAristocratKey", HillclimbAristocratSwapNeighborKeysObjCmd, (ClientData)NULL, NULL);
Tcl_CreateObjCommand(interp, "Hillclimb::randomizeList", HillclimbRandomizeListObjCmd, (ClientData)NULL, NULL);
Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION);
if (Dictionary_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
Tcl_SetResult(interp, PACKAGE_VERSION, TCL_STATIC);
return TCL_OK;
}