OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp.c versions 1.3 and 1.4
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.3 -> 1.4

--- lmtp2nntp.c  2001/07/24 11:32:07     1.3
+++ lmtp2nntp.c  2001/07/25 11:29:38     1.4
@@ -37,6 +37,8 @@
 static lmtp_rc_t lmtp_cb_mail   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
 static lmtp_rc_t lmtp_cb_rcpt   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
 static lmtp_rc_t lmtp_cb_data   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
+static lmtp_rc_t lmtp_cb_noop   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
+static lmtp_rc_t lmtp_cb_rset   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
 static lmtp_rc_t lmtp_cb_quit   (lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
 
 static void usage(char *command);
@@ -44,9 +46,30 @@
 
 int main(int argc, char **argv)
 {
-    int i; // general purpose scratch int, index ...
+    int i; /* general purpose scratch int, index ... */
 
-    // read in the arguments
+    {
+        char buf[1000];
+        int bufused = 0;
+        int tracefile;
+
+// printf("DEBUG: start of argdump\n", buf);
+        for (i=0; i<argc; i++) {
+// printf("DEBUG: [%d]=***%s***\n", i, argv[i]);
+            bufused+=sprintf(buf+bufused, "[%d]=\"%s\"\n", i, argv[i]);
+        }
+// printf("DEBUG: buffer ***%s***\n", buf);
+        if ((tracefile = open("/tmp/t", O_CREAT|O_WRONLY|O_APPEND, 0664)) != -1) {
+            write(tracefile, buf, bufused);
+// printf("DEBUG: writing\n", buf);
+            close(tracefile);
+        }
+// printf("DEBUG: end of argdump\n", buf);
+    }
+
+    /* read in the arguments */
+
+#if 0
 
     while ((i = getopt(argc, argv, "p:l:h:m:tv")) != -1)
         switch (i) {
@@ -68,7 +91,8 @@
                 //FIXME exit(ERR_EXECUTION);
         }
     argc -= optind; argv += optind; // remaining args is/are newsgroup/s
-
+#endif
+    
     //FIXME printf("Hello, World!\n");
     test();
     //FIXME printf("Hello, Again!\n");
@@ -133,6 +157,7 @@
     lmtp_io_t io;
 #define BUFLEN 100
     char buf[BUFLEN];
+    lmtp_cb_t oldcb = NULL;
     
 
     io.read=trace_read;
@@ -140,10 +165,14 @@
     io.select=select;
     lmtp = lmtp_create(STDIN_FILENO, STDOUT_FILENO, &io);
     // lmtp_debug_dumplmtp(lmtp);
-    lmtp_register(lmtp, "LHLO", lmtp_cb_lhlo, NULL, NULL, NULL);
+    lmtp_register(lmtp, "LHLO",         NULL, NULL,&oldcb,NULL); // printf("DEBUG: 1 oldcb=%d\n", (int)oldcb);
+    lmtp_register(lmtp, "LHLO", lmtp_cb_lhlo, NULL,&oldcb,NULL); // printf("DEBUG: 2 oldcb=%d\n", (int)oldcb);
+    lmtp_register(lmtp, "LHLO",         NULL, NULL,&oldcb,NULL); // printf("DEBUG: 3 oldcb=%d\n", (int)oldcb);
     lmtp_register(lmtp, "MAIL", lmtp_cb_mail, NULL, NULL, NULL);
     lmtp_register(lmtp, "RCPT", lmtp_cb_rcpt, NULL, NULL, NULL);
     lmtp_register(lmtp, "DATA", lmtp_cb_data, NULL, NULL, NULL);
+    lmtp_register(lmtp, "NOOP", lmtp_cb_noop, NULL, NULL, NULL);
+    lmtp_register(lmtp, "RSET", lmtp_cb_rset, NULL, NULL, NULL);
     lmtp_register(lmtp, "QUIT", lmtp_cb_quit, NULL, NULL, NULL);
     // lmtp_debug_dumplmtp(lmtp);
 
@@ -179,7 +208,13 @@
     lmtp_rc_t rc = LMTP_OK;
     res.statuscode = "250";
     res.dsncode    = NULL; /* DSN not used for greeting */
-    res.statusmsg  = "ENHANCEDSTATUSCODES\nDSN"; /* RFC2034, RFC1894 */
+    res.statusmsg  = "ENHANCEDSTATUSCODES\nDSN\nPIPELINING\n8BITMIME";
+        /*
+         *  RFC2034 = EHANCEDSTATUSCODES
+         *  RFC1894 = DSN
+         *  RFC1854 = PIPELINING
+         *  RFC1652 = 8BITMIME
+         */
     lmtp_response(lmtp, &res);
     return rc;
 }
@@ -190,22 +225,32 @@
     lmtp_rc_t rc = LMTP_OK;
     res.statuscode = "553";
     res.dsncode    = "5.1.8";
-    res.statusmsg  = "bad sender FIXME";
+    res.statusmsg  = "Bad sender FIXME";
     res.statuscode = "250";
     res.dsncode    = "2.1.0";
-    res.statusmsg  = "sender ok FIXME";
+    res.statusmsg  = "Sender ok FIXME";
     lmtp_response(lmtp, &res);
     return rc;
 }
 
 static lmtp_rc_t lmtp_cb_rcpt(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx)
 {
-    lmtp_res_t res;
     lmtp_rc_t rc = LMTP_OK;
+    lmtp_res_t res;
+    char **cp;
+
     res.statuscode = "250";
     res.dsncode    = "2.1.5";
     res.statusmsg  = "Recipient ok FIXME";
     lmtp_response(lmtp, &res);
+
+    cp = lmtp_message(lmtp, "RCPT");
+    if (cp == NULL) {
+        printf("DEBUG: cp=NULL\n");
+    } else {
+        printf("DEBUG: cp=%d\n", cp);
+    }
+
     return rc;
 }
 
@@ -242,6 +287,26 @@
     return rc;
 }
 
+static lmtp_rc_t lmtp_cb_noop(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx)
+{
+    lmtp_res_t res;
+    lmtp_rc_t rc = LMTP_OK;
+    res.statuscode = "250";
+    res.dsncode    = "2.0.0";
+    res.statusmsg  = "OK";
+    lmtp_response(lmtp, &res);
+    return rc;
+}
+static lmtp_rc_t lmtp_cb_rset(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx)
+{
+    lmtp_res_t res;
+    lmtp_rc_t rc = LMTP_OK;
+    res.statuscode = "250";
+    res.dsncode    = "2.0.0";
+    res.statusmsg  = "Reset state.";
+    lmtp_response(lmtp, &res);
+    return rc;
+}
 static lmtp_rc_t lmtp_cb_quit(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx)
 {
     lmtp_res_t res;

CVSTrac 2.0.1