annotate lib/bookmark.c @ 65:4b5fec7711e9

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