annotate lib/config_file.c @ 858:10e2ce91e26c

2006-11-30 Brian Masney <masneyb@gftp.org> * lib/rfc959.c lib/sshv2.c src/uicommon/gftpui.c - don't abort the entire file transfer if there is a permission denied at some point during the file transfer. Give the user an error at the very end if there were any errors. (closes #328550)
author masneyb
date Fri, 01 Dec 2006 00:57:50 +0000
parents 2c94567f9a53
children 1808cebed602
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 /* config_file.c - config file routines */
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
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: 26
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
23 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
24 gftp_add_bookmark (gftp_bookmarks_var * newentry)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
26 gftp_bookmarks_var * preventry, * folderentry, * endentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
27 char *curpos;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
29 if (!newentry->protocol)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
30 newentry->protocol = g_strdup ("FTP");
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
32 /* We have to create the folders. For example, if we have
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
33 Debian Sites/Debian, we have to create a Debian Sites entry */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
34 preventry = gftp_bookmarks;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
35 if (preventry->children != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
37 endentry = preventry->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
38 while (endentry->next != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
39 endentry = endentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
40 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
41 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
42 endentry = NULL;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
43 curpos = newentry->path;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
44 while ((curpos = strchr (curpos, '/')) != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
45 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
46 *curpos = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
47 /* See if we already made this folder */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
48 if ((folderentry = (gftp_bookmarks_var *)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
49 g_hash_table_lookup (gftp_bookmarks_htable, newentry->path)) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
51 /* Allocate the individual folder. We have to do this for the edit
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
52 bookmarks feature */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
53 folderentry = g_malloc0 (sizeof (*folderentry));
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
54 folderentry->path = g_strdup (newentry->path);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
55 folderentry->prev = preventry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
56 folderentry->isfolder = 1;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
57 g_hash_table_insert (gftp_bookmarks_htable, folderentry->path,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
58 folderentry);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
59 if (preventry->children == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
60 preventry->children = folderentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
61 else
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
62 endentry->next = folderentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
63 preventry = folderentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
64 endentry = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
67 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
68 preventry = folderentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
69 if (preventry->children != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
70 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
71 endentry = preventry->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
72 while (endentry->next != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
73 endentry = endentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
74 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
75 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
76 endentry = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
78 *curpos = '/';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
79 curpos++;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81
605
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
82 if (newentry->path[strlen (newentry->path) - 1] == '/')
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
83 {
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
84 newentry->path[strlen (newentry->path) - 1] = '\0';
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
85 newentry->isfolder = 1;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
86 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
87 else
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 {
605
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
89 /* Get the parent node */
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
90 if ((curpos = strrchr (newentry->path, '/')) == NULL)
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
91 preventry = gftp_bookmarks;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
92 else
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
93 {
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
94 *curpos = '\0';
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
95 preventry = (gftp_bookmarks_var *)
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
96 g_hash_table_lookup (gftp_bookmarks_htable, newentry->path);
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
97 *curpos = '/';
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
98 }
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
99
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
100 if (preventry->children != NULL)
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
101 {
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
102 endentry = preventry->children;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
103 while (endentry->next != NULL)
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
104 endentry = endentry->next;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
105 endentry->next = newentry;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
106 }
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
107 else
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
108 preventry->children = newentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109
605
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
110 newentry->prev = preventry;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
111 newentry->next = NULL;
b60dad25b641 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 600
diff changeset
112 g_hash_table_insert (gftp_bookmarks_htable, newentry->path, newentry);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
117 static int
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
118 copyfile (char *source, char *dest)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
119 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
120 int srcfd, destfd;
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
121 char buf[8192];
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
122 ssize_t n;
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
123
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
124 if ((srcfd = gftp_fd_open (NULL, source, O_RDONLY, 0)) == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
125 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
126 printf (_("Error: Cannot open local file %s: %s\n"),
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
127 source, g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
128 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
129 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
130
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
131 if ((destfd = gftp_fd_open (NULL, dest, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
132 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
133 printf (_("Error: Cannot open local file %s: %s\n"),
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
134 dest, g_strerror (errno));
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
135 close (srcfd);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
136 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
137 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
138
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
139 while ((n = read (srcfd, buf, sizeof (buf))) > 0)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
140 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
141 if (write (destfd, buf, n) == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
142 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
143 printf (_("Error: Could not write to socket: %s\n"),
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
144 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
145 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
146 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
147 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
148
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
149 if (n == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
150 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
151 printf (_("Error: Could not read from socket: %s\n"), g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
152 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
153 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
154
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
155 if (close (srcfd) == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
156 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
157 printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
158 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
159 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
160
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
161 if (close (destfd) == -1)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
162 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
163 printf (_("Error closing file descriptor: %s\n"), g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
164 exit (EXIT_FAILURE);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
165 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
166
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
167 return (1);
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
168 }
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
169
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 229
diff changeset
170
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
171 static void
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
172 gftp_read_bookmarks (char *global_data_path)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 char *tempstr, *temp1str, buf[255], *curpos;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
175 gftp_config_vars * global_entry;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
176 gftp_bookmarks_var * newentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 FILE *bmfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 size_t len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 int line;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
181 if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 printf (_("gFTP Error: Bad bookmarks file name %s\n"), BOOKMARKS_FILE);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
184 exit (EXIT_FAILURE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 if (access (tempstr, F_OK) == -1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 {
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
189 temp1str = g_strdup_printf ("%s/bookmarks", global_data_path);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 if (access (temp1str, F_OK) == -1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 printf (_("Warning: Cannot find master bookmark file %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 temp1str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 g_free (temp1str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 copyfile (temp1str, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 g_free (temp1str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 }
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
200
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 if ((bmfile = fopen (tempstr, "r")) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), tempstr,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
205 exit (EXIT_FAILURE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 line = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 newentry = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 while (fgets (buf, sizeof (buf), bmfile))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 {
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 429
diff changeset
213 len = strlen (buf);
107
982e3890e7fe 2003-2-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 101
diff changeset
214 if (len > 0 && buf[len - 1] == '\n')
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
215 buf[--len] = '\0';
107
982e3890e7fe 2003-2-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 101
diff changeset
216 if (len > 0 && buf[len - 1] == '\r')
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
217 buf[--len] = '\0';
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 line++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 if (*buf == '[')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 newentry = g_malloc0 (sizeof (*newentry));
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
223 for (; buf[len - 1] == ' ' || buf[len - 1] == ']'; buf[--len] = '\0');
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
224 newentry->path = g_strdup (buf + 1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 newentry->isfolder = 0;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
226 gftp_add_bookmark (newentry);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 else if (strncmp (buf, "hostname", 8) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 curpos = buf + 9;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 if (newentry->hostname)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 g_free (newentry->hostname);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
233 newentry->hostname = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 else if (strncmp (buf, "port", 4) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 newentry->port = strtol (buf + 5, NULL, 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 else if (strncmp (buf, "protocol", 8) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 curpos = buf + 9;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 if (newentry->protocol)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 g_free (newentry->protocol);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
242 newentry->protocol = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 else if (strncmp (buf, "remote directory", 16) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 curpos = buf + 17;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 if (newentry->remote_dir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 g_free (newentry->remote_dir);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
249 newentry->remote_dir = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 else if (strncmp (buf, "local directory", 15) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 curpos = buf + 16;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 if (newentry->local_dir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 g_free (newentry->local_dir);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
256 newentry->local_dir = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 else if (strncmp (buf, "username", 8) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 curpos = buf + 9;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 if (newentry->user)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 g_free (newentry->user);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
263 newentry->user = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 else if (strncmp (buf, "password", 8) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 curpos = buf + 9;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 if (newentry->pass)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 g_free (newentry->pass);
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
270
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
271 /* Always try to descramble passords. If the password is not
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
272 scrambled, descramble_password returns the string unchanged */
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
273 newentry->pass = gftp_descramble_password (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 newentry->save_password = *newentry->pass != '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 else if (strncmp (buf, "account", 7) == 0 && newentry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 curpos = buf + 8;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 if (newentry->acct)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 g_free (newentry->acct);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
281 newentry->acct = g_strdup (curpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282 }
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
283 else if (*buf == '#' || *buf == '\0')
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
284 continue;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
285 else
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
286 {
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
287 if ((curpos = strchr (buf, '=')) == NULL)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
288 continue;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
289 *curpos = '\0';
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
290
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
291 if ((global_entry = g_hash_table_lookup (gftp_global_options_htable,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
292 buf)) == NULL ||
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
293 gftp_option_types[global_entry->otype].read_function == NULL)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
294 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
295 printf (_("gFTP Warning: Skipping line %d in bookmarks file: %s\n"),
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
296 line, buf);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
297 continue;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
298 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
299
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
300 if (newentry->local_options_hash == NULL)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
301 newentry->local_options_hash = g_hash_table_new (string_hash_function,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
302 string_hash_compare);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
303
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
304 newentry->num_local_options_vars++;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
305 newentry->local_options_vars = g_realloc (newentry->local_options_vars,
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
306 (gulong) sizeof (gftp_config_vars) * newentry->num_local_options_vars);
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
307
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
308 memcpy (&newentry->local_options_vars[newentry->num_local_options_vars - 1], global_entry,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
309 sizeof (newentry->local_options_vars[newentry->num_local_options_vars - 1]));
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
310
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
311 newentry->local_options_vars[newentry->num_local_options_vars - 1].flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
312 newentry->local_options_vars[newentry->num_local_options_vars - 1].value = NULL;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
313
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
314 if (gftp_option_types[global_entry->otype].read_function (curpos + 1,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
315 &newentry->local_options_vars[newentry->num_local_options_vars - 1], line) != 0)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
316 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
317 printf (_("gFTP Warning: Skipping line %d in bookmarks file: %s\n"),
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
318 line, buf);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
319 continue;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
320 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
321
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
322 g_hash_table_insert (newentry->local_options_hash, newentry->local_options_vars[newentry->num_local_options_vars - 1].key, &newentry->local_options_vars[newentry->num_local_options_vars - 1]);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327
198
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
328 int
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
329 gftp_config_parse_args (char *str, int numargs, int lineno, char **first, ...)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 char *curpos, *endpos, *pos, **dest, tempchar;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332 int ret, has_colon;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 va_list argp;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 ret = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 va_start (argp, first);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337 curpos = str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 dest = first;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 *dest = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 while (numargs > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
342 has_colon = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
343 if (numargs > 1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
344 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
345 if ((endpos = strchr (curpos, ':')) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
346 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 printf (_("gFTP Warning: Line %d doesn't have enough arguments\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
348 lineno);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
349 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350 endpos = curpos + strlen (curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 /* Allow colons inside the fields. If you want a colon inside a
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355 field, just put 2 colons in there */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356 while (endpos != NULL && *(endpos - 1) == '\\')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 endpos = strchr (endpos + 1, ':');
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 has_colon = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 endpos = curpos + strlen (curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
366 *dest = g_malloc ((gulong) (endpos - curpos + 1));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 tempchar = *endpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 *endpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 strcpy (*dest, curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 *endpos = tempchar;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 if (has_colon)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373 pos = *dest;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374 curpos = *dest;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375 while (*pos != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 if (*pos != '\\' && *(pos + 1) != ':')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 *curpos++ = *pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 *curpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 if (*endpos == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 curpos = endpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 if (numargs > 1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 dest = va_arg (argp, char **);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 *dest = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 numargs--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 while (numargs > 1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 dest = va_arg (argp, char **);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398 *dest = g_malloc (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 **dest = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 numargs--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 va_end (argp);
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
403 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
407 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
408 gftp_config_read_str (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
409 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
410 return (g_strdup (buf));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
411 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
412
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
413
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
414 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
415 gftp_config_write_str (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
416 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
417 fprintf (fd, "%s", (char *) data);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
418 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
419
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
420
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
421 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
422 gftp_config_read_proxy (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
423 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
424 gftp_proxy_hosts * host;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
425 unsigned int nums[4];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
426 char *pos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
427
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
428 host = g_malloc0 (sizeof (*host));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
429 if ((pos = strchr (buf, '/')) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
430 host->domain = g_strdup (buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
431 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
432 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
433 *pos = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
434 sscanf (buf, "%u.%u.%u.%u", &nums[0], &nums[1], &nums[2], &nums[3]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
435 host->ipv4_network_address =
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
436 nums[0] << 24 | nums[1] << 16 | nums[2] << 8 | nums[3];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
437
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
438 if (strchr (pos + 1, '.') == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
439 host->ipv4_netmask = 0xffffffff << (32 - strtol (pos + 1, NULL, 10));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
440 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
441 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
442 sscanf (pos + 1, "%u.%u.%u.%u", &nums[0], &nums[1], &nums[2],
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
443 &nums[3]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
444 host->ipv4_netmask =
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
445 nums[0] << 24 | nums[1] << 16 | nums[2] << 8 | nums[3];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
446 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
447 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
448
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
449 return (host);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
450 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
451
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
452
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
453 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
454 gftp_config_write_proxy (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
455 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
456 gftp_proxy_hosts * host;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
457
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
458 host = data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
459
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
460 if (host->domain)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
461 fprintf (fd, "%s", host->domain);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
462 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
463 fprintf (fd, "%d.%d.%d.%d/%d.%d.%d.%d",
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
464 host->ipv4_network_address >> 24 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
465 host->ipv4_network_address >> 16 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
466 host->ipv4_network_address >> 8 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
467 host->ipv4_network_address & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
468 host->ipv4_netmask >> 24 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
469 host->ipv4_netmask >> 16 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
470 host->ipv4_netmask >> 8 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
471 host->ipv4_netmask & 0xff);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
472 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
473
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
474
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
475 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
476 gftp_config_read_ext (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
477 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
478 gftp_file_extensions * tempext;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
479
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
480 tempext = g_malloc (sizeof (*tempext));
198
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
481 gftp_config_parse_args (buf, 4, line, &tempext->ext, &tempext->filename,
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
482 &tempext->ascii_binary, &tempext->view_program);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
483
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
484 tempext->stlen = strlen (tempext->ext);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
485
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
486 return (tempext);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
487 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
488
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
489
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
490 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
491 gftp_config_write_ext (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
492 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
493 gftp_file_extensions * tempext;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
494
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
495 tempext = data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
496 fprintf (fd, "%s:%s:%c:%s", tempext->ext, tempext->filename,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
497 *tempext->ascii_binary == '\0' ? ' ' : *tempext->ascii_binary,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
498 tempext->view_program);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
499 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
500
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
501
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
502 static gftp_config_list_vars gftp_config_list[] = {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
503 {"dont_use_proxy", gftp_config_read_proxy, gftp_config_write_proxy,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
504 NULL, 0,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
505 N_("This section specifies which hosts are on the local subnet and won't need to go out the proxy server (if available). Syntax: dont_use_proxy=.domain or dont_use_proxy=network number/netmask")},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
506 {"ext", gftp_config_read_ext, gftp_config_write_ext,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
507 NULL, 0,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
508 N_("ext=file extenstion:XPM file:Ascii or Binary (A or B):viewer program. Note: All arguments except the file extension are optional")},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
509 {"localhistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
510 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
511 {"remotehistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
512 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
513 {"hosthistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
514 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
515 {"porthistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
516 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
517 {"userhistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
518 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
519 {NULL, NULL, NULL,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
520 NULL, 0, NULL}
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
521 };
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
522
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
523
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
524 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
525 gftp_setup_global_options (gftp_config_vars * cvars)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
526 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
527 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
528
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
529 for (i=0; cvars[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
530 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
531 if (cvars[i].key != NULL && *cvars[i].key != '\0')
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
532 g_hash_table_insert (gftp_global_options_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
533 cvars[i].key, &cvars[i]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
534 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
535 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
536
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
537
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
538 void
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
539 gftp_read_config_file (char *global_data_path)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
540 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
541 char *tempstr, *temp1str, *curpos, buf[255];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
542 gftp_config_list_vars * tmplistvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
543 gftp_config_vars * tmpconfigvar;
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
544 char **protocol_list;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
545 FILE *conffile;
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
546 int line, i, j;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
547 size_t len;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
548
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
549 gftp_global_options_htable = g_hash_table_new (string_hash_function,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
550 string_hash_compare);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
551
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
552 gftp_register_config_vars (gftp_global_config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
553
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
554 protocol_list = NULL;
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
555 for (i=0, j=0; gftp_protocols[i].register_options != NULL; i++)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
556 {
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
557 if (gftp_protocols[i].shown)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
558 {
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
559 protocol_list = g_realloc (protocol_list,
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
560 (gulong) sizeof (char *) * (j + 2));
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
561 protocol_list[j] = gftp_protocols[i].name;
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
562 protocol_list[j + 1] = NULL;
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
563 j++;
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
564 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
565
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
566 if (gftp_protocols[i].register_options != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
567 gftp_protocols[i].register_options ();
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
568 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
569
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
570 if ((tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
571 "default_protocol")) != NULL)
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
572 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
573 tmpconfigvar->listdata = protocol_list;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
574 tmpconfigvar->flags |= GFTP_CVARS_FLAGS_DYNLISTMEM;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
575 }
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
576
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
577 gftp_config_list_htable = g_hash_table_new (string_hash_function,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
578 string_hash_compare);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
579
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
580 for (i=0; gftp_config_list[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
581 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
582 g_hash_table_insert (gftp_config_list_htable, gftp_config_list[i].key,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
583 &gftp_config_list[i]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
584 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
585
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
586 if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
587 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
588 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
589 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
590 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
591
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
592 if (access (tempstr, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
593 {
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
594 temp1str = gftp_expand_path (NULL, BASE_CONF_DIR);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
595 if (access (temp1str, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
596 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
597 if (mkdir (temp1str, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
598 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
599 printf (_("gFTP Error: Could not make directory %s: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
600 temp1str, g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
601 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
602 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
603 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
604 g_free (temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
605
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
606 temp1str = g_strdup_printf ("%s/gftprc", global_data_path);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
607 if (access (temp1str, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
608 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
609 printf (_("gFTP Error: Cannot find master config file %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
610 temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
611 printf (_("Did you do a make install?\n"));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
612 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
613 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
614 copyfile (temp1str, tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
615 g_free (temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
616 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
617
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
618 if ((conffile = fopen (tempstr, "r")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
619 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
620 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
621 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
622 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
623 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
624 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
625
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
626 line = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
627 while (fgets (buf, sizeof (buf), conffile))
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
628 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
629 len = strlen (buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
630 if (len > 0 && buf[len - 1] == '\n')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
631 buf[--len] = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
632 if (len > 0 && buf[len - 1] == '\r')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
633 buf[--len] = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
634 line++;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
635
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
636 if (*buf == '#' || *buf == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
637 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
638
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
639 if ((curpos = strchr (buf, '=')) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
640 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
641
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
642 *curpos = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
643
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
644 if ((tmplistvar = g_hash_table_lookup (gftp_config_list_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
645 buf)) != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
646 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
647 tmplistvar->list = g_list_append (tmplistvar->list,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
648 tmplistvar->read_func (curpos + 1,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
649 line));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
650 tmplistvar->num_items++;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
651 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
652 else if ((tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
653 buf)) != NULL &&
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
654 gftp_option_types[tmpconfigvar->otype].read_function != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
655 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
656 if (gftp_option_types[tmpconfigvar->otype].read_function (curpos + 1,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
657 tmpconfigvar, line) != 0)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
658 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
659 printf (_("Terminating due to parse errors at line %d in the config file\n"), line);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
660 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
661 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
662 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
663 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
664 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
665 printf (_("gFTP Warning: Skipping line %d in config file: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
666 line, buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
667 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
668 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
669
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
670 if ((tempstr = gftp_expand_path (NULL, LOG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
671 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
672 printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
673 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
674 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
675
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
676 if ((gftp_logfd = fopen (tempstr, "w")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
677 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
678 printf (_("gFTP Warning: Cannot open %s for writing: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
679 tempstr, g_strerror (errno));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
680 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
681 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
682
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
683 gftp_bookmarks = g_malloc0 (sizeof (*gftp_bookmarks));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
684 gftp_bookmarks->isfolder = 1;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
685 gftp_bookmarks->path = g_malloc0 (1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
686 gftp_bookmarks_htable = g_hash_table_new (string_hash_function, string_hash_compare);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
687
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
688 gftp_read_bookmarks (global_data_path);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
689 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
690
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
691
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
692 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
693 write_comment (FILE * fd, const char *comment)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
694 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
695 const char *pos, *endpos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
696
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
697 fwrite ("# ", 1, 2, fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
698 pos = comment;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
699 while (strlen (pos) > 76)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
700 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
701 for (endpos = pos + 76; *endpos != ' ' && endpos > pos; endpos--);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
702 if (endpos == pos)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
703 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
704 for (endpos = pos + 76; *endpos != ' ' && *endpos != '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
705 endpos++);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
706 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
707 fwrite (pos, 1, endpos - pos, fd);
854
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
708 fwrite ("\n", 1, 1, fd);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
709 if (*endpos == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
710 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
711 pos = endpos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
712 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
713 }
854
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
714 pos = endpos + 1;
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
715 fwrite ("# ", 1, 2, fd);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
716 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
717 if (strlen (pos) > 1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
718 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
719 fwrite (pos, 1, strlen (pos), fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
720 fwrite ("\n", 1, 1, fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
721 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
722 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
723
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
724
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
725 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
726 gftp_write_bookmarks_file (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
727 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
728 char *bmhdr, *pwhdr, *tempstr, *password, buf[256];
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
729 gftp_bookmarks_var * tempentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
730 FILE * bmfile;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
731 int i;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
732
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
733 bmhdr = N_("Bookmarks file for gFTP. Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be overwritten");
332
6317b45645a8 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 330
diff changeset
734 pwhdr = N_("Note: The passwords contained inside this file are scrambled. This algorithm is not secure. This is to avoid your password being easily remembered by someone standing over your shoulder while you're editing this file. Prior to this, all passwords were stored in plaintext.");
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
735
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
736 if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
737 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
738 printf (_("gFTP Error: Bad bookmarks file name %s\n"), CONFIG_FILE);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
739 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
740 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
741
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
742 if ((bmfile = fopen (tempstr, "w+")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
743 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
744 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
745 CONFIG_FILE, g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
746 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
747 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
748
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
749 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
750
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
751 write_comment (bmfile, _(bmhdr));
332
6317b45645a8 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 330
diff changeset
752 write_comment (bmfile, _(pwhdr));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
753 fwrite ("\n", 1, 1, bmfile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
754
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
755 tempentry = gftp_bookmarks->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
756 while (tempentry != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
757 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
758 if (tempentry->children != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
759 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
760 tempentry = tempentry->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
761 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
762 }
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
763
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
764 tempstr = tempentry->path;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
765 while (*tempstr == '/')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
766 tempstr++;
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
767
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
768 if (tempentry->isfolder)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
769 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
770 fprintf (bmfile, "[%s/]\n", tempstr);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
771 }
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
772 else
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
773 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
774 if (tempentry->save_password && tempentry->pass != NULL)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
775 password = gftp_scramble_password (tempentry->pass);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
776 else
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
777 password = NULL;
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
778
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
779 fprintf (bmfile,
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
780 "[%s]\nhostname=%s\nport=%u\nprotocol=%s\nremote directory=%s\nlocal directory=%s\nusername=%s\npassword=%s\naccount=%s\n",
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
781 tempstr, tempentry->hostname == NULL ? "" : tempentry->hostname,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
782 tempentry->port, tempentry->protocol == NULL
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
783 || *tempentry->protocol ==
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
784 '\0' ? gftp_protocols[0].name : tempentry->protocol,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
785 tempentry->remote_dir == NULL ? "" : tempentry->remote_dir,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
786 tempentry->local_dir == NULL ? "" : tempentry->local_dir,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
787 tempentry->user == NULL ? "" : tempentry->user,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
788 password == NULL ? "" : password,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
789 tempentry->acct == NULL ? "" : tempentry->acct);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
790 if (password != NULL)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
791 g_free(password);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
792
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
793 if (tempentry->local_options_vars != NULL)
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
794 {
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
795 for (i=0; i<tempentry->num_local_options_vars; i++)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
796 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
797 gftp_option_types[tempentry->local_options_vars[i].otype].write_function (&tempentry->local_options_vars[i], buf, sizeof (buf), 1);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
798
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
799 fprintf (bmfile, "%s=%s\n", tempentry->local_options_vars[i].key,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
800 buf);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
801 }
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
802 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
803 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
804
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
805 fprintf (bmfile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
806
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
807 if (tempentry->next == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
808 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
809 tempentry = tempentry->prev;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
810 while (tempentry->next == NULL && tempentry->prev != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
811 tempentry = tempentry->prev;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
812 tempentry = tempentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
813 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
814 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
815 tempentry = tempentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
816 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
817
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
818 fclose (bmfile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
819 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
820
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
821
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
822 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
823 gftp_write_config_file (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
824 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
825 char *tempstr, buf[256];
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
826 gftp_config_vars * cv;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
827 GList *templist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
828 FILE *conffile;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
829 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
830
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
831 if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
832 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
833 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
834 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
835 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
836
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
837 if ((conffile = fopen (tempstr, "w+")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
838 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
839 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
840 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
841 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
842 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
843
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
844 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
845
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
846 write_comment (conffile, _("Config file for gFTP. Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be overwritten. If a entry has a (*) in it's comment, you can't change it inside gFTP"));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
847
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
848 for (templist = gftp_options_list;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
849 templist != NULL;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
850 templist = templist->next)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
851 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
852 cv = templist->data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
853
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
854 for (i=0; cv[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
855 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
856 if (gftp_option_types[cv[i].otype].write_function == NULL ||
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
857 *cv[i].key == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
858 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
859
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
860 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
861 if (cv[i].comment != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
862 write_comment (conffile, _(cv[i].comment));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
863
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
864 gftp_option_types[cv[i].otype].write_function (&cv[i], buf,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
865 sizeof (buf), 1);
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
866 fprintf (conffile, "%s=%s\n", cv[i].key, buf);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
867 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
868 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
869
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
870 for (i=0; gftp_config_list[i].key != NULL; i++)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
871 {
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
872 if (gftp_config_list[i].header == NULL &&
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
873 gftp_config_list[i].list == NULL)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
874 continue;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
875
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
876 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
877 if (gftp_config_list[i].header != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
878 write_comment (conffile, _(gftp_config_list[i].header));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
879
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
880 for (templist = gftp_config_list[i].list;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
881 templist != NULL;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
882 templist = templist->next)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
883 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
884 fprintf (conffile, "%s=", gftp_config_list[i].key);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
885 gftp_config_list[i].write_func (conffile, templist->data);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
886 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
887 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
888 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
889
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
890 fclose (conffile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
891 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
892
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
893
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
894 GHashTable *
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
895 build_bookmarks_hash_table (gftp_bookmarks_var * entry)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
896 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
897 gftp_bookmarks_var * tempentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898 GHashTable * htable;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 htable = g_hash_table_new (string_hash_function, string_hash_compare);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 tempentry = entry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 g_hash_table_insert (htable, tempentry->path, tempentry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
905 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
906 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
911 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
914 return (htable);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
915 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
916
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
917
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
918 void
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
919 print_bookmarks (gftp_bookmarks_var * bookmarks)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
920 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
921 gftp_bookmarks_var * tempentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 tempentry = bookmarks->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
925 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926 printf ("Path: %s (%d)\n", tempentry->path, tempentry->children != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 if (tempentry->next == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
943
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
944
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
945 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
946 gftp_config_file_read_text (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
947 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
948 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM && cv->value != NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
949 g_free (cv->value);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
950
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
951 if (str != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
952 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
953 cv->value = g_strdup (str);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
954 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
955 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
956 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
957 else
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
958 {
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
959 cv->value = NULL;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
960 cv->flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
961 return (-1);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
962 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
963 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
964
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
965
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
966 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
967 gftp_config_file_write_text (gftp_config_vars * cv, char *buf, size_t buflen,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
968 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
969 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
970 char *outstr;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
971
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
972 if (cv->value != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
973 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
974 outstr = cv->value;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
975 g_snprintf (buf, buflen, "%s", outstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
976 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
977 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
978 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
979 return (-1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
980 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
981
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
982
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
983 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
984 gftp_config_file_write_hidetext (gftp_config_vars * cv, char *buf,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
985 size_t buflen, int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
986 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
987 char *outstr;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
988
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
989 if (cv->value != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
990 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
991 outstr = cv->value;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
992 if (*outstr != '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
993 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
994 if (to_config_file)
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
995 g_snprintf (buf, buflen, "%s", outstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
996 else
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
997 g_snprintf (buf, buflen, "*****");
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
998 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
999 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1000 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1001 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1002 return (-1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1003 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1004
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1005
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1006 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1007 gftp_config_file_copy_text (gftp_config_vars * cv, gftp_config_vars * dest_cv)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1008 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1009 if (dest_cv->flags & GFTP_CVARS_FLAGS_DYNMEM && dest_cv->value != NULL)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1010 g_free (dest_cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1011
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1012 if (cv->value != NULL)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1013 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1014 dest_cv->value = g_strdup ((char *) cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1015 dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1016 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1017 else
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1018 dest_cv->value = NULL;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1019 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1020
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1021
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1022 static int
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1023 gftp_config_file_compare_text (gftp_config_vars * cv1, gftp_config_vars * cv2)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1024 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1025 char *str1, *str2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1026
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1027 str1 = cv1->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1028 str2 = cv2->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1029
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1030 if (cv1->value == NULL && cv2->value == NULL)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1031 return (0);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1032
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1033 if ((cv1->value == NULL && cv2->value != NULL) ||
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1034 (cv1->value != NULL && cv2->value == NULL))
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1035 return (-1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1036
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1037 return (strcmp (str1, str2));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1038 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1039
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1040
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1041 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1042 gftp_config_file_copy_ptr_contents (gftp_config_vars * cv, gftp_config_vars * dest_cv)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1043 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1044 memcpy (&dest_cv->value, &cv->value, sizeof (dest_cv->value));
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1045 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1046
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1047 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1048 gftp_config_file_read_int (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1049 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1050 cv->value = GINT_TO_POINTER(strtol (str, NULL, 10));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1051 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1052 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1053
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1054
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1055 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1056 gftp_config_file_write_int (gftp_config_vars * cv, char *buf, size_t buflen,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1057 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1058 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1059 g_snprintf (buf, buflen, "%d", GPOINTER_TO_INT (cv->value));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1060 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1061 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1062
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1063
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1064 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1065 gftp_config_file_compare_int (gftp_config_vars * cv1, gftp_config_vars * cv2)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1066 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1067 return (GPOINTER_TO_INT(cv1->value) == GPOINTER_TO_INT(cv2->value) ? 0 : -1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1068 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1069
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1070
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1071 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1072 gftp_config_file_read_checkbox (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1073 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1074 cv->value = GINT_TO_POINTER(strtol (str, NULL, 10) ? 1 : 0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1075 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1076 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1077
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1078
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1079 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1080 gftp_config_file_read_float (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1081 {
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1082 union { intptr_t i; float f; } r;
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1083
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1084 r.f = strtod (str, NULL);
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1085 memcpy (&cv->value, &r.i, sizeof (cv->value));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1086 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1087 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1088
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1089
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1090 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1091 gftp_config_file_write_float (gftp_config_vars * cv, char *buf, size_t buflen,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1092 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1093 {
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1094 float f;
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1095
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1096 memcpy (&f, &cv->value, sizeof (f));
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1097 g_snprintf (buf, buflen, "%.2f", f);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1098 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1099 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1100
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1101
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1102 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1103 gftp_config_file_compare_float (gftp_config_vars * cv1, gftp_config_vars * cv2)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1104 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1105 float f1, f2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1106
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1107 memcpy (&f1, &cv1->value, sizeof (f1));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1108 memcpy (&f2, &cv2->value, sizeof (f2));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1109 return (f1 == f2 ? 0 : -1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1110 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1111
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1112
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1113 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1114 gftp_config_file_read_color (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1115 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1116 char *red, *green, *blue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1117 gftp_color * color;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1118
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1119 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM && cv->value != NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1120 g_free (cv->value);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1121
198
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
1122 gftp_config_parse_args (str, 3, line, &red, &green, &blue);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1123
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1124 color = g_malloc (sizeof (*color));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1125 color->red = strtol (red, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1126 color->green = strtol (green, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1127 color->blue = strtol (blue, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1128 g_free (red);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1129 g_free (green);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1130 g_free (blue);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1131
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1132 cv->value = color;
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1133 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1134
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1135 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1136 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1137
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1138
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1139 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1140 gftp_config_file_write_color (gftp_config_vars * cv, char *buf, size_t buflen,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1141 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1142 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1143 gftp_color * color;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1144
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1145 color = cv->value;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1146 g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1147 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1148 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1149
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1150
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1151 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1152 gftp_config_file_copy_color (gftp_config_vars * cv, gftp_config_vars * dest_cv)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1153 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1154 if (dest_cv->flags & GFTP_CVARS_FLAGS_DYNMEM && dest_cv->value != NULL)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1155 g_free (dest_cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1156
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1157 dest_cv->value = g_malloc (sizeof (gftp_color));
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1158 memcpy (dest_cv->value, cv->value, sizeof (gftp_color));
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1159 dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1160 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1161
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1162
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1163 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1164 gftp_config_file_compare_color (gftp_config_vars * cv1, gftp_config_vars * cv2)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1165 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1166 gftp_color * color1, * color2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1167
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1168 color1 = cv1->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1169 color2 = cv2->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1170
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1171 return (color1->red == color2->red && color1->green == color2->green &&
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1172 color1->blue == color2->blue ? 0 : -1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1173 }
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1174
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1175
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1176 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1177 gftp_config_file_read_intcombo (char *str, gftp_config_vars * cv, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1178 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1179 char **clist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1180 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1181
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1182 cv->value = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1183 if (cv->listdata != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1184 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1185 clist = cv->listdata;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1186 for (i=0; clist[i] != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1187 {
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1188 if (strcasecmp (clist[i], str) == 0)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1189 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1190 cv->value = GINT_TO_POINTER(i);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1191 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1192 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1193 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1194 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1195
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1196 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1197 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1198
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1199
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1200 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1201 gftp_config_file_write_intcombo (gftp_config_vars * cv, char *buf,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1202 size_t buflen, int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1203 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1204 char **clist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1205
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1206 clist = cv->listdata;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1207 if (clist != NULL)
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1208 g_snprintf (buf, buflen, "%s", clist[GPOINTER_TO_INT(cv->value)]);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1209 else
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1210 g_snprintf (buf, buflen, _("<unknown>"));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1211
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1212 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1213 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1214
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1215
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1216 static int
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1217 gftp_config_file_read_textcombo (char *str, gftp_config_vars * cv, int line)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1218 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1219 char **clist;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1220 int i;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1221
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1222 cv->value = NULL;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1223 if (cv->listdata != NULL)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1224 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1225 clist = cv->listdata;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1226 for (i=0; clist[i] != NULL; i++)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1227 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1228 if (strcasecmp (clist[i], str) == 0)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1229 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1230 cv->value = clist[i];
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1231 break;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1232 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1233 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1234 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1235
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1236 return (0);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1237 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1238
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1239
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1240 /* Note, the index numbers of this array must match up to the numbers in
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1241 gftp_option_type_enum in gftp.h */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1242 gftp_option_type_var gftp_option_types[] = {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1243 {gftp_config_file_read_text, gftp_config_file_write_text,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1244 gftp_config_file_copy_text, gftp_config_file_compare_text, NULL, NULL, NULL,
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1245 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1246 {gftp_config_file_read_textcombo, gftp_config_file_write_text,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1247 gftp_config_file_copy_text, gftp_config_file_compare_text, NULL, NULL, NULL,
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1248 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1249 {gftp_config_file_read_text, gftp_config_file_write_text,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1250 gftp_config_file_copy_text, gftp_config_file_compare_text, NULL, NULL, NULL,
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1251 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1252 {gftp_config_file_read_text, gftp_config_file_write_hidetext,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1253 gftp_config_file_copy_text, gftp_config_file_compare_text, NULL, NULL, NULL,
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1254 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1255 {gftp_config_file_read_int, gftp_config_file_write_int,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1256 gftp_config_file_copy_ptr_contents, gftp_config_file_compare_int,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1257 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1258 {gftp_config_file_read_checkbox, gftp_config_file_write_int,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1259 gftp_config_file_copy_ptr_contents, gftp_config_file_compare_int,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1260 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1261 {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1262 gftp_config_file_copy_ptr_contents, gftp_config_file_compare_int,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1263 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1264 {gftp_config_file_read_float, gftp_config_file_write_float,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1265 gftp_config_file_copy_ptr_contents, gftp_config_file_compare_float,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1266 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1267 {gftp_config_file_read_color, gftp_config_file_write_color,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1268 gftp_config_file_copy_color, gftp_config_file_compare_color,
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1269 NULL, NULL, NULL, NULL},
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1270 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1271 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1272 };
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1273
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1274
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1275 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1276 gftp_lookup_global_option (const char * key, void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1277 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1278 gftp_config_list_vars * tmplistvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1279 gftp_config_vars * tmpconfigvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1280
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1281 if (gftp_global_options_htable != NULL &&
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1282 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1283 key)) != NULL)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1284 memcpy (value, &tmpconfigvar->value, sizeof (value));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1285 else if ((tmplistvar = g_hash_table_lookup (gftp_config_list_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1286 key)) != NULL)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1287 *(gftp_config_list_vars **) value = tmplistvar;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1288 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1289 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1290 fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1291 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1292 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1293 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1294
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1295
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1296 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1297 gftp_lookup_request_option (gftp_request * request, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1298 void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1299 {
143
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1300 gftp_config_vars * tmpconfigvar;
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1301
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1302 if (request != NULL && request->local_options_hash != NULL &&
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1303 (tmpconfigvar = g_hash_table_lookup (request->local_options_hash,
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1304 key)) != NULL)
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1305 memcpy (value, &tmpconfigvar->value, sizeof (value));
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1306 else
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1307 gftp_lookup_global_option (key, value);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1308 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1309
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1310
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1311 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1312 gftp_lookup_bookmark_option (gftp_bookmarks_var * bm, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1313 void *value)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1314 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1315 gftp_config_vars * tmpconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1316
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1317 if (bm != NULL && bm->local_options_hash != NULL &&
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1318 (tmpconfigvar = g_hash_table_lookup (bm->local_options_hash,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1319 key)) != NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1320 memcpy (value, &tmpconfigvar->value, sizeof (value));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1321 else
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1322 gftp_lookup_global_option (key, value);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1323 }
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1324
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1325
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1326 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1327 gftp_set_global_option (const char * key, const void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1328 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1329 gftp_config_vars * tmpconfigvar, newconfigvar;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1330 void *nc_ptr;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1331 int ret;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1332
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1333 if (gftp_global_options_htable != NULL &&
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1334 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1335 key)) != NULL)
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1336 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1337 memcpy (&newconfigvar, tmpconfigvar, sizeof (newconfigvar));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1338
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1339 /* Cheap warning fix for const pointer... */
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1340 memcpy (&nc_ptr, &value, sizeof (nc_ptr));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1341 newconfigvar.value = nc_ptr;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1342 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1343
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1344 ret = gftp_option_types[tmpconfigvar->otype].compare_function (&newconfigvar, tmpconfigvar);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1345 if (ret != 0)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1346 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1347 gftp_option_types[tmpconfigvar->otype].copy_function (&newconfigvar, tmpconfigvar);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1348 gftp_configuration_changed = 1;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1349 }
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1350 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1351 else
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1352 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1353 fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1354 exit (EXIT_FAILURE);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1355 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1356 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1357
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1358
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1359 static void
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1360 _gftp_set_option_value (gftp_config_vars * cv, const void * newval)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1361 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1362 gftp_config_vars newconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1363 void *nc_ptr;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1364
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1365 memcpy (&newconfigvar, cv, sizeof (newconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1366
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1367 /* Cheap warning fix for const pointer... */
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1368 memcpy (&nc_ptr, &newval, sizeof (nc_ptr));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1369 newconfigvar.value = nc_ptr;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1370 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1371
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1372 gftp_option_types[cv->otype].copy_function (&newconfigvar, cv);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1373 }
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1374
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1375
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1376 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1377 gftp_set_request_option (gftp_request * request, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1378 const void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1379 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1380 gftp_config_vars * tmpconfigvar;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1381
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1382 if (request->local_options_hash == NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1383 request->local_options_hash = g_hash_table_new (string_hash_function,
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1384 string_hash_compare);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1385
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1386 if ((tmpconfigvar = g_hash_table_lookup (request->local_options_hash,
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1387 key)) != NULL)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1388 _gftp_set_option_value (tmpconfigvar, value);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1389 else
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1390 {
143
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1391 if (gftp_global_options_htable == NULL ||
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1392 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1393 key)) == NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1394 {
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1395 fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1396 exit (EXIT_FAILURE);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1397 }
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1398
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1399 request->num_local_options_vars++;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1400 request->local_options_vars = g_realloc (request->local_options_vars,
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1401 (gulong) sizeof (gftp_config_vars) * request->num_local_options_vars);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1402
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1403 memcpy (&request->local_options_vars[request->num_local_options_vars - 1], tmpconfigvar, sizeof (*tmpconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1404 _gftp_set_option_value (&request->local_options_vars[request->num_local_options_vars - 1], value);
143
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1405
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1406 g_hash_table_insert (request->local_options_hash, request->local_options_vars[request->num_local_options_vars - 1].key, &request->local_options_vars[request->num_local_options_vars - 1]);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1407 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1408 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1409
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1410
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1411 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1412 gftp_set_bookmark_option (gftp_bookmarks_var * bm, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1413 const void *value)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1414 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1415 gftp_config_vars * tmpconfigvar, newconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1416 int ret;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1417
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1418 if (bm->local_options_hash != NULL &&
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1419 (tmpconfigvar = g_hash_table_lookup (bm->local_options_hash,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1420 key)) != NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1421 _gftp_set_option_value (tmpconfigvar, value);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1422 else
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1423 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1424 if (gftp_global_options_htable == NULL ||
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1425 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1426 key)) == NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1427 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1428 fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1429 exit (EXIT_FAILURE);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1430 }
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1431
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1432 /* Check to see if this is set to the same value as the global option.
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1433 If so, don't add it to the bookmark preferences */
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1434 memcpy (&newconfigvar, tmpconfigvar, sizeof (newconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1435 memcpy (&newconfigvar.value, &value, sizeof (newconfigvar.value));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1436 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1437
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1438 ret = gftp_option_types[tmpconfigvar->otype].compare_function (&newconfigvar, tmpconfigvar);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1439 if (ret == 0)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1440 return;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1441
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1442 if (bm->local_options_hash == NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1443 bm->local_options_hash = g_hash_table_new (string_hash_function,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1444 string_hash_compare);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1445
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1446 bm->num_local_options_vars++;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1447 bm->local_options_vars = g_realloc (bm->local_options_vars,
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1448 (gulong) sizeof (gftp_config_vars) * bm->num_local_options_vars);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1449
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1450 memcpy (&bm->local_options_vars[bm->num_local_options_vars - 1], tmpconfigvar, sizeof (*tmpconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1451 _gftp_set_option_value (&bm->local_options_vars[bm->num_local_options_vars - 1], value);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1452
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1453 g_hash_table_insert (bm->local_options_hash, bm->local_options_vars[bm->num_local_options_vars - 1].key, &bm->local_options_vars[bm->num_local_options_vars - 1]);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1454 }
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1455 }
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1456
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1457
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1458 void
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1459 gftp_register_config_vars (gftp_config_vars * config_vars)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1460 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1461 gftp_options_list = g_list_append (gftp_options_list, config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1462 gftp_setup_global_options (config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1463 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1464
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1465
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1466 void
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1467 gftp_copy_local_options (gftp_config_vars ** new_options_vars,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1468 GHashTable ** new_options_hash,
429
1d45758e5cf5 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
1469 int *new_num_local_options_vars,
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1470 gftp_config_vars * orig_options,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1471 int num_local_options_vars)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1472 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1473 int i;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1474
429
1d45758e5cf5 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
1475 *new_num_local_options_vars = num_local_options_vars;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1476 if (orig_options == NULL || num_local_options_vars == 0)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1477 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1478 *new_options_vars = NULL;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1479 *new_options_hash = NULL;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1480 return;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1481 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1482
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1483 *new_options_hash = g_hash_table_new (string_hash_function,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1484 string_hash_compare);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1485
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
1486 *new_options_vars = g_malloc ((gulong) sizeof (gftp_config_vars) * num_local_options_vars);
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1487 memcpy (*new_options_vars, orig_options,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1488 sizeof (gftp_config_vars) * num_local_options_vars);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1489
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1490 for (i=0; i<num_local_options_vars; i++)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1491 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1492 g_hash_table_insert (*new_options_hash, (*new_options_vars)[i].key,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1493 &(*new_options_vars)[i]);
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1494
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1495 (*new_options_vars)[i].value = NULL;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1496 (*new_options_vars)[i].flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1497
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1498 gftp_option_types[(*new_options_vars)[i].otype].copy_function (&(orig_options)[i], &(*new_options_vars)[i]);
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1499 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1500 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1501
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1502
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1503 void
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1504 gftp_config_free_options (gftp_config_vars * options_vars,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1505 GHashTable * options_hash,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1506 int num_options_vars)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1507 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1508 int i;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1509
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1510 if (num_options_vars == 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1511 return;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1512
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1513 if (num_options_vars > 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1514 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1515 /* If num_options_vars is 0, then the options was allocated with malloc */
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1516
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1517 for (i=0; i<num_options_vars; i++)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1518 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1519 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1520 options_vars[i].value != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1521 g_free (options_vars[i].value);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1522 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1523
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1524 g_free (options_vars);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1525 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1526 else if (num_options_vars < 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1527 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1528 /* Otherwise we are freeing the global options */
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1529
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1530 for (i=0; options_vars[i].key != NULL; i++)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1531 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1532 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1533 options_vars[i].value != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1534 g_free (options_vars[i].value);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1535
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1536 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNLISTMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1537 options_vars[i].listdata != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1538 g_free (options_vars[i].listdata);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1539 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1540 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1541
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1542 if (options_hash != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1543 g_hash_table_destroy (options_hash);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1544 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1545
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1546
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1547 void
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1548 gftp_bookmarks_destroy (gftp_bookmarks_var * bookmarks)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1549 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1550 gftp_bookmarks_var * tempentry, * delentry;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1551
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1552 if (bookmarks == NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1553 return;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1554
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1555 tempentry = bookmarks;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1556 while (tempentry != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1557 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1558 if (tempentry->children != NULL)
609
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1559 tempentry = tempentry->children;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1560 else
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1561 {
609
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1562 while (tempentry->next == NULL && tempentry->prev != NULL)
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1563 {
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1564 delentry = tempentry;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1565 tempentry = tempentry->prev;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1566 gftp_free_bookmark (delentry, 1);
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1567 }
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1568
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1569 delentry = tempentry;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1570 tempentry = tempentry->next;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1571 gftp_free_bookmark (delentry, 1);
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1572 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1573 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1574 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1575
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1576
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1577 void
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1578 gftp_free_proxy_hosts (GList * proxy_hosts)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1579 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1580 gftp_proxy_hosts * hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1581 GList * templist;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1582
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1583 for (templist = proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1584 templist != NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1585 templist = templist->next)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1586 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1587 hosts = templist->data;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1588
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1589 if (hosts->domain)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1590 g_free (hosts->domain);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1591 g_free (hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1592 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1593
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1594 g_list_free (proxy_hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1595 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1596
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1597
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1598 GList *
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1599 gftp_copy_proxy_hosts (GList * proxy_hosts)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1600 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1601 gftp_proxy_hosts * oldhosts, * newhosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1602 GList * templist, * new_proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1603
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1604 new_proxy_hosts = NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1605
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1606 if (proxy_hosts != NULL)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1607 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1608 for (templist = proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1609 templist != NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1610 templist = templist->next)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1611 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1612 oldhosts = templist->data;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1613
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1614 newhosts = g_malloc0 (sizeof (*newhosts));
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1615 memcpy (newhosts, oldhosts, sizeof (*newhosts));
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1616
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1617 if (oldhosts->domain)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1618 newhosts->domain = g_strdup (oldhosts->domain);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1619
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1620 new_proxy_hosts = g_list_append (new_proxy_hosts, newhosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1621 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1622 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1623
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1624 return (new_proxy_hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1625 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1626