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

Function plugin_init

src/proxy/Plugin.cc:274–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274bool
275plugin_init(bool validateOnly)
276{
277 ats_scoped_str path;
278 char line[1024], *p;
279 char *argv[MAX_PLUGIN_ARGS];
280 char *vars[MAX_PLUGIN_ARGS];
281 int argc;
282 int fd;
283 int i;
284 bool retVal = true;
285 static bool INIT_ONCE = true;
286
287 if (INIT_ONCE) {
288 plugin_dir = ats_stringdup(RecConfigReadPluginDir());
289 INIT_ONCE = false;
290 }
291
292 Note("%s loading ...", ts::filename::PLUGIN);
293 path = RecConfigReadConfigPath(nullptr, ts::filename::PLUGIN);
294 fd = open(path, O_RDONLY);
295 if (fd < 0) {
296 Warning("%s failed to load: %d, %s", ts::filename::PLUGIN, errno, strerror(errno));
297 return false;
298 }
299
300 while (ink_file_fd_readline(fd, sizeof(line) - 1, line) > 0) {
301 argc = 0;
302 p = line;
303
304 // strip leading white space and test for comment or blank line
305 while (*p && ParseRules::is_wslfcr(*p)) {
306 ++p;
307 }
308 if ((*p == '\0') || (*p == '#')) {
309 continue;
310 }
311
312 // not comment or blank, so rip line into tokens
313 while (true) {
314 if (argc >= MAX_PLUGIN_ARGS) {
315 Warning("Exceeded max number of args (%d) for plugin: [%s]", MAX_PLUGIN_ARGS, argc > 0 ? argv[0] : "???");
316 break;
317 }
318
319 while (*p && ParseRules::is_wslfcr(*p)) {
320 ++p;
321 }
322 if ((*p == '\0') || (*p == '#')) {
323 break; // EOL
324 }
325
326 if (*p == '\"') {
327 p += 1;
328
329 argv[argc++] = p;
330
331 while (*p && (*p != '\"')) {

Callers 2

cmd_verifyFunction · 0.85
mainFunction · 0.85

Calls 8

ats_stringdupFunction · 0.85
RecConfigReadPluginDirFunction · 0.85
RecConfigReadConfigPathFunction · 0.85
ink_file_fd_readlineFunction · 0.85
plugin_expandFunction · 0.85
single_plugin_initFunction · 0.85
ats_freeFunction · 0.85
ErrorClass · 0.50

Tested by

no test coverage detected