comparison lib/sshv2.c @ 843:32dbed7e0dc4

2006-11-2 Brian Masney <masneyb@gftp.org> * lib/local.c lib/misc.c lib/sshv2.c - more improvements to make sure that the filename is encoded in the proper character set.
author masneyb
date Fri, 03 Nov 2006 02:35:47 +0000
parents dd83cd01dc30
children 8263cc35c027
comparison
equal deleted inserted replaced
842:0d6fba16c7db 843:32dbed7e0dc4
1023 1023
1024 1024
1025 static int 1025 static int
1026 sshv2_getcwd (gftp_request * request) 1026 sshv2_getcwd (gftp_request * request)
1027 { 1027 {
1028 char *tempstr, *dir, *utf8;
1028 sshv2_message message; 1029 sshv2_message message;
1029 char *tempstr, *dir; 1030 size_t len;
1030 size_t msglen;
1031 int ret; 1031 int ret;
1032 1032
1033 g_return_val_if_fail (request != NULL, GFTP_EFATAL); 1033 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
1034 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL); 1034 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
1035 1035
1036 if (request->directory == NULL || *request->directory == '\0') 1036 if (request->directory == NULL || *request->directory == '\0')
1037 dir = "."; 1037 dir = ".";
1038 else 1038 else
1039 dir = request->directory; 1039 dir = request->directory;
1040 1040
1041 tempstr = sshv2_initialize_buffer_with_i18n_string (request, dir, &msglen); 1041 tempstr = sshv2_initialize_buffer_with_i18n_string (request, dir, &len);
1042 ret = sshv2_send_command (request, SSH_FXP_REALPATH, tempstr, msglen); 1042 ret = sshv2_send_command (request, SSH_FXP_REALPATH, tempstr, len);
1043 g_free (tempstr); 1043 g_free (tempstr);
1044 if (ret < 0) 1044 if (ret < 0)
1045 return (ret); 1045 return (ret);
1046 1046
1047 if (request->directory) 1047 if (request->directory)
1057 1057
1058 message.pos += 4; 1058 message.pos += 4;
1059 if ((ret = sshv2_buffer_get_int32 (request, &message, 1, 1, NULL)) < 0) 1059 if ((ret = sshv2_buffer_get_int32 (request, &message, 1, 1, NULL)) < 0)
1060 return (ret); 1060 return (ret);
1061 1061
1062 if ((request->directory = sshv2_buffer_get_string (request, &message, 1)) == NULL) 1062 if ((dir = sshv2_buffer_get_string (request, &message, 1)) == NULL)
1063 return (GFTP_EFATAL); 1063 return (GFTP_EFATAL);
1064
1065 utf8 = gftp_string_to_utf8 (request, dir, &len);
1066 if (utf8 != NULL)
1067 {
1068 request->directory = utf8;
1069 g_free (dir);
1070 }
1071 else
1072 request->directory = dir;
1064 1073
1065 sshv2_message_free (&message); 1074 sshv2_message_free (&message);
1066 return (0); 1075 return (0);
1067 } 1076 }
1068 1077