summaryrefslogtreecommitdiff
path: root/scripts/maildaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-12-23 14:33:23 -0500
committerEvan Prodromou <evan@prodromou.name>2008-12-23 14:33:23 -0500
commit04ef1ba8eee7a9e2a565d7b4b747ef607665d562 (patch)
treed56ac33bd6bfb8f8641cc9f63b0f6af52b6edfb9 /scripts/maildaemon.php
parenteb2f9c98ac115ce67e9a740b200c832153ffa05c (diff)
change function headers to K&R style
Another huge change, for PEAR code standards compliance. Function headers have to be in K&R style (opening brace on its own line), instead of having the opening brace on the same line as the function and parameters. So, a little perl magic found all the function definitions and move the opening brace to the next line (properly indented... usually). darcs-hash:20081223193323-84dde-a28e36ecc66672c783c2842d12fc11043c13ab28.gz
Diffstat (limited to 'scripts/maildaemon.php')
-rwxr-xr-xscripts/maildaemon.php36
1 files changed, 24 insertions, 12 deletions
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index 886e72ba7..6100cd21b 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -36,10 +36,12 @@ require_once('Mail/mimeDecode.php');
class MailerDaemon {
- function __construct() {
+ function __construct()
+ {
}
- function handle_message($fname='php://stdin') {
+ function handle_message($fname='php://stdin')
+ {
list($from, $to, $msg) = $this->parse_message($fname);
if (!$from || !$to || !$msg) {
$this->error(null, _('Could not parse message.'));
@@ -66,12 +68,14 @@ class MailerDaemon {
$this->add_notice($user, $msg);
}
- function error($from, $msg) {
+ function error($from, $msg)
+ {
file_put_contents("php://stderr", $msg . "\n");
exit(1);
}
- function user_from($from_hdr) {
+ function user_from($from_hdr)
+ {
$froms = mailparse_rfc822_parse_addresses($from_hdr);
if (!$froms) {
return null;
@@ -85,7 +89,8 @@ class MailerDaemon {
return $user;
}
- function user_match_to($user, $to_hdr) {
+ function user_match_to($user, $to_hdr)
+ {
$incoming = $user->incomingemail;
$tos = mailparse_rfc822_parse_addresses($to_hdr);
foreach ($tos as $to) {
@@ -96,7 +101,8 @@ class MailerDaemon {
return false;
}
- function handle_command($user, $from, $msg) {
+ function handle_command($user, $from, $msg)
+ {
$inter = new CommandInterpreter();
$cmd = $inter->handle_command($user, $msg);
if ($cmd) {
@@ -106,7 +112,8 @@ class MailerDaemon {
return false;
}
- function respond($from, $to, $response) {
+ function respond($from, $to, $response)
+ {
$headers['From'] = $to;
$headers['To'] = $from;
@@ -115,11 +122,13 @@ class MailerDaemon {
return mail_send(array($from), $headers, $response);
}
- function log($level, $msg) {
+ function log($level, $msg)
+ {
common_log($level, 'MailDaemon: '.$msg);
}
- function add_notice($user, $msg) {
+ function add_notice($user, $msg)
+ {
// should test
// $msg_shortened = common_shorten_links($msg);
// if (mb_strlen($msg_shortened) > 140) ERROR and STOP
@@ -133,7 +142,8 @@ class MailerDaemon {
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
}
- function parse_message($fname) {
+ function parse_message($fname)
+ {
$contents = file_get_contents($fname);
$parsed = Mail_mimeDecode::decode(array('input' => $contents,
'include_bodies' => true,
@@ -166,11 +176,13 @@ class MailerDaemon {
return array($from, $to, $msg);
}
- function unsupported_type($type) {
+ function unsupported_type($type)
+ {
$this->error(null, "Unsupported message type: " . $type);
}
- function cleanup_msg($msg) {
+ function cleanup_msg($msg)
+ {
$lines = explode("\n", $msg);
$output = '';