aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-09-02 15:11:08 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-09-02 15:11:08 +0000
commit56d9624b566ac15ffb4b4b6eef220a5000b767e0 (patch)
tree9511f37ced87ba79fe96416b21e41fadffe17224 /lib/url.c
parent911d135deb619f6d18ae3e0150c3808be54831a3 (diff)
John Kelly added TFTP support to libcurl. A bunch of new error codes was
added. TODO: add them to docs. add TFTP server to test suite. add TFTP to list of protocols whereever those are mentioned.
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index 92d81caa4..06784fe34 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -77,9 +77,7 @@
#error "We can't compile without socket() support!"
#endif
-
#endif
-
#ifdef USE_LIBIDN
#include <idna.h>
#include <tld.h>
@@ -123,6 +121,7 @@ void idn_free (void *ptr); /* prototype from idn-free.h, not provided by
#include "ftp.h"
#include "dict.h"
#include "telnet.h"
+#include "tftp.h"
#include "http.h"
#include "file.h"
#include "ldap.h"
@@ -2917,6 +2916,43 @@ static CURLcode CreateConnection(struct SessionHandle *data,
" was built with FILE disabled!");
#endif
}
+ else if (strequal(conn->protostr, "TFTP")) {
+#ifndef CURL_DISABLE_TFTP
+ char *type;
+ conn->protocol |= PROT_TFTP;
+ conn->port = PORT_TFTP;
+ conn->remote_port = PORT_TFTP;
+ conn->curl_connect = Curl_tftp_connect;
+ conn->curl_do = Curl_tftp;
+ conn->curl_done = Curl_tftp_done;
+ /* TFTP URLs support an extension like ";mode=<typecode>" that
+ * we'll try to get now! */
+ type=strstr(conn->path, ";mode=");
+ if(!type) {
+ type=strstr(conn->host.rawalloc, ";mode=");
+ }
+ if(type) {
+ char command;
+ *type=0; /* it was in the middle of the hostname */
+ command = toupper((int)type[6]);
+ switch(command) {
+ case 'A': /* ASCII mode */
+ case 'N': /* NETASCII mode */
+ data->set.ftp_ascii = 1;
+ break;
+ case 'O': /* octet mode */
+ case 'I': /* binary mode */
+ default:
+ /* switch off ASCII */
+ data->set.ftp_ascii = 0;
+ break;
+ }
+ }
+#else
+ failf(data, LIBCURL_NAME
+ " was built with TFTP disabled!");
+#endif
+ }
else {
/* We fell through all checks and thus we don't support the specified
protocol */