Mercurial > gftp.yaz
diff lib/protocols.c @ 87:6df043359b41
2003-1-11 Brian Masney <masneyb@gftp.org>
* autogen.sh - removed --intl and --no-changelog flags to gettextize
* aclocal.m4 - updated
* configure.in - and intl and po directories to AC_OUTPUT
* cvsclean - remove more stuff
* lib/bookmark.c (bookmark_parse_url) - use gftp_parse_bookmark
function
* lib/cache.c - remove gftp_cache_get_url_prefix(). Use
request->url_prefix instead
* lib/config_file.c - use proper exit codes. Also complain if the
default protocol specified in the config file is invalid
* lib/gftp.h lib/local.c lib/protocols.c - removed isblock, ischar,
issocket and isfifo in struct gftp_file (not used anymore)
* lib/gftp.h lib/misc.c - removed file_countlf (not used anymore)
* lib/local.c lib/misc.c lib/protocols.c - various small cleanups
* lib/misc.c (string_hash_function) - check key[i] instead of key[0]
* lib/protocols.c lib/gftp.h - added gftp_parse_bookmark()
* lib/rfc2068.c - if we are connected to a FTP url via a proxy, set
request->url_prefix to be ftp. Added rfc2068_destroy() to free
url_prefix whenever the structure is to be freed
author | masneyb |
---|---|
date | Sat, 11 Jan 2003 15:47:09 +0000 |
parents | 7ef60ce2bdb2 |
children | 8c37d73d3f1f |
line wrap: on
line diff
--- a/lib/protocols.c Mon Dec 30 01:32:19 2002 +0000 +++ b/lib/protocols.c Sat Jan 11 15:47:09 2003 +0000 @@ -188,7 +188,7 @@ g_return_val_if_fail (toreq != NULL, GFTP_EFATAL); g_return_val_if_fail (tofile != NULL, GFTP_EFATAL); - if (strcmp (fromreq->protocol_name, toreq->protocol_name) == 0 && + if (fromreq->protonum == toreq->protonum && fromreq->transfer_file != NULL) return (fromreq->transfer_file (fromreq, fromfile, fromsize, toreq, tofile, tosize)); @@ -373,6 +373,79 @@ int +gftp_parse_bookmark (gftp_request * request, const char * bookmark) +{ + gftp_logging_func logging_function; + gftp_bookmarks * tempentry; + int i; + + g_return_val_if_fail (request != NULL, GFTP_EFATAL); + g_return_val_if_fail (bookmark != NULL, GFTP_EFATAL); + + logging_function = request->logging_function; + gftp_request_destroy (request, 0); + request->logging_function = logging_function; + + if ((tempentry = g_hash_table_lookup (bookmarks_htable, bookmark)) == NULL) + { + request->logging_function (gftp_logging_error, request->user_data, + _("Error: Could not find bookmark %s\n"), + bookmark); + return (GFTP_EFATAL); + } + else if (tempentry->hostname == NULL || *tempentry->hostname == '\0') + { + request->logging_function (gftp_logging_error, request->user_data, + _("Bookmarks Error: The bookmark entry %s does not have a hostname\n"), bookmark); + return (GFTP_EFATAL); + } + + if (tempentry->user != NULL) + gftp_set_username (request, tempentry->user); + + if (tempentry->pass != NULL) + { + if (strncmp (tempentry->pass, "@EMAIL@", 7) == 0) + gftp_set_password (request, emailaddr); + else + gftp_set_password (request, tempentry->pass); + } + + if (tempentry->acct != NULL) + gftp_set_account (request, tempentry->acct); + + gftp_set_hostname (request, tempentry->hostname); + gftp_set_directory (request, tempentry->remote_dir); + gftp_set_port (request, tempentry->port); + gftp_set_sftpserv_path (request, tempentry->sftpserv_path); + + for (i = 0; gftp_protocols[i].name; i++) + { + if (strcmp (gftp_protocols[i].name, tempentry->protocol) == 0) + { + gftp_protocols[i].init (request); + break; + } + } + + if (!gftp_protocols[i].name) + { + for (i = 0; gftp_protocols[i].url_prefix; i++) + { + if (strcmp (gftp_protocols[i].name, default_protocol) == 0) + break; + } + + if (gftp_protocols[i].url_prefix == NULL) + i = GFTP_FTP_NUM; + } + + gftp_protocols[i].init (request); + return (0); +} + + +int gftp_parse_url (gftp_request * request, const char *url) { char *pos, *endpos, *endhostpos, *str, tempchar; @@ -1350,14 +1423,6 @@ fle->islink = 1; if (strchr (fle->attribs, 'x') != NULL && !fle->isdir && !fle->islink) fle->isexe = 1; - if (*fle->attribs == 'b') - fle->isblock = 1; - if (*fle->attribs == 'c') - fle->ischar = 1; - if (*fle->attribs == 's') - fle->issocket = 1; - if (*fle->attribs == 'p') - fle->isfifo = 1; return (result); }