logo       

cvs: pear /Mail_Mbox mbox.php mbox_test.php: msg#00299

Subject: cvs: pear /Mail_Mbox mbox.php mbox_test.php
darkelder               Mon Dec 30 11:26:47 2002 EDT

  Modified files:              
    /pear/Mail_Mbox     mbox.php mbox_test.php 
  Log:
  current development version
  
Index: pear/Mail_Mbox/mbox.php
diff -u pear/Mail_Mbox/mbox.php:1.5 pear/Mail_Mbox/mbox.php:1.6
--- pear/Mail_Mbox/mbox.php:1.5 Mon Dec 30 11:25:19 2002
+++ pear/Mail_Mbox/mbox.php     Mon Dec 30 11:26:44 2002
@@ -16,7 +16,7 @@
 // | Authors: Roberto Berto <darkelder.php.net>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: mbox.php,v 1.5 2002/12/30 16:25:19 darkelder Exp $
+// $Id: mbox.php,v 1.6 2002/12/30 16:26:44 darkelder Exp $
 
 require_once "PEAR.php";
 
@@ -536,51 +536,50 @@
 
         while (feof($this->_resources[$resourceId]["fresource"]) != true) {
             // getting char by char
-            $c = fgetc($this->_resources[$resourceId]["fresource"]);
-            $lineThis .= $c;
-            // each \n we will check things 
-            if ($c === "\n") {
-                // checking if start with From
-                if (substr($lineThis, 0, 5) === "From ") {
-                    // this line byte count is last line more 1 byte
-                    $bytesStart = $bytesEnd + 1;
-                    // last line byte count is this line bytes minus this line 
length
-                    $bytesEnd = $bytes - strlen($lineThis);
-                    // we will check messages after they end
-                    if ($bytesStart != 1) {
-                        if ($this->debug) {
-                            printf("#################### from byte %08d to 
byte %08d ################### <br />", $bytesStart, $bytesEnd);
-                        }
-
-                        // setting new message points
-                        $messagesCount = $this->size($resourceId);
-                        
$this->_resources[$resourceId]["messages"][$messagesCount][0] = $bytesStart;
-                        
$this->_resources[$resourceId]["messages"][$messagesCount][1] = $bytesEnd;
+            $lineThis = fgets($this->_resources[$resourceId]["fresource"]);
+            if (feof($this->_resources[$resourceId]["fresource"])) {
+                break;
+            }
+            $bytes    += strlen($lineThis);
+            // checking if start with From
+            if (substr($lineThis, 0, 5) === "From ") {
+                // this line byte count is last line more 1 byte
+                $bytesStart = $bytesEnd + 1;
+                // last line byte count is this line bytes minus this line 
length
+                $bytesEnd = $bytes - strlen($lineThis);
+                // we will check messages after they end
+                if ($bytesStart != 1) {
+                    if ($this->debug) {
+                        printf("#################### from byte %08d to byte 
%08d ################### <br />", $bytesStart, $bytesEnd);
                     }
-                }
 
-                // increasing number of lines (doesn't matter)
-                if ($this->debug) {
-                    $lines++;
-                }
- 
-                // last line is this line
-                $lineLast = $lineThis;
-
-                // this line is blank now
-                unset($lineThis);
-                if ($this->debug) {
-                    printf("%08d:%08d %s<br/>", $lines, $bytes, $lineLast);
+                    // setting new message points
+                    $messagesCount = $this->size($resourceId);
+                    
$this->_resources[$resourceId]["messages"][$messagesCount][0] = $bytesStart;
+                    
$this->_resources[$resourceId]["messages"][$messagesCount][1] = $bytesEnd;
                 }
             }
-            $bytes++;
+
+            // increasing number of lines (doesn't matter)
+            if ($this->debug) {
+                $lines++;
+            }
+
+            // last line is this line
+            $lineLast = $lineThis;
+
+            // this line is blank now
+            unset($lineThis);
+            if ($this->debug) {
+                printf("%08d:%08d %s<br/>", $lines, $bytes, $lineLast);
+            }
         }
         // last message must be made here - again same things - 
 
         // this line byte count is last line more 1 byte
         $bytesStart = $bytesEnd + 1;
-        // last line byte count is this line bytes minus this line length
-        $bytesEnd = $bytes - strlen($lineThis) - 2;
+        // last line byte count is this line bytes minus this line length and 
the blank line from Mbox format
+        $bytesEnd = $bytes - strlen($lineThis) - 1;
         // we will check messages after they end
 
         $messagesCount = $this->size($resourceId);
Index: pear/Mail_Mbox/mbox_test.php
diff -u pear/Mail_Mbox/mbox_test.php:1.3 pear/Mail_Mbox/mbox_test.php:1.4
--- pear/Mail_Mbox/mbox_test.php:1.3    Mon Dec 30 11:22:53 2002
+++ pear/Mail_Mbox/mbox_test.php        Mon Dec 30 11:26:46 2002
@@ -16,19 +16,19 @@
 // | Authors: Roberto Berto <darkelder.php.net>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: mbox_test.php,v 1.3 2002/12/30 16:22:53 darkelder Exp $
+// $Id: mbox_test.php,v 1.4 2002/12/30 16:26:46 darkelder Exp $
 
     // some random content
     $content = <<<EOF
 From Foo@xxxxxxxxxxx Fri Dec 27 14:31:10 2002
 Return-Path: 
-Received: from [unix socket] by campos.example.com (LMTP); Fri, 27 Dec
+Received: from [unix socket] by campos.terra.com.br (LMTP); Fri, 27 Dec
     2002 14:31:10 -0200 (BRST)
 Date: Fri, 27 Dec 2002 14:31:21 -0500
 Message-Id: <200212271931.gBRJVL012289@xxxxxxxxxxx>
-Received: from  pcp128525pcs.foo.example.com (
-    pcp128525pcs.example.com [99.99.99.99]) by/
-    serjolen6com.example.com (v64.19) with ESMTP id
+Received: from  pcp128525pcs.medfrd01.nj.comcast.net (
+    pcp128525pcs.medfrd01.nj.comcast.net [68.45.42.4]) by
+    serjolen6com.siteprotect.net (v64.19) with ESMTP id
     MAILRELAYINZA98-3601058302; Fri, 08 Nov 2002 06:39:05 -0500
 From: "Foo@xxxxxxxxxxx"
 To: fool@xxxxxxxxxxx
@@ -40,7 +40,7 @@
 
     // starting mbox
     require_once "mbox.php";
-    $mbox    =      new Mail_Mbox();
+    $mbox    =&    new Mail_Mbox();
 
     // uncomment to see lots of things
     #$mbox->debug    = true;
@@ -54,7 +54,7 @@
 
 
     // deleting a message (uncomment to test)
-    #$res1 =  $mbox->remove($mid,0);
+    $res1 =  $mbox->remove($mid,0);
     if (PEAR::isError($res1))
     {
         print $res1->getMessage();
@@ -65,7 +65,7 @@
 
 
         // changing a message (uncomment to test)
-    #$res2 = $mbox->update($mid,0,$content);
+        $res2 = $mbox->update($mid,0,$content);
         if (PEAR::isError($res2))
         {
                 print $res2->getMessage();
@@ -88,12 +88,12 @@
         printf("Message: %08d<pre>",$x);
         $thisMessage     = $mbox->get($mid,$x);
         print $thisMessage;    
-        print "<hr />";
+        print "<hr>";
         $decode = new Mail_mimeDecode($thisMessage, "\r\n");
         $structure = $decode->decode();
         print_r($structure);
 
-        print "</pre><hr /><hr /><hr />";
+        print "</pre><hr><hr><hr>";
     }
 
     



-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe