Repository: trafficserver Updated Branches: refs/heads/master ead727223 -> 0df8e8600
TS-2772: Clean up mgmt/preparse code that's unused Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0df8e860 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0df8e860 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0df8e860 Branch: refs/heads/master Commit: 0df8e8600983f43a7d4bf0bcfe0cb44ade32ae56 Parents: ead7272 Author: Brian Geffon <[email protected]> Authored: Thu May 1 10:43:59 2014 -0700 Committer: Brian Geffon <[email protected]> Committed: Thu May 1 10:43:59 2014 -0700 ---------------------------------------------------------------------- mgmt/preparse/Makefile.am | 29 ------ mgmt/preparse/RemapReadConfig.cc | 182 ---------------------------------- mgmt/preparse/StoreReadConfig.cc | 81 --------------- 3 files changed, 292 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0df8e860/mgmt/preparse/Makefile.am ---------------------------------------------------------------------- diff --git a/mgmt/preparse/Makefile.am b/mgmt/preparse/Makefile.am deleted file mode 100644 index 8b36d7d..0000000 --- a/mgmt/preparse/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# 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. - -AM_CPPFLAGS = \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/lib/ts \ - -I$(top_srcdir)/proxy/hdrs - -MGMT_DEFS = @MGMT_DEFS@ -DEFS += $(MGMT_DEFS) - -noinst_LIBRARIES = libpreparse.a - -libpreparse_a_SOURCES = \ - RemapReadConfig.cc \ - StoreReadConfig.cc http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0df8e860/mgmt/preparse/RemapReadConfig.cc ---------------------------------------------------------------------- diff --git a/mgmt/preparse/RemapReadConfig.cc b/mgmt/preparse/RemapReadConfig.cc deleted file mode 100644 index 0b8d9d0..0000000 --- a/mgmt/preparse/RemapReadConfig.cc +++ /dev/null @@ -1,182 +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. - */ - -/***************************************************************************** - * - * RemapReadConfig.cc - Parser to validate the remap.config for the - * User Interface - * - * - ****************************************************************************/ - -#include "ink_platform.h" -#include "ink_string.h" -#include "ink_file.h" -#include "Tokenizer.h" -#include "URL.h" -#include "MIME.h" -#include "ParseRules.h" - -char * -parseRemapFile(int fd) -{ - int entry = 0; - char line[512]; - const char *err = NULL; - char *errBuf; - Tokenizer whiteTok(" \t\r\n"); - int numToks; - const char *map_from; - const char *map_from_start; - const char *map_to; - bool forward_map; - - // For testing of URLs - URL fromURL; - URL toURL; - int length; - - int fromSchemeLen, toSchemeLen; - int fromHostLen, toHostLen; - int fromPathLen, toPathLen; - const char *fromScheme; - const char *toScheme; - const char *fromHost; - const char *fromPath; - const char *toPath; - - while (ink_file_fd_readline(fd, sizeof(line) - 1, line) > 0) { - if (*line != '#' && *line != '\0') { - entry++; - - numToks = whiteTok.Initialize(line, SHARE_TOKS); - if (numToks == 0) { - // Handle empty (whitespace only) line - // However, do not count it in the entry count - entry--; - continue; - } else if (numToks < 3) { //INKqa09603: can have 3 or 4 fields - err = "Missing field"; - goto FAIL; - } else { - - // Check to see whether is a reverse or forward mapping - if (strcasecmp("reverse_map", whiteTok[0]) == 0) { - forward_map = false; - } else if (strcasecmp("map", whiteTok[0]) == 0) { - forward_map = true; - } else { - err = "Unknown mapping type"; - goto FAIL; - } - - map_from = whiteTok[1]; - length = strlen(map_from); - - // URL::create modified map from so keep a point to - // the beginning of the string - map_from_start = map_from; - fromURL.create(NULL); - if (fromURL.parse(&map_from, map_from + length) != PARSE_DONE) { - err = "Malformed From URL"; - goto FAIL; - } - - map_to = whiteTok[2]; - length = strlen(map_to); - toURL.create(NULL); - if (toURL.parse(&map_to, map_to + length) != PARSE_DONE) { - err = "Malformed To URL"; - goto FAIL; - } - - fromScheme = fromURL.scheme_get(&fromSchemeLen); - toScheme = toURL.scheme_get(&toSchemeLen); - - if ((fromScheme != URL_SCHEME_HTTP && fromScheme != URL_SCHEME_HTTPS) || - (toScheme != URL_SCHEME_HTTP && toScheme != URL_SCHEME_HTTPS)) { - err = "Only http and https remappings are supported"; - goto FAIL; - } - // Check to see if we have a complete URL, if not - // we should only a path component - if (strstr(map_from_start, "://") == NULL) { - if (*map_from_start != '/') { - err = "Relative remappings must begin with a /"; - goto FAIL; - } - } - // Check to see the fromHost remapping is a relative one - fromHost = fromURL.host_get(&fromHostLen); - if (fromHost == NULL) { - if (forward_map) { - if (*map_from_start != '/') { - err = "Relative remappings must begin with a /"; - goto FAIL; - } - } else { - err = "Remap source in reverse mappings requires a hostname"; - goto FAIL; - } - } - - if (toURL.host_get(&toHostLen) == NULL) { - err = "The remap destinations require a hostname"; - goto FAIL; - } - // Make sure that there are not any unsafe characters in - // the URLs - fromPath = fromURL.path_get(&fromPathLen); - while (fromPathLen > 0) { - if (ParseRules::is_unsafe(*fromPath)) { - err = "Unsafe character in `From` URL"; - goto FAIL; - } - fromPath++; - fromPathLen--; - } - toPath = toURL.path_get(&toPathLen); - while (toPathLen > 0) { - if (ParseRules::is_unsafe(*toPath)) { - err = "Unsafe character in `To` URL"; - goto FAIL; - } - toPath++; - toPathLen--; - } - } - } - } - return NULL; - -FAIL: - errBuf = (char *)ats_malloc(1024); - snprintf(errBuf, 1024, "[Entry %d] %s", entry, err); - return errBuf; -} - -char * -parseRemapFile(FILE * fp) -{ - return (parseRemapFile(fileno(fp))); -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0df8e860/mgmt/preparse/StoreReadConfig.cc ---------------------------------------------------------------------- diff --git a/mgmt/preparse/StoreReadConfig.cc b/mgmt/preparse/StoreReadConfig.cc deleted file mode 100644 index 70673cd..0000000 --- a/mgmt/preparse/StoreReadConfig.cc +++ /dev/null @@ -1,81 +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 "libts.h" -/**************************************************************************** - - StoreReadConfig.cc - - - ****************************************************************************/ - -char * -parseStorageFile(int fd) -{ - int ln = 0; - char line[256]; - const char *err = NULL; - while (ink_file_fd_readline(fd, sizeof(line) - 1, line) > 0) { - // update lines - - line[255] = 0; - ln++; - - // skip comments and blank lines - - if (*line == '#') - continue; - char *n = line; - n += strspn(n, " \t"); - if (!*n) - continue; - - // parse - - char *e = strpbrk(n, " \t\n"); - int64_t size = -1; - while (*e && !isdigit(*e)) - e++; - if (e && *e) { - // coverity[secure_coding] - if (1 != sscanf(e, "%" PRId64 "", &size)) { - err = "error parsing size"; - goto Lfail; - } - } - } - return NULL; -Lfail: - int e_size = 1000; - char *e = (char *)ats_malloc(e_size); - - snprintf(e, e_size, "Error reading storage.config: %s line %d\n", err, ln); - return e; -} - - -char * -parseStorageFile(FILE * fp) -{ - return (parseStorageFile(fileno(fp))); -}
