Mercurial > gftp.yaz
changeset 126:1e65871fdfa1
2003-4-9 Brian Masney <masneyb@gftp.org>
* lib/gftp.h lib/config_file.c - reordered config option types. Added
gftp_option_type_textcomboedt type
* lib/options.h lib/rfc959.c - moved gftp_proxy_type to rfc959.c
* lib/rfc959.c - added proxy_type that is
gftp_option_type_textcomboedt. Consolidated help text into comment.
In parse_ftp_proxy_string(), improve parsing of proxy config
author | masneyb |
---|---|
date | Thu, 10 Apr 2003 02:29:44 +0000 |
parents | b875de05c22d |
children | a856923de087 |
files | ChangeLog lib/config_file.c lib/gftp.h lib/options.h lib/rfc959.c |
diffstat | 5 files changed, 82 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Apr 08 22:28:17 2003 +0000 +++ b/ChangeLog Thu Apr 10 02:29:44 2003 +0000 @@ -1,3 +1,13 @@ +2003-4-9 Brian Masney <masneyb@gftp.org> + * lib/gftp.h lib/config_file.c - reordered config option types. Added + gftp_option_type_textcomboedt type + + * lib/options.h lib/rfc959.c - moved gftp_proxy_type to rfc959.c + + * lib/rfc959.c - added proxy_type that is + gftp_option_type_textcomboedt. Consolidated help text into comment. + In parse_ftp_proxy_string(), improve parsing of proxy config + 2003-4-8 Brian Masney <masneyb@gftp.org> * src/text/gftp-text.c lib/misc.c - moved r_gethostbyname() and r_getservbyname() to lib/misc.c. Now uses GMutex functions @@ -640,7 +650,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.67 2003/04/08 22:28:16 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.68 2003/04/10 02:29:42 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/lib/config_file.c Tue Apr 08 22:28:17 2003 +0000 +++ b/lib/config_file.c Thu Apr 10 02:29:44 2003 +0000 @@ -1010,18 +1010,18 @@ gftp_option_type_enum in gftp.h */ gftp_option_type_var gftp_option_types[] = { {gftp_config_file_read_text, gftp_config_file_write_text, NULL, NULL}, + {gftp_config_file_read_textcombo, gftp_config_file_write_text, NULL, NULL}, + {gftp_config_file_read_text, gftp_config_file_write_text, NULL, NULL}, + {gftp_config_file_read_text, gftp_config_file_write_hidetext, NULL, NULL}, {gftp_config_file_read_int, gftp_config_file_write_int, NULL, NULL}, + {gftp_config_file_read_checkbox, gftp_config_file_write_int, NULL, NULL}, + {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo, NULL, NULL}, {gftp_config_file_read_float, gftp_config_file_write_float, NULL, NULL}, - {gftp_config_file_read_checkbox, gftp_config_file_write_int, NULL, NULL}, {gftp_config_file_read_color, gftp_config_file_write_color, NULL, NULL}, {NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL}, - {gftp_config_file_read_text, gftp_config_file_write_hidetext, NULL, NULL}, {NULL, NULL, NULL, NULL}, - {gftp_config_file_read_text, gftp_config_file_write_text, NULL, NULL}, {NULL, NULL, NULL, NULL}, - {gftp_config_file_read_intcombo, gftp_config_file_write_intcombo, NULL, NULL}, - {gftp_config_file_read_textcombo, gftp_config_file_write_text, NULL, NULL}, {NULL, NULL, NULL, NULL} };
--- a/lib/gftp.h Tue Apr 08 22:28:17 2003 +0000 +++ b/lib/gftp.h Thu Apr 10 02:29:44 2003 +0000 @@ -426,18 +426,18 @@ typedef enum { gftp_option_type_text = 0, - gftp_option_type_int = 1, - gftp_option_type_float = 2, - gftp_option_type_checkbox = 3, - gftp_option_type_color = 4, - gftp_option_type_notebook = 5, - gftp_option_type_newtable = 6, - gftp_option_type_hidetext = 7, - gftp_option_type_label = 8, - gftp_option_type_textbox = 9, - gftp_option_type_subtree = 10, - gftp_option_type_intcombo = 11, - gftp_option_type_textcombo = 12, + gftp_option_type_textcombo = 1, + gftp_option_type_textcomboedt = 2, + gftp_option_type_hidetext = 3, + gftp_option_type_int = 4, + gftp_option_type_checkbox = 5, + gftp_option_type_intcombo = 6, + gftp_option_type_float = 7, + gftp_option_type_color = 8, + gftp_option_type_notebook = 9, + gftp_option_type_newtable = 10, + gftp_option_type_label = 11, + gftp_option_type_subtree = 12, gftp_option_type_table = 13 } gftp_option_type_enum; @@ -487,13 +487,12 @@ } gftp_option_type_var; -typedef struct gftp_proxy_type_var_tag +typedef struct gftp_textcomboedt_data_tag { char *key, *description; -} gftp_proxy_type_var; +} gftp_textcomboedt_data; -#define GFTP_CUSTOM_PROXY_NUM 8 typedef struct gftp_getline_buffer_tag { @@ -503,6 +502,7 @@ cur_bufsize; } gftp_getline_buffer; + /* Global config options. These are defined in options.h */ extern GList * gftp_file_transfers, * gftp_file_transfer_logs, * gftp_options_list; @@ -510,7 +510,6 @@ * gftp_config_list_htable; extern gftp_config_vars gftp_global_config_vars[]; extern supported_gftp_protocols gftp_protocols[]; -extern gftp_proxy_type_var gftp_proxy_type[]; extern gftp_bookmarks_var * gftp_bookmarks; extern char gftp_version[]; extern FILE * gftp_logfd;
--- a/lib/options.h Tue Apr 08 22:28:17 2003 +0000 +++ b/lib/options.h Thu Apr 10 02:29:44 2003 +0000 @@ -21,19 +21,6 @@ #include "gftp.h" -gftp_proxy_type_var gftp_proxy_type[] = { - {N_("none"), ""}, - {N_("SITE command"), "USER %pu\nPASS %pp\nSITE %hh\nUSER %hu\nPASS %hp\n"}, - {N_("user@host"), "USER %pu\nPASS %pp\nUSER %hu@%hh\nPASS %hp\n"}, - {N_("user@host:port"), "USER %hu@%hh:%ho\nPASS %hp\n"}, - {N_("AUTHENTICATE"), "USER %hu@%hh\nPASS %hp\nSITE AUTHENTICATE %pu\nSITE RESPONSE %pp\n"}, - {N_("user@host port"), "USER %hu@%hh %ho\nPASS %hp\n"}, - {N_("user@host NOAUTH"), "USER %hu@%hh\nPASS %hp\n"}, - {N_("HTTP Proxy"), "http"}, - {N_("Custom"), ""}, - {NULL, NULL} -}; - static char *gftp_sort_columns[] = { N_("none"), N_("file"), N_("size"), N_("user"), N_("group"), N_("datetime"), N_("attribs"), NULL };
--- a/lib/rfc959.c Tue Apr 08 22:28:17 2003 +0000 +++ b/lib/rfc959.c Thu Apr 10 02:29:44 2003 +0000 @@ -20,6 +20,19 @@ #include "gftp.h" static const char cvsid[] = "$Id$"; +static gftp_textcomboedt_data gftp_proxy_type[] = { + {N_("none"), ""}, + {N_("SITE command"), "USER %pu\nPASS %pp\nSITE %hh\nUSER %hu\nPASS %hp\n"}, + {N_("user@host"), "USER %pu\nPASS %pp\nUSER %hu@%hh\nPASS %hp\n"}, + {N_("user@host:port"), "USER %hu@%hh:%ho\nPASS %hp\n"}, + {N_("AUTHENTICATE"), "USER %hu@%hh\nPASS %hp\nSITE AUTHENTICATE %pu\nSITE RESPONSE %pp\n"}, + {N_("user@host port"), "USER %hu@%hh %ho\nPASS %hp\n"}, + {N_("user@host NOAUTH"), "USER %hu@%hh\nPASS %hp\n"}, + {N_("HTTP Proxy"), "http"}, + {N_("Custom"), ""}, + {NULL, NULL} +}; + static gftp_config_vars config_vars[] = { {"", N_("FTP"), gftp_option_type_notebook, NULL, NULL, 0, NULL, @@ -39,7 +52,7 @@ GFTP_PORT_ALL, NULL}, {"ascii_transfers", N_("Transfer files in ASCII mode"), gftp_option_type_checkbox, GINT_TO_POINTER(0), NULL, 0, - N_("If you are transfering a text file from Windows to UNIX box or vice versa, then you should enable this. Each system represents newlines differently. If you are transfering from UNIX to UNIX, then it is safe to leave this off."), + N_("If you are transfering a text file from Windows to UNIX box or vice versa, then you should enable this. Each system represents newlines differently for text files. If you are transfering from UNIX to UNIX, then it is safe to leave this off. If you are downloading binary data, you will want to disable this."), GFTP_PORT_ALL, NULL}, {"ftp_proxy_host", N_("Proxy hostname:"), gftp_option_type_text, "", NULL, 0, @@ -58,32 +71,12 @@ N_("Your firewall account (optional)"), GFTP_PORT_ALL, NULL}, {"", "", gftp_option_type_newtable, "", NULL, 0, "", GFTP_PORT_GTK, NULL}, -/* FIXME {"", N_("Proxy server type"), CONFIG_COMBO, "PS", NULL, GFTP_PORT_GTK},*/ - {"proxy_config", N_("Proxy config"), - gftp_option_type_textbox, "", NULL, 0, - N_("This specifies how your proxy server expects us to log in"), - GFTP_PORT_GTK, NULL}, - {"", N_("%pu = proxy user"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%hu = host user"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%pp = proxy pass"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%hp = host pass"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%ph = proxy host"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%hh = host"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%po = proxy port"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%ho = host port"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%pa = proxy account"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, - {"", N_("%ha = host account"), gftp_option_type_label, "", NULL, 0, "", - GFTP_PORT_GTK, NULL}, + {"proxy_config", N_("Proxy server type:"), + gftp_option_type_textcomboedt, "", gftp_proxy_type, 0, + N_("This specifies how your proxy server expects us to log in. You can specify a 2 character replacement string prefixed by a % that will be replaced with the proper data. The first character can be either p for proxy or h for the host of the FTP server. The second character can be u (user), p (pass), h (host), o (port) or a (account). For example, to specify the proxy user, you can you type in %pu"), + GFTP_PORT_ALL, NULL}, + {NULL, NULL, 0, NULL, NULL, 0, NULL, 0, NULL} }; @@ -183,19 +176,21 @@ static char * parse_ftp_proxy_string (gftp_request * request) { - char *startpos, *endpos, *oldstr, *newstr, *newval, *tempport, *proxy_config; + char *startpos, *endpos, *newstr, *newval, tempport[6], *proxy_config, + savechar; + size_t len; int tmp; g_return_val_if_fail (request != NULL, NULL); g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, NULL); - newstr = g_malloc (1); - *newstr = '\0'; gftp_lookup_request_option (request, "proxy_config", &proxy_config); + + newstr = g_malloc0 (1); + len = 0; startpos = endpos = proxy_config; while (*endpos != '\0') { - tempport = NULL; if (*endpos == '%' && tolower ((int) *(endpos + 1)) == 'p') { switch (tolower ((int) *(endpos + 2))) @@ -211,7 +206,7 @@ break; case 'o': gftp_lookup_request_option (request, "ftp_proxy_port", &tmp); - tempport = g_strdup_printf ("%d", tmp); + g_snprintf (tempport, sizeof (tempport), "%d", tmp); newval = tempport; break; case 'a': @@ -236,7 +231,7 @@ newval = request->hostname; break; case 'o': - tempport = g_strdup_printf ("%d", request->port); + g_snprintf (tempport, sizeof (tempport), "%d", request->port); newval = tempport; break; case 'a': @@ -249,10 +244,15 @@ } else if (*endpos == '%' && tolower ((int) *(endpos + 1)) == 'n') { - *endpos = '\0'; - oldstr = newstr; - newstr = g_strconcat (oldstr, startpos, "\r\n", NULL); - g_free (oldstr); + savechar = *endpos; + *endpos = '\0'; + + len += strlen (startpos) + 2; + newstr = g_realloc (newstr, sizeof (char) * (len + 1)); + strcat (newstr, startpos); + strcat (newstr, "\r\n"); + + *endpos = savechar; endpos += 2; startpos = endpos; continue; @@ -263,21 +263,27 @@ continue; } + savechar = *endpos; *endpos = '\0'; - oldstr = newstr; + len += strlen (startpos); if (!newval) - newstr = g_strconcat (oldstr, startpos, NULL); + { + newstr = g_realloc (newstr, sizeof (char) * (len + 1)); + strcat (newstr, startpos); + } else - newstr = g_strconcat (oldstr, startpos, newval, NULL); - if (tempport) - { - g_free (tempport); - tempport = NULL; - } - g_free (oldstr); + { + len += strlen (newval); + newstr = g_realloc (newstr, sizeof (char) * (len + 1)); + strcat (newstr, startpos); + strcat (newstr, newval); + } + + *endpos = savechar; endpos += 3; startpos = endpos; } + return (newstr); }