annotate lib/local.c @ 992:9c583f570950 default tip

more character set conversion on remote file names.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 15 Sep 2010 11:42:57 +0900
parents c99b134c6185
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* local.c - functions that will use the local system */
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
3 /* Copyright (C) 1998-2007 Brian Masney <masneyb@gftp.org> */
1
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: 19
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 typedef struct local_protocol_data_tag
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 DIR *dir;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 GHashTable *userhash, *grouphash;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27 } local_protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
30 static void
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
31 local_remove_key (gpointer key, gpointer value, gpointer user_data)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
33 g_free (value);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 local_destroy (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40 local_protocol_data * lpd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 g_return_if_fail (request != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43 g_return_if_fail (request->protonum == GFTP_LOCAL_NUM);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
45 lpd = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 g_hash_table_foreach (lpd->userhash, local_remove_key, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47 g_hash_table_destroy (lpd->userhash);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
48 g_hash_table_foreach (lpd->grouphash, local_remove_key, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
49 g_hash_table_destroy (lpd->grouphash);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50 lpd->userhash = lpd->grouphash = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
53
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 static int
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
55 local_getcwd (gftp_request * request)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
56 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
57 char tempstr[PATH_MAX], *utf8;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
58 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
59
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
60 if (request->directory != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
61 g_free (request->directory);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
62
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
63 if (getcwd (tempstr, sizeof (tempstr)) == NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
64 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
65 request->logging_function (gftp_logging_error, request,
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
66 _("Could not get current working directory: %s\n"),
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
67 g_strerror (errno));
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
68 request->directory = NULL;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
69 return (GFTP_ERETRYABLE);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
70 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
71
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
72 utf8 = gftp_filename_to_utf8 (request, tempstr, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
73 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
74 request->directory = utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
75 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
76 request->directory = g_strdup (tempstr);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
77
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
78 return (0);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
79 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
80
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
81
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
82 static int
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
83 local_chdir (gftp_request * request, const char *directory)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
84 {
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
85 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
86 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
87 int ret;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
88
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
89 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
90 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
91 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
92
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
93 utf8 = gftp_filename_from_utf8 (request, directory, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
94 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
95 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
96 ret = chdir (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
97 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
98 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
99 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
100 ret = chdir (directory);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
101
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
102 if (ret == 0)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
103 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
104 request->logging_function (gftp_logging_misc, request,
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
105 _("Successfully changed local directory to %s\n"),
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
106 directory);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
107 ret = local_getcwd (request);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
108 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
109 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
110 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
111 request->logging_function (gftp_logging_error, request,
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
112 _("Could not change local directory to %s: %s\n"),
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
113 directory, g_strerror (errno));
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
114 ret = GFTP_ERETRYABLE;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
115 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
116
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
117 return (ret);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
118 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
119
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
120
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
121 static int
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 local_connect (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 {
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
124 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
125 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126
510
e0585b062a75 2004-7-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 504
diff changeset
127 if (request->directory != NULL)
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
128 return (local_chdir (request, request->directory));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 else
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
130 return (local_getcwd (request));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 local_disconnect (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 g_return_if_fail (request != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 g_return_if_fail (request->protonum == GFTP_LOCAL_NUM);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
140 if (request->datafd != -1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 {
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
142 if (close (request->datafd) == -1)
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
143 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 _("Error closing file descriptor: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145 g_strerror (errno));
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
146 request->datafd = -1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
151 static off_t
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
152 local_get_file (gftp_request * request, const char *filename,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 off_t startsize)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 {
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
155 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
156 char *utf8;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
157 off_t size;
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
158 int flags;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
160 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
161 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
162 g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
164 flags = O_RDONLY;
434
f2e7b8218558 2004-3-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
165 #if defined (_LARGEFILE_SOURCE) && defined (O_LARGEFILE)
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
166 flags |= O_LARGEFILE;
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
167 #endif
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
168
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
169 utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
170 if (utf8 != NULL)
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
171 {
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
172 request->datafd = gftp_fd_open (request, utf8, flags, 0);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
173 g_free (utf8);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 else
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
176 request->datafd = gftp_fd_open (request, filename, flags, 0);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
177
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
178 if (request->datafd == -1)
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
179 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
181 if ((size = lseek (request->datafd, 0, SEEK_END)) == -1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
183 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 _("Error: Cannot seek on file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 filename, g_strerror (errno));
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
186 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
187 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
190 if (lseek (request->datafd, startsize, SEEK_SET) == -1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
192 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 _("Error: Cannot seek on file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 filename, g_strerror (errno));
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
195 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
196 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 return (size);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 static int
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
204 local_put_file (gftp_request * request, const char *filename,
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
205 off_t startsize, off_t totalsize)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 {
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
207 int flags, perms;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
208 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
209 char *utf8;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
211 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
212 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
213 g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
215 flags = O_WRONLY | O_CREAT;
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
216 if (startsize > 0)
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
217 flags |= O_APPEND;
434
f2e7b8218558 2004-3-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
218 #if defined (_LARGEFILE_SOURCE) && defined (O_LARGEFILE)
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
219 flags |= O_LARGEFILE;
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
220 #endif
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
221
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
222 perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
223 utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
224 if (utf8 != NULL)
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
225 {
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
226 request->datafd = gftp_fd_open (request, utf8, flags, perms);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
227 g_free (utf8);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 else
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
230 request->datafd = gftp_fd_open (request, filename, flags, perms);
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
231
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
232 if (request->datafd == -1)
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
233 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
235 if (ftruncate (request->datafd, startsize) == -1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
237 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 _("Error: Cannot truncate local file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 filename, g_strerror (errno));
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
240 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
241 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
244 if (lseek (request->datafd, startsize, SEEK_SET) == -1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
246 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 _("Error: Cannot seek on file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 filename, g_strerror (errno));
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
249 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
250 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 local_end_transfer (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 local_protocol_data * lpd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 lpd = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 if (lpd->dir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
263 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 closedir (lpd->dir);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 lpd->dir = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
268 if (request->datafd > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 {
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
270 if (close (request->datafd) == -1)
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
271 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 _("Error closing file descriptor: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
275 request->datafd = -1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
282 static int
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
283 local_stat_filename (gftp_request * request, const char *filename,
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
284 mode_t * mode, off_t * filesize)
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
285 {
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
286 struct stat st;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
287 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
288 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
289 int ret;
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
290
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
291 utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
292 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
293 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
294 ret = stat (utf8, &st);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
295 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
296 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
297 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
298 ret = stat (filename, &st);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
299
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
300 if (ret != 0)
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
301 return (GFTP_ERETRYABLE);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
302
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
303 *mode = st.st_mode;
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
304 *filesize = st.st_size;
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
305
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
306 return (0);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
307 }
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
308
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
309
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 static int
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
311 local_get_next_file (gftp_request * request, gftp_file * fle, int fd)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
313 local_protocol_data * lpd;
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 253
diff changeset
314 struct stat st, fst;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
315 struct dirent *dirp;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 char *user, *group;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317 struct passwd *pw;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318 struct group *gr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 /* the struct passwd and struct group are not thread safe. But,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 we're ok here because I have threading turned off for the local
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 309
diff changeset
322 protocol (see use_threads in gftp_protocols in options.h) */
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
323 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
324 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
325 g_return_val_if_fail (fle != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 lpd = request->protocol_data;
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
328
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
329 g_return_val_if_fail (lpd != NULL, GFTP_EFATAL);
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
330
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 memset (fle, 0, sizeof (*fle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 if ((dirp = readdir (lpd->dir)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 closedir (lpd->dir);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 lpd->dir = NULL;
274
4610d25d4abb 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
337 return (GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
340 fle->file = g_strdup (dirp->d_name);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 if (lstat (fle->file, &st) != 0)
274
4610d25d4abb 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
342 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
343
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 253
diff changeset
344 if (stat (fle->file, &fst) != 0)
274
4610d25d4abb 2003-9-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 255
diff changeset
345 return (GFTP_ERETRYABLE);
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 253
diff changeset
346
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 if ((user = g_hash_table_lookup (lpd->userhash,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
348 GUINT_TO_POINTER(st.st_uid))) != NULL)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
349 fle->user = g_strdup (user);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352 if ((pw = getpwuid (st.st_uid)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 fle->user = g_strdup_printf ("%u", st.st_uid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 else
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
355 fle->user = g_strdup (pw->pw_name);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
357 user = g_strdup (fle->user);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 g_hash_table_insert (lpd->userhash, GUINT_TO_POINTER (st.st_uid), user);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 if ((group = g_hash_table_lookup (lpd->grouphash,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 GUINT_TO_POINTER(st.st_gid))) != NULL)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
363 fle->group = g_strdup (group);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 if ((gr = getgrgid (st.st_gid)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 fle->group = g_strdup_printf ("%u", st.st_gid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 else
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
369 fle->group = g_strdup (gr->gr_name);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
371 group = g_strdup (fle->group);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 g_hash_table_insert (lpd->grouphash, GUINT_TO_POINTER (st.st_gid), group);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374
852
5e3005923374 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
375 fle->st_dev = fst.st_dev;
5e3005923374 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
376 fle->st_ino = fst.st_ino;
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
377 fle->st_mode = fst.st_mode;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 fle->datetime = st.st_mtime;
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
379
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
380 if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
381 fle->size = (off_t) st.st_rdev;
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
382 else
294
4747f621b79b 2003-10-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 274
diff changeset
383 fle->size = fst.st_size;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 local_list_files (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 local_protocol_data *lpd;
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
393 char *dir, *utf8;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
394 size_t destlen;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
396 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
397 g_return_val_if_fail (request->directory != NULL, GFTP_EFATAL);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
398 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
399
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 lpd = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
402 g_return_val_if_fail (lpd != NULL, GFTP_EFATAL);
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
403
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
404 if (request->directory[strlen (request->directory) - 1] != '/')
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
405 dir = g_strconcat (request->directory, "/", NULL);
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
406 else
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
407 dir = request->directory;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
408
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
409 utf8 = gftp_filename_from_utf8 (request, dir, &destlen);
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
410 if (utf8 != NULL)
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
411 {
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
412 lpd->dir = opendir (utf8);
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
413 g_free (utf8);
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
414 }
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
415 else
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
416 lpd->dir = opendir (dir);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
418 if (dir != request->directory)
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
419 g_free (dir);
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
420
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
421 if (lpd->dir == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
423 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 _("Could not get local directory listing %s: %s\n"),
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
425 request->directory, g_strerror (errno));
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
426 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
427 }
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
428 else
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
429 return (0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
430 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
431
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
432
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433 static off_t
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
434 local_get_file_size (gftp_request * request, const char *filename)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
435 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436 struct stat st;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
437 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
438 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
439 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
441 utf8 = gftp_filename_from_utf8 (request, filename, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
442 if (utf8 != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443 {
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
444 ret = stat (utf8, &st);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
445 g_free (utf8);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 }
87
6df043359b41 2003-1-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 84
diff changeset
447 else
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
448 ret = stat (filename, &st);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
449
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
450 if (ret == -1)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
451 return (GFTP_ERETRYABLE);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
452
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
453 return (st.st_size);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
456
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458 local_rmdir (gftp_request * request, const char *directory)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
459 {
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
460 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
461 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
462 int ret;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
463
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
464 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
465 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
466 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
467
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
468 utf8 = gftp_filename_from_utf8 (request, directory, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
469 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
470 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
471 ret = rmdir (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
472 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
473 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
474 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
475 ret = rmdir (directory);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
476
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
477 if (ret == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
479 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
480 _("Successfully removed %s\n"), directory);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
483 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
484 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
485 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
486 _("Error: Could not remove directory %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
487 directory, g_strerror (errno));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
488 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
490 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
493 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
494 local_rmfile (gftp_request * request, const char *file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495 {
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
496 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
497 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
498 int ret;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
499
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
500 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
501 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
502 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
504 utf8 = gftp_filename_from_utf8 (request, file, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
505 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
506 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
507 ret = unlink (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
508 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
509 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
510 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
511 ret = unlink (file);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
512
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
513 if (ret == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
514 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
515 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
516 _("Successfully removed %s\n"), file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
517 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
521 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
522 _("Error: Could not remove file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
523 file, g_strerror (errno));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
524 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
527
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
528
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
529 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
530 local_mkdir (gftp_request * request, const char *directory)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
531 {
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
532 int ret, perms;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
533 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
534 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
535
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
536 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
537 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
538 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
539
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
540 perms = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
541
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
542 utf8 = gftp_filename_from_utf8 (request, directory, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
543 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
544 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
545 ret = mkdir (utf8, perms);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
546 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
547 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
548 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
549 ret = mkdir (directory, perms);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
550
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
551 if (ret == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
552 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
553 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
554 _("Successfully made directory %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
555 directory);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
556 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
557 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
558 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
559 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
560 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
561 _("Error: Could not make directory %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
562 directory, g_strerror (errno));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
563 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
564 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
565 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
566
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
567
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
568 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
569 local_rename (gftp_request * request, const char *oldname,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570 const char *newname)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
571 {
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
572 const char *conv_oldname, *conv_newname;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
573 char *old_utf8, *new_utf8;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
574 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
575 int ret;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
576
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
577 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
578 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
579 g_return_val_if_fail (oldname != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
580 g_return_val_if_fail (newname != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
581
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
582 old_utf8 = gftp_filename_from_utf8 (request, oldname, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
583 conv_oldname = old_utf8 != NULL ? old_utf8 : oldname;
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
584 new_utf8 = gftp_filename_from_utf8 (request, newname, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
585 conv_newname = new_utf8 != NULL ? new_utf8 : newname;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
586
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
587 if (rename (conv_oldname, conv_newname) == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
589 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
590 _("Successfully renamed %s to %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
591 oldname, newname);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
592 ret = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
593 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
594 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
595 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
596 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
597 _("Error: Could not rename %s to %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 oldname, newname, g_strerror (errno));
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
599 ret = GFTP_ERETRYABLE;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600 }
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
601
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
602 if (old_utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
603 g_free (old_utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
604 if (new_utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
605 g_free (new_utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
606
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
607 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
608 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
609
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
610
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
611 static int
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
612 local_chmod (gftp_request * request, const char *file, mode_t mode)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613 {
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
614 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
615 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
616 int ret;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
617
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
618 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
619 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
620 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
621
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
622 utf8 = gftp_filename_from_utf8 (request, file, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
623 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
624 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
625 ret = chmod (utf8, mode);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
626 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
627 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
628 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
629 ret = chmod (file, mode);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
630
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
631 if (ret == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
632 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
633 request->logging_function (gftp_logging_misc, request,
504
93d7d3b9a477 2004-7-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
634 _("Successfully changed mode of %s to %o\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
635 file, mode);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
636 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
637 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
638 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
639 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
640 request->logging_function (gftp_logging_error, request,
504
93d7d3b9a477 2004-7-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
641 _("Error: Could not change mode of %s to %o: %s\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
642 file, mode, g_strerror (errno));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
643 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
644 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
645 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
646
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
647
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
648 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
649 local_set_file_time (gftp_request * request, const char *file,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
650 time_t datetime)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
651 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
652 struct utimbuf time_buf;
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
653 size_t destlen;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
654 char *utf8;
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
655 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
656
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
657 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
658 g_return_val_if_fail (request->protonum == GFTP_LOCAL_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
659 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
660
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 510
diff changeset
661 time_buf.modtime = datetime;
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 510
diff changeset
662 time_buf.actime = datetime;
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
663
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
664 utf8 = gftp_filename_from_utf8 (request, file, &destlen);
831
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
665 if (utf8 != NULL)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
666 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
667 ret = utime (utf8, &time_buf);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
668 g_free (utf8);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
669 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
670 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
671 ret = utime (file, &time_buf);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
672
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
673 if (ret == 0)
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
674 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
675 request->logging_function (gftp_logging_misc, request,
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
676 _("Successfully changed the time stamp of %s\n"),
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
677 file);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
678 return (0);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
679 }
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
680 else
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
681 {
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
682 request->logging_function (gftp_logging_error, request,
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
683 _("Error: Could not change the time stamp of %s: %s\n"),
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
684 file, g_strerror (errno));
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
685 return (GFTP_ERETRYABLE);
739462d1bfb5 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
686 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
687 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
688
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
689
989
c99b134c6185 [mq]: charset2
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 918
diff changeset
690 void
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
691 local_register_module (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
692 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
693 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
694
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
695
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
696 int
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
697 local_init (gftp_request * request)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
698 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
699 local_protocol_data *lpd;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
700
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
701 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
702
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
703 request->protonum = GFTP_LOCAL_NUM;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
704 request->init = local_init;
309
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
705 request->copy_param_options = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
706 request->destroy = local_destroy;
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
707 request->read_function = gftp_fd_read;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
708 request->write_function = gftp_fd_write;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
709 request->connect = local_connect;
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
710 request->post_connect = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
711 request->disconnect = local_disconnect;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
712 request->get_file = local_get_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
713 request->put_file = local_put_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
714 request->transfer_file = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
715 request->get_next_file_chunk = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
716 request->put_next_file_chunk = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
717 request->end_transfer = local_end_transfer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
718 request->abort_transfer = local_end_transfer; /* NOTE: uses end_transfer */
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
719 request->stat_filename = local_stat_filename;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
720 request->list_files = local_list_files;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
721 request->get_next_file = local_get_next_file;
485
7334a74db6f6 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 434
diff changeset
722 request->get_next_dirlist_line = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
723 request->get_file_size = local_get_file_size;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
724 request->chdir = local_chdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
725 request->rmdir = local_rmdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
726 request->rmfile = local_rmfile;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
727 request->mkdir = local_mkdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
728 request->rename = local_rename;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
729 request->chmod = local_chmod;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
730 request->set_file_time = local_set_file_time;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
731 request->site = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
732 request->parse_url = NULL;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
733 request->set_config_options = NULL;
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 62
diff changeset
734 request->swap_socks = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
735 request->url_prefix = "file";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
736 request->need_hostport = 0;
553
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 520
diff changeset
737 request->need_username = 0;
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 520
diff changeset
738 request->need_password = 0;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
739 request->use_cache = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
740 request->always_connected = 1;
832
f2772ac00751 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 831
diff changeset
741 request->use_local_encoding = 1;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
742
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
743 lpd = g_malloc0 (sizeof (*lpd));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
744 request->protocol_data = lpd;
852
5e3005923374 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
745 lpd->userhash = g_hash_table_new (uint_hash_function, uint_hash_compare);
5e3005923374 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
746 lpd->grouphash = g_hash_table_new (uint_hash_function, uint_hash_compare);
66
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
747
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
748 if (request->hostname != NULL)
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
749 g_free (request->hostname);
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 65
diff changeset
750 request->hostname = g_strdup (_("local filesystem"));
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
751
177
aec4b4541d3a 2003-6-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
752 return (gftp_set_config_options (request));
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
753 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
754