]> granicus.if.org Git - curl/commitdiff
adjusted to support krb4
authorDaniel Stenberg <daniel@haxx.se>
Thu, 21 Sep 2000 08:49:16 +0000 (08:49 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 21 Sep 2000 08:49:16 +0000 (08:49 +0000)
lib/sendf.c
lib/sendf.h

index 7d238a974e52f15223f6482acd175aa3ae5454c3..77f403d7052fb202f9773bcd5065c70a45bedb8b 100644 (file)
 
 #include <curl/mprintf.h>
 
+#ifdef KRB4
+#include "security.h"
+#include <string.h>
+#endif
+
 /* infof() is for info message along the way */
 
 void infof(struct UrlData *data, char *fmt, ...)
@@ -96,9 +101,10 @@ int sendf(int fd, struct UrlData *data, char *fmt, ...)
     return 0; /* failure */
   if(data->bits.verbose)
     fprintf(data->err, "> %s", s);
+
 #ifndef USE_SSLEAY
-   bytes_written = swrite(fd, s, strlen(s));
-#else
+  bytes_written = swrite(fd, s, strlen(s));
+#else /* USE_SSLEAY */
   if (data->use_ssl) {
     bytes_written = SSL_write(data->ssl, s, strlen(s));
   } else {
@@ -109,22 +115,65 @@ int sendf(int fd, struct UrlData *data, char *fmt, ...)
   return(bytes_written);
 }
 
+/*
+ * ftpsendf() sends the formated string as a ftp command to a ftp server
+ */
+int ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
+{
+  size_t bytes_written;
+  char *s;
+  va_list ap;
+  va_start(ap, fmt);
+  s = mvaprintf(fmt, ap);
+  va_end(ap);
+  if(!s)
+    return 0; /* failure */
+  if(conn->data->bits.verbose)
+    fprintf(conn->data->err, "> %s\n", s);
+
+#ifdef KRB4
+  if(conn->sec_complete && conn->data->cmdchannel) {
+    bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
+    bytes_written += fprintf(conn->data->cmdchannel, "\r\n");
+    fflush(conn->data->cmdchannel);
+  }
+  else
+#endif /* KRB4 */
+    {
+      bytes_written = swrite(fd, s, strlen(s));
+      bytes_written += swrite(fd, "\r\n", 2);
+    }
+  free(s); /* free the output string */
+  return(bytes_written);
+}
+
+
 /* ssend() sends plain (binary) data to the server */
-size_t ssend(int fd, struct UrlData *data, void *mem, size_t len)
+size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
 {
   size_t bytes_written;
+  struct UrlData *data=conn->data; /* conn knows data, not vice versa */
 
   if(data->bits.verbose)
     fprintf(data->err, "> [binary output]\n");
-#ifndef USE_SSLEAY
-   bytes_written = swrite(fd, mem, len);
-#else
+
+#ifdef USE_SSLEAY
   if (data->use_ssl) {
     bytes_written = SSL_write(data->ssl, mem, len);
-  } else {
-    bytes_written = swrite(fd, mem, len);
   }
-#endif /* USE_SSLEAY */
+  else {
+#endif
+#ifdef KRB4
+    if(conn->sec_complete) {
+      bytes_written = sec_write(conn, fd, mem, len);
+    }
+    else
+#endif /* KRB4 */
+      bytes_written = swrite(fd, mem, len);
+#ifdef USE_SSLEAY
+  }
+#endif
+
   return bytes_written;
 }
 
index 79eff1c40bb4241c489d8255b0bb96bdac4b6111..91af88f998c7e0cc75c71d9f39122f097553dad9 100644 (file)
@@ -40,8 +40,9 @@
  * ------------------------------------------------------------
  ****************************************************************************/
 
+size_t ftpsendf(int fd, struct connectdata *, char *fmt, ...);
 size_t sendf(int fd, struct UrlData *, char *fmt, ...);
-size_t ssend(int fd, struct UrlData *, void *fmt, size_t len);
+size_t ssend(int fd, struct connectdata *, void *fmt, size_t len);
 void infof(struct UrlData *, char *fmt, ...);
 void failf(struct UrlData *, char *fmt, ...);