* improved but still wrong
[citadel.git] / ctdlphp / ctdlprotocol.php
index ff23a05b61b3df2e5553c7d117d323ebc60a45e3..a104d03bbbaea174efe626da4d3d6e8723baf1d2 100644 (file)
@@ -31,6 +31,32 @@ function serv_puts($buf) {
 }
 
 
+// 
+// text_to_server() -- sends a block of text to the server.  Assumes that
+//                     the server just sent back a SEND_LISTING response code
+//                     and is now expecting a 000-terminated series of lines.
+//                     Set 'convert_to_html' to TRUE to convert the block of
+//                     text to HTML along the way.
+//
+function text_to_server($thetext, $convert_to_html) {
+
+
+       $this_line = strtok($thetext, "\n");
+
+       while ($this_line) {
+               $this_line = trim($this_line, "\n\r");
+               if ($this_line == "000") $this_line = "-000" ;
+               serv_puts($this_line);
+               $this_line = strtok("\n");
+       }
+
+       serv_puts("000");
+       serv_puts("ECHO echo test.");           // FIXME
+       echo "Echo test: " . serv_gets() . "<BR>\n" ;
+
+}
+
+
 
 //
 // Identify ourselves to the Citadel server (do this once after connection)