diff options
author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-20 18:42:58 -0400 |
---|---|---|
committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-20 18:42:58 -0400 |
commit | 381c9c8870fad4c544f29deec22ba4be3549a731 (patch) | |
tree | f5f26e2dd380910b0ddd26e3d885d6bf56d40181 /src/mail.cpp | |
parent | 2528dc80bd1b3e6b2c09db23eb51659e30128110 (diff) |
The first of a few "CBX OCDing over code style" commits, focusing on include/* and src/* but not src/core/* or src/modules/*.
Diffstat (limited to 'src/mail.cpp')
-rw-r--r-- | src/mail.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/mail.cpp b/src/mail.cpp index 9e1c60c6b..c7c8ebda7 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -14,9 +14,7 @@ void MailThread::Run() FILE *pipe = popen(Config.SendMailPath, "w"); if (!pipe) - { return; - } fprintf(pipe, "From: %s\n", Config.SendFrom); if (Config.DontQuoteAddresses) @@ -26,7 +24,7 @@ void MailThread::Run() fprintf(pipe, "Subject: %s\n", Subject.c_str()); fprintf(pipe, "%s", Message.c_str()); fprintf(pipe, "\n.\n"); - + pclose(pipe); Success = true; @@ -36,9 +34,9 @@ bool Mail(User *u, NickRequest *nr, const std::string &service, const std::strin { if (!u || !nr || subject.empty() || service.empty() || message.empty()) return false; - + time_t t = time(NULL); - + if (!Config.UseMail) notice_lang(service.c_str(), u, MAIL_DISABLED); else if (t - u->lastmail < Config.MailDelay) @@ -59,7 +57,7 @@ bool Mail(User *u, NickCore *nc, const std::string &service, const std::string & { if (!u || !nc || subject.empty() || service.empty() || message.empty()) return false; - + time_t t = time(NULL); if (!Config.UseMail) @@ -82,7 +80,7 @@ bool Mail(NickCore *nc, const std::string &subject, const std::string &message) { if (!Config.UseMail || !nc || !nc->email || subject.empty() || message.empty()) return false; - + nc->lastmail = time(NULL); threadEngine.Start(new MailThread(nc->display, nc->email, subject, message)); @@ -103,14 +101,12 @@ bool MailValidate(const std::string &email) bool has_period = false; char copy[BUFSIZE]; - static char specials[] = { - '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', ' ' - }; + static char specials[] = {'(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', ' '}; if (email.empty()) return false; strlcpy(copy, email.c_str(), sizeof(copy)); - + char *domain = strchr(copy, '@'); if (!domain) return false; @@ -119,28 +115,28 @@ bool MailValidate(const std::string &email) /* Don't accept NULL copy or domain. */ if (!*copy || !*domain) return false; - + /* Check for forbidden characters in the name */ - for (unsigned int i = 0; i < strlen(copy); i++) + for (unsigned int i = 0; i < strlen(copy); ++i) { if (copy[i] <= 31 || copy[i] >= 127) return false; - for (unsigned int j = 0; j < 13; j++) + for (unsigned int j = 0; j < 13; ++j) if (copy[i] == specials[j]) return false; } /* Check for forbidden characters in the domain */ - for (unsigned int i = 0; i < strlen(domain); i++) + for (unsigned int i = 0; i < strlen(domain); ++i) { if (domain[i] <= 31 || domain[i] >= 127) return false; - for (unsigned int j = 0; j < 13; j++) + for (unsigned int j = 0; j < 13; ++j) if (domain[i] == specials[j]) return false; if (domain[i] == '.') { - if (i == 0 || i == strlen(domain) - 1) + if (!i || i == strlen(domain) - 1) return false; has_period = true; } @@ -148,4 +144,3 @@ bool MailValidate(const std::string &email) return has_period; } - |