bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenbool doveadm_verbose = FALSE, doveadm_debug = FALSE, doveadm_server = FALSE;
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen /* some doveadm plugins have dependencies to mail plugins. we can load
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen only those whose dependencies have been loaded earlier, the rest are
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen modules = module_dir_load_missing(modules, DOVEADM_MODULEDIR,
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainenbool doveadm_has_unloaded_plugin(const char *name)
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen /* first check that it's not actually loaded */
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen for (module = modules; module != NULL; module = module->next) {
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (strcmp(module_get_plugin_name(module), name) == 0)
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen plugin_name = module_file_get_name(d->d_name);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (strncmp(plugin_name, name, name_len) == 0 &&
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen strcmp(plugin_name + name_len, "_plugin") == 0)) {
b1f37113a5760bee842c5a7678bb5fa6f5bd8b60Timo Sirainen return t_strflocaltime("%Y-%m-%d %H:%M:%S", timestamp);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainenconst char *doveadm_plugin_getenv(const char *name)
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (!array_is_created(&doveadm_settings->plugin_envs))
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen envs = array_get(&doveadm_settings->plugin_envs, &count);
009217abb57a24a4076092e8e4e165545747839eStephan Boschdoveadm_tcp_connect_port(const char *host, in_port_t port)
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen ret = net_gethostbyname(host, &ips, &ips_count);
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen fd = net_connect_ip_blocking(&ips[0], port, NULL);
009217abb57a24a4076092e8e4e165545747839eStephan Boschint doveadm_tcp_connect(const char *target, in_port_t default_port)
7c925149e49f7cce41c90d562ff3835b66ddca29Timo Sirainen if (net_str2hostport(target, default_port, &host, &port) < 0) {
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen i_fatal("Port not known for %s. Either set proxy_port "
250a06cde50c4004ac1cc72279b75a229a7f90f5Timo Sirainenint doveadm_connect_with_default_port(const char *path,
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen /* we'll assume UNIX sockets typically have an absolute path,
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen or at the very least '/' somewhere. */
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen i_fatal("net_connect_unix(%s) failed: %m", path);
250a06cde50c4004ac1cc72279b75a229a7f90f5Timo Sirainen return doveadm_connect_with_default_port(path, 0);
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomi if ((*a == ' ' || *a == '-') && *a != *b && *b != ' ' && *b != '-') {
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomi } else if ((*b == ' ' || *b == '-') && *a != *b && *a != ' ' && *a != '-') {
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomi (*a != *b)) break;
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomi return *a-*b;
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x01';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x02';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x03';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x04';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x05';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi return '\x06';
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomibool doveadm_log_type_from_char(char c, enum log_type *type_r)
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x01':
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x02':
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x03':
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x04':
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x05':
c9dd53f7180a78668cbc1e6eb34d5b1722beccb9Aki Tuomi case '\x06':