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
|
// Copyright (C) 1999-2020
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
using namespace std;
#include <tcl.h>
#include "tclfitsy.h"
extern "C" {
int Tclfitsy_Init(Tcl_Interp* interp);
int TclfitsyCmd(ClientData data, Tcl_Interp *interp, int argc,
const char* argv[]);
}
TclFITSY* fitsy=NULL;
int Tclfitsy_Init(Tcl_Interp* interp) {
if (Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0) == NULL)
return TCL_ERROR;
Tcl_CreateCommand(interp, "fitsy", TclfitsyCmd,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK)
return TCL_ERROR;
fitsy = new TclFITSY(interp);
if (fitsy)
return TCL_OK;
else
return TCL_ERROR;
}
int TclfitsyCmd(ClientData data, Tcl_Interp *interp, int argc, const char* argv[])
{
if (argc>=2) {
if (!strncmp(argv[1], "hello", 4))
return fitsy->hello(argc, argv);
else {
Tcl_AppendResult(interp, "fitsy: unknown command: ", argv[1], NULL);
return TCL_ERROR;
}
}
else {
Tcl_AppendResult(interp, "usage: fitsy ?hello?", NULL);
return TCL_ERROR;
}
}
TclFITSY::TclFITSY(Tcl_Interp* interp)
{
interp_ = interp;
}
TclFITSY::~TclFITSY()
{
}
int TclFITSY::hello(int argc, const char* argv[])
{
cout << "world" << endl;
return TCL_OK;
}
|