]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/ctdlprotocol.php
* wait a second so the session proxy has time to start, and become responsive.
[citadel.git] / ctdlphp / ctdlprotocol.php
index 677ad5c000e9e482955c51d67aba9f44b1469d21..7a332052b4ca57faa305968aa9e239900c26b3c5 100644 (file)
@@ -8,6 +8,10 @@
 include "config_ctdlclient.php";
 
 
+define("FMT_CITADEL", 0);
+define("FMT_FIXED", 1);
+define("FMT_RFC822", 4);
+
 //--------------------------------------------------------------------------------
 //   internal functions for server communication
 //--------------------------------------------------------------------------------
@@ -39,33 +43,13 @@ function serv_get_n($nBytes) {
                printf("reading ".$nBytes." bytes from server\n");
                printf ("</div>\n");
        }
-       $i = 0;
-       $buf = "";
-       $nRead = 0;
-//     while ($nRead < $nBytes)
-       {
-               $buf = fread($clientsocket, $nBytes);
-//             $buf.=fgetc($clientsocket) | die ("fgetc failed");
-//             $buf .= serv_gets(TRUE);
-//             $tbuf = fgets($clientsocket, $nBytes - $nRead);
-               if (CITADEL_DEBUG_CITPROTO == 1) {
-                       if (!$buf) printf ("<div class='ctdldbgRead'>\n");
-                       printf($buf);
-                       if (!$buf) printf ("</div>\n");
-                       else printf ("<br>\n");
-               }
-//             $buf .= $tbuf;
-//             $nRead = strlen ($buf);
-
-       }
-               
-       //$buf = fread($clientsocket, $nBytes) | die ("fread failed");          // Read line
+       $buf = fread($clientsocket, $nBytes);
        if (CITADEL_DEBUG_CITPROTO == 1) {
-               printf ("<div class='ctdldbgRead'>\n");
+               if (!$buf) printf ("<div class='ctdldbgRead'>\n");
                printf($buf);
-               printf ("</div>\n");
+               if (!$buf) printf ("</div>\n");
+               else printf ("<br>\n");
        }
-       print_r($buf);
        return $buf;
 }
 
@@ -117,11 +101,8 @@ function read_binary() {
                $buf = serv_get_n($statusline[1]);
                
        }
-       
-       if (CITADEL_DEBUG_CITPROTO == 1){
-               echo "read ".$statusline[1]." bytes from the server.\n";
-               printf ("</div>\n");
-       }
+       if (CITADEL_DEBUG_CITPROTO == 1)
+           printf ("</div>\n");
        return array($statusline, $buf);
 }
 
@@ -731,17 +712,86 @@ function ctdl_msg4_from_server() {
 
 
 
-function downoad_attachment($msgnum, $attindex)
+function download_attachment($msgnum, $attindex)
 {
        $command = "DLAT ".$msgnum."|".$attindex;
        serv_puts($command);
        $reply = read_binary();
-
-       print_r($reply);
        return $reply;
 
 }
 
 
+function enter_message_0($msgHdr, $contentType, $data)
+{
+       $send = array();
+
+       if (isset($msgHdr['newusermail']))
+               array_unshift($send, $msgHdr['newusermail']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['supplied_euid']))
+               array_unshift($send, $msgHdr['supplied_euid']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['bcc']))
+               array_unshift($send, $msgHdr['bcc']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['cc']))
+               array_unshift($send, $msgHdr['cc']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['do_confirm']))
+               array_unshift($send, $msgHdr['do_confirm']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['newusername']))
+               array_unshift($send, $msgHdr['newusername']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['subject']))
+               array_unshift($send, $msgHdr['subject']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['format_type']))
+               array_unshift($send, $msgHdr['format_type']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['anon_flag']))
+               array_unshift($send, $msgHdr['anon_flag']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['recp']))
+               array_unshift($send, $msgHdr['recp']);
+       else
+               array_unshift($send, "");
+
+       if (isset($msgHdr['post']))
+               array_unshift($send, $msgHdr['post']);
+       else
+               array_unshift($send, "");
+
+       $params = implode('|', $send);
+       serv_puts("ENT0 ".$params);
+
+       $reply=serv_gets();
+       if (substr($reply, 0, 1) != 4)
+               return array(false, array(), array());
+       serv_puts("Content-type: ".$contentType);
+       serv_puts("");
+       serv_puts($data."\r\n");
+       serv_puts("000");
+}
+
 
 ?>