////////////////////////////////////////////////////////////////////////// One instance per remap.config invocation.
| 1195 | // One instance per remap.config invocation. |
| 1196 | // |
| 1197 | TSReturnCode |
| 1198 | TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */) |
| 1199 | { |
| 1200 | static const struct option longopt[] = { |
| 1201 | {const_cast<char *>("access_key"), required_argument, nullptr, 'a' }, |
| 1202 | {const_cast<char *>("config"), required_argument, nullptr, 'c' }, |
| 1203 | {const_cast<char *>("secret_key"), required_argument, nullptr, 's' }, |
| 1204 | {const_cast<char *>("version"), required_argument, nullptr, 'v' }, |
| 1205 | {const_cast<char *>("virtual_host"), no_argument, nullptr, 'h' }, |
| 1206 | {const_cast<char *>("v4-include-headers"), required_argument, nullptr, 'i' }, |
| 1207 | {const_cast<char *>("v4-exclude-headers"), required_argument, nullptr, 'e' }, |
| 1208 | {const_cast<char *>("v4-region-map"), required_argument, nullptr, 'm' }, |
| 1209 | {const_cast<char *>("session_token"), required_argument, nullptr, 't' }, |
| 1210 | {nullptr, no_argument, nullptr, '\0'}, |
| 1211 | }; |
| 1212 | |
| 1213 | S3Config *s3 = new S3Config(true); // true == this config gets the continuation |
| 1214 | S3Config *file_config = nullptr; |
| 1215 | |
| 1216 | // argv contains the "to" and "from" URLs. Skip the first so that the |
| 1217 | // second one poses as the program name. |
| 1218 | --argc; |
| 1219 | ++argv; |
| 1220 | |
| 1221 | while (true) { |
| 1222 | int opt = getopt_long(argc, static_cast<char *const *>(argv), "", longopt, nullptr); |
| 1223 | |
| 1224 | switch (opt) { |
| 1225 | case 'c': |
| 1226 | file_config = gConfCache.get(optarg); // Get cached, or new, config object, from a file |
| 1227 | if (!file_config) { |
| 1228 | TSError("[%s] invalid configuration file, %s", PLUGIN_NAME, optarg); |
| 1229 | *ih = nullptr; |
| 1230 | return TS_ERROR; |
| 1231 | } |
| 1232 | break; |
| 1233 | case 'a': |
| 1234 | s3->set_keyid(optarg); |
| 1235 | break; |
| 1236 | case 's': |
| 1237 | s3->set_secret(optarg); |
| 1238 | break; |
| 1239 | case 't': |
| 1240 | s3->set_token(optarg); |
| 1241 | break; |
| 1242 | case 'h': |
| 1243 | s3->set_virt_host(); |
| 1244 | break; |
| 1245 | case 'v': |
| 1246 | s3->set_version(optarg); |
| 1247 | break; |
| 1248 | case 'i': |
| 1249 | s3->set_include_headers(optarg); |
| 1250 | break; |
| 1251 | case 'e': |
| 1252 | s3->set_exclude_headers(optarg); |
| 1253 | break; |
| 1254 | case 'm': |
nothing calls this directly
no test coverage detected