return -1;
}
- if (ac_prefs->protocol == A_LOCAL && ac_prefs->use_mail_command)
- {
- val = send_message_with_command(to_list,
- ac_prefs->mail_command,
- fp);
- }
- else
- {
- port = ac_prefs->set_smtpport
- ? ac_prefs->smtpport : SMTP_PORT;
- domain = ac_prefs->set_domain
- ? ac_prefs->domain : NULL;
-
- val = send_message_smtp(to_list, ac_prefs->address,
- ac_prefs->smtp_server, port,
- domain, ac_prefs->userid,
- ac_prefs->passwd,
- ac_prefs->use_smtp_auth, fp);
- }
+ if (ac_prefs->protocol == A_LOCAL && ac_prefs->use_mail_command) {
+ val = send_message_with_command(to_list,
+ ac_prefs->mail_command,
+ fp);
+ } else {
+ port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT;
+ domain = ac_prefs->set_domain ? ac_prefs->domain : NULL;
+
+ val = send_message_smtp(to_list, ac_prefs->address,
+ ac_prefs->smtp_server, port,
+ domain, ac_prefs->userid,
+ ac_prefs->passwd,
+ ac_prefs->use_smtp_auth, fp);
+ }
fclose(fp);
return val;
cmdline = g_new(gchar, len + 1);
strcpy(cmdline, mailcmd);
- for (cur = to_list; cur != NULL; cur = cur->next)
- {
- cmdline = strncat(cmdline, " ", len);
- cmdline = strncat(cmdline, (gchar *)cur->data, len);
- }
+ for (cur = to_list; cur != NULL; cur = cur->next) {
+ cmdline = strncat(cmdline, " ", len);
+ cmdline = strncat(cmdline, (gchar *)cur->data, len);
+ }
log_message(_("Using command to send mail: %s ...\n"), cmdline);
p = popen(cmdline, "w");
- if (p != NULL)
- {
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- strretchomp(buf);
-
- /* escape when a dot appears on the top */
- if (buf[0] == '.')
- fputs(".", p);
-
- fputs(buf, p);
- fputs("\n", p);
- }
+ if (p != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ strretchomp(buf);
+
+ /* escape when a dot appears on the top */
+ if (buf[0] == '.')
+ fputs(".", p);
+
+ fputs(buf, p);
+ fputs("\n", p);
}
+ }
pclose(p);
log_message(_("Mail sent successfully ...\n"));
const gchar *bp_ = NULL;
const gchar *ep_ = NULL;
+ /* the informative part of the email address (describing the name
+ * of the email address owner) may contain quoted parts. the
+ * closure stack stores the last encountered quotes. */
+ gchar closure_stack[128];
+ gchar *ptr = closure_stack;
+
g_return_val_if_fail(start != NULL, FALSE);
g_return_val_if_fail(scanpos != NULL, FALSE);
g_return_val_if_fail(bp != NULL, FALSE);
}
}
+ if (!result) return FALSE;
+
/* we now have at least the address. now see if this is <bracketed>; in this
* case we also scan for the informative part. we could make this a useful
* function because it tries to parse out an email address backwards. :) */
- if (result) {
- if ( ((bp_ - 1 > start) && *(bp_ - 1) == '<') && (*ep_ == '>')) {
-
- /* the informative part of the email address (describing the name
- * of the email address owner) may contain quoted parts. the
- * closure stack stores the last encountered quotes. */
- gchar closure_stack[128];
- gchar *ptr = closure_stack;
-#define FULL_STACK() ((size_t) (ptr - closure_stack) >= sizeof closure_stack)
-#define IN_STACK() (ptr > closure_stack)
+ if (bp_ - 1 <= start || *(bp_ - 1) != '<' || *ep_ != '>')
+ return TRUE;
+
+#define FULL_STACK() ((size_t) (ptr - closure_stack) >= sizeof closure_stack)
+#define IN_STACK() (ptr > closure_stack)
/* has underrun check */
-#define POP_STACK() if(IN_STACK()) --ptr
+#define POP_STACK() if(IN_STACK()) --ptr
/* has overrun check */
-#define PUSH_STACK(c) if(!FULL_STACK()) *ptr++ = (c); else return TRUE
+#define PUSH_STACK(c) if(!FULL_STACK()) *ptr++ = (c); else return TRUE
/* has underrun check */
#define PEEK_STACK() (IN_STACK() ? *(ptr - 1) : 0)
- ep_++;
-
- /* scan for the informative part. */
-
- for (bp_ -= 2; bp_ >= start; bp_--) {
- /* if closure on the stack keep scanning */
- if (PEEK_STACK() == *bp_) {
- POP_STACK();
- }
- else {
- if (*bp_ == '\'' || *bp_ == '"') {
- PUSH_STACK(*bp_);
- }
- else {
- /* if nothing in the closure stack, do the special conditions
- * the following if..else expression simply checks whether
- * a token is acceptable. if not acceptable, the clause
- * should terminate the loop with a 'break' */
- if (!PEEK_STACK()) {
- if ( *bp_ == '-'
- && (((bp_ - 1) >= start) && isalnum(*(bp_ - 1)))
- && (((bp_ + 1) < ep_) && isalnum(*(bp_ + 1))) ) {
- /* hyphens are allowed, but only in between alnums */
- }
- else if ( !ispunct(*bp_) ) {
- /* but anything not being a punctiation is ok */
- }
- else {
- break; /* anything else is rejected */
- }
- }
- }
- }
+ ep_++;
+
+ /* scan for the informative part. */
+ for (bp_ -= 2; bp_ >= start; bp_--) {
+ /* if closure on the stack keep scanning */
+ if (PEEK_STACK() == *bp_) {
+ POP_STACK();
+ continue;
+ }
+ if (*bp_ == '\'' || *bp_ == '"') {
+ PUSH_STACK(*bp_);
+ continue;
+ }
+
+ /* if nothing in the closure stack, do the special conditions
+ * the following if..else expression simply checks whether
+ * a token is acceptable. if not acceptable, the clause
+ * should terminate the loop with a 'break' */
+ if (!PEEK_STACK()) {
+ if (*bp_ == '-'
+ && (((bp_ - 1) >= start) && isalnum(*(bp_ - 1)))
+ && (((bp_ + 1) < ep_) && isalnum(*(bp_ + 1)))) {
+ /* hyphens are allowed, but only in
+ between alnums */
+ } else if (!ispunct(*bp_)) {
+ /* but anything not being a punctiation
+ is ok */
+ } else {
+ break; /* anything else is rejected */
}
-
- bp_++;
+ }
+ }
+
+ bp_++;
#undef PEEK_STACK
#undef PUSH_STACK
#undef IN_STACK
#undef FULL_STACK
- /* scan forward (should start with an alnum) */
- for (; *bp_ != '<' && isspace(*bp_) && *bp_ != '"'; bp_++)
- ;
+ /* scan forward (should start with an alnum) */
+ for (; *bp_ != '<' && isspace(*bp_) && *bp_ != '"'; bp_++)
+ ;
+
+ *ep = ep_;
+ *bp = bp_;
- *ep = ep_;
- *bp = bp_;
- }
- }
return result;
}