#include "imap-id.h"
#include "dovecot-version.h"
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>
-#endif
-
/* Limit the allowed characters that an IMAP ID parameter might have. */
#define IMAP_ID_KEY_ACCEPT_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_-"
-static struct utsname utsname_result;
-static bool utsname_set = FALSE;
-
-static const char *imap_id_get_uname(const char *key)
-{
- if (!utsname_set) {
- utsname_set = TRUE;
- if (uname(&utsname_result) < 0) {
- i_error("uname() failed: %m");
- i_zero(&utsname_result);
- }
- }
-
- if (strcasecmp(key, "os") == 0)
- return utsname_result.sysname;
- if (strcasecmp(key, "os-version") == 0)
- return utsname_result.release;
- return NULL;
-}
-
-static const char *imap_id_get_default(const char *key)
-{
- if (strcasecmp(key, "name") == 0)
- return DOVECOT_NAME;
- if (strcasecmp(key, "version") == 0)
- return PACKAGE_VERSION;
- if (strcasecmp(key, "revision") == 0)
- return DOVECOT_REVISION;
- if (strcasecmp(key, "support-url") == 0)
- return PACKAGE_WEBPAGE;
- if (strcasecmp(key, "support-email") == 0)
- return PACKAGE_BUGREPORT;
- return imap_id_get_uname(key);
-}
-
const char *imap_id_reply_generate(const ARRAY_TYPE(const_string) *args)
{
if (array_is_empty(args))
imap_append_quoted(str, kv[i]);
str_append_c(str, ' ');
const char *value = kv[i + 1];
- if (strcmp(value, "*") == 0)
- value = imap_id_get_default(kv[i]);
#if defined(DOVECOT_EDITION)
- else if (strcasecmp(kv[i], "name") == 0 &&
- strcmp(DOVECOT_EDITION, "Pro") == 0)
- value = imap_id_get_default(kv[i]);
+ if (strcasecmp(kv[i], "name") == 0 &&
+ strcmp(DOVECOT_EDITION, "Pro") == 0)
+ value = DOVECOT_NAME;
#endif
imap_append_nstring(str, value);
}