00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "CommandQueue.h"
00019 #include "VMDApp.h"
00020 #include "MoleculeList.h"
00021 #include "utilities.h"
00022 #include "config.h"
00023 #include <stdlib.h>
00024 #include <tcl.h>
00025
00026 #include "VMDCollab.h"
00027
00028 int text_cmd_collab(ClientData cd, Tcl_Interp *interp, int argc,
00029 const char *argv[]) {
00030 VMDApp *app = (VMDApp *)cd;
00031
00032 if (argc == 4 && !strupncmp(argv[1], "connect", CMDLEN)) {
00033 const char *host = argv[2];
00034 int port;
00035 if (Tcl_GetInt(interp, argv[3], &port) != TCL_OK) return TCL_ERROR;
00036 if (!strcmp(host, Tcl_GetHostName())) {
00037 if (!app->vmdcollab->startserver(port)) {
00038 Tcl_AppendResult(interp, "Failed to start server on port ", argv[3], NULL);
00039 return TCL_ERROR;
00040 }
00041 }
00042 if (!app->vmdcollab->connect(host, port)) {
00043 Tcl_AppendResult(interp, "Failed to connect to vmdcollab at ", host,
00044 "port: ", argv[3], NULL);
00045 return TCL_ERROR;
00046 }
00047 return TCL_OK;
00048 }
00049 if (argc == 2 && !strupncmp(argv[1], "disconnect", CMDLEN)) {
00050 app->vmdcollab->disconnect();
00051 return TCL_OK;
00052 }
00053
00054 Tcl_SetResult(interp, "Usage: vmdcollab [connect <host> <port> | disconnect",
00055 TCL_STATIC);
00056 return TCL_ERROR;
00057 }
00058
00059