annotate lib/local.c @ 831:739462d1bfb5

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