Mercurial > gftp.yaz
diff lib/config_file.c @ 125:b875de05c22d
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
* lib/config_file.c lib/gftp.h lib/options.h - added config
variable type textcombo. default_protocol uses this
* lib/config_file.c (gftp_read_config_file) - when reading in the
list of supported protocols, add the protocol names to the list
associated with default_protocol. Also, don't try to have
default_protocol fall back to FTP. The code that uses this will fall
back properly
* lib/gftp.h (struct gftp_transfer) - renamed node to user_data
* lib/misc.c lib/gftp.h - moved parse_attribs() from
src/gtk/transfer.c to misc.c. Renamed to gftp_parse_attribs()
* lib/protocols.c lib/gftp.h - moved get_status() from
src/gtk/transfer.c to protocols.c. Renamed to
gftp_get_transfer_status(). Uses GMutex functions
author | masneyb |
---|---|
date | Tue, 08 Apr 2003 22:28:17 +0000 |
parents | 65048c959029 |
children | 1e65871fdfa1 |
line wrap: on
line diff
--- a/lib/config_file.c Tue Apr 08 01:43:33 2003 +0000 +++ b/lib/config_file.c Tue Apr 08 22:28:17 2003 +0000 @@ -452,6 +452,7 @@ char *tempstr, *temp1str, *curpos, buf[255]; gftp_config_list_vars * tmplistvar; gftp_config_vars * tmpconfigvar; + char **protocol_list; FILE *conffile; int line, i; size_t len; @@ -461,12 +462,24 @@ gftp_register_config_vars (gftp_global_config_vars); + protocol_list = NULL; for (i=0; gftp_protocols[i].register_options != NULL; i++) { + if (gftp_protocols[i].shown) + { + protocol_list = g_realloc (protocol_list, sizeof (char *) * (i + 2)); + protocol_list[i] = gftp_protocols[i].name; + protocol_list[i + 1] = NULL; + } + if (gftp_protocols[i].register_options != NULL) gftp_protocols[i].register_options (); } + if ((tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable, + "default_protocol")) != NULL) + tmpconfigvar->listdata = protocol_list; + gftp_config_list_htable = g_hash_table_new (string_hash_function, string_hash_compare); @@ -560,26 +573,6 @@ } } -/* FIXME - gftp_lookup_global_option ("default_protocol", &tempstr); - if (tempstr == NULL || *tempstr == '\0') - { - tempstr = "FTP"; - gftp_set_global_option ("default_protocol", tempstr); - } - - for (i = 0; gftp_protocols[i].name; i++) - { - if (strcmp (gftp_protocols[i].name, tempstr) == 0) - break; - } - - if (gftp_protocols[i].name == NULL) - { - printf (_("gFTP Error: Default protocol %s is not a valid protocol\n"), tempstr); - exit (1); - } -*/ if ((tempstr = expand_path (LOG_FILE)) == NULL) { printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE); @@ -962,7 +955,7 @@ clist = cv->listdata; for (i=0; clist[i] != NULL; i++) { - if (strcasecmp (_(clist[i]), str) == 0) + if (strcasecmp (clist[i], str) == 0) { cv->value = GINT_TO_POINTER(i); break; @@ -981,7 +974,7 @@ clist = cv->listdata; if (clist != NULL) - fprintf (fd, "%s", _(clist[GPOINTER_TO_INT(cv->value)])); + fprintf (fd, "%s", clist[GPOINTER_TO_INT(cv->value)]); else fprintf (fd, _("<unknown>")); @@ -989,7 +982,31 @@ } -/* *Note, the index numbers of this array must match up to the numbers in +static int +gftp_config_file_read_textcombo (char *str, gftp_config_vars * cv, int line) +{ + char **clist; + int i; + + cv->value = NULL; + if (cv->listdata != NULL) + { + clist = cv->listdata; + for (i=0; clist[i] != NULL; i++) + { + if (strcasecmp (clist[i], str) == 0) + { + cv->value = clist[i]; + break; + } + } + } + + return (0); +} + + +/* Note, the index numbers of this array must match up to the numbers in 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}, @@ -1004,7 +1021,7 @@ {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}, - {NULL, NULL, NULL, NULL}, + {gftp_config_file_read_textcombo, gftp_config_file_write_text, NULL, NULL}, {NULL, NULL, NULL, NULL} };