Mercurial > gftp.yaz
changeset 532:bccfdbfaac00
2004-8-17 Brian Masney <masneyb@gftp.org>
* lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c -
added #defines for encoding and decoding file sizes that will work
properly for large files (GFTP_OFF_T_HEX_PRINTF_MOD,
GFTP_OFF_T_INTL_PRINTF_MOD, GFTP_OFF_T_PRINTF_MOD,
GFTP_OFF_T_11PRINTF_MOD and gftp_parse_file_size). Fixed file size
not being displayed properly when the system does not support the '
printf formatter
* acinclude.m4 (AC_INTL_PRINTF) - check to see if _LARGEFILE_SOURCE
is defined. If so, use %'lld instead of %'ld
author | masneyb |
---|---|
date | Wed, 18 Aug 2004 01:58:43 +0000 |
parents | 65cd664cbf32 |
children | 0f43d84c7f7c |
files | ChangeLog acinclude.m4 lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c |
diffstat | 7 files changed, 41 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Aug 18 00:56:58 2004 +0000 +++ b/ChangeLog Wed Aug 18 01:58:43 2004 +0000 @@ -1,4 +1,15 @@ 2004-8-17 Brian Masney <masneyb@gftp.org> + * lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c - + added #defines for encoding and decoding file sizes that will work + properly for large files (GFTP_OFF_T_HEX_PRINTF_MOD, + GFTP_OFF_T_INTL_PRINTF_MOD, GFTP_OFF_T_PRINTF_MOD, + GFTP_OFF_T_11PRINTF_MOD and gftp_parse_file_size). Fixed file size + not being displayed properly when the system does not support the ' + printf formatter + + * acinclude.m4 (AC_INTL_PRINTF) - check to see if _LARGEFILE_SOURCE + is defined. If so, use %'lld instead of %'ld + * lib/rfc959.c lib/sshv2.c - removed unneeded code in the *_chmod() functions @@ -2730,7 +2741,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.305 2004/08/18 00:56:58 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.306 2004/08/18 01:58:43 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/acinclude.m4 Wed Aug 18 00:56:58 2004 +0000 +++ b/acinclude.m4 Wed Aug 18 01:58:43 2004 +0000 @@ -28,7 +28,11 @@ int main(void) { char buf[20]; +#if defined (_LARGEFILE_SOURCE) + sprintf (buf, "%'lld", (long) 1); +#else sprintf (buf, "%'ld", (long) 1); +#endif if (strchr (buf, '1') == NULL) return (1); return (0);
--- a/lib/gftp.h Wed Aug 18 00:56:58 2004 +0000 +++ b/lib/gftp.h Wed Aug 18 01:58:43 2004 +0000 @@ -158,9 +158,17 @@ #endif #if defined (_LARGEFILE_SOURCE) -#define GFTP_OFF_T_PRINTF_MOD "%'lld" +#define GFTP_OFF_T_HEX_PRINTF_MOD "%llx" +#define GFTP_OFF_T_INTL_PRINTF_MOD "%'lld" +#define GFTP_OFF_T_PRINTF_MOD "%lld" +#define GFTP_OFF_T_11PRINTF_MOD "%11lld" +#define gftp_parse_file_size(str) strtoll (str, NULL, 10) #else -#define GFTP_OFF_T_PRINTF_MOD "%'ld" +#define GFTP_OFF_T_HEX_PRINTF_MOD "%lx" +#define GFTP_OFF_T_INTL_PRINTF_MOD "%'ld" +#define GFTP_OFF_T_PRINTF_MOD "%ld" +#define GFTP_OFF_T_11PRINTF_MOD "%11ld" +#define gftp_parse_file_size(str) strtol (str, NULL, 10) #endif /* Server types (used by FTP protocol from SYST command) */ @@ -763,8 +771,6 @@ char * gftp_build_path ( const char *first_element, ... ); -off_t gftp_parse_file_size ( char *str ); - void gftp_locale_init ( void ); char * gftp_scramble_password ( const char *password );
--- a/lib/misc.c Wed Aug 18 00:56:58 2004 +0000 +++ b/lib/misc.c Wed Aug 18 01:58:43 2004 +0000 @@ -27,9 +27,9 @@ insert_commas (off_t number, char *dest_str, size_t dest_len) { if (dest_str != NULL) - g_snprintf (dest_str, dest_len, GFTP_OFF_T_PRINTF_MOD, number); + g_snprintf (dest_str, dest_len, GFTP_OFF_T_INTL_PRINTF_MOD, number); else - dest_str = g_strdup_printf (GFTP_OFF_T_PRINTF_MOD, number); + dest_str = g_strdup_printf (GFTP_OFF_T_INTL_PRINTF_MOD, number); return (dest_str); } @@ -871,13 +871,7 @@ if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode)) tempstr2 = g_strdup_printf ("%d, %d", major (fle->size), minor (fle->size)); else - { -#if defined (_LARGEFILE_SOURCE) - tempstr2 = g_strdup_printf ("%11lld", fle->size); -#else - tempstr2 = g_strdup_printf ("%11ld", fle->size); -#endif - } + tempstr2 = g_strdup_printf (GFTP_OFF_T_11PRINTF_MOD, fle->size); time (&t); @@ -1176,17 +1170,6 @@ } -off_t -gftp_parse_file_size (char *str) -{ -#if defined (_LARGEFILE_SOURCE) - return (strtoll (str, NULL, 10)); -#else - return (strtol (str, NULL, 10)); -#endif -} - - void gftp_locale_init (void) {
--- a/lib/protocols.c Wed Aug 18 00:56:58 2004 +0000 +++ b/lib/protocols.c Wed Aug 18 01:58:43 2004 +0000 @@ -2318,17 +2318,10 @@ tempfle = templist->data; attribs = gftp_convert_attributes_from_mode_t (tempfle->st_mode); -#if defined (_LARGEFILE_SOURCE) - printf ("%s:%s:%lld:%lld:%s:%s:%s\n", + printf ("%s:%s:" GFTP_OFF_T_PRINTF_MOD ":" GFTP_OFF_T_PRINTF_MOD ":%s:%s:%s\n", tempfle->file, tempfle->destfile, tempfle->size, tempfle->startsize, tempfle->user, tempfle->group, attribs); -#else - printf ("%s:%s:%ld:%ld:%s:%s:%s\n", - tempfle->file, tempfle->destfile, - tempfle->size, tempfle->startsize, - tempfle->user, tempfle->group, attribs); -#endif g_free (attribs); if (templist->next == NULL) @@ -2341,17 +2334,10 @@ tempfle = templist->data; attribs = gftp_convert_attributes_from_mode_t (tempfle->st_mode); -#if defined (_LARGEFILE_SOURCE) - printf ("%s:%s:%lld:%lld:%s:%s:%s\n", + printf ("%s:%s:" GFTP_OFF_T_PRINTF_MOD ":" GFTP_OFF_T_PRINTF_MOD ":%s:%s:%s\n", tempfle->file, tempfle->destfile, tempfle->size, tempfle->startsize, tempfle->user, tempfle->group, attribs); -#else - printf ("%s:%s:%ld:%ld:%s:%s:%s\n", - tempfle->file, tempfle->destfile, - tempfle->size, tempfle->startsize, - tempfle->user, tempfle->group, attribs); -#endif g_free (attribs); if (templist == list)
--- a/lib/rfc2068.c Wed Aug 18 00:56:58 2004 +0000 +++ b/lib/rfc2068.c Wed Aug 18 01:58:43 2004 +0000 @@ -144,13 +144,7 @@ sizeof (tempstr), request->datafd)) < 0) return (ret); -#ifdef _LARGEFILE_SOURCE - ret = sscanf (tempstr, "%llx", ¶ms->chunk_size); -#else - ret = sscanf (tempstr, "%lx", ¶ms->chunk_size); -#endif - - if (ret != 1) + if (sscanf (tempstr, GFTP_OFF_T_HEX_PRINTF_MOD, ¶ms->chunk_size) != 1) { request->logging_function (gftp_logging_recv, request, _("Received wrong response from server, disconnecting\nInvalid chunk size '%s' returned by the remote server\n"), @@ -305,23 +299,14 @@ if (use_http11 && startsize > 0) { -#if defined (_LARGEFILE_SOURCE) request->logging_function (gftp_logging_misc, request, - _("Starting the file transfer at offset %lld\n"), + _("Starting the file transfer at offset " GFTP_OFF_T_PRINTF_MOD "\n"), startsize); oldstr = tempstr; - tempstr = g_strdup_printf ("%sRange: bytes=%lld-\n", tempstr, startsize); + tempstr = g_strdup_printf ("%sRange: bytes=" GFTP_OFF_T_PRINTF_MOD "-\n", + tempstr, startsize); g_free (oldstr); -#else - request->logging_function (gftp_logging_misc, request, - _("Starting the file transfer at offset %ld\n"), - startsize); - - oldstr = tempstr; - tempstr = g_strdup_printf ("%sRange: bytes=%ld-\n", tempstr, startsize); - g_free (oldstr); -#endif } size = rfc2068_send_command (request, tempstr, strlen (tempstr)); @@ -852,13 +837,8 @@ *crlfpos = '\0'; crlfpos++; /* advance to line feed */ -#ifdef _LARGEFILE_SOURCE - ret = sscanf (stpos + 2, "%llx", ¶ms->chunk_size); -#else - ret = sscanf (stpos + 2, "%lx", ¶ms->chunk_size); -#endif - - if (ret != 1) + if (sscanf (stpos + 2, GFTP_OFF_T_HEX_PRINTF_MOD, + ¶ms->chunk_size) != 1) { request->logging_function (gftp_logging_recv, request, _("Received wrong response from server, disconnecting\nInvalid chunk size '%s' returned by the remote server\n"),
--- a/lib/rfc959.c Wed Aug 18 00:56:58 2004 +0000 +++ b/lib/rfc959.c Wed Aug 18 01:58:43 2004 +0000 @@ -1079,11 +1079,8 @@ if (startsize > 0) { -#if defined (_LARGEFILE_SOURCE) - command = g_strdup_printf ("REST %lld\r\n", startsize); -#else - command = g_strdup_printf ("REST %ld\r\n", startsize); -#endif + command = g_strdup_printf ("REST " GFTP_OFF_T_PRINTF_MOD "\r\n", + startsize); ret = rfc959_send_command (request, command, 1); g_free (command); @@ -1157,11 +1154,8 @@ if (startsize > 0) { -#if defined (_LARGEFILE_SOURCE) - command = g_strdup_printf ("REST %lld\r\n", startsize); -#else - command = g_strdup_printf ("REST %ld\r\n", startsize); -#endif + command = g_strdup_printf ("REST " GFTP_OFF_T_PRINTF_MOD "\r\n", + startsize); ret = rfc959_send_command (request, command, 1); g_free (command); if (ret < 0)