annotate lib/config_file.c @ 983:ed4854eef853

Added Marathi Translations
author sandeeps
date Thu, 19 Mar 2009 12:15:24 +0000
parents 85cf59eafce2
children 63555c9744c2
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 */
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 854
diff changeset
3 /* Copyright (C) 1998-2007 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 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
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
366 *dest = g_malloc0 ((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 **);
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
398 *dest = g_malloc0 (1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 numargs--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 va_end (argp);
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
402 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
406 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
407 gftp_config_read_str (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
408 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
409 return (g_strdup (buf));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
410 }
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 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
414 gftp_config_write_str (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
415 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
416 fprintf (fd, "%s", (char *) data);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
417 }
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 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
421 gftp_config_read_proxy (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
422 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
423 gftp_proxy_hosts * host;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
424 unsigned int nums[4];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
425 char *pos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
426
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
427 host = g_malloc0 (sizeof (*host));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
428 if ((pos = strchr (buf, '/')) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
429 host->domain = g_strdup (buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
430 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
431 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
432 *pos = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
433 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
434 host->ipv4_network_address =
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
435 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
436
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
437 if (strchr (pos + 1, '.') == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
438 host->ipv4_netmask = 0xffffffff << (32 - strtol (pos + 1, NULL, 10));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
439 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
440 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
441 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
442 &nums[3]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
443 host->ipv4_netmask =
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
444 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
445 }
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 return (host);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
449 }
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 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
453 gftp_config_write_proxy (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
454 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
455 gftp_proxy_hosts * host;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
456
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
457 host = data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
458
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
459 if (host->domain)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
460 fprintf (fd, "%s", host->domain);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
461 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
462 fprintf (fd, "%d.%d.%d.%d/%d.%d.%d.%d",
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
463 host->ipv4_network_address >> 24 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
464 host->ipv4_network_address >> 16 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
465 host->ipv4_network_address >> 8 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
466 host->ipv4_network_address & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
467 host->ipv4_netmask >> 24 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
468 host->ipv4_netmask >> 16 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
469 host->ipv4_netmask >> 8 & 0xff,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
470 host->ipv4_netmask & 0xff);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
471 }
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 static void *
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
475 gftp_config_read_ext (char *buf, int line)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
476 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
477 gftp_file_extensions * tempext;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
478
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
479 tempext = g_malloc0 (sizeof (*tempext));
198
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
480 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
481 &tempext->ascii_binary, &tempext->view_program);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
482
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
483 tempext->stlen = strlen (tempext->ext);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
484
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
485 return (tempext);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
486 }
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 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
490 gftp_config_write_ext (FILE *fd, void *data)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
491 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
492 gftp_file_extensions * tempext;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
493
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
494 tempext = data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
495 fprintf (fd, "%s:%s:%c:%s", tempext->ext, tempext->filename,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
496 *tempext->ascii_binary == '\0' ? ' ' : *tempext->ascii_binary,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
497 tempext->view_program);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
498 }
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
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
501 static gftp_config_list_vars gftp_config_list[] = {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
502 {"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
503 NULL, 0,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
504 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
505 {"ext", gftp_config_read_ext, gftp_config_write_ext,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
506 NULL, 0,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
507 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
508 {"localhistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
509 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
510 {"remotehistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
511 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
512 {"hosthistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
513 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
514 {"porthistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
515 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
516 {"userhistory", gftp_config_read_str, gftp_config_write_str,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
517 NULL, 0, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
518 {NULL, NULL, NULL,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
519 NULL, 0, NULL}
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
520 };
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 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
524 gftp_setup_global_options (gftp_config_vars * cvars)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
525 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
526 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
527
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
528 for (i=0; cvars[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
529 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
530 if (cvars[i].key != NULL && *cvars[i].key != '\0')
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
531 g_hash_table_insert (gftp_global_options_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
532 cvars[i].key, &cvars[i]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
533 }
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 void
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
538 gftp_read_config_file (char *global_data_path)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
539 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
540 char *tempstr, *temp1str, *curpos, buf[255];
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
541 gftp_config_list_vars * tmplistvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
542 gftp_config_vars * tmpconfigvar;
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
543 char **protocol_list;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
544 FILE *conffile;
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
545 int line, i, j;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
546 size_t len;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
547
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
548 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
549 string_hash_compare);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
550
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
551 gftp_register_config_vars (gftp_global_config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
552
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
553 protocol_list = NULL;
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
554 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
555 {
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
556 if (gftp_protocols[i].shown)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
557 {
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
558 protocol_list = g_realloc (protocol_list,
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
559 (gulong) sizeof (char *) * (j + 2));
600
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
560 protocol_list[j] = gftp_protocols[i].name;
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
561 protocol_list[j + 1] = NULL;
0a1d03fa2261 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 555
diff changeset
562 j++;
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
563 }
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
564
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
565 if (gftp_protocols[i].register_options != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
566 gftp_protocols[i].register_options ();
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
567 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
568
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
569 if ((tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
570 "default_protocol")) != NULL)
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
571 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
572 tmpconfigvar->listdata = protocol_list;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
573 tmpconfigvar->flags |= GFTP_CVARS_FLAGS_DYNLISTMEM;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
574 }
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
575
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
576 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
577 string_hash_compare);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
578
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
579 for (i=0; gftp_config_list[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
580 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
581 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
582 &gftp_config_list[i]);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
583 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
584
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
585 if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
586 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
587 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
588 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
589 }
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 if (access (tempstr, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
592 {
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
593 temp1str = gftp_expand_path (NULL, BASE_CONF_DIR);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
594 if (access (temp1str, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
595 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
596 if (mkdir (temp1str, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
597 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
598 printf (_("gFTP Error: Could not make directory %s: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
599 temp1str, g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
600 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
601 }
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 g_free (temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
604
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
605 temp1str = g_strdup_printf ("%s/gftprc", global_data_path);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
606 if (access (temp1str, F_OK) == -1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
607 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
608 printf (_("gFTP Error: Cannot find master config file %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
609 temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
610 printf (_("Did you do a make install?\n"));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
611 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
612 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
613 copyfile (temp1str, tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
614 g_free (temp1str);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
615 }
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 if ((conffile = fopen (tempstr, "r")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
618 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
619 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
620 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
621 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
622 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
623 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
624
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
625 line = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
626 while (fgets (buf, sizeof (buf), conffile))
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
627 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
628 len = strlen (buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
629 if (len > 0 && buf[len - 1] == '\n')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
630 buf[--len] = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
631 if (len > 0 && buf[len - 1] == '\r')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
632 buf[--len] = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
633 line++;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
634
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
635 if (*buf == '#' || *buf == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
636 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
637
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
638 if ((curpos = strchr (buf, '=')) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
639 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
640
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
641 *curpos = '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
642
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
643 if ((tmplistvar = g_hash_table_lookup (gftp_config_list_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
644 buf)) != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
645 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
646 tmplistvar->list = g_list_append (tmplistvar->list,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
647 tmplistvar->read_func (curpos + 1,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
648 line));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
649 tmplistvar->num_items++;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
650 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
651 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
652 buf)) != NULL &&
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
653 gftp_option_types[tmpconfigvar->otype].read_function != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
654 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
655 if (gftp_option_types[tmpconfigvar->otype].read_function (curpos + 1,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
656 tmpconfigvar, line) != 0)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
657 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
658 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
659 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
660 }
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 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
663 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
664 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
665 line, buf);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
666 }
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
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
669 if ((tempstr = gftp_expand_path (NULL, LOG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
670 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
671 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
672 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
673 }
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 if ((gftp_logfd = fopen (tempstr, "w")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
676 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
677 printf (_("gFTP Warning: Cannot open %s for writing: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
678 tempstr, g_strerror (errno));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
679 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
680 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
681
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
682 gftp_bookmarks = g_malloc0 (sizeof (*gftp_bookmarks));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
683 gftp_bookmarks->isfolder = 1;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
684 gftp_bookmarks->path = g_malloc0 (1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
685 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
686
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
687 gftp_read_bookmarks (global_data_path);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
688 }
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 static void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
692 write_comment (FILE * fd, const char *comment)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
693 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
694 const char *pos, *endpos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
695
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
696 fwrite ("# ", 1, 2, fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
697 pos = comment;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
698 while (strlen (pos) > 76)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
699 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
700 for (endpos = pos + 76; *endpos != ' ' && endpos > pos; endpos--);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
701 if (endpos == pos)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
702 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
703 for (endpos = pos + 76; *endpos != ' ' && *endpos != '\0';
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
704 endpos++);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
705 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
706 fwrite (pos, 1, endpos - pos, fd);
854
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
707 fwrite ("\n", 1, 1, fd);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
708 if (*endpos == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
709 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
710 pos = endpos;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
711 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
712 }
854
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
713 pos = endpos + 1;
2c94567f9a53 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
714 fwrite ("# ", 1, 2, fd);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
715 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
716 if (strlen (pos) > 1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
717 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
718 fwrite (pos, 1, strlen (pos), fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
719 fwrite ("\n", 1, 1, fd);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
720 }
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 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
725 gftp_write_bookmarks_file (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
726 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
727 char *bmhdr, *pwhdr, *tempstr, *password, buf[256];
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
728 gftp_bookmarks_var * tempentry;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
729 FILE * bmfile;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
730 int i;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
731
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 854
diff changeset
732 bmhdr = N_("Bookmarks file for gFTP. Copyright (C) 1998-2007 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
733 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
734
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
735 if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
736 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
737 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
738 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
739 }
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 if ((bmfile = fopen (tempstr, "w+")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
742 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
743 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
744 CONFIG_FILE, g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
745 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
746 }
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 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
749
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
750 write_comment (bmfile, _(bmhdr));
332
6317b45645a8 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 330
diff changeset
751 write_comment (bmfile, _(pwhdr));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
752 fwrite ("\n", 1, 1, bmfile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
753
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
754 tempentry = gftp_bookmarks->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
755 while (tempentry != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
756 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
757 if (tempentry->children != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
758 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
759 tempentry = tempentry->children;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
760 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
761 }
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
762
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
763 tempstr = tempentry->path;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
764 while (*tempstr == '/')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
765 tempstr++;
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
766
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
767 if (tempentry->isfolder)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
768 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
769 fprintf (bmfile, "[%s/]\n", tempstr);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
770 }
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
771 else
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
772 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
773 if (tempentry->save_password && tempentry->pass != NULL)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
774 password = gftp_scramble_password (tempentry->pass);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
775 else
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
776 password = NULL;
330
532eb171d5c2 2003-12-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 325
diff changeset
777
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
778 fprintf (bmfile,
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
779 "[%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
780 tempstr, tempentry->hostname == NULL ? "" : tempentry->hostname,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
781 tempentry->port, tempentry->protocol == NULL
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
782 || *tempentry->protocol ==
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
783 '\0' ? gftp_protocols[0].name : tempentry->protocol,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
784 tempentry->remote_dir == NULL ? "" : tempentry->remote_dir,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
785 tempentry->local_dir == NULL ? "" : tempentry->local_dir,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
786 tempentry->user == NULL ? "" : tempentry->user,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
787 password == NULL ? "" : password,
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
788 tempentry->acct == NULL ? "" : tempentry->acct);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
789 if (password != NULL)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
790 g_free(password);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
791
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
792 if (tempentry->local_options_vars != NULL)
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
793 {
607
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
794 for (i=0; i<tempentry->num_local_options_vars; i++)
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
795 {
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
796 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
797
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
798 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
799 buf);
f946521bb2f2 2004-11-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 605
diff changeset
800 }
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
801 }
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
802 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
803
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
804 fprintf (bmfile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
805
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
806 if (tempentry->next == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
807 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
808 tempentry = tempentry->prev;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
809 while (tempentry->next == NULL && tempentry->prev != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
810 tempentry = tempentry->prev;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
811 tempentry = tempentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
812 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
813 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
814 tempentry = tempentry->next;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
815 }
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 fclose (bmfile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
818 }
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 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
822 gftp_write_config_file (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
823 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
824 char *tempstr, buf[256];
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
825 gftp_config_vars * cv;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
826 GList *templist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
827 FILE *conffile;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
828 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
829
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
830 if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
831 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
832 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
833 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
834 }
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 if ((conffile = fopen (tempstr, "w+")) == NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
837 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
838 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
839 g_strerror (errno));
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 609
diff changeset
840 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
841 }
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 g_free (tempstr);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
844
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 854
diff changeset
845 write_comment (conffile, _("Config file for gFTP. Copyright (C) 1998-2007 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"));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
846
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
847 for (templist = gftp_options_list;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
848 templist != NULL;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
849 templist = templist->next)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
850 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
851 cv = templist->data;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
852
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
853 for (i=0; cv[i].key != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
854 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
855 if (gftp_option_types[cv[i].otype].write_function == NULL ||
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
856 *cv[i].key == '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
857 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
858
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
859 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
860 if (cv[i].comment != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
861 write_comment (conffile, _(cv[i].comment));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
862
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
863 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
864 sizeof (buf), 1);
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
865 fprintf (conffile, "%s=%s\n", cv[i].key, buf);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
866 }
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
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
869 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
870 {
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
871 if (gftp_config_list[i].header == NULL &&
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
872 gftp_config_list[i].list == NULL)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
873 continue;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
874
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
875 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
876 if (gftp_config_list[i].header != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
877 write_comment (conffile, _(gftp_config_list[i].header));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
878
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
879 for (templist = gftp_config_list[i].list;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
880 templist != NULL;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
881 templist = templist->next)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
882 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
883 fprintf (conffile, "%s=", gftp_config_list[i].key);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
884 gftp_config_list[i].write_func (conffile, templist->data);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
885 fprintf (conffile, "\n");
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
886 }
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 fclose (conffile);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
890 }
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
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 GHashTable *
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
894 build_bookmarks_hash_table (gftp_bookmarks_var * entry)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
895 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
896 gftp_bookmarks_var * tempentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
897 GHashTable * htable;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899 htable = g_hash_table_new (string_hash_function, string_hash_compare);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 tempentry = entry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 g_hash_table_insert (htable, tempentry->path, tempentry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
905 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
906 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
911 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 return (htable);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
914 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
915
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
916
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
917 void
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
918 print_bookmarks (gftp_bookmarks_var * bookmarks)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
919 {
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
920 gftp_bookmarks_var * tempentry;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
921
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922 tempentry = bookmarks->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 while (tempentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
925 printf ("Path: %s (%d)\n", tempentry->path, tempentry->children != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926 if (tempentry->children != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928 tempentry = tempentry->children;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932 if (tempentry->next == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934 while (tempentry->next == NULL && tempentry->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935 tempentry = tempentry->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939 tempentry = tempentry->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
943
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
944 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
945 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
946 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
947 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM && cv->value != NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
948 g_free (cv->value);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
949
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
950 if (str != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
951 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
952 cv->value = g_strdup (str);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
953 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
954 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
955 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
956 else
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
957 {
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
958 cv->value = NULL;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
959 cv->flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
960 return (-1);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
961 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
962 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
966 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
967 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
968 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
969 char *outstr;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
970
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
971 if (cv->value != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
972 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
973 outstr = cv->value;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
974 g_snprintf (buf, buflen, "%s", outstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
975 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
976 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
977 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
978 return (-1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
979 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
983 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
984 size_t buflen, int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
985 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
986 char *outstr;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
987
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
988 if (cv->value != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
989 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
990 outstr = cv->value;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
991 if (*outstr != '\0')
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
992 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
993 if (to_config_file)
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
994 g_snprintf (buf, buflen, "%s", outstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
995 else
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
996 g_snprintf (buf, buflen, "*****");
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
997 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
998 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
999 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1000 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1001 return (-1);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1002 }
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
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1005 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1006 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
1007 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1008 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
1009 g_free (dest_cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1010
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1011 if (cv->value != NULL)
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1012 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1013 dest_cv->value = g_strdup ((char *) cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1014 dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1015 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1016 else
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1017 dest_cv->value = NULL;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1018 }
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
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1021 static int
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1022 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
1023 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1024 char *str1, *str2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1025
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1026 str1 = cv1->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1027 str2 = cv2->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1028
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1029 if (cv1->value == NULL && cv2->value == NULL)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1030 return (0);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1031
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1032 if ((cv1->value == NULL && cv2->value != NULL) ||
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1033 (cv1->value != NULL && cv2->value == NULL))
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1034 return (-1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1035
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1036 return (strcmp (str1, str2));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1037 }
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
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1040 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1041 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
1042 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1043 memcpy (&dest_cv->value, &cv->value, sizeof (dest_cv->value));
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1044 }
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1045
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1046 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1047 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
1048 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1049 cv->value = GINT_TO_POINTER(strtol (str, NULL, 10));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1050 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1051 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1055 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
1056 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1057 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1058 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
1059 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1060 }
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 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1064 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
1065 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1066 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
1067 }
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 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1071 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
1072 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1073 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
1074 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1075 }
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 static int
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1079 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
1080 {
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1081 union { intptr_t i; float f; } r;
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1082
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1083 r.f = strtod (str, NULL);
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
1084 memcpy (&cv->value, &r.i, sizeof (cv->value));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1085 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1086 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1090 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
1091 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1092 {
131
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1093 float f;
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1094
c77f85763e28 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
1095 memcpy (&f, &cv->value, sizeof (f));
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1096 g_snprintf (buf, buflen, "%.2f", f);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1097 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1098 }
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 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1102 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
1103 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1104 float f1, f2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1105
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1106 memcpy (&f1, &cv1->value, sizeof (f1));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1107 memcpy (&f2, &cv2->value, sizeof (f2));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1108 return (f1 == f2 ? 0 : -1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1109 }
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 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1113 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
1114 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1115 char *red, *green, *blue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1116 gftp_color * color;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1117
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1118 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM && cv->value != NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1119 g_free (cv->value);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1120
198
8fea1b1a2ec6 2003-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
1121 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
1122
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
1123 color = g_malloc0 (sizeof (*color));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1124 color->red = strtol (red, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1125 color->green = strtol (green, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1126 color->blue = strtol (blue, NULL, 16);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1127 g_free (red);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1128 g_free (green);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1129 g_free (blue);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1130
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1131 cv->value = color;
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1132 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1133
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1134 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1135 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1139 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
1140 int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1141 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1142 gftp_color * color;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1143
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1144 color = cv->value;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1145 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
1146 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1147 }
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
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1150 static void
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1151 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
1152 {
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1153 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
1154 g_free (dest_cv->value);
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1155
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
1156 dest_cv->value = g_malloc0 (sizeof (gftp_color));
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1157 memcpy (dest_cv->value, cv->value, sizeof (gftp_color));
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1158 dest_cv->flags |= GFTP_CVARS_FLAGS_DYNMEM;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1159 }
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
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1162 static int
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1163 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
1164 {
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1165 gftp_color * color1, * color2;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1166
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1167 color1 = cv1->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1168 color2 = cv2->value;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1169
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1170 return (color1->red == color2->red && color1->green == color2->green &&
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1171 color1->blue == color2->blue ? 0 : -1);
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1172 }
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 static int
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1176 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
1177 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1178 char **clist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1179 int i;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1180
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1181 cv->value = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1182 if (cv->listdata != NULL)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1183 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1184 clist = cv->listdata;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1185 for (i=0; clist[i] != NULL; i++)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1186 {
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1187 if (strcasecmp (clist[i], str) == 0)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1188 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1189 cv->value = GINT_TO_POINTER(i);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1190 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1191 }
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 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1196 }
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 static int
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1200 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
1201 size_t buflen, int to_config_file)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1202 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1203 char **clist;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1204
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1205 clist = cv->listdata;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1206 if (clist != NULL)
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1207 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
1208 else
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1209 g_snprintf (buf, buflen, _("<unknown>"));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1210
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1211 return (0);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1212 }
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
125
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1215 static int
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1216 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
1217 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1218 char **clist;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1219 int i;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1220
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1221 cv->value = NULL;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1222 if (cv->listdata != NULL)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1223 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1224 clist = cv->listdata;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1225 for (i=0; clist[i] != NULL; i++)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1226 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1227 if (strcasecmp (clist[i], str) == 0)
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1228 {
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1229 cv->value = clist[i];
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1230 break;
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1231 }
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 return (0);
b875de05c22d 2003-4-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 124
diff changeset
1236 }
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 /* 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
1240 gftp_option_type_enum in gftp.h */
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1241 gftp_option_type_var gftp_option_types[] = {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1242 {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
1243 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
1244 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1245 {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
1246 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
1247 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1248 {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
1249 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
1250 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1251 {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
1252 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
1253 NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1254 {gftp_config_file_read_int, gftp_config_file_write_int,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1255 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
1256 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1257 {gftp_config_file_read_checkbox, gftp_config_file_write_int,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1258 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
1259 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1260 {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1261 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
1262 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1263 {gftp_config_file_read_float, gftp_config_file_write_float,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1264 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
1265 NULL, NULL, NULL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1266 {gftp_config_file_read_color, gftp_config_file_write_color,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1267 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
1268 NULL, NULL, NULL, NULL},
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 516
diff changeset
1269 {NULL, NULL, NULL, NULL, 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}
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1271 };
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 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1275 gftp_lookup_global_option (const char * key, void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1276 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1277 gftp_config_list_vars * tmplistvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1278 gftp_config_vars * tmpconfigvar;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1279
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1280 if (gftp_global_options_htable != NULL &&
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1281 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1282 key)) != NULL)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1283 memcpy (value, &tmpconfigvar->value, sizeof (value));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1284 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
1285 key)) != NULL)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1286 *(gftp_config_list_vars **) value = tmplistvar;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1287 else
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1288 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1289 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
1290 exit (EXIT_FAILURE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1291 }
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 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1296 gftp_lookup_request_option (gftp_request * request, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1297 void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1298 {
143
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1299 gftp_config_vars * tmpconfigvar;
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1300
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1301 if (request != NULL && request->local_options_hash != NULL &&
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1302 (tmpconfigvar = g_hash_table_lookup (request->local_options_hash,
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1303 key)) != NULL)
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1304 memcpy (value, &tmpconfigvar->value, sizeof (value));
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1305 else
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1306 gftp_lookup_global_option (key, value);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1307 }
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 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1311 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
1312 void *value)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1313 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1314 gftp_config_vars * tmpconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1315
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1316 if (bm != NULL && bm->local_options_hash != NULL &&
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1317 (tmpconfigvar = g_hash_table_lookup (bm->local_options_hash,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1318 key)) != NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1319 memcpy (value, &tmpconfigvar->value, sizeof (value));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1320 else
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1321 gftp_lookup_global_option (key, value);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1322 }
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 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1326 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
1327 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1328 gftp_config_vars * tmpconfigvar, newconfigvar;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1329 void *nc_ptr;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1330 int ret;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1331
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1332 if (gftp_global_options_htable != NULL &&
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1333 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1334 key)) != NULL)
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1335 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1336 memcpy (&newconfigvar, tmpconfigvar, sizeof (newconfigvar));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1337
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1338 /* Cheap warning fix for const pointer... */
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1339 memcpy (&nc_ptr, &value, sizeof (nc_ptr));
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1340 newconfigvar.value = nc_ptr;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1341 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1342
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1343 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
1344 if (ret != 0)
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1345 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1346 gftp_option_types[tmpconfigvar->otype].copy_function (&newconfigvar, tmpconfigvar);
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1347 gftp_configuration_changed = 1;
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1348 }
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1349 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1350 else
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1351 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1352 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
1353 exit (EXIT_FAILURE);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 126
diff changeset
1354 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1355 }
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
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1358 static void
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1359 _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
1360 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1361 gftp_config_vars newconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1362 void *nc_ptr;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1363
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1364 memcpy (&newconfigvar, cv, sizeof (newconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1365
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1366 /* Cheap warning fix for const pointer... */
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1367 memcpy (&nc_ptr, &newval, sizeof (nc_ptr));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1368 newconfigvar.value = nc_ptr;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1369 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1370
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1371 gftp_option_types[cv->otype].copy_function (&newconfigvar, cv);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1372 }
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
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1375 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1376 gftp_set_request_option (gftp_request * request, const char * key,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1377 const void *value)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1378 {
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1379 gftp_config_vars * tmpconfigvar;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1380
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1381 if (request->local_options_hash == NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1382 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
1383 string_hash_compare);
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1384
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1385 if ((tmpconfigvar = g_hash_table_lookup (request->local_options_hash,
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1386 key)) != NULL)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1387 _gftp_set_option_value (tmpconfigvar, value);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1388 else
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1389 {
143
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1390 if (gftp_global_options_htable == NULL ||
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1391 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1392 key)) == NULL)
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1393 {
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1394 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
1395 exit (EXIT_FAILURE);
136
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1396 }
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 request->num_local_options_vars++;
84b3e69807a2 2003-4-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 131
diff changeset
1399 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
1400 (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
1401
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1402 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
1403 _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
1404
5c952c5cb438 2003-4-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 136
diff changeset
1405 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
1406 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1407 }
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 void
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 332
diff changeset
1411 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
1412 const void *value)
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1413 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1414 gftp_config_vars * tmpconfigvar, newconfigvar;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1415 int ret;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1416
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1417 if (bm->local_options_hash != NULL &&
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1418 (tmpconfigvar = g_hash_table_lookup (bm->local_options_hash,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1419 key)) != NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1420 _gftp_set_option_value (tmpconfigvar, value);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1421 else
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1422 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1423 if (gftp_global_options_htable == NULL ||
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1424 (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1425 key)) == NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1426 {
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1427 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
1428 exit (EXIT_FAILURE);
229
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1429 }
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 /* 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
1432 If so, don't add it to the bookmark preferences */
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1433 memcpy (&newconfigvar, tmpconfigvar, sizeof (newconfigvar));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1434 memcpy (&newconfigvar.value, &value, sizeof (newconfigvar.value));
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1435 newconfigvar.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1436
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1437 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
1438 if (ret == 0)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1439 return;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1440
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1441 if (bm->local_options_hash == NULL)
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1442 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
1443 string_hash_compare);
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1444
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1445 bm->num_local_options_vars++;
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1446 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
1447 (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
1448
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1449 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
1450 _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
1451
35ae2e80962e 2003-7-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 227
diff changeset
1452 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
1453 }
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 void
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1458 gftp_register_config_vars (gftp_config_vars * config_vars)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1459 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1460 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
1461 gftp_setup_global_options (config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1462 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 107
diff changeset
1463
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1464
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1465 void
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1466 gftp_copy_local_options (gftp_config_vars ** new_options_vars,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1467 GHashTable ** new_options_hash,
429
1d45758e5cf5 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
1468 int *new_num_local_options_vars,
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1469 gftp_config_vars * orig_options,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1470 int num_local_options_vars)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1471 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1472 int i;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1473
429
1d45758e5cf5 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
1474 *new_num_local_options_vars = num_local_options_vars;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1475 if (orig_options == NULL || num_local_options_vars == 0)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1476 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1477 *new_options_vars = NULL;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1478 *new_options_hash = NULL;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1479 return;
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1480 }
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 *new_options_hash = g_hash_table_new (string_hash_function,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1483 string_hash_compare);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1484
942
85cf59eafce2 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
1485 *new_options_vars = g_malloc0 ((gulong) sizeof (gftp_config_vars) * num_local_options_vars);
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1486 memcpy (*new_options_vars, orig_options,
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1487 sizeof (gftp_config_vars) * num_local_options_vars);
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1488
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1489 for (i=0; i<num_local_options_vars; i++)
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1490 {
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1491 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
1492 &(*new_options_vars)[i]);
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1493
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1494 (*new_options_vars)[i].value = NULL;
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1495 (*new_options_vars)[i].flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
199
75eebb3b0592 2003-6-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 198
diff changeset
1496
207
cf4098008615 2003-7-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 201
diff changeset
1497 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
1498 }
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
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1501
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1502 void
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1503 gftp_config_free_options (gftp_config_vars * options_vars,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1504 GHashTable * options_hash,
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1505 int num_options_vars)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1506 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1507 int i;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1508
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1509 if (num_options_vars == 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1510 return;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1511
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1512 if (num_options_vars > 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1513 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1514 /* 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
1515
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1516 for (i=0; i<num_options_vars; i++)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1517 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1518 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1519 options_vars[i].value != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1520 g_free (options_vars[i].value);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1521 }
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 g_free (options_vars);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1524 }
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1525 else if (num_options_vars < 0)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1526 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1527 /* Otherwise we are freeing the global options */
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1528
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1529 for (i=0; options_vars[i].key != NULL; i++)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1530 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1531 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1532 options_vars[i].value != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1533 g_free (options_vars[i].value);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1534
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1535 if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNLISTMEM &&
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1536 options_vars[i].listdata != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1537 g_free (options_vars[i].listdata);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1538 }
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 if (options_hash != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1542 g_hash_table_destroy (options_hash);
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1543 }
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 void
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1547 gftp_bookmarks_destroy (gftp_bookmarks_var * bookmarks)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1548 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1549 gftp_bookmarks_var * tempentry, * delentry;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1550
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1551 if (bookmarks == NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1552 return;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1553
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1554 tempentry = bookmarks;
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1555 while (tempentry != NULL)
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1556 {
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1557 if (tempentry->children != NULL)
609
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1558 tempentry = tempentry->children;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1559 else
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1560 {
609
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1561 while (tempentry->next == NULL && tempentry->prev != NULL)
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1562 {
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1563 delentry = tempentry;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1564 tempentry = tempentry->prev;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1565 gftp_free_bookmark (delentry, 1);
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1566 }
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 delentry = tempentry;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1569 tempentry = tempentry->next;
d97e985f5dbe 2004-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 607
diff changeset
1570 gftp_free_bookmark (delentry, 1);
201
0098dae654a5 2003-6-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 199
diff changeset
1571 }
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
218
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1575
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1576 void
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1577 gftp_free_proxy_hosts (GList * proxy_hosts)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1578 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1579 gftp_proxy_hosts * hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1580 GList * templist;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1581
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1582 for (templist = proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1583 templist != NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1584 templist = templist->next)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1585 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1586 hosts = templist->data;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1587
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1588 if (hosts->domain)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1589 g_free (hosts->domain);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1590 g_free (hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1591 }
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 g_list_free (proxy_hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1594 }
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 GList *
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1598 gftp_copy_proxy_hosts (GList * proxy_hosts)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1599 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1600 gftp_proxy_hosts * oldhosts, * newhosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1601 GList * templist, * new_proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1602
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1603 new_proxy_hosts = NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1604
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1605 if (proxy_hosts != NULL)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1606 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1607 for (templist = proxy_hosts;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1608 templist != NULL;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1609 templist = templist->next)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1610 {
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1611 oldhosts = templist->data;
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1612
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1613 newhosts = g_malloc0 (sizeof (*newhosts));
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1614 memcpy (newhosts, oldhosts, sizeof (*newhosts));
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1615
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1616 if (oldhosts->domain)
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1617 newhosts->domain = g_strdup (oldhosts->domain);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1618
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1619 new_proxy_hosts = g_list_append (new_proxy_hosts, newhosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1620 }
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 return (new_proxy_hosts);
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1624 }
de6a2e8e51cb 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
1625