http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cli_feature_spec.txt ---------------------------------------------------------------------- diff --git a/mgmt/cli/cli_feature_spec.txt b/mgmt/cli/cli_feature_spec.txt deleted file mode 100644 index f6e7c9d..0000000 --- a/mgmt/cli/cli_feature_spec.txt +++ /dev/null @@ -1,230 +0,0 @@ -traffic_shell "a CLI for Traffic Server" - -========== -Motivation -========== - -The purpose of traffic_shell (command line interface, or CLI) is to -improve the usability of Traffic Server in both OEM and direct sales -environments. The CLI is a powerful, easy to use tool which can be -used to configure and monitor individual Traffic Server machines. Our -goal is to make configuring Traffic Server as easy as configuring -other network devices such as routers and switches. - -The CLI accepts commands in a unix shell-like fashion. Commands are -organized in an easy to navigate hierarchy. The CLI supports basic -command completion, command history, and context sensitive help. This -format was designed to be familiar to network engineers everywhere, -and also to be easier to document, maintain, and add features. - -============ -Architecture -============ - -The CLI is a standalone executable which is part of a Traffic Server -installation on the Linux platform. The CLI supports the following -operation modes. Note that a "user" can be a person, a script, or some -other mechanism for remote control of network devices via command line -interface. - -- Interactive mode: -"traffic_shell" -Similar to unix shell, the CLI can be the login shell for -administrators. The user types command at a prompt, and the CLI -processes the command and displays the result. While in interactive -mode, the user can execute a file which contains a list of commands. - --- Execute file mode: -"traffic_shell -f filename" where file contains a list of CLI commands. -CLI runs commands and sends results to stdout. - -The CLI interface is implemented in a combination of TCL and C++. -From the traffic_shell prompt, users can access the scripting -capabilities of TCL. - -The shell and parsing functionality will utilize TCL. Commands -themselves will be written in C++. The CLI uses the traffic_manager -Management API to make Traffic Server configuration changes. - -The overall CLI architecture is as follows: - -- traffic_shell --------------------------- -| | -| --------------------------------------- | -| Shell and parser implemented in TCL/C++ | -| --------------------------------------- | -| ^ | -| ----------------|------------------- | -| CLI commands implemented in C++ | -| ------------------------------------ | -| ^ | -| --------|---------- | -| Management API (.a) | -| ------------------- | -| | -------------------------------------------- - -================= -Quick Start Guide -================= - -There are two basic commands categories, "show" and "config". Show -commands are used to view configuration information and statistics. -Config commands are used to configure Traffic Server. To use the -config commands, you must first enter "enable mode" by using the -enable command, which asks for the admin password (same password as -WebUI). - -At any point you can access context sensitive help by specifying "-h" -or "-help" after a command name. The following is a list of commands -and options: - -------------- -Show Commands -------------- - -show Show command -show:status Proxy status -show:version Version information -show:security Security information -show:http HTTP protocol configuration -show:icp [peer] ICP protocol configuration -show:proxy Proxy configuration -show:cache [rules|storage] Cache configuration -show:virtual-ip Virtual-ip configuration -show:hostdb Host database configuration -show:dns-resolver DNS resolver configuration -show:logging Logging configuration -show:ssl SSL configuration -show:parent Parent configuration -show:remap Remap configuration -show:socks SOCKS configuration -show:port-tunnels Port tunnels configuration -show:scheduled-update Scheduled update configuration -show:proxy-stats Proxy statistics -show:http-trans-stats HTTP transaction statistics -show:http-stats HTTP statistics -show:icp-stats ICP statistics -show:cache-stats Cache statistics -show:hostdb-stats Host database statistics -show:dns-stats DNS statistics -show:logging-stats Logging statistics -show:alarms Show active alarms - ---------------- -Config commands ---------------- - -config:get <variable> Display a variable value -config:set <variable> <value> Set variable to specified value -config:name <string> Set proxy name <string> -config:start Start proxy software -config:stop Stop proxy software - -config:ssl <on | off> -config:ssl ports <int> - -config:parent <on | off> -config:parent name <parent> -config:parent rules <url> - -config:remap <url> Update remap configuration file <url> - -config:clock date <mm/dd/yyyy> -config:clock time <hh:mm:ss> -config:clock timezone <number from list> - -config:security <ip-allow | mgmt-allow | admin> <url-config-file> -config:security password - -config:http <on | off> -config:http <keep-alive-timeout-in | keep-alive-timeout-out> <seconds> -config:http <inactive-timeout-in | inactive-timeout-out> <seconds> -config:http <active-timeout-in | active-timeout-out> <seconds> -config:http <remove-from | remove-referer> <on | off> -config:http <remove-user | remove-cookie> <on | off> -config:http <remove-header> <string> -config:http <insert-ip | remove-ip> <on | off> -config:http proxy <fwd | rev | fwd-rev> - -config:icp mode <disabled | receive | send-receive> -config:icp port <int> -config:icp multicast <on | off> -config:icp query-timeout <seconds> -config:icp peers <url-config-file> - -config:port-tunnels server-other-ports <port> - -config:scheduled-update mode <on | off> -config:scheduled-update retry count <int> interval <int> -config:scheduled-update max-concurrent <int> -config:scheduled-update force-immediate <on | off> -config:scheduled-update rules <url-config-file> - -config:socks <on | off> -config:socks server-ip <x.x.x.x> -config:socks port <int> -config:socks timeout <seconds> - - -config:cache <on | off> -config:cache <http> <on | off> -config:cache ignore-bypass <on | off> -config:cache <max-object-size | max-alternates> <int> -config:cache file <url-config-file> -config:cache freshness verify <when-expired | no-date | always | never> -config:cache freshness minimum <explicit | last-modified | nothing> -config:cache freshness no-expire-limit greater-than <sec> less-than <sec> -config:cache <dynamic | alternates> <on | off> -config:cache vary <text | images | other> <string> -config:cache vary cookies <none | all | non-text> - - -config:hostdb <lookup-timeout | foreground-timeout> <seconds> -config:hostdb <background-timeout | invalid-host-timeout> <seconds> -config:hostdb <re-dns-on-reload> <on | off>, -Configure Host Database - -config:logging event <enabled | trans-only | error-only | disabled> -config:logging mgmt-directory <string> -config:logging <space-limit | space-headroom> <megabytes> -config:logging collation-status <inactive | host | send-standard | - send-custom | send-all> -config:logging collation-host <string> -config:logging collation secret <string> tagged <on | off> orphan-limit <int> -config:logging format <squid | netscape-common | netscape-ext | netscape-ext2> - type <ascii | binary> file <string> header <string> -config:logging splitting <icp | http> <on | off> -config:logging custom <on | off> format <traditional | xml> -config:logging rolling <on | off> offset <hour> interval <hours> - auto-delete <on | off>, - -config:dns resolve-timeout <seconds> -config:dns retries <int>, - -config:virtual-ip <on | off> -config:virtual-ip add <x.x.x.x> device <string> sub-intf <int> -config:virtual-ip delete <virtual ip number>, - -config:network ip-address <x.x.x.x> (Linux only) -config:network hostname <string> (Linux only) -config:network netmask <x.x.x.x> (Linux only) -config:network domainname <string> (Linux only) -config:network dns-ip <x.x.x.x> (Linux only) -config:network defaultrouter <x.x.x.x> (Linux only) - -config:alarms resolve-name <string> -config:alarms resolve-number <int> -config:alarms resolve-all -config:alarms notify <on | off>, - ----------------- -Utility commands ----------------- - -enable Enable Restricted Commands - -disable Disable Restricted Commands - -debug <on|off> Turn debugging print statements on/off -
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/commandOptions.h ---------------------------------------------------------------------- diff --git a/mgmt/cli/commandOptions.h b/mgmt/cli/commandOptions.h deleted file mode 100644 index 1f8f9c6..0000000 --- a/mgmt/cli/commandOptions.h +++ /dev/null @@ -1,47 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* commandOptions.h - * these are valid options for createArgument - * - * - */ - -#ifndef COMMAND_OPTIONS -#define COMMAND_OPTIONS - - -#define CLI_ARGV_CONSTANT_OPTIONAL 0x401 -#define CLI_ARGV_INT_OPTIONAL 0x402 -#define CLI_ARGV_STRING_OPTIONAL 0x404 -#define CLI_ARGV_FLOAT_OPTIONAL 0x408 -#define CLI_ARGV_FUNC_OPTIONAL 0x410 -#define CLI_ARGV_HELP_OPTIONAL 0x420 -#define CLI_ARGV_CONST_OPTION_OPTIONAL 0x440 -#define CLI_ARGV_CONSTANT_REQUIRED 0x801 -#define CLI_ARGV_INT_REQUIRED 0x802 -#define CLI_ARGV_STRING_REQUIRED 0x804 -#define CLI_ARGV_FLOAT_REQUIRED 0x808 - - -#endif /*COMMAND_OPTIONS */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createArgument.cc ---------------------------------------------------------------------- diff --git a/mgmt/cli/createArgument.cc b/mgmt/cli/createArgument.cc deleted file mode 100644 index e2f4e1b..0000000 --- a/mgmt/cli/createArgument.cc +++ /dev/null @@ -1,387 +0,0 @@ -/** @file - - This file provides basic create Argument defintion, for any new arguments. - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - -#include <stdlib.h> -#include <tcl.h> -#include <string.h> - -#include "createArgument.h" -#include "definitions.h" -#include "commandOptions.h" -#include "hashtable.h" -#include "ink_string.h" - -#define totalArguments 30 /* This is arbitary value */ -#define NEG_BOUND -10 -#define POS_BOUND 10 - -static cli_ArgvInfo *ArgvTable; -static cli_ArgvInfo *org_ArgvTable; -extern Tcl_Interp *interp; - -cli_ArgvInfo *cliGetArgvInfo(); -cli_ArgvInfo *cliGetOrgArgvInfo(); -int getCommandOption(int commandoption, int *arg_type, int *arg_option); -char **findRequired(cli_ArgvInfo * argtable); -extern void setReqdArgs(char **required_args); - -int -createArgument(const char *argument, int position, int commandoption, - char *range, int argumentRef, const char *helpString, char *defValue) -{ - int arg_type = 0; - int arg_option = 0; - char **reqd_args; - cli_ArgvInfo *aCliArgvTable = cliGetArgvInfo(); - - size_t key_len = sizeof(char) * (strlen(argument) + 1); - aCliArgvTable->key = (char *) ckalloc(key_len); - ink_strlcpy(aCliArgvTable->key, argument, key_len); - - aCliArgvTable->position = position; - - getCommandOption(commandoption, &arg_type, &arg_option); - aCliArgvTable->type = arg_type; - if (arg_option != 0) { - aCliArgvTable->option = arg_option; - } - - - aCliArgvTable->arg_ref = argumentRef; - - if (range != NULL) { - aCliArgvTable->range_set = true; - if (aCliArgvTable->type == CLI_ARGV_INT || aCliArgvTable->type == CLI_ARGV_OPTION_INT_VALUE) { - getIntRange(range, &(aCliArgvTable->l_range.int_r1), &(aCliArgvTable->u_range.int_r2)); - } - if (aCliArgvTable->type == CLI_ARGV_FLOAT || aCliArgvTable->type == CLI_ARGV_OPTION_FLOAT_VALUE) { - getFloatRange(range, &(aCliArgvTable->l_range.float_r1), &(aCliArgvTable->u_range.float_r2)); - } - - } - - if (defValue != NULL) { - size_t def_len = sizeof(char) * (strlen(defValue) + 1); - aCliArgvTable->def = (char *) ckalloc(def_len); - ink_strlcpy(aCliArgvTable->def, defValue, def_len); - } - - - if (helpString != NULL) { - size_t help_len = sizeof(char) * (strlen(helpString) + 1); - aCliArgvTable->help = (char *) ckalloc(help_len); - ink_strlcpy(aCliArgvTable->help, helpString, help_len); - } - - reqd_args = findRequired(cliGetOrgArgvInfo()); - setReqdArgs(reqd_args); - return TCL_OK; -} - - -cli_ArgvInfo * -cliGetArgvInfo() -{ - cli_ArgvInfo *temp_ArgvTable = ArgvTable; - ArgvTable++; - return temp_ArgvTable; -} - -int -cliSetArgvInfo(cli_ArgvInfo * argtable) -{ - ArgvTable = argtable; - org_ArgvTable = argtable; - return TCL_OK; -} - -cli_ArgvInfo * -cliGetOrgArgvInfo() -{ - return org_ArgvTable; -} - - -char ** -findRequired(cli_ArgvInfo * argtable) -{ - char **args; - cli_ArgvInfo *infoPtr; - int count_required = 0, i = 0; - for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) { - if (infoPtr->option == CLI_ARGV_REQUIRED) { - count_required++; - } - } - if (count_required == 0) - return (char **) NULL; - - args = (char **) ckalloc(sizeof(char *) * (count_required + 1)); - for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) { - if (infoPtr->option == CLI_ARGV_REQUIRED) { - - args[i] = ats_strdup(infoPtr->key); - i++; - } - } - args[i] = NULL; - return args; -} - - -int -getCommandOption(int commandoption, int *arg_type, int *arg_option) -{ - switch (commandoption) { - case CLI_ARGV_CONSTANT: - *arg_type = CLI_ARGV_CONSTANT; - *arg_option = 0; - break; - case CLI_ARGV_CONST_OPTION: - *arg_type = CLI_ARGV_CONST_OPTION; - *arg_option = 0; - break; - case CLI_ARGV_INT: - *arg_type = CLI_ARGV_INT; - *arg_option = 0; - break; - case CLI_ARGV_STRING: - *arg_type = CLI_ARGV_STRING; - *arg_option = 0; - break; - case CLI_ARGV_FLOAT: - *arg_type = CLI_ARGV_FLOAT; - *arg_option = 0; - break; - case CLI_ARGV_OPTION_NAME_VALUE: - *arg_type = CLI_ARGV_OPTION_NAME_VALUE; - *arg_option = 0; - break; - case CLI_ARGV_OPTION_FLOAT_VALUE: - *arg_type = CLI_ARGV_OPTION_FLOAT_VALUE; - *arg_option = 0; - break; - case CLI_ARGV_OPTION_INT_VALUE: - *arg_type = CLI_ARGV_OPTION_INT_VALUE; - *arg_option = 0; - break; - case CLI_ARGV_CONSTANT_OPTIONAL: - *arg_type = CLI_ARGV_CONSTANT; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_INT_OPTIONAL: - *arg_type = CLI_ARGV_INT; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_STRING_OPTIONAL: - *arg_type = CLI_ARGV_STRING; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_FLOAT_OPTIONAL: - *arg_type = CLI_ARGV_FLOAT; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_FUNC_OPTIONAL: - *arg_type = CLI_ARGV_FUNC; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_HELP_OPTIONAL: - *arg_type = CLI_ARGV_HELP; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_CONST_OPTION_OPTIONAL: - *arg_type = CLI_ARGV_CONST_OPTION; - *arg_option = CLI_ARGV_OPTIONAL; - break; - case CLI_ARGV_CONSTANT_REQUIRED: - *arg_type = CLI_ARGV_CONSTANT; - *arg_option = CLI_ARGV_REQUIRED; - break; - case CLI_ARGV_INT_REQUIRED: - *arg_type = CLI_ARGV_INT; - *arg_option = CLI_ARGV_REQUIRED; - break; - case CLI_ARGV_STRING_REQUIRED: - *arg_type = CLI_ARGV_STRING; - *arg_option = CLI_ARGV_REQUIRED; - break; - case CLI_ARGV_FLOAT_REQUIRED: - *arg_type = CLI_ARGV_FLOAT; - *arg_option = CLI_ARGV_REQUIRED; - break; - default: - *arg_type = 0; - *arg_option = 0; - break; - } - return TCL_OK; -} - -int -getIntRange(char *range, int *r1, int *r2) -{ - char *range_str; - char *str; - int bound, i = 0, len; - char *buf; - char *endPtr; - - buf = (char *) ckalloc(sizeof(char) * 256); - range_str = ats_strdup(range); - len = strlen(range_str); - range_str[len] = 0; - str = range_str; - while (*str != 0) { - if (*str == '-') { - bound = NEG_BOUND; - str++; - } - - else if (*str == '+') { - bound = POS_BOUND; - str++; - } else { - Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - } - if (*str == 'r') { - str++; - i = 0; - for (; (*str != '+'); str++) { - if (*str == 0) - break; - buf[i] = *str; - i++; - } - buf[i] = 0; - if (bound == NEG_BOUND) { - *r1 = strtol(buf, &endPtr, 0); - if ((endPtr == buf) || (*endPtr != 0)) { - Tcl_AppendResult(interp, "negative range is not correct\n", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - - } - } else if (bound == POS_BOUND) { - *r2 = strtol(buf, &endPtr, 0); - if ((endPtr == buf) || (*endPtr != 0)) { - Tcl_AppendResult(interp, "positive range is not correct\n", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - - } - } - - } else { - Tcl_AppendResult(interp, "range not specified correctly\n"); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - } - - - } - ckfree(buf); - ckfree(range_str); - return TCL_OK; -} - - -int -getFloatRange(char *range, float *r1, float *r2) -{ - char *range_str; - char *str; - int bound, i = 0, len; - char *buf; - char *endPtr; - - buf = (char *) ckalloc(sizeof(char) * 256); - range_str = ats_strdup(range); - len = strlen(range_str); - range_str[len] = 0; - str = range_str; - while (*str != 0) { - if (*str == '-') { - bound = NEG_BOUND; - str++; - } - - else if (*str == '+') { - bound = POS_BOUND; - str++; - } else { - Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - } - if (*str == 'r') { - str++; - i = 0; - for (; (*str != '+'); str++) { - if (*str == 0) - break; - buf[i] = *str; - i++; - } - buf[i] = 0; - if (bound == NEG_BOUND) { - // Solaris is messed up, in that strtod() does not honor C99/SUSv3 mode. - *r1 = strtold(buf, &endPtr); - if ((endPtr == buf) || (*endPtr != 0)) { - Tcl_AppendResult(interp, "negative range is not correct", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - - } - } else if (bound == POS_BOUND) { - *r2 = strtold(buf, &endPtr); - if ((endPtr == buf) || (*endPtr != 0)) { - Tcl_AppendResult(interp, "positive range is not correct", (char *) NULL); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - - } - } - - } else { - Tcl_AppendResult(interp, "range not specified correctly"); - ckfree(buf); - ckfree(range_str); - return TCL_ERROR; - } - - - } - ckfree(buf); - ckfree(range_str); - return TCL_OK; -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createArgument.h ---------------------------------------------------------------------- diff --git a/mgmt/cli/createArgument.h b/mgmt/cli/createArgument.h deleted file mode 100644 index 4681c3a..0000000 --- a/mgmt/cli/createArgument.h +++ /dev/null @@ -1,119 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* - * createArgument.h -- - * - * - * This file provides basic create Argument declartion, - * for any new arguments. - * - * - * - * - * Dated : 12/11/2000. - */ - -#ifndef CREATE_ARGUMENT -#define CREATE_ARGUMENT - -#include <commandOptions.h> - -typedef union arg_value -{ /* Value of the argument can be - integr or float or string */ - char *arg_string; - int arg_int; - float arg_float; -} arg_value; - -typedef union lower_range -{ - int int_r1; - float float_r1; -} lower_range; - -typedef union upper_range -{ - int int_r2; - float float_r2; -} upper_range; - -typedef struct cli_ArgvInfo -{ - char *key; /* The key string that flags - the option in the argv array */ - int position; /* indicates position of the - argument in command */ - int type; /* Indicates argument type; */ - int arg_ref; /* User creates an integer to - refer to this argument */ - lower_range l_range; /* lower_range */ - upper_range u_range; /* upper_range */ - bool range_set; /* flag which indicates if range is set by user */ - int option; /* flag which indicates if argument is optional or required */ - char *help; /* Documentation message describing this option. */ - char *def; /* default value */ - -} cli_ArgvInfo; - - -typedef struct cli_parsedArgInfo -{ - int parsed_args; - char *data; - int arg_int; - float arg_float; - char *arg_string; - char *arg_usage; -} cli_parsedArgInfo; - - -typedef struct cli_cmdCallbackInfo -{ - const char *command_usage; - cli_parsedArgInfo *parsedArgTable; - void *userdata; -} cli_cmdCallbackInfo; - - -typedef struct cli_CommandInfo -{ - const char *command_name; /* command name */ - cli_ArgvInfo *argtable; /* pointer to argv table */ - char **reqd_args; /* holds reference no for - required arguments */ - cli_parsedArgInfo *parsedArgTable; /* holds parsed arguments */ - char *helpString; - -} cli_CommandInfo; - -extern int createArgument(const char *argument, int position, int commandoption, - char *range, int argumentRef, const char *helpString, char *defValue); - - - -extern int getIntRange(char *range, int *r1, int *r2); -extern int getFloatRange(char *range, float *r1, float *r2); - -#endif /*CREATE_ARGUMENT */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createCommand.cc ---------------------------------------------------------------------- diff --git a/mgmt/cli/createCommand.cc b/mgmt/cli/createCommand.cc deleted file mode 100644 index d1dc5e4..0000000 --- a/mgmt/cli/createCommand.cc +++ /dev/null @@ -1,166 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* - * createCommand.c -- - * - * - * This file provides basic create command definition, - * for any new commands. - * - * It overrides any existing commands with the new command - * without any warning - * - * - * Dated : 12/11/2000. - */ - -#include <tcl.h> -#include <stdlib.h> -#include "definitions.h" -#include "createArgument.h" -#include "hashtable.h" - -static char **reqd_args; -char **getReqdArgs(); - -extern Tcl_Interp *interp; -/* This is the only interp for the whole application */ - -extern cli_ArgvInfo *cliGetArgvInfo(); -extern int cliSetArgvInfo(cli_ArgvInfo * argtable); - - - -int -createCommand(const char *cmdName, Tcl_CmdProc cmdFuncPtr, - createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpString) -{ - /* No code to support threads for Tcl */ - - /* If required add thread Specific code - here - Hint: Use Tcl_GetThreadData - - */ - int isSafe, i; - cli_ArgvInfo *argtable; - char **required_args; - cli_cmdCallbackInfo *cmdCallbackInfo; - - if ((cmdName == NULL) || (cmdFuncPtr == NULL) || (helpString == NULL)) { - printf("Error: New command with NULL string or object procs or with no help string provided\n"); - return TCL_ERROR; - } - - - /* Used for creating internal commands */ - isSafe = Tcl_IsSafe(interp); - - argtable = (cli_ArgvInfo *) ckalloc(sizeof(cli_ArgvInfo) * 100); - for (i = 0; i < 100; i++) { - argtable[i].key = (char *) NULL; - argtable[i].type = CLI_ARGV_END; - argtable[i].range_set = false; - argtable[i].option = CLI_ARGV_OPTIONAL; - argtable[i].def = (char *) NULL; - argtable[i].help = (char *) NULL; - - } - - cmdCallbackInfo = (cli_cmdCallbackInfo *) ckalloc(sizeof(cli_cmdCallbackInfo)); - - cmdCallbackInfo->command_usage = usage; - - cmdCallbackInfo->parsedArgTable = (cli_parsedArgInfo *) ckalloc(sizeof(cli_parsedArgInfo) * 100); - for (i = 0; i < 100; i++) { - cmdCallbackInfo->parsedArgTable[i].parsed_args = CLI_PARSED_ARGV_END; - cmdCallbackInfo->parsedArgTable[i].data = (char *) NULL; - cmdCallbackInfo->parsedArgTable[i].arg_string = (char *) NULL; - cmdCallbackInfo->parsedArgTable[i].arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE; - cmdCallbackInfo->parsedArgTable[i].arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE; - cmdCallbackInfo->parsedArgTable[i].arg_usage = (char *) NULL; - - } - - cmdCallbackInfo->userdata = (void *) NULL; - - /* Create a new command with cmdName */ - Tcl_CreateCommand(interp, cmdName, cmdFuncPtr, (ClientData) cmdCallbackInfo, - (void (*)_ANSI_ARGS_((ClientData))) NULL); - - cliSetArgvInfo(argtable); - if (isSafe) { - if (cmdScope == CLI_COMMAND_INTERNAL) { - Tcl_HideCommand(interp, cmdName, cmdName); - } - } - - - if (argvFuncPtr != NULL) { - (*argvFuncPtr) (); - /* Now call create Arguments so that we can fill the necessary - data structure and call parseArgv to parse the arguments. - */ - } - - required_args = getReqdArgs(); - cliAddCommandtoHashtable(cmdName, argtable, required_args, cmdCallbackInfo->parsedArgTable, helpString); - - - return TCL_OK; - -} - -void -setReqdArgs(char **required_args) -{ - reqd_args = required_args; -} - -char ** -getReqdArgs() -{ - return reqd_args; -} - -int -cmd_ok() -{ - /* if it called many times, the interperter will store only - the latest. - */ - Tcl_AppendElement(interp, "+OK"); - return TCL_OK; -} - - -int -cmd_error() -{ - /* If it called many times, the interpreter will store only - the latest - */ - Tcl_AppendElement(interp, "-ERROR"); - return TCL_ERROR; -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createCommand.h ---------------------------------------------------------------------- diff --git a/mgmt/cli/createCommand.h b/mgmt/cli/createCommand.h deleted file mode 100644 index b6a5147..0000000 --- a/mgmt/cli/createCommand.h +++ /dev/null @@ -1,59 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* - * createCommand.h -- - * - * - * This file provides basic create command declartion, - * for any new commands. - * - * It overrides any existing commands with the new command - * - * - * - * Dated : 12/11/2000. - */ - -#ifndef CREATE_COMMAND -#define CREATE_COMMAND - -#include "definitions.h" - - - -/* First Argument cmdName: New command name for CLI - Second Argument cmdFuncPtr : A 'C' function to be invoked - for the new Command - Third Argument argvFuncPtr : Function to attach arguments - Pass NULL for no arguments. - Fourth Argument cmdScope : Scope of the command. - Pass NULL, if the new command - needs to be visible for - the customer. -*/ - -extern int createCommand(const char *cmdName, Tcl_CmdProc * cmdFuncPtr, - createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpstring); - -#endif /* CREATE_COMMAND */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/definitions.h ---------------------------------------------------------------------- diff --git a/mgmt/cli/definitions.h b/mgmt/cli/definitions.h deleted file mode 100644 index 327baad..0000000 --- a/mgmt/cli/definitions.h +++ /dev/null @@ -1,77 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* - * Legal values for the type field of a createArgv: - * - */ -#include <tcl.h> - -#ifndef DEFINITIONS -#define DEFINITIONS - -#define CLI_OK TCL_OK - -#define CLI_ERROR TCL_ERROR -#define CMD_OK cmd_ok() -#define CMD_ERROR cmd_error() - -#define CLI_ARGV_CONSTANT 0x1 -#define CLI_ARGV_INT 0x2 -#define CLI_ARGV_STRING 0x4 -#define CLI_ARGV_FLOAT 0x8 -#define CLI_ARGV_FUNC 0x10 -#define CLI_ARGV_HELP 0x20 -#define CLI_ARGV_CONST_OPTION 0x40 -#define CLI_ARGV_OPTION_FLOAT_VALUE 0x80 -#define CLI_ARGV_OPTION_INT_VALUE 0x90 -#define CLI_ARGV_OPTION_NAME_VALUE 0x100 -#define CLI_ARGV_END 0x200 -#define CLI_PARSED_ARGV_END 0x1000 -#define CLI_PARSED_ARGV_DATA 0x1001 -#define CLI_PARENT_ARGV 1 -#define CLI_ARGV_NO_POS -1 - -#define CLI_ARGV_OPTIONAL 0x400 -#define CLI_ARGV_REQUIRED 0x800 - -#define CLI_DEFAULT_INT_OR_FLOAT_VALUE -32768 - -typedef enum -{ - CLI_COMMAND_INTERNAL = 0x300, - CLI_COMMAND_EXTERNAL = 0x700 -} cmdTerritory; - -typedef int (commandFunctionptr) (ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]); -typedef int (createArgumentFuncPtr) (); - -int cmd_ok(void); -int cmd_error(void); - -extern int AlarmCallbackPrint; - -int processArgForCommand(Tcl_Interp * interp, int argc, const char *argv[]); -int processHelpCommand(int argc, const char *argv[]); - -#endif /*DEFINITIONS */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/hashtable.cc ---------------------------------------------------------------------- diff --git a/mgmt/cli/hashtable.cc b/mgmt/cli/hashtable.cc deleted file mode 100644 index 183ebf0..0000000 --- a/mgmt/cli/hashtable.cc +++ /dev/null @@ -1,219 +0,0 @@ -/** @file - - Stuff related to hashtable - - @section license License - - Copyright (c) 1997-1998 Sun Microsystems, Inc. - - TK 8.3 license: - - This software is copyrighted by the Regents of the University of - California, Sun Microsystems, Inc., and other parties. The following - terms apply to all files associated with the software unless explicitly - disclaimed in individual files. - - The authors hereby grant permission to use, copy, modify, distribute, - and license this software and its documentation for any purpose, provided - that existing copyright notices are retained in all copies and that this - notice is included verbatim in any distributions. No written agreement, - license, or royalty fee is required for any of the authorized uses. - Modifications to this software may be copyrighted by their authors - and need not follow the licensing terms described here, provided that - the new terms are clearly indicated on the first page of each file where - they apply. - - IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY - FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY - DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE - IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE - NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR - MODIFICATIONS. - - GOVERNMENT USE: If you are acquiring this software on behalf of the - U.S. government, the Government shall have only "Restricted Rights" - in the software and related documentation as defined in the Federal - Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you - are acquiring the software on behalf of the Department of Defense, the - software shall be classified as "Commercial Computer Software" and the - Government shall have only "Restricted Rights" as defined in Clause - 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the - authors grant the U.S. Government and others acting in its behalf - permission to use and distribute the software in accordance with the - terms specified in this license. - - @section details Details - - Parts of this code is based on code from TK, tkConfig.c. The license - on this code allows us to use as long as we keep the license with - the source. Note that only parts of this code is from tkConfig.c, - since it's been modified to work with our internals. - - */ - -#include <tcl.h> -#include <stdlib.h> -#include <string.h> -#include "definitions.h" -#include "createArgument.h" -#include "ink_string.h" -#include "ink_defs.h" - - -extern Tcl_Interp *interp; -Tcl_HashTable CommandHashtable; - -#define OPTION_HASH_KEY "cliOptionTable" -static void DestroyOptionHashTable _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp)); - -int -cliCreateCommandHashtable() -{ - Tcl_HashTable *hashTablePtr; - - /* - * We use an AssocData value in the interpreter to keep a hash - * table of all the option tables we've created for this application. - * This is used for two purposes. First, it allows us to share the - * tables (e.g. in several chains) and second, we use the deletion - * callback for the AssocData to delete all the option tables when - * the interpreter is deleted. The code below finds the hash table - * or creates a new one if it doesn't already exist. - */ - hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); - if (hashTablePtr == NULL) { - hashTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(hashTablePtr, TCL_STRING_KEYS); - Tcl_SetAssocData(interp, OPTION_HASH_KEY, DestroyOptionHashTable, (ClientData) hashTablePtr); - } - - return TCL_OK; -} - - -int -cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable, - char **reqd_args, cli_parsedArgInfo * parsedArgTable, const char *helpString) -{ - Tcl_HashEntry *entryPtr; - int newCmd; - cli_CommandInfo *commandinfo; - Tcl_HashTable *hashTablePtr; - - hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); - if (hashTablePtr == NULL) { - Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL); - return TCL_ERROR; - } - - - commandinfo = (cli_CommandInfo *) ckalloc(sizeof(cli_CommandInfo)); - commandinfo->command_name = name; - commandinfo->argtable = argtable; - commandinfo->reqd_args = reqd_args; - commandinfo->parsedArgTable = parsedArgTable; - if (helpString != NULL) { - int helpString_size = sizeof(char) * (strlen(helpString) + 1); - commandinfo->helpString = (char *) ckalloc(helpString_size); - ink_strlcpy(commandinfo->helpString, helpString, helpString_size); - } - - /* - * See if a table has already been created for this template. If - * so, just reuse the existing table. - */ - - entryPtr = Tcl_CreateHashEntry(hashTablePtr, name, &newCmd); - if (entryPtr == NULL) { - Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL); - return TCL_ERROR; - } - Tcl_SetHashValue(entryPtr, commandinfo); - return TCL_OK; -} - - -cli_CommandInfo * -cliGetCommandArgsfromHashtable(char *name) -{ - Tcl_HashEntry *entryPtr; - cli_CommandInfo *commandinfo; - Tcl_HashTable *hashTablePtr; - - hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); - if (hashTablePtr == NULL) { - Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL); - return NULL; - } - - entryPtr = Tcl_FindHashEntry(hashTablePtr, name); - if (entryPtr == NULL) { - Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL); - return NULL; - } - - commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(entryPtr); - if (commandinfo == (cli_CommandInfo *) NULL) { - Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL); - return NULL; - } - - return (commandinfo); - -} - - -static void -DestroyOptionHashTable(ClientData clientData, Tcl_Interp * /* interp ATS_UNUSED */) - /* The hash table we are destroying */ - /* The interpreter we are destroying */ -{ - Tcl_HashTable *hashTablePtr = (Tcl_HashTable *) clientData; - Tcl_HashSearch search; - Tcl_HashEntry *hashEntryPtr; - cli_CommandInfo *commandinfo; - cli_ArgvInfo *infoPtr; - - for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search); - hashEntryPtr != NULL; hashEntryPtr = Tcl_NextHashEntry(&search)) { - - commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(hashEntryPtr); - if (commandinfo) { - if (commandinfo->reqd_args) { - ckfree((char *) commandinfo->reqd_args); - } - - if (commandinfo->argtable) { - for (infoPtr = commandinfo->argtable; infoPtr->key != NULL; infoPtr++) { - if (infoPtr->key) { - ckfree((char *) infoPtr->key); - } - if (infoPtr->help) { - ckfree((char *) infoPtr->help); - } - if (infoPtr->def) { - ckfree((char *) infoPtr->def); - } - } - ckfree((char *) commandinfo->argtable); - } - - if (commandinfo->command_name) { - ckfree((char *) commandinfo->command_name); - } - if (commandinfo->helpString) { - ckfree((char *) commandinfo->helpString); - } - ckfree((char *) commandinfo); - } - hashEntryPtr = Tcl_NextHashEntry(&search); - } - Tcl_DeleteHashTable(hashTablePtr); - ckfree((char *) hashTablePtr); -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/hashtable.h ---------------------------------------------------------------------- diff --git a/mgmt/cli/hashtable.h b/mgmt/cli/hashtable.h deleted file mode 100644 index 96f9f7b..0000000 --- a/mgmt/cli/hashtable.h +++ /dev/null @@ -1,45 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/* hashtable.h - * has function declarations for the stuff realted to hashtable - * - */ - -#ifndef CREATE_HASH -#define CREATE_HASH - -#include "createArgument.h" - -extern int cliCreateCommandHashtable(); - -extern int cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable, char **reqd_args, - cli_parsedArgInfo * parsedArgTable, const char *helpString); - -extern cli_CommandInfo *cliGetCommandArgsfromHashtable(char *name); - -extern int cliParseArgument(int argc, const char **argv, cli_CommandInfo * commandinfo); - -extern int getIntRange(char *range, int *r1, int *r2); -extern int floatIntRange(char *range, float *r1, float *r2); -#endif /* CREATE_HASH */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/processArgument.cc ---------------------------------------------------------------------- diff --git a/mgmt/cli/processArgument.cc b/mgmt/cli/processArgument.cc deleted file mode 100644 index 24f0810..0000000 --- a/mgmt/cli/processArgument.cc +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#include <tcl.h> -#include "hashtable.h" -#include "definitions.h" -#include "ink_error.h" -#include "ink_defs.h" -#include <string.h> - -// processArgForCommand -int -processArgForCommand(Tcl_Interp * /* interp ATS_UNUSED */, int argc, const char *argv[]) -{ - cli_CommandInfo *commandinfo = cliGetCommandArgsfromHashtable((char *) argv[0]); - - if (commandinfo == NULL) - return TCL_ERROR; - - return (cliParseArgument(argc, argv, commandinfo)); -} - - -//processHelpCmd -int -processHelpCommand(int argc, const char *argv[]) -{ - if (argc == 2) { - int length = strlen(argv[1]); - if ((length >= 2) && ((strncmp(argv[1], "-help", length) == 0) || (strncmp(argv[1], "-h", length) == 0))) { - return TCL_OK; - } - } else - return TCL_ERROR; - - return TCL_ERROR; -}
