MCPcopy Create free account
hub / github.com/apache/trafficserver / fromArgs

Method fromArgs

plugins/slice/Config.cc:81–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81bool
82Config::fromArgs(int const argc, char const *const argv[])
83{
84 DEBUG_LOG("Number of arguments: %d", argc);
85 for (int index = 0; index < argc; ++index) {
86 DEBUG_LOG("args[%d] = %s", index, argv[index]);
87 }
88
89 // look for lowest priority deprecated blockbytes
90 int64_t blockbytes = 0;
91
92 // backwards compat: look for blockbytes
93 for (int index = 0; index < argc; ++index) {
94 std::string_view const argstr = argv[index];
95
96 std::size_t const spos = argstr.find_first_of(':');
97 if (spos != std::string_view::npos) {
98 std::string_view const key = argstr.substr(0, spos);
99 std::string_view const val = argstr.substr(spos + 1);
100
101 if (!key.empty() && !val.empty()) {
102 char const *const valstr = val.data(); // inherits argv's null
103 int64_t const bytesread = bytesFrom(valstr);
104
105 if (blockbytesmin <= bytesread && bytesread <= blockbytesmax) {
106 DEBUG_LOG("Found deprecated blockbytes %" PRId64, bytesread);
107 blockbytes = bytesread;
108 }
109 }
110 }
111 }
112
113 // standard parsing
114 constexpr struct option longopts[] = {
115 {const_cast<char *>("blockbytes"), required_argument, nullptr, 'b'},
116 {const_cast<char *>("crr-ims-header"), required_argument, nullptr, 'c'},
117 {const_cast<char *>("disable-errorlog"), no_argument, nullptr, 'd'},
118 {const_cast<char *>("exclude-regex"), required_argument, nullptr, 'e'},
119 {const_cast<char *>("include-regex"), required_argument, nullptr, 'i'},
120 {const_cast<char *>("ref-relative"), no_argument, nullptr, 'l'},
121 {const_cast<char *>("pace-errorlog"), required_argument, nullptr, 'p'},
122 {const_cast<char *>("remap-host"), required_argument, nullptr, 'r'},
123 {const_cast<char *>("skip-header"), required_argument, nullptr, 's'},
124 {const_cast<char *>("blockbytes-test"), required_argument, nullptr, 't'},
125 {const_cast<char *>("prefetch-count"), required_argument, nullptr, 'f'},
126 {const_cast<char *>("strip-range-for-head"), no_argument, nullptr, 'h'},
127 {const_cast<char *>("minimum-size"), required_argument, nullptr, 'm'},
128 {const_cast<char *>("metadata-cache-size"), required_argument, nullptr, 'z'},
129 {const_cast<char *>("stats-prefix"), required_argument, nullptr, 'x'},
130 {nullptr, 0, nullptr, 0 },
131 };
132
133 // getopt assumes args start at '1' so this hack is needed
134 char *const *argvp = (const_cast<char *const *>(argv) - 1);
135 for (;;) {
136 int const opt = getopt_long(argc + 1, argvp, "b:dc:e:i:lm:p:r:s:t:x:z:", longopts, nullptr);
137 if (-1 == opt) {
138 break;

Callers 3

TSRemapNewInstanceFunction · 0.80
TSPluginInitFunction · 0.80
test_config.ccFile · 0.80

Calls 7

cache_capacityMethod · 0.80
substrMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
assignMethod · 0.45
c_strMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected