You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/06/06 05:21:35 UTC
[trafficserver] branch master updated: Cleans up various bits of
old code
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new f5daae1 Cleans up various bits of old code
f5daae1 is described below
commit f5daae15a0278b01979c93381cfbb6beb3a31fe8
Author: Randall Meyer <ra...@yahoo.com>
AuthorDate: Wed May 23 15:40:49 2018 -0700
Cleans up various bits of old code
* removes unused ats-util.h file
ink_zero now lives in ts/ink_memory.h
* removes unused #defines
* removes unused GenericParser class
---
CMakeLists.txt | 3 -
lib/ts/apidefs.h.in | 2 -
mgmt/api/GenericParser.cc | 940 ------------------------
mgmt/api/GenericParser.h | 319 --------
mgmt/api/Makefile.am | 2 -
mgmt/api/include/mgmtapi.h | 59 --
plugins/experimental/ssl_cert_loader/ats-util.h | 62 --
7 files changed, 1387 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a859b30..edcf8d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -590,8 +590,6 @@ add_executable(ats
mgmt/api/EventCallback.h
mgmt/api/EventControlMain.cc
mgmt/api/EventControlMain.h
- mgmt/api/GenericParser.cc
- mgmt/api/GenericParser.h
mgmt/api/INKMgmtAPI.cc
mgmt/api/NetworkMessage.cc
mgmt/api/NetworkMessage.h
@@ -774,7 +772,6 @@ add_executable(ats
plugins/experimental/remap_purge/remap_purge.c
plugins/experimental/remap_stats/remap_stats.c
plugins/experimental/server_push_preload/server_push_preload.cc
- plugins/experimental/ssl_cert_loader/ats-util.h
plugins/experimental/ssl_cert_loader/domain-tree.cc
plugins/experimental/ssl_cert_loader/domain-tree.h
plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index b59c168..84a1aee 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -92,8 +92,6 @@ extern "C" {
#define TS_RES_MEM_PATH TS_RES_PATH("memory/")
#endif
-#define TS_MAX_USER_NAME_LEN 256
-
#ifndef TS_DEPRECATED
#define TS_DEPRECATED __attribute__((deprecated))
#endif
diff --git a/mgmt/api/GenericParser.cc b/mgmt/api/GenericParser.cc
deleted file mode 100644
index 5ad8293..0000000
--- a/mgmt/api/GenericParser.cc
+++ /dev/null
@@ -1,940 +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 "ts/ink_platform.h"
-#include "ts/ink_string.h"
-#include "GenericParser.h"
-
-/***************************************************************************
- * Token
- * a token is a name/value pairs of data. The data are of the type char *.
- * The setName and setValue are not meant for data encapsulation, but
- * free callers from allocating the memory.
- ***************************************************************************/
-
-Token::Token() : name(nullptr), value(nullptr) {}
-
-Token::~Token()
-{
- ats_free(name);
- ats_free(value);
-}
-
-void
-Token::setName(const char *str)
-{
- name = (char *)strtrim(str);
- // name = ats_strdup(str_copy); DOESN't WORK
-}
-
-//
-// need to allocate more memory than the actual str len in case
-// more characters are appended to the value
-//
-void
-Token::setValue(const char *str)
-{
- char *str_copy = (char *)strtrim(str);
- // Can't use ats_strdup after strtrim?
- // value = ats_strdup(str);
- ink_assert(value == nullptr);
- if (str_copy) {
- size_t len = strlen(str_copy);
- value = (char *)ats_malloc(sizeof(char) * (BUFSIZ));
- len = (len < BUFSIZ) ? len : BUFSIZ - 1;
- memcpy(value, str_copy, len);
- value[len] = '\0';
- ats_free(str_copy);
- }
-}
-
-void
-Token::appendValue(const char *str)
-{
- char *str_copy = (char *)strtrim(str);
- static bool firstTime = true;
-
- if (value == nullptr) {
- setValue(str_copy);
- } else {
- if (!firstTime) {
- ink_strlcat(value, " ", BUFSIZ);
- }
- ink_strlcat(value, str_copy, BUFSIZ);
- }
- firstTime = false;
- ats_free(str_copy);
-}
-
-void
-Token::Print()
-{
- ink_assert(name != nullptr);
- printf(" (%s", name);
- if (value != nullptr) {
- printf(", %s", value);
- }
- printf("),");
-}
-
-/***************************************************************************
- * TokenList
- * a token list is a list of token (obviously). It uses List.h to link
- * the tokens together. This object includes some queue and stack manlipuation
- * function calls in addition to the common length() and the debugging
- * print() member functions.
- ***************************************************************************/
-TokenList::TokenList() : length(0) {}
-
-TokenList::~TokenList()
-{
- Token *token = nullptr;
-
- while ((token = dequeue())) {
- delete (token);
- }
-}
-
-void
-TokenList::Print()
-{
- printf("\tRULE -->");
- for (Token *token = first(); token; token = next(token)) {
- token->Print();
- }
- printf("\n");
-}
-
-/***************************************************************************
- * Rule
- * a rule is nothing more than just a token list. This object also
- * contains a very important member function -- parse(). Depending on
- * on the configuration file type, a specific parse function is invoked.
- * Since the user of "Rule" are not expected to access the member data
- * driectly, the get/set member functions are used for data encapsulation.
- ***************************************************************************/
-
-Rule::Rule()
- : tokenList(nullptr),
- m_filetype(TS_FNAME_UNDEFINED),
- m_filename(nullptr),
- m_ruleStr(nullptr),
- m_comment(nullptr),
- m_errorHint(nullptr)
-{
-}
-
-void
-Rule::setRuleStr(const char *str)
-{
- ink_assert(m_comment == nullptr);
- m_ruleStr = ats_strdup(str);
-}
-
-void
-Rule::setComment(const char *str)
-{
- ink_assert(m_comment == nullptr);
- m_comment = ats_strdup(str);
-}
-
-void
-Rule::setErrorHint(const char *str)
-{
- ink_assert(m_errorHint == nullptr);
- m_errorHint = ats_strdup(str);
-}
-
-Rule::~Rule()
-{
- delete tokenList;
- ats_free(m_comment);
- ats_free(m_errorHint);
- ats_free(m_ruleStr);
- ats_free(m_filename);
-}
-
-void
-Rule::Print()
-{
- if (tokenList) {
- tokenList->Print();
- }
- if (m_errorHint) {
- printf("\treason: %s\n", m_errorHint);
- }
-}
-
-TokenList *
-Rule::parse(const char *const_rule, TSFileNameT filetype)
-{
- char *rule = (char *)const_rule;
- m_filetype = filetype;
-
- switch (m_filetype) {
- case TS_FNAME_CACHE_OBJ: /* cache.config */
- return cacheParse(rule);
- case TS_FNAME_HOSTING: /* hosting.config */
- return hostingParse(rule);
- case TS_FNAME_IP_ALLOW: /* ip_allow.config */
- return ip_allowParse(rule);
- case TS_FNAME_PARENT_PROXY: /* parent.config */
- return parentParse(rule);
- case TS_FNAME_VOLUME: /* volume.config */
- return volumeParse(rule);
- case TS_FNAME_PLUGIN: /* plugin.config */
- return pluginParse(rule);
- case TS_FNAME_REMAP: /* remap.config */
- return remapParse(rule);
- case TS_FNAME_SOCKS: /* socks.config */
- return socksParse(rule);
- case TS_FNAME_SPLIT_DNS: /* splitdns.config */
- return splitdnsParse(rule);
- case TS_FNAME_STORAGE: /* storage.config */
- return storageParse(rule);
- default:
- return nullptr;
- }
-}
-
-/**
- * arm_securityParse
- **/
-TokenList *
-Rule::arm_securityParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
- Token *token = (Token *)nullptr;
- TokenList *m_tokenList = new TokenList();
-
- // ASSUMPTIONS:
- // every token starts with a non-digit character is a "name"
- // every token starts with a digit is a "value" or part of a "value"
- // NO SPACE for port/ip range
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- // If 1st element is non-digit, it is a value
- if (!ParseRules::is_digit(tokenStr[0])) {
- // it is a name
- if (token != (Token *)nullptr) {
- // We have a token that hasn't been enqueue, enqueue it
- m_tokenList->enqueue(token);
- }
-
- token = new Token(); // Create a new token
- token->setName(tokenStr); // Set token Name
- } else if (token != (Token *)nullptr) {
- // it is a value or part of a value
- token->appendValue(tokenStr); // ISA port# or IP; append to value
- }
- }
-
- if (token != (Token *)nullptr) { // Enqueue the last token -- we haven't done it yet.
- m_tokenList->enqueue(token);
- }
-
- return m_tokenList;
-}
-
-/**
- * cacheParse
- * CAUTION: This function is used for number of similar formatted
- * configureation file parsing. Modification to this function
- * will manifest changes to other parsing function.
- **/
-TokenList *
-Rule::cacheParse(char *rule, unsigned short minNumToken, unsigned short maxNumToken)
-{
- Tokenizer ruleTok(" \t");
- int numRuleTok = ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
- Token *token = nullptr;
- bool insideQuote = false;
- const char *newStr;
-
- // Sanity Check -- number of token
- if (numRuleTok < minNumToken) {
- setErrorHint("Expecting more space delimited tokens!");
- return nullptr;
- }
- if (numRuleTok > maxNumToken) {
- setErrorHint("Expecting less space delimited tokens!");
- return nullptr;
- }
- // Sanity Check -- no space before or after '='
- if (strstr(rule, " =")) {
- setErrorHint("Expected space before '='");
- return nullptr;
- }
- if (strstr(rule, "= ")) {
- setErrorHint("Expected space after '='");
- return nullptr;
- }
-
- TokenList *m_tokenList = new TokenList();
-
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- if (!insideQuote) {
- Tokenizer subruleTok("=");
- int numSubRuleTok = subruleTok.Initialize(tokenStr);
- tok_iter_state subruleTok_state;
- const char *subtoken = subruleTok.iterFirst(&subruleTok_state);
-
- // Every token must have a '=' sign
- if (numSubRuleTok < 2) {
- setErrorHint("'=' is expected in space-delimited token");
- delete m_tokenList;
- return nullptr;
- }
-
- token = new Token();
- /* set the name */
- token->setName(subtoken);
-
- /* set the value */
- if (numSubRuleTok == 2) {
- subtoken = subruleTok.iterNext(&subruleTok_state);
- } else {
- /* Ignore the first "=" sign and treat the rest as one token
- for TSqa09488 */
- const char *secondEqual = strstr(strstr(tokenStr, "="), "=");
- secondEqual++;
- subtoken = ats_strdup(secondEqual);
- }
- insideQuote = inQuote(subtoken);
-
- newStr = strtrim(subtoken, '\"');
- if (!insideQuote) {
- // printf("!insideQuote: %s\n", subtoken);
- token->setValue(newStr);
- m_tokenList->enqueue(token);
- } else {
- // printf("insideQuote: %s\n", subtoken);
- // printf("%s 1\n", subtoken);
- token->appendValue(newStr);
- }
- ats_free((void *)newStr);
-
- } else {
- // printf("%s 2\n", tokenStr);
- newStr = strtrim(tokenStr, '\"');
- token->appendValue(newStr);
- ats_free((void *)newStr);
- insideQuote = inQuote(tokenStr);
- if (insideQuote) {
- // printf("enqueue\n");
- m_tokenList->enqueue(token);
- token = nullptr; // transfered ownership of token to the token list
- insideQuote = false;
- } else {
- insideQuote = true;
- }
- }
- }
-
- delete token;
- return m_tokenList;
-}
-
-/**
- * hostingParse
- **/
-TokenList *
-Rule::hostingParse(char *rule)
-{
- // ASSUMPTIONS:
- // NO SPACE around "=" sign
- // NO SPACE around ","
- return cacheParse(rule, 2, 2);
-}
-
-/**
- * ip_allowParse
- **/
-TokenList *
-Rule::ip_allowParse(char *rule)
-{
- // ASSUMPTIONS:
- // NO SPACE around "=" sign
- // NO SPACE around "-"
- return cacheParse(rule, 2, 2);
-}
-
-/**
- * logsParse
- **/
-TokenList *
-Rule::logsParse(char * /* rule ATS_UNUSED */)
-{
- return nullptr;
-}
-
-/**
- * log_hostsParse
- **/
-TokenList *
-Rule::log_hostsParse(char *rule)
-{
- if (strstr(rule, " ")) {
- return nullptr;
- }
-
- Token *token = new Token();
- TokenList *m_tokenList = new TokenList();
- token->setName(rule);
- m_tokenList->enqueue(token);
-
- return m_tokenList;
-}
-
-/**
- * parentParse
- **/
-TokenList *
-Rule::parentParse(char *rule)
-{
- return cacheParse(rule, 2);
-}
-
-/**
- * volumeParse
- **/
-TokenList *
-Rule::volumeParse(char *rule)
-{
- return cacheParse(rule, 3, 3);
-}
-
-/**
- * pluginParse
- **/
-TokenList *
-Rule::pluginParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
- Token *token;
- TokenList *m_tokenList = new TokenList();
-
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- token = new Token();
- token->setName(tokenStr);
- m_tokenList->enqueue(token);
- }
-
- return m_tokenList;
-}
-
-/**
- * remapParse
- **/
-TokenList *
-Rule::remapParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- int numRuleTok = ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
-
- if ((numRuleTok != 3) && (numRuleTok != 4)) {
- setErrorHint("Expecting exactly 4 space delimited tokens");
- return nullptr;
- }
-
- Token *token;
- TokenList *m_tokenList = new TokenList();
-
- token = new Token();
- token->setName(tokenStr);
- m_tokenList->enqueue(token);
- tokenStr = ruleTok.iterNext(&ruleTok_state);
-
- token = new Token();
- token->setName(tokenStr);
- tokenStr = ruleTok.iterNext(&ruleTok_state);
- token->setValue(tokenStr);
- m_tokenList->enqueue(token);
-
- // Just to make sure that there are no left overs
- tokenStr = ruleTok.iterNext(&ruleTok_state);
- if (tokenStr) {
- token = new Token();
- token->setName(tokenStr);
- m_tokenList->enqueue(token);
- ruleTok.iterNext(&ruleTok_state);
- }
- return m_tokenList;
-}
-
-/**
- * socksParse
- **/
-TokenList *
-Rule::socksParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- int numRuleTok = ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
- Token *token = nullptr;
- bool insideQuote = false;
- const char *newStr;
-
- if (numRuleTok < 2) {
- setErrorHint("Expecting at least 2 space delimited tokens");
- return nullptr;
- }
-
- TokenList *m_tokenList = new TokenList();
-
- /* check which rule type it is */
- if (strcmp(tokenStr, "no_socks") == 0) { /* TS_SOCKS_BYPASS rule type */
- /* the token name = "no socks", the value = "list of ip addresses" */
- token = new Token();
- token->setName(tokenStr);
-
- for (; (tokenStr = ruleTok.iterNext(&ruleTok_state));) {
- token->appendValue(tokenStr);
- }
- m_tokenList->enqueue(token);
- } else if (strcmp(tokenStr, "auth") == 0) { /* TS_SOCKS_AUTH rule type */
- /* first token: name = "auth", value = "u"
- second token: name = <username>
- third token: name = <password> */
- token = new Token();
- token->setName(tokenStr);
- tokenStr = ruleTok.iterNext(&ruleTok_state);
- token->setValue(tokenStr); /* should be "u" authoriziation type */
- m_tokenList->enqueue(token);
-
- /* create tokens for username and password */
- for (; (tokenStr = ruleTok.iterNext(&ruleTok_state));) {
- token = new Token();
- token->setName(tokenStr);
- m_tokenList->enqueue(token);
- }
-
- } else { /* TS_SOCKS_MULTIPLE rule type */
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- /* token is a name-value pair separated with = sign */
- if (!insideQuote) {
- Tokenizer subruleTok("=");
- int numSubRuleTok = subruleTok.Initialize(tokenStr);
- tok_iter_state subruleTok_state;
- const char *subtoken = subruleTok.iterFirst(&subruleTok_state);
-
- // Every token must have a '=' sign
- if (numSubRuleTok < 2) {
- setErrorHint("'=' is expected in space-delimited token");
- delete m_tokenList;
- return nullptr;
- }
-
- token = new Token();
- /* set the name */
- token->setName(subtoken);
-
- /* set the value */
- if (numSubRuleTok == 2) {
- subtoken = subruleTok.iterNext(&subruleTok_state);
- } else {
- /* Ignore the first "=" sign and treat the rest as one token
- for TSqa09488 */
- const char *secondEqual = strstr(strstr(tokenStr, "="), "=");
- secondEqual++;
- subtoken = ats_strdup(secondEqual);
- }
- insideQuote = inQuote(subtoken);
-
- newStr = strtrim(subtoken, '\"');
- if (!insideQuote) {
- // printf("!insideQuote: %s\n", subtoken);
- token->setValue(newStr);
- m_tokenList->enqueue(token);
- token = nullptr; // transfered ownership of token to the token list
- } else {
- // printf("insideQuote: %s\n", subtoken);
- // printf("%s 1\n", subtoken);
- token->appendValue(newStr);
- }
- ats_free((void *)newStr);
-
- } else {
- // printf("%s 2\n", tokenStr);
- newStr = strtrim(tokenStr, '\"');
- token->appendValue(newStr);
- ats_free((void *)newStr);
- insideQuote = inQuote(tokenStr);
- if (insideQuote) {
- // printf("enqueue\n");
- m_tokenList->enqueue(token);
- token = nullptr; // transfered ownership of token to the token list
- insideQuote = false;
- } else {
- insideQuote = true;
- }
- }
- } /* end for loop */
- }
-
- delete token;
- return m_tokenList;
-}
-
-/**
- * splitdnsParse
- **/
-TokenList *
-Rule::splitdnsParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- int numRuleTok = ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
- Token *token = nullptr;
- bool insideQuote = false;
- const char *newStr;
-
- // Sanity Check -- number of token
- if (numRuleTok < 0) {
- setErrorHint("Expecting more space delimited tokens!");
- return nullptr;
- }
- if (numRuleTok > 10) {
- setErrorHint("Expecting less space delimited tokens!");
- return nullptr;
- }
- // Sanity Check -- no space before or after '='
- if (strstr(rule, " =")) {
- setErrorHint("Expected space before '='");
- return nullptr;
- }
- if (strstr(rule, "= ")) {
- setErrorHint("Expected space after '='");
- return nullptr;
- }
-
- TokenList *m_tokenList = new TokenList();
-
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- if (!insideQuote) {
- Tokenizer subruleTok("=");
- int numSubRuleTok = subruleTok.Initialize(tokenStr);
- tok_iter_state subruleTok_state;
- const char *subtoken = subruleTok.iterFirst(&subruleTok_state);
-
- // Every token must have a '=' sign
- if (numSubRuleTok < 2) {
- setErrorHint("'=' is expected in space-delimited token");
- delete m_tokenList;
- return nullptr;
- }
-
- token = new Token();
- token->setName(subtoken);
- subtoken = subruleTok.iterNext(&subruleTok_state);
-
- insideQuote = inQuote(subtoken);
-
- newStr = strtrim(subtoken, '\"');
- if (!insideQuote) {
- token->setValue(newStr);
- m_tokenList->enqueue(token);
- token = nullptr; // transfered ownership of token to the token list
- } else {
- // printf("%s 1\n", subtoken);
- token->appendValue(newStr);
- }
- ats_free((void *)newStr);
-
- } else {
- // printf("%s 2\n", tokenStr);
- newStr = strtrim(tokenStr, '\"');
- token->appendValue(newStr);
- ats_free((void *)newStr);
- insideQuote = inQuote(tokenStr);
- if (insideQuote) {
- // printf("enqueue\n");
- m_tokenList->enqueue(token);
- token = nullptr; // transfered ownership of token to the token list
- insideQuote = false;
- } else {
- insideQuote = true;
- }
- }
- }
-
- delete token;
- return m_tokenList;
- // return cacheParse(rule, 2);
-}
-
-/**
- * updateParse
- **/
-TokenList *
-Rule::updateParse(char *rule)
-{
- Tokenizer ruleTok("\\");
- int numRuleTok = ruleTok.Initialize(rule, ALLOW_EMPTY_TOKS);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
-
- // NOTE: ignore white spaces before/after the '\'
- // There should only be 5 tokens; if there are 6 tokens, the
- // sixth token must be all white spaces
- if (numRuleTok < 5 || numRuleTok > 6 || (numRuleTok == 6 && strspn(ruleTok[5], " ") != strlen(ruleTok[5]))) {
- setErrorHint("Expecting exactly 5 '\' delimited tokens");
- return nullptr;
- }
-
- Token *token;
- TokenList *m_tokenList = new TokenList();
-
- for (; tokenStr; tokenStr = ruleTok.iterNext(&ruleTok_state)) {
- token = new Token();
- token->setName(tokenStr);
- m_tokenList->enqueue(token);
- }
-
- return m_tokenList;
-}
-
-/**
- * storageParse
- * ------------
- * the token value is pathname; if a size is specified, that is stored as
- * the token's value
- **/
-TokenList *
-Rule::storageParse(char *rule)
-{
- Tokenizer ruleTok(" \t");
- int numRuleTok = ruleTok.Initialize(rule);
- tok_iter_state ruleTok_state;
- const char *tokenStr = ruleTok.iterFirst(&ruleTok_state);
-
- if ((numRuleTok != 1) && (numRuleTok != 2)) {
- setErrorHint("Expecting one or two tokens");
- return nullptr;
- }
-
- Token *token;
- TokenList *m_tokenList = new TokenList();
-
- // at least one token, anyways
- token = new Token();
- token->setName(tokenStr);
- if (numRuleTok > 1) { // numRulTok == 2
- tokenStr = ruleTok.iterNext(&ruleTok_state);
- token->setValue(tokenStr);
- }
- m_tokenList->enqueue(token);
-
- return m_tokenList;
-}
-
-/*
- * bool Rule::inQuote(char *str)
- * Counts the number of quote found in "str"
- * RETURN true if "str" contains odd number of quotes (")
- * false if "str" contains even number of quotes (including zero)
- */
-bool
-Rule::inQuote(const char *str)
-{
- unsigned numQuote = 0;
- for (const char *ptr = str; *ptr != '\0'; ptr++) {
- if (*ptr == '\"') {
- numQuote++;
- }
- }
- return (numQuote & 1);
-}
-
-/***************************************************************************
- * RuleList
- * a rule list is a list of rule; which compose to a configuration file.
- * Again some queue and stack manlipation member functions are included.
- * The important function is this object is also parse() which breaks up
- * the file into individual lines and passes on to the Rule object to
- * continue parsing each rule.
- * NOTE: a rule that spans more than one line would be a problem in here.
- ***************************************************************************/
-RuleList::RuleList() : length(0), m_filename(nullptr)
-{
- m_filetype = TS_FNAME_UNDEFINED;
-}
-
-RuleList::~RuleList()
-{
- ats_free(m_filename);
-
- Rule *rule = nullptr;
- while ((rule = dequeue())) {
- delete rule;
- }
-}
-
-void
-RuleList::Print()
-{
- printf("RULELIST-->\n");
- for (Rule *rule = first(); rule; rule = next(rule)) {
- rule->Print();
- }
- printf("length: %u\n", length);
-}
-
-/*
- * void RuleList::parse(char *fileBuf, const char *filename)
- * Takes configuration file buffer, tokenize the buffer according carriage
- * return. For each line, pasre it.
- *
- */
-void
-RuleList::parse(char *fileBuf, const char *filename)
-{
- m_filename = ats_strdup(filename);
-
- if (strstr(filename, "cache.config")) {
- m_filetype = TS_FNAME_CACHE_OBJ; /* cache.config */
- } else if (strstr(filename, "hosting.config")) {
- m_filetype = TS_FNAME_HOSTING; /* hosting.config */
- } else if (strstr(filename, "ip_allow.config")) {
- m_filetype = TS_FNAME_IP_ALLOW; /* ip_allow.config */
- } else if (strstr(filename, "parent.config")) {
- m_filetype = TS_FNAME_PARENT_PROXY; /* parent.config */
- } else if (strstr(filename, "volume.config")) {
- m_filetype = TS_FNAME_VOLUME; /* volume.config */
- } else if (strstr(filename, "plugin.config")) {
- m_filetype = TS_FNAME_PLUGIN; /* plugin.config */
- } else if (strstr(filename, "remap.config")) {
- m_filetype = TS_FNAME_REMAP; /* remap.config */
- } else if (strstr(filename, "socks.config")) {
- m_filetype = TS_FNAME_SOCKS; /* socks.config */
- } else if (strstr(filename, "splitdns.config")) {
- m_filetype = TS_FNAME_SPLIT_DNS; /* splitdns.config */
- } else if (strstr(filename, "plugin.config")) {
- m_filetype = TS_FNAME_UNDEFINED; /* plugin.config */
- } else if (strstr(filename, "storage.config")) {
- m_filetype = TS_FNAME_STORAGE; /* storage.config */
- } else {
- m_filetype = TS_FNAME_UNDEFINED;
- }
-
- // Call the proper function
- this->parse(fileBuf, m_filetype);
-}
-
-/*
- * void RuleList::parse(char *fileBuf, TSFileNameT filetype)
- * Takes configuration file buffer, tokenize the buffer according carriage
- * return. For each line, pasre it.
- * NOTE: (1) comment line must start with '#' as the first character without
- * leading spaces
- * (2) a line must
- *
- */
-void
-RuleList::parse(char *fileBuf, TSFileNameT filetype)
-{
- Tokenizer lineTok("\n");
- tok_iter_state lineTok_state;
- const char *line;
-
- lineTok.Initialize(fileBuf);
- line = lineTok.iterFirst(&lineTok_state);
- while (line) {
- Rule *rule = new Rule();
-
- if (line[0] == '#') { // is this comment
- rule->setComment(line);
- } else {
- TokenList *m_tokenList = rule->parse(line, filetype);
- if (m_tokenList) {
- rule->setRuleStr(line);
- rule->tokenList = m_tokenList;
- } else {
- // rule->setComment("## WARNING: The following configuration rule is invalid!");
- size_t error_rule_size = sizeof(char) * (strlen(line) + strlen("#ERROR: ") + 1);
- char *error_rule = (char *)ats_malloc(error_rule_size);
-
- snprintf(error_rule, error_rule_size, "#ERROR: %s", line);
- rule->setComment(error_rule);
- ats_free(error_rule);
- }
- }
-
- // rule->Print();
- this->enqueue(rule);
-
- // Get next line
- line = lineTok.iterNext(&lineTok_state);
- }
- // this->Print();
-}
-
-/***************************************************************************
- * General Routines
- ***************************************************************************/
-// Concatenate two strings together and return the resulting string
-
-/*
-char *
-strtrim(char *str) {
- while(isspace(*str)) {
- str++;
- }
- while(isspace(str[strlen(str)-1])) {
- str[strlen(str)-1] = '\0';
- }
- return str;
-}
-*/
-
-//
-// This function ALLOCATES MEMORY FOR A NEW STRING!!
-//
-const char *
-strtrim(const char *str_in, char chr)
-{
- char *str = ats_strdup(str_in);
-
- char *str_ptr = str; // so we can free str later if it changes
- while (*str == chr) {
- str++;
- }
- while (str[strlen(str) - 1] == chr) {
- str[strlen(str) - 1] = '\0';
- }
-
- char *newStr = ats_strdup(str);
- ats_free(str_ptr);
- return newStr;
-}
diff --git a/mgmt/api/GenericParser.h b/mgmt/api/GenericParser.h
deleted file mode 100644
index a09c0f6..0000000
--- a/mgmt/api/GenericParser.h
+++ /dev/null
@@ -1,319 +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.
- */
-
-/***************************************************************************
- GenericParser.h
-
-
- ***************************************************************************/
-#pragma once
-
-#include <cstring>
-#include "ts/ink_assert.h"
-#include "ts/Tokenizer.h"
-#include "ts/List.h"
-#include "mgmtapi.h" // INKFileNameT
-
-#define MIN_CONFIG_TOKEN 1
-#define MAX_CONFIG_TOKEN 30
-
-/***************************************************************************
- * Token
- * a token is a name/value pairs of data. The data are of the type char *.
- * The setName and setValue are not meant for data encapsulation, but
- * free callers from allocating the memory.
- ***************************************************************************/
-class Token
-{
-public:
- Token();
- Token(char *);
- ~Token();
- void setName(const char *);
- void setValue(const char *);
- void appendValue(const char *);
- void Print();
-
- char *name;
- char *value;
- LINK(Token, link);
-};
-
-/***************************************************************************
- * TokenList
- * a token list is a list of token (obviously). It uses List.h to link
- * the tokens together. This object includes some queue and stack manlipuation
- * function calls in addition to the common length() and the debugging
- * print() member functions.
- ***************************************************************************/
-class TokenList
-{
-public:
- TokenList();
- ~TokenList();
-
- unsigned length;
-
- /**
- * Queue method
- */
- inline Token *
- first()
- {
- return m_nameList.head;
- };
- inline Token *
- last()
- {
- return m_nameList.tail;
- };
- inline void
- enqueue(Token *entry)
- {
- length++;
- m_nameList.enqueue(entry);
- };
- inline Token *
- dequeue()
- {
- length--;
- return (Token *)m_nameList.dequeue();
- };
- inline void
- remove(Token *entry)
- {
- length--;
- m_nameList.remove(entry);
- };
- /**
- * Stack method
- */
- inline Token *
- top()
- {
- return m_nameList.tail;
- };
- inline Token *
- bottom()
- {
- return m_nameList.head;
- };
- inline void
- push(Token *entry)
- {
- length++;
- m_nameList.push(entry);
- };
- inline Token *
- pop()
- {
- length--;
- return m_nameList.pop();
- };
- /**
- * General method
- */
- inline void
- insert(Token *newNode, Token *current)
- {
- m_nameList.insert(newNode, current);
- };
- inline Token *
- next(Token *current)
- {
- return (current->link).next;
- };
-
- void Print(); /* debugging use only */
-
-private:
- Queue<Token> m_nameList;
-};
-
-/***************************************************************************
- * Rule
- * a rule is nothing more than just a token list. This object also
- * contains a very important member function -- parse(). Depending on
- * on the configuration file type, a specific parse function is invoked.
- * Since the user of "Rule" are not expected to access the member data
- * driectly, the get/set member functions are used for data encapsulation.
- ***************************************************************************/
-class Rule
-{
-public:
- TokenList *tokenList;
-
- inline TSFileNameT
- getFiletype()
- {
- return m_filetype;
- };
- void setRuleStr(const char *);
- inline char *
- getRuleStr()
- {
- return m_ruleStr;
- };
- void setComment(const char *);
- inline char *
- getComment()
- {
- return m_comment;
- };
- void setErrorHint(const char *);
- inline char *
- getErrorHint()
- {
- return m_errorHint;
- };
-
- Rule();
- ~Rule();
- void Print();
- TokenList *parse(const char *buf, TSFileNameT filetype);
-
- LINK(Rule, link);
-
-private:
- TSFileNameT m_filetype;
- char *m_filename;
- char *m_ruleStr;
- char *m_comment;
- char *m_errorHint;
-
- TokenList *cacheParse(char *rule, unsigned short minNumToken = MIN_CONFIG_TOKEN, unsigned short maxNumToken = MAX_CONFIG_TOKEN);
- TokenList *parentParse(char *rule);
- TokenList *remapParse(char *rule);
- TokenList *socksParse(char *rule);
- TokenList *splitdnsParse(char *rule);
- TokenList *updateParse(char *rule);
- TokenList *arm_securityParse(char *rule);
- TokenList *hostingParse(char *rule);
- TokenList *ip_allowParse(char *rule);
- TokenList *volumeParse(char *rule);
- TokenList *logsParse(char *rule);
- TokenList *pluginParse(char *rule);
- TokenList *storageParse(char *rule);
- TokenList *log_hostsParse(char *rule);
- bool inQuote(const char *str);
-};
-
-/***************************************************************************
- * RuleList
- * a rule list is a list of rule; which compose to a configuration file.
- * Again some queue and stack manlipation member functions are included.
- * The important function is this object is also parse() which breaks up
- * the file into individual lines and passes on to the Rule object to
- * continue parsing each rule.
- * NOTE: a rule that spans more than one line would be a problem in here.
- ***************************************************************************/
-class RuleList
-{
-public:
- RuleList();
- ~RuleList();
-
- unsigned length;
-
- /**
- * Queue method
- */
- inline Rule *
- first()
- {
- return m_lineList.head;
- }
- inline Rule *
- last()
- {
- return m_lineList.tail;
- }
- inline void
- enqueue(Rule *entry)
- {
- if (!entry->getComment()) {
- length++;
- }
- m_lineList.enqueue(entry);
- }
- inline Rule *
- dequeue()
- {
- length--;
- return (Rule *)m_lineList.dequeue();
- }
- /**
- * Stack method
- */
- inline Rule *
- top()
- {
- return m_lineList.tail;
- }
- inline Rule *
- bottom()
- {
- return m_lineList.head;
- }
- inline void
- push(Rule *entry)
- {
- if (!entry->getComment()) {
- length++;
- }
- m_lineList.push(entry);
- }
- inline Rule *
- pop()
- {
- length--;
- return m_lineList.pop();
- }
- /**
- * General method
- */
- inline Rule *
- next(Rule *current)
- {
- return (current->link).next;
- }
- inline void
- insert(Rule *newNode, Rule *current)
- {
- m_lineList.insert(newNode, current);
- }
- void Print(); /* debugging use only */
- void parse(char *buf, TSFileNameT filetype);
- void parse(char *buf, const char *filename);
-
-private:
- TSFileNameT m_filetype;
- char *m_filename;
- Queue<Rule> m_lineList;
-};
-
-/*****************************************************************************************
- * General Routines
- *****************************************************************************************/
-// char *strtrim(char *);
-const char *strtrim(const char *, char chr = ' ');
diff --git a/mgmt/api/Makefile.am b/mgmt/api/Makefile.am
index c60cdd4..29c01d9 100644
--- a/mgmt/api/Makefile.am
+++ b/mgmt/api/Makefile.am
@@ -40,8 +40,6 @@ libmgmtapi_la_SOURCES = \
CoreAPIShared.h \
EventCallback.cc \
EventCallback.h \
- GenericParser.cc \
- GenericParser.h \
INKMgmtAPI.cc \
NetworkMessage.cc \
NetworkMessage.h \
diff --git a/mgmt/api/include/mgmtapi.h b/mgmt/api/include/mgmtapi.h
index 19eaad6..161ce6f 100644
--- a/mgmt/api/include/mgmtapi.h
+++ b/mgmt/api/include/mgmtapi.h
@@ -80,30 +80,6 @@ typedef enum {
} TSMgmtError;
/***************************************************************************
- * Constants
- ***************************************************************************/
-
-#define TS_INVALID_HANDLE NULL
-#define TS_INVALID_LIST TS_INVALID_HANDLE
-#define TS_INVALID_CFG_CONTEXT TS_INVALID_HANDLE
-#define TS_INVALID_THREAD TS_INVALID_HANDLE
-#define TS_INVALID_MUTEX TS_INVALID_HANDLE
-
-#define TS_INVALID_IP_ADDR NULL
-#define TS_INVALID_IP_CIDR -1
-#define TS_INVALID_PORT 0
-
-#define TS_SSPEC_TIME 0x1
-#define TS_SSPEC_SRC_IP 0x2
-#define TS_SSPEC_PREFIX 0x4
-#define TS_SSPEC_SUFFIX 0x8
-#define TS_SSPEC_PORT 0x10
-#define TS_SSPEC_METHOD 0x20
-#define TS_SSPEC_SCHEME 0x40
-
-#define TS_ENCRYPT_PASSWD_LEN 23
-
-/***************************************************************************
* Types
***************************************************************************/
@@ -150,16 +126,6 @@ typedef enum {
TS_EVENT_PRIORITY_UNDEFINED
} TSEventPriorityT;
-/*--- abstract file operations --------------------------------------------*/
-
-typedef enum {
- TS_ACCESS_NONE, /* no access */
- TS_ACCESS_MONITOR, /* monitor only access */
- TS_ACCESS_MONITOR_VIEW, /* monitor and view configuration access */
- TS_ACCESS_MONITOR_CHANGE, /* monitor and change configuration access */
- TS_ACCESS_UNDEFINED
-} TSAccessT;
-
typedef enum {
TS_REC_INT,
TS_REC_COUNTER,
@@ -168,24 +134,6 @@ typedef enum {
TS_REC_UNDEFINED,
} TSRecordT;
-/* ToDo: This should be moved over to the core, into the GenericParser.h */
-typedef enum {
- TS_FNAME_CACHE_OBJ, /* cache.config */
- TS_FNAME_HOSTING, /* hosting.config */
- TS_FNAME_IP_ALLOW, /* ip_allow.config */
- TS_FNAME_PARENT_PROXY, /* parent.config */
- TS_FNAME_VOLUME, /* volume.config */
- TS_FNAME_PLUGIN, /* plugin.config */
- TS_FNAME_REMAP, /* remap.config */
- TS_FNAME_SOCKS, /* socks.config */
- TS_FNAME_SPLIT_DNS, /* splitdns.config */
- TS_FNAME_STORAGE, /* storage.config */
- TS_FNAME_VSCAN, /* vscan.config */
- TS_FNAME_VS_TRUSTED_HOST, /* trusted-host.config */
- TS_FNAME_VS_EXTENSION, /* extensions.config */
- TS_FNAME_UNDEFINED
-} TSFileNameT;
-
/* These are initialization options for the Init() function. */
typedef enum {
TS_MGMT_OPT_DEFAULTS = 0,
@@ -271,13 +219,6 @@ typedef struct {
TSEventPriorityT priority; /* WARNING, ERROR, FATAL */
} TSMgmtEvent;
-/* Will not be used until new Cougar Event Processor */
-typedef struct {
- char *name;
- /*int signalCount; */ /* 0 is inactive, >= 1 is active event */
- /*unsigned long timestamp; */ /* only applies to active events */
-} TSActiveEvent;
-
/***************************************************************************
* Function Types
***************************************************************************/
diff --git a/plugins/experimental/ssl_cert_loader/ats-util.h b/plugins/experimental/ssl_cert_loader/ats-util.h
deleted file mode 100644
index b9dd049..0000000
--- a/plugins/experimental/ssl_cert_loader/ats-util.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file
-
- Include file for ...
-
- @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.
-
-*/
-
-#pragma once
-
-#if defined(__cplusplus)
-/** Set data to zero.
-
- Calls @c memset on @a t with a value of zero and a length of @c
- sizeof(t). This can be used on ordinary and array variables. While
- this can be used on variables of intrinsic type it's inefficient.
-
- @note Because this uses templates it cannot be used on unnamed or
- locally scoped structures / classes. This is an inherent
- limitation of templates.
-
- Examples:
- @code
- foo bar; // value.
- ink_zero(bar); // zero bar.
-
- foo *bar; // pointer.
- ink_zero(bar); // WRONG - makes the pointer @a bar zero.
- ink_zero(*bar); // zero what bar points at.
-
- foo bar[ZOMG]; // Array of structs.
- ink_zero(bar); // Zero all structs in array.
-
- foo *bar[ZOMG]; // array of pointers.
- ink_zero(bar); // zero all pointers in the array.
- @endcode
-
- */
-template <typename T>
-inline void
-ink_zero(T &t ///< Object to zero.
-)
-{
- memset(&t, 0, sizeof(t));
-}
-#endif /* __cplusplus */
--
To stop receiving notification emails like this one, please contact
zwoop@apache.org.