comparison lib/misc.c @ 460:075f89b4395c

2004-4-14 Brian Masney <masneyb@gftp.org> * lib/sshv2.c lib/gftp.h src/text/textui.c src/gtk/gtkui.c - when connecting with the SSH protocol, if the user is asked a question, relay that question back to the user and allow them to answer it. * doc/gftp-faq.sgml - moved the SSH troubleshooting section to the issues for older releases section. All of the issues that this talks about have been fixed in CVS. * src/gtk/gftp-gtk.c (main) - call gdk_threads_init() on startup * lib/cache.c lib/config_file.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c - removed some uses of strlen() so that they only occur once on a string instead of multiple times in some cases * lib/sslcommon.c - fixed typo * configure.in lib/gftp.h - added configure check for inttypes.h * docs/gftp.lsm - updated with 2.0.17 information
author masneyb
date Thu, 15 Apr 2004 00:59:23 +0000
parents 83cfffb2878a
children 4376ffeab64e
comparison
equal deleted inserted replaced
459:b4abf70c6425 460:075f89b4395c
51 51
52 char * 52 char *
53 insert_commas (off_t number, char *dest_str, size_t dest_len) 53 insert_commas (off_t number, char *dest_str, size_t dest_len)
54 { 54 {
55 char *frompos, *topos, src[50], *dest; 55 char *frompos, *topos, src[50], *dest;
56 int len, num, rem, i; 56 size_t num, rem, srclen;
57 int len, i;
57 58
58 #if defined (_LARGEFILE_SOURCE) 59 #if defined (_LARGEFILE_SOURCE)
59 g_snprintf (src, sizeof (src), "%lld", (long long) number); 60 g_snprintf (src, sizeof (src), "%lld", (long long) number);
60 #else 61 #else
61 g_snprintf (src, sizeof (src), "%ld", number); 62 g_snprintf (src, sizeof (src), "%ld", number);
91 if (dest_str == NULL) 92 if (dest_str == NULL)
92 dest = g_malloc0 (len); 93 dest = g_malloc0 (len);
93 else 94 else
94 dest = dest_str; 95 dest = dest_str;
95 96
96 num = strlen (src) / 3 - 1; 97 srclen = strlen (src);
97 rem = strlen (src) % 3; 98 num = srclen / 3 - 1;
99 rem = srclen % 3;
100
98 frompos = src; 101 frompos = src;
99 topos = dest; 102 topos = dest;
100 for (i = 0; i < rem; i++) 103 for (i = 0; i < rem; i++)
101 *topos++ = *frompos++; 104 *topos++ = *frompos++;
102 105
1016 1019
1017 /* The standard to Base64 encoding can be found in RFC2045 */ 1020 /* The standard to Base64 encoding can be found in RFC2045 */
1018 1021
1019 char *newstr, *newpos, *fillpos, *pos; 1022 char *newstr, *newpos, *fillpos, *pos;
1020 unsigned char table[64], encode[3]; 1023 unsigned char table[64], encode[3];
1021 int i, num; 1024 size_t slen, num;
1025 int i;
1022 1026
1023 for (i = 0; i < 26; i++) 1027 for (i = 0; i < 26; i++)
1024 { 1028 {
1025 table[i] = 'A' + i; 1029 table[i] = 'A' + i;
1026 table[i + 26] = 'a' + i; 1030 table[i + 26] = 'a' + i;
1030 table[i + 52] = '0' + i; 1034 table[i + 52] = '0' + i;
1031 1035
1032 table[62] = '+'; 1036 table[62] = '+';
1033 table[63] = '/'; 1037 table[63] = '/';
1034 1038
1035 num = strlen (str) / 3; 1039 slen = strlen (str);
1036 if (strlen (str) % 3 > 0) 1040 num = slen / 3;
1041 if (slen % 3 > 0)
1037 num++; 1042 num++;
1043
1038 newstr = g_malloc (num * 4 + 1); 1044 newstr = g_malloc (num * 4 + 1);
1039 newstr[num * 4] = '\0'; 1045 newstr[num * 4] = '\0';
1040 newpos = newstr; 1046 newpos = newstr;
1041 1047
1042 pos = str; 1048 pos = str;
1264 char *newstr, *newpos; 1270 char *newstr, *newpos;
1265 1271
1266 if (strcmp (password, "@EMAIL@") == 0) 1272 if (strcmp (password, "@EMAIL@") == 0)
1267 return (g_strdup (password)); 1273 return (g_strdup (password));
1268 1274
1269 newstr = g_malloc (strlen(password) * 2 + 2); 1275 newstr = g_malloc (strlen (password) * 2 + 2);
1270 newpos = newstr; 1276 newpos = newstr;
1271 1277
1272 *newpos++ = '$'; 1278 *newpos++ = '$';
1273 1279
1274 while (*password != 0) 1280 while (*password != 0)