1
|
1 /*****************************************************************************/
|
33
|
2 /* bookmark.c - functions for connecting to a site via a bookmark */
|
1
|
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
|
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
|
|
18 /*****************************************************************************/
|
|
19
|
|
20 #include "gftp.h"
|
33
|
21 static const char cvsid[] = "$Id$";
|
1
|
22
|
|
23
|
|
24 static int
|
|
25 bookmark_parse_url (gftp_request * request, const char * url)
|
|
26 {
|
|
27 gftp_bookmarks * tempentry;
|
|
28 const char * pos;
|
|
29 int i;
|
|
30
|
|
31 g_return_val_if_fail (request != NULL, -2);
|
|
32 g_return_val_if_fail (url != NULL, -2);
|
|
33
|
|
34 if ((pos = strstr (url, "://")) != NULL)
|
|
35 pos += 3;
|
|
36 else
|
|
37 pos = url;
|
|
38
|
|
39 if ((tempentry = g_hash_table_lookup (bookmarks_htable, pos)) == NULL)
|
|
40 {
|
|
41 request->logging_function (gftp_logging_error, request->user_data,
|
|
42 _("Error: Could not find bookmark %s\n"), pos);
|
|
43 return (-2);
|
|
44 }
|
|
45 else if (tempentry->hostname == NULL || *tempentry->hostname == '\0' ||
|
|
46 tempentry->user == NULL || *tempentry->user == '\0')
|
|
47 {
|
|
48 request->logging_function (gftp_logging_error, request->user_data,
|
|
49 _("Bookmarks Error: There are some missing entries in this bookmark. Make sure you have a hostname and username\n"));
|
|
50 return (-2);
|
|
51 }
|
|
52
|
|
53 gftp_set_username (request, tempentry->user);
|
|
54 if (strncmp (tempentry->pass, "@EMAIL@", 7) == 0)
|
|
55 gftp_set_password (request, emailaddr);
|
|
56 else
|
|
57 gftp_set_password (request, tempentry->pass);
|
|
58 if (tempentry->acct != NULL)
|
|
59 gftp_set_account (request, tempentry->acct);
|
|
60 gftp_set_hostname (request, tempentry->hostname);
|
|
61 gftp_set_directory (request, tempentry->remote_dir);
|
|
62 gftp_set_port (request, tempentry->port);
|
|
63 gftp_set_sftpserv_path (request, tempentry->sftpserv_path);
|
|
64
|
|
65 for (i = 0; gftp_protocols[i].name; i++)
|
|
66 {
|
|
67 if (strcmp (gftp_protocols[i].name, tempentry->protocol) == 0)
|
|
68 {
|
|
69 gftp_protocols[i].init (request);
|
|
70 break;
|
|
71 }
|
|
72 }
|
|
73
|
|
74 if (!gftp_protocols[i].name)
|
|
75 gftp_protocols[0].init (request);
|
|
76
|
|
77 return (0);
|
|
78 }
|
|
79
|
48
|
80
|
|
81 void
|
|
82 bookmark_init (gftp_request * request)
|
|
83 {
|
|
84 g_return_if_fail (request != NULL);
|
|
85
|
|
86 request->protonum = GFTP_BOOKMARK_NUM;
|
|
87 request->init = bookmark_init;
|
|
88 request->destroy = NULL;
|
|
89 request->connect = NULL;
|
|
90 request->disconnect = NULL;
|
|
91 request->get_file = NULL;
|
|
92 request->put_file = NULL;
|
|
93 request->transfer_file = NULL;
|
|
94 request->get_next_file_chunk = NULL;
|
|
95 request->put_next_file_chunk = NULL;
|
|
96 request->end_transfer = NULL;
|
|
97 request->list_files = NULL;
|
|
98 request->get_next_file = NULL;
|
|
99 request->set_data_type = NULL;
|
|
100 request->get_file_size = NULL;
|
|
101 request->chdir = NULL;
|
|
102 request->rmdir = NULL;
|
|
103 request->rmfile = NULL;
|
|
104 request->mkdir = NULL;
|
|
105 request->rename = NULL;
|
|
106 request->chmod = NULL;
|
|
107 request->set_file_time = NULL;
|
|
108 request->site = NULL;
|
|
109 request->parse_url = bookmark_parse_url;
|
|
110 request->url_prefix = "bookmark";
|
|
111 request->protocol_name = "Bookmark";
|
|
112 request->need_hostport = 0;
|
|
113 request->need_userpass = 0;
|
|
114 request->use_threads = 0;
|
|
115 request->use_cache = 0;
|
|
116 request->always_connected = 0;
|
|
117 gftp_set_config_options (request);
|
|
118 }
|
|
119
|