# HG changeset patch # User masneyb # Date 1075775277 0 # Node ID 2f5ce7fb5aadcfc4e2d0b3879c26ac8a298a5d22 # Parent 16497a84c34b2a5936c3a96da82bf5332cdc7b8d 2003-2-2 Brian Masney * lib/config_file.c lib/gftp.h src/uicommon/gftpui.c src/gtk/gftp-gtk.c - updated the format of the config file write_functions so that the value isn't written to a file descriptor. Instead, it is written to a buffer. * src/text/gftp-text.c (gftp_text_log) - search for newlines in the string and split on those characters first * src/text/textui.c (gftpui_disconnect) - disconnect from the host * src/uicommon/gftpui.c - removed calls to printf() functions. Instead print the values out using the logging function * src/uicommon/gftpuicallbacks.c (gftpui_common_run_ls) - if we are connected to a local site, lookup the options local_sortasds and local_sortcol. Otherwise, lookup remove_sortasds and remote_sortcol. * autogen.sh - disable maintainer mode * TODO - updated diff -r 16497a84c34b -r 2f5ce7fb5aad ChangeLog --- a/ChangeLog Mon Feb 02 18:54:43 2004 +0000 +++ b/ChangeLog Tue Feb 03 02:27:57 2004 +0000 @@ -1,3 +1,25 @@ +2003-2-2 Brian Masney + * lib/config_file.c lib/gftp.h src/uicommon/gftpui.c + src/gtk/gftp-gtk.c - updated the format of the config file + write_functions so that the value isn't written to a file descriptor. + Instead, it is written to a buffer. + + * src/text/gftp-text.c (gftp_text_log) - search for newlines in the + string and split on those characters first + + * src/text/textui.c (gftpui_disconnect) - disconnect from the host + + * src/uicommon/gftpui.c - removed calls to printf() functions. Instead + print the values out using the logging function + + * src/uicommon/gftpuicallbacks.c (gftpui_common_run_ls) - if we are + connected to a local site, lookup the options local_sortasds and + local_sortcol. Otherwise, lookup remove_sortasds and remote_sortcol. + + * autogen.sh - disable maintainer mode + + * TODO - updated + 2004-02-01 Alastair McKinstry * configure.in: Add Irish ("ga") to ALL_LINGUAS @@ -2124,7 +2146,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.213 2004/02/02 09:04:01 alastairmck Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.214 2004/02/03 02:27:55 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 16497a84c34b -r 2f5ce7fb5aad TODO --- a/TODO Mon Feb 02 18:54:43 2004 +0000 +++ b/TODO Tue Feb 03 02:27:57 2004 +0000 @@ -2,24 +2,22 @@ of gFTP. If there is something you feel should be included in a future version of gFTP, please email me about it. +* FXP transfers segfault +* Does not work with rssh, need to improve the SSH login sequence +* Be able to paste a URL in the host box in the GUI + +* If the IPV6 connection fails, automatically try a IPV4 connection. * I need to be able to send an event from the core library to the presentation layer to have it ask the user a question. I need this for the SSL layer so that if an unknown certificate authority signed the certificate, the user can be prompted whether or not to accept it. Also, it would be handy to prompt the user for their password if a bad password was entered. -* Text Port - resume transfers, add --mirror option, --continue option - and --background options to the command line. -* DND - be able to resume transfers * HTTP - keepalive * Support tabbed interface in GTK+ port * Parallel chdir in GTK+ port * GTK 2.0 port - make 2 buttons in toolbar be the same size as the gnome 2 icons -* Add option to hide certain files * Be able to save the state of the transfer queue. Be able to pause transfers. -* For bookmarks, be able to specify a local protocol, host, port, directory - to connect to -* Show status information in title bar * -d command line, check if it's a file first, if so download. If not, grab directory * Add option for @dynamic@ for bookmarks' account * Playing sounds after certain events or calling external program diff -r 16497a84c34b -r 2f5ce7fb5aad autogen.sh --- a/autogen.sh Mon Feb 02 18:54:43 2004 +0000 +++ b/autogen.sh Tue Feb 03 02:27:57 2004 +0000 @@ -110,7 +110,7 @@ cd $ORIGDIR if test -z "$AUTOGEN_SUBDIR_MODE"; then - CFLAGS="-Wall -ansi -D_GNU_SOURCE -O -g" $srcdir/configure --enable-maintainer-mode "$@" + CFLAGS="-Wall -ansi -D_GNU_SOURCE -O -g" $srcdir/configure "$@" echo echo "Now type 'make' to compile $PROJECT." diff -r 16497a84c34b -r 2f5ce7fb5aad lib/config_file.c --- a/lib/config_file.c Mon Feb 02 18:54:43 2004 +0000 +++ b/lib/config_file.c Tue Feb 03 02:27:57 2004 +0000 @@ -717,8 +717,8 @@ void gftp_write_bookmarks_file (void) { + char *bmhdr, *pwhdr, *tempstr, *password, buf[256]; gftp_bookmarks_var * tempentry; - char *bmhdr, *pwhdr, *tempstr, *password; FILE * bmfile; int i; @@ -781,9 +781,10 @@ { for (i=0; inum_local_options_vars; i++) { - fprintf (bmfile, "%s=", tempentry->local_options_vars[i].key); - gftp_option_types[tempentry->local_options_vars[i].otype].write_function (&tempentry->local_options_vars[i], bmfile, 1); - fprintf (bmfile, "\n"); + gftp_option_types[tempentry->local_options_vars[i].otype].write_function (&tempentry->local_options_vars[i], buf, sizeof (buf), 1); + + fprintf (bmfile, "%s=%s\n", tempentry->local_options_vars[i].key, + buf); } } @@ -807,10 +808,10 @@ void gftp_write_config_file (void) { + char *tempstr, buf[256]; gftp_config_vars * cv; GList *templist; FILE *conffile; - char *tempstr; int i; if ((tempstr = expand_path (CONFIG_FILE)) == NULL) @@ -846,9 +847,9 @@ if (cv[i].comment != NULL) write_comment (conffile, _(cv[i].comment)); - fprintf (conffile, "%s=", cv[i].key); - gftp_option_types[cv[i].otype].write_function (&cv[i], conffile, 1); - fprintf (conffile, "\n"); + gftp_option_types[cv[i].otype].write_function (&cv[i], buf, + sizeof (buf), 1); + fprintf (conffile, "%s=%s\n", cv[i].key, buf); } } @@ -949,15 +950,15 @@ static int -gftp_config_file_write_text (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_text (gftp_config_vars * cv, char *buf, size_t buflen, + int to_config_file) { char *outstr; if (cv->value != NULL) { outstr = cv->value; - if (*outstr != '\0') - fprintf (fd, "%s", outstr); + g_snprintf (buf, buflen, "%s", outstr); return (0); } else @@ -966,7 +967,8 @@ static int -gftp_config_file_write_hidetext (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_hidetext (gftp_config_vars * cv, char *buf, + size_t buflen, int to_config_file) { char *outstr; @@ -976,9 +978,9 @@ if (*outstr != '\0') { if (to_config_file) - fprintf (fd, "%s", outstr); + g_snprintf (buf, buflen, "%s", outstr); else - fprintf (fd, "*****"); + g_snprintf (buf, buflen, "*****"); } return (0); } @@ -1037,9 +1039,10 @@ static int -gftp_config_file_write_int (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_int (gftp_config_vars * cv, char *buf, size_t buflen, + int to_config_file) { - fprintf (fd, "%d", GPOINTER_TO_INT(cv->value)); + g_snprintf (buf, buflen, "%d", GPOINTER_TO_INT (cv->value)); return (0); } @@ -1071,12 +1074,13 @@ static int -gftp_config_file_write_float (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_float (gftp_config_vars * cv, char *buf, size_t buflen, + int to_config_file) { float f; memcpy (&f, &cv->value, sizeof (f)); - fprintf (fd, "%.2f", f); + g_snprintf (buf, buflen, "%.2f", f); return (0); } @@ -1119,12 +1123,13 @@ static int -gftp_config_file_write_color (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_color (gftp_config_vars * cv, char *buf, size_t buflen, + int to_config_file) { gftp_color * color; color = cv->value; - fprintf (fd, "%x:%x:%x", color->red, color->green, color->blue); + g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue); return (0); } @@ -1179,15 +1184,16 @@ static int -gftp_config_file_write_intcombo (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_config_file_write_intcombo (gftp_config_vars * cv, char *buf, + size_t buflen, int to_config_file) { char **clist; clist = cv->listdata; if (clist != NULL) - fprintf (fd, "%s", clist[GPOINTER_TO_INT(cv->value)]); + g_snprintf (buf, buflen, "%s", clist[GPOINTER_TO_INT(cv->value)]); else - fprintf (fd, _("")); + g_snprintf (buf, buflen, _("")); return (0); } diff -r 16497a84c34b -r 2f5ce7fb5aad lib/gftp.h --- a/lib/gftp.h Mon Feb 02 18:54:43 2004 +0000 +++ b/lib/gftp.h Tue Feb 03 02:27:57 2004 +0000 @@ -293,7 +293,8 @@ typedef struct gftp_option_type_tag { int (*read_function) (char *str, gftp_config_vars * cv, int line); - int (*write_function) (gftp_config_vars * cv, FILE * fd, int to_config_file); + int (*write_function) (gftp_config_vars * cv, char *buf, size_t buflen, + int to_config_file); void (*copy_function) (gftp_config_vars * cv, gftp_config_vars * dest_cv); int (*compare_function) (gftp_config_vars * cv1, gftp_config_vars * cv2); void *(*ui_print_function) (gftp_config_vars * cv, void *user_data, void *value); diff -r 16497a84c34b -r 2f5ce7fb5aad src/gtk/gftp-gtk.c --- a/src/gtk/gftp-gtk.c Mon Feb 02 18:54:43 2004 +0000 +++ b/src/gtk/gftp-gtk.c Tue Feb 03 02:27:57 2004 +0000 @@ -1189,12 +1189,13 @@ static int -gftp_gtk_config_file_write_color (gftp_config_vars * cv, FILE * fd, int to_config_file) +gftp_gtk_config_file_write_color (gftp_config_vars * cv, char *buf, + size_t buflen, int to_config_file) { GdkColor * color; color = cv->value; - fprintf (fd, "%x:%x:%x", color->red, color->green, color->blue); + g_snprintf (buf, buflen, "%x:%x:%x", color->red, color->green, color->blue); return (0); } diff -r 16497a84c34b -r 2f5ce7fb5aad src/text/gftp-text.c --- a/src/text/gftp-text.c Mon Feb 02 18:54:43 2004 +0000 +++ b/src/text/gftp-text.c Tue Feb 03 02:27:57 2004 +0000 @@ -38,13 +38,57 @@ } +static void +gftp_text_write_string (char *string) +{ + char *stpos, *endpos, savechar; + int sw; + + sw = gftp_text_get_win_size (); + + stpos = string; + do + { + if ((endpos = strchr (stpos, '\n')) == NULL) + endpos = stpos + strlen (stpos); + + savechar = *endpos; + *endpos = '\0'; + + if (strlen (stpos) <= sw) + { + printf ("%s%c", stpos, savechar); + *endpos = savechar; + if (savechar == '\0') + break; + stpos = endpos + 1; + } + else + { + *endpos = savechar; + for (endpos = stpos + sw - 1; + *endpos != ' ' && endpos > stpos; + endpos--); + + if (endpos != stpos) + *endpos = '\0'; + + printf ("%s\n", stpos); + stpos = endpos + 1; + } + + sw = sw; + } + while (stpos != endpos); +} + + void gftp_text_log (gftp_logging_level level, gftp_request * request, const char *string, ...) { - char tempstr[512], *stpos, *endpos, *utf8_str = NULL, *outstr; + char tempstr[512], *utf8_str = NULL, *outstr; va_list argp; - int sw; g_return_if_fail (string != NULL); @@ -90,25 +134,10 @@ fflush (gftp_logfd); } - sw = gftp_text_get_win_size (); - stpos = outstr; - endpos = outstr + 1; - do - { - if (strlen (stpos) <= sw) - { - printf ("%s", stpos); - break; - } - for (endpos = stpos + sw - 1; *endpos != ' ' && endpos > stpos; endpos--); - if (endpos != stpos) - { - *endpos = '\0'; - } - printf ("%s\n", stpos); - stpos = endpos + 1; - } - while (stpos != endpos); + if (level == gftp_logging_misc_nolog) + printf ("%s\n", outstr); + else + gftp_text_write_string (outstr); printf ("%s", GFTPUI_COMMON_COLOR_DEFAULT); diff -r 16497a84c34b -r 2f5ce7fb5aad src/text/textui.c --- a/src/text/textui.c Mon Feb 02 18:54:43 2004 +0000 +++ b/src/text/textui.c Tue Feb 03 02:27:57 2004 +0000 @@ -238,5 +238,9 @@ void gftpui_disconnect (void *uidata) { + gftp_request * request; + + request = uidata; /* Note: uidata is set to the request in gftp_text.c */ + gftp_disconnect (request); } diff -r 16497a84c34b -r 2f5ce7fb5aad src/uicommon/gftpui.c --- a/src/uicommon/gftpui.c Mon Feb 02 18:54:43 2004 +0000 +++ b/src/uicommon/gftpui.c Tue Feb 03 02:27:57 2004 +0000 @@ -606,9 +606,7 @@ intptr_t retries; if (GFTP_IS_CONNECTED (request)) - { - gftp_disconnect (request); /* FIXME */ - } + gftpui_disconnect (uidata); if (command != NULL) { @@ -655,8 +653,8 @@ void *other_uidata, gftp_request * other_request, const char *command) { + char *pos, *backpos, buf[256]; gftp_config_vars * cv, newcv; - char *pos, *backpos; GList * templist; int i; @@ -677,9 +675,11 @@ gftp_option_types[cv[i].otype].write_function == NULL) continue; - printf ("%s = ", cv[i].key); - gftp_option_types[cv[i].otype].write_function (&cv[i], stdout, 0); - printf ("\n"); + gftp_option_types[cv[i].otype].write_function (&cv[i], buf, + sizeof (buf), 0); + + gftpui_common_logfunc (gftp_logging_misc_nolog, request, + "%s = %s\n", cv[i].key, buf); } } } @@ -722,6 +722,12 @@ gftp_set_global_option (command, newcv.value); + gftp_option_types[newcv.otype].write_function (&newcv, buf, + sizeof (buf), 0); + + gftpui_common_logfunc (gftp_logging_misc_nolog, request, + "%s = %s\n", newcv.key, buf); + if (newcv.flags & GFTP_CVARS_FLAGS_DYNMEM) g_free (newcv.value); } @@ -738,6 +744,7 @@ { int i, j, ele, numrows, numcols = 6, handled, number_commands, cmdlen, found; + char commands[128], cmdstr[30]; const char *pos; for (number_commands=0; @@ -766,7 +773,8 @@ handled = 0; if (!handled) - printf ("%s\n", _(gftpui_common_commands[i].cmd_description)); + gftpui_common_logfunc (gftp_logging_misc_nolog, request, "%s\n", + _(gftpui_common_commands[i].cmd_description)); } else found = 0; @@ -780,21 +788,26 @@ if (number_commands % numcols != 0) numrows++; - printf (_("Supported commands:\n\n")); + gftpui_common_logfunc (gftp_logging_misc_nolog, request, + _("Supported commands:\n\n")); + for (i=0; i= number_commands) break; - printf ("%-10s", gftpui_common_commands[ele].command); + + g_snprintf (cmdstr, sizeof (cmdstr), "%-10s", + gftpui_common_commands[ele].command); + strncat (commands, cmdstr, sizeof (commands)); } - printf ("\n"); + gftpui_common_logfunc (gftp_logging_misc_nolog, request, "%s\n", + commands); } - - printf ("\n"); } return (1); } @@ -1052,7 +1065,7 @@ ret = gftpui_common_commands[i].func (uidata, request, other_uidata, other_request, pos); - if (!GFTP_IS_CONNECTED (request)) + if (request != NULL && !GFTP_IS_CONNECTED (request)) gftpui_disconnect (uidata); } else @@ -1443,6 +1456,6 @@ } tdata->done = 1; - return (1); /* FIXME */ + return (1); } diff -r 16497a84c34b -r 2f5ce7fb5aad src/uicommon/gftpuicallbacks.c --- a/src/uicommon/gftpuicallbacks.c Mon Feb 02 18:54:43 2004 +0000 +++ b/src/uicommon/gftpuicallbacks.c Tue Feb 03 02:27:57 2004 +0000 @@ -62,6 +62,7 @@ gftpui_common_run_ls (gftpui_callback_data * cdata) { int got, matched_filespec, have_dotdot; + char *sortcol_var, *sortasds_var; intptr_t sortcol, sortasds; gftp_file * fle; @@ -112,8 +113,19 @@ if (cdata->files != NULL) { - gftp_lookup_global_option ("local_sortcol", &sortcol); /* FIXME */ - gftp_lookup_global_option ("local_sortasds", &sortasds); + if (cdata->request->protonum == GFTP_LOCAL_NUM) + { + sortasds_var = "local_sortasds"; + sortcol_var = "local_sortcol"; + } + else + { + sortasds_var = "remote_sortasds"; + sortcol_var = "remote_sortcol"; + } + + gftp_lookup_global_option (sortcol_var, &sortcol); + gftp_lookup_global_option (sortasds_var, &sortasds); cdata->files = gftp_sort_filelist (cdata->files, sortcol, sortasds); }