Changeset 5181
- Timestamp:
- 01/18/08 18:04:15 (6 months ago)
- Files:
-
- wire/trunk/NEWS (modified) (1 diff)
- wire/trunk/wire/client.c (modified) (13 diffs)
- wire/trunk/wire/client.h (modified) (2 diffs)
- wire/trunk/wire/commands.c (modified) (12 diffs)
- wire/trunk/wire/files.c (modified) (5 diffs)
- wire/trunk/wire/files.h (modified) (2 diffs)
- wire/trunk/wire/main.c (modified) (2 diffs)
- wire/trunk/wire/transfers.c (modified) (16 diffs)
- wire/trunk/wire/transfers.h (modified) (7 diffs)
- wire/trunk/wire/windows.c (modified) (4 diffs)
- wire/trunk/wire/windows.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wire/trunk/NEWS
r5172 r5181 3 3 4 4 1.1.3 5 - Support downloads/uploads of full directories 6 - Add /download command to set the local download directory 5 7 - Make /open command take its options before the hostname, instead of after 8 - Add more descriptions to /help command 6 9 - Fix problems with completing file paths 7 10 - Fix parsing of IPv6 addresses wire/trunk/wire/client.c
r5160 r5181 139 139 "Vy/xW31D+jfvNtPdS+ASBQAAAABJRU5ErkJggg=="; 140 140 141 static wi_socket_context_t *wr_socket_context; 142 141 wi_socket_context_t *wr_socket_context; 143 142 wi_socket_t *wr_socket; 144 143 wi_address_t *wr_address; … … 157 156 158 157 void wr_client_init(void) { 159 wi_integer_t options;160 161 158 wr_socket_context = wi_socket_context_init(wi_socket_context_alloc()); 162 159 … … 167 164 wi_log_err(WI_STR("Could not set SSL ciphers: %m")); 168 165 166 wr_server_string_encoding = wi_string_encoding_init_with_charset( 167 wi_string_encoding_alloc(), 168 WI_STR("UTF-8"), 169 WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE); 170 171 wr_set_charset(WI_STR("ISO-8859-1")); 172 173 wr_nick = wi_retain(wi_user_name()); 174 wr_icon = wi_string_init_with_cstring(wi_string_alloc(), wr_default_icon); 175 } 176 177 178 179 #pragma mark - 180 181 wi_boolean_t wr_set_charset(wi_string_t *charset) { 182 wi_string_encoding_t *encoding; 183 wi_integer_t options; 184 185 if(wr_client_string_encoding && wi_is_equal(charset, wi_string_encoding_charset(wr_client_string_encoding))) 186 return true; 187 169 188 options = WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE; 170 171 wr_client_string_encoding = wi_string_encoding_init_with_charset(wi_string_encoding_alloc(), 172 WI_STR("ISO-8859-1"), 173 options); 174 175 wr_server_string_encoding = wi_string_encoding_init_with_charset(wi_string_encoding_alloc(), 176 WI_STR("UTF-8"), 177 options); 178 179 wr_icon = wi_string_init_with_cstring(wi_string_alloc(), wr_default_icon); 189 encoding = wi_string_encoding_init_with_charset(wi_string_encoding_alloc(), 190 charset, 191 options); 192 193 if(!encoding) 194 return false; 195 196 wi_release(wr_client_string_encoding); 197 wr_client_string_encoding = encoding; 198 199 wr_printf_prefix(WI_STR("Using character set %@"), charset); 200 201 return true; 180 202 } 181 203 … … 408 430 409 431 case 521: 410 wr_printf_prefix(WI_STR("%@: File or directory already exists"), 411 wr_last_command); 432 if(!wr_transfers_recursive_upload) { 433 wr_printf_prefix(WI_STR("%@: File or directory already exists"), 434 wr_last_command); 435 } 412 436 break; 413 437 … … 996 1020 997 1021 static void wr_msg_400(wi_array_t *arguments) { 998 wi_address_t *address;999 1022 wr_transfer_t *transfer; 1000 1023 1001 transfer = wr_transfers_transfer_with_ path(WI_ARRAY(arguments, 0));1024 transfer = wr_transfers_transfer_with_remote_path(WI_ARRAY(arguments, 0)); 1002 1025 1003 1026 if(!transfer) 1004 1027 return; 1005 1028 1006 address = wi_copy(wr_address); 1007 wi_address_set_port(address, wi_address_port(address) + 1); 1008 1009 transfer->state = WR_TRANSFER_RUNNING; 1010 transfer->offset = wi_string_uint64(WI_ARRAY(arguments, 1)); 1011 transfer->transferred = transfer->offset; 1012 transfer->key = wi_retain(WI_ARRAY(arguments, 2)); 1013 transfer->start_time = wi_time_interval(); 1014 transfer->socket = wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP); 1015 1016 wi_socket_set_interactive(transfer->socket, false); 1017 1018 if(!wi_socket_connect(transfer->socket, wr_socket_context, 15.0)) { 1019 wr_printf_prefix(WI_STR("Could not connect to %@: %m"), wi_address_string(address)); 1020 1021 wr_transfer_stop(transfer); 1022 1023 goto end; 1024 } 1025 1026 wi_file_seek(transfer->file, transfer->offset); 1027 1028 if(transfer->type == WR_TRANSFER_DOWNLOAD) { 1029 wi_socket_set_direction(transfer->socket, WI_SOCKET_READ); 1030 wr_runloop_add_socket(transfer->socket, wr_runloop_download_callback); 1031 } else { 1032 wi_socket_set_direction(transfer->socket, WI_SOCKET_WRITE); 1033 wr_runloop_add_socket(transfer->socket, wr_runloop_upload_callback); 1034 } 1035 1036 wr_send_command_on_socket(transfer->socket, WI_STR("TRANSFER %#@"), transfer->key); 1037 1038 wr_printf_prefix(WI_STR("Starting transfer of \"%@\""), transfer->name); 1039 1040 wr_draw_transfers(true); 1041 1042 end: 1043 wi_release(address); 1029 wr_transfer_open(transfer, wi_string_uint64(WI_ARRAY(arguments, 1)), WI_ARRAY(arguments, 2)); 1044 1030 } 1045 1031 … … 1049 1035 wr_transfer_t *transfer; 1050 1036 1051 transfer = wr_transfers_transfer_with_ path(WI_ARRAY(arguments, 0));1037 transfer = wr_transfers_transfer_with_remote_path(WI_ARRAY(arguments, 0)); 1052 1038 1053 1039 if(transfer) { … … 1062 1048 wi_date_t *date; 1063 1049 wi_string_t *path, *kind, *string; 1050 wr_file_t *file; 1064 1051 wr_transfer_t *transfer; 1065 1052 wi_file_offset_t size; … … 1121 1108 } 1122 1109 else if(wr_stat_state == WR_STAT_TRANSFER) { 1123 transfer = wr_transfers_transfer_with_ path(WI_ARRAY(arguments, 0));1110 transfer = wr_transfers_transfer_with_remote_path(WI_ARRAY(arguments, 0)); 1124 1111 1125 1112 if(transfer) { … … 1127 1114 if(transfer->checksum && !wi_is_equal(transfer->checksum, WI_ARRAY(arguments, 5))) { 1128 1115 wr_printf_prefix(WI_STR("get: Checksum mismatch for \"%@\""), 1129 transfer->name); 1116 transfer->name); 1117 1130 1118 wr_transfer_stop(transfer); 1131 1119 … … 1133 1121 } 1134 1122 1135 transfer->size = size; 1123 if(!transfer->recursive) { 1124 file = wr_file_init_with_arguments(wr_file_alloc(), arguments); 1125 wr_transfer_download_add_file(transfer, file, false); 1126 wi_release(file); 1127 } 1136 1128 1137 wr_send_command(WI_STR("GET %#@%c%llu"), 1138 transfer->path, WR_FIELD_SEPARATOR, 1139 transfer->offset); 1129 wr_transfer_request(transfer); 1140 1130 } else { 1141 wr_printf_prefix(WI_STR("get: Cannot download directories")); 1131 wr_ls_state = WR_LS_TRANSFER; 1132 transfer->recursive = true; 1133 1134 wr_files_clear(); 1135 wr_send_command(WI_STR("LISTRECURSIVE %#@"), path); 1142 1136 } 1143 1137 } … … 1149 1143 static void wr_msg_410(wi_array_t *arguments) { 1150 1144 wr_file_t *file; 1151 1145 1152 1146 file = wr_file_init_with_arguments(wr_file_alloc(), arguments); 1153 1147 wi_array_add_data(wr_files, file); … … 1158 1152 1159 1153 static void wr_msg_411(wi_array_t *arguments) { 1154 wr_transfer_t *transfer; 1160 1155 wi_file_offset_t free; 1161 1156 … … 1170 1165 wr_print_files(); 1171 1166 } 1167 else if(wr_ls_state == WR_LS_TRANSFER) { 1168 transfer = wr_transfers_transfer_with_remote_path(WI_ARRAY(arguments, 0)); 1169 1170 if(transfer) { 1171 if(transfer->type == WR_TRANSFER_DOWNLOAD) 1172 wr_transfer_download_add_files(transfer, wr_files); 1173 else 1174 wr_transfer_upload_remove_files(transfer, wr_files); 1175 1176 transfer->state = WR_TRANSFER_WAITING; 1177 transfer->listed = true; 1178 1179 wr_transfer_request(transfer); 1180 } 1181 } 1172 1182 } 1173 1183 wire/trunk/wire/client.h
r5079 r5181 52 52 void wr_client_init(void); 53 53 54 wi_boolean_t wr_set_charset(wi_string_t *); 55 54 56 void wr_connect(wi_string_t *, wi_uinteger_t, wi_string_t *, wi_string_t *); 55 57 void wr_disconnect(void); … … 84 86 extern wi_time_interval_t wr_ping_time; 85 87 88 extern wi_socket_context_t *wr_socket_context; 86 89 extern wi_socket_t *wr_socket; 87 90 extern wi_address_t *wr_address; wire/trunk/wire/commands.c
r5163 r5181 50 50 51 51 wi_boolean_t help; 52 const char *description; 52 53 const char *usage; 53 54 … … 74 75 static void wr_cmd_comment(wi_array_t *); 75 76 static void wr_cmd_disconnect(wi_array_t *); 77 static void wr_cmd_download(wi_array_t *); 76 78 static void wr_cmd_echo(wi_array_t *); 77 79 static void wr_cmd_get(wi_array_t *); … … 117 119 118 120 121 #define WR_CMD_INFO_DESCRIPTION "Get info for the user" 122 #define WR_CMD_INFO_USAGE "<user>" 123 124 #define WR_CMD_OPEN_DESCRIPTION "Connect to a server" 125 #define WR_CMD_OPEN_USAGE "[-l <login>] [-p <password>] [-P <port>] <server>" 126 127 #define WR_CMD_MV_DESCRIPTION "Move or rename a path" 128 #define WR_CMD_MV_USAGE "<path> <path>" 129 130 #define WR_CMD_QUIT_DESCRIPTION "Quit wire" 131 #define WR_CMD_QUIT_USAGE "" 132 133 #define WR_CMD_RM_DESCRIPTION "Delete the path" 134 #define WR_CMD_RM_USAGE "<path>" 135 119 136 static wr_commands_t wr_commands[] = { 120 137 { "ban", 121 true, " <user> <message>",138 true, "Ban the user from the server with a message", "<user> <message>", 122 139 true, 2, 1, WR_COMPLETER_NICKNAME, 123 140 wr_cmd_ban }, 124 141 { "broadcast", 125 true, " <message>",142 true, "Broadcast a message to all users", "<message>", 126 143 true, 1, 0, WR_COMPLETER_NICKNAME, 127 144 wr_cmd_broadcast }, 128 145 { "cd", 129 true, " <path>",146 true, "Change the working directory", "<path>", 130 147 true, 1, -1, WR_COMPLETER_DIRECTORY, 131 148 wr_cmd_cd }, 132 149 { "charset", 133 true, " <charset>",150 true, "Set the character set that is used to convert text from the server", "<charset>", 134 151 false, 1, -1, WR_COMPLETER_NONE, 135 152 wr_cmd_charset }, 136 153 { "clear", 137 true, " ",154 true, "Clear all output", "", 138 155 false, 0, -1, WR_COMPLETER_NONE, 139 156 wr_cmd_clear }, 140 157 { "clearnews", 141 true, " ",158 true, "Clear the news", "", 142 159 true, 0, -1, WR_COMPLETER_NONE, 143 160 wr_cmd_clearnews }, 144 161 { "close", 145 true, " ",162 true, "Close the current window, or disconnect from the server if in main window", "", 146 163 false, 0, -1, WR_COMPLETER_NONE, 147 164 wr_cmd_close }, 148 165 { "comment", 149 true, " <path> <comment>",166 true, "Set the comment for the path", "<path> <comment>", 150 167 true, 1, -1, WR_COMPLETER_FILENAME, 151 168 wr_cmd_comment }, 152 169 { "connect", 153 false, "[-l <login>] [-p <password>] [-P <port>] <server>",170 false, WR_CMD_OPEN_DESCRIPTION, WR_CMD_OPEN_USAGE, 154 171 false, 1, -1, WR_COMPLETER_NONE, 155 172 wr_cmd_open }, 156 173 { "delete", 157 true, "<path>",174 true, WR_CMD_RM_DESCRIPTION, WR_CMD_RM_USAGE, 158 175 true, 1, -1, WR_COMPLETER_FILENAME, 159 176 wr_cmd_rm }, 160 177 { "disconnect", 161 true, " ",178 true, "Disconnect from the server", "", 162 179 true, 0, -1, WR_COMPLETER_NONE, 163 180 wr_cmd_disconnect }, 181 { "download", 182 true, "Set the directory where downloads will be created", "<path>", 183 false, 1, -1, WR_COMPLETER_LOCAL_FILENAME, 184 wr_cmd_download }, 164 185 { "echo", 165 false, " <text>",186 false, "Print the string", "<text>", 166 187 false, 1, 0, WR_COMPLETER_NONE, 167 188 wr_cmd_echo }, 168 189 { "exit", 169 false, "",190 false, WR_CMD_QUIT_DESCRIPTION, WR_CMD_QUIT_USAGE, 170 191 false, 0, -1, WR_COMPLETER_NONE, 171 192 wr_cmd_quit }, 172 193 { "get", 173 true, " <path>",194 true, "Downloads the path", "<path>", 174 195 true, 1, -1, WR_COMPLETER_FILENAME, 175 196 wr_cmd_get }, 176 197 { "help", 177 true, " [<command>]",198 true, "Print a list of commands, or help for a specific command", "[<command>]", 178 199 false, 0, -1, WR_COMPLETER_COMMAND, 179 200 wr_cmd_help }, 180 201 { "icon", 181 true, " <path>",202 true, "Load a custom icon from a 32x32 PNG image file", "<path>", 182 203 false, 1, -1, WR_COMPLETER_LOCAL_FILENAME, 183 204 wr_cmd_icon }, 184 205 { "ignore", 185 true, " [<nick>]",206 true, "Add the user to the ignore list", "[<nick>]", 186 207 false, 0, -1, WR_COMPLETER_NICKNAME, 187 208 wr_cmd_ignore }, 188 209 { "ignores", 189 true, " [<nick>]",210 true, "List ignores", "[<nick>]", 190 211 false, 0, -1, WR_COMPLETER_NICKNAME, 191 212 wr_cmd_ignore }, 192 213 { "info", 193 true, "<user>",214 true, WR_CMD_INFO_DESCRIPTION, WR_CMD_INFO_USAGE, 194 215 true, 1, -1, WR_COMPLETER_NICKNAME, 195 216 wr_cmd_info }, 196 217 { "invite", 197 true, " <user>",218 true, "Invite the user to the current private chat", "<user>", 198 219 true, 1, -1, WR_COMPLETER_NICKNAME, 199 220 wr_cmd_invite }, 200 221 { "join", 201 false, "[-l <login>] [-p <password>] [-P <port>] <server>",222 false, WR_CMD_OPEN_DESCRIPTION, WR_CMD_OPEN_USAGE, 202 223 false, 1, -1, WR_COMPLETER_NONE, 203 224 wr_cmd_open }, 204 225 { "kick", 205 true, " <user> <message>",226 true, "Kick the user from the server with a message", "<user> <message>", 206 227 true, 1, 1, WR_COMPLETER_NICKNAME, 207 228 wr_cmd_kick }, 208 229 { "load", 209 true, " <bookmark>",230 true, "Load the bookmark from the ~/.wire/ directory", "<bookmark>", 210 231 false, 1, -1, WR_COMPLETER_BOOKMARK, 211 232 wr_cmd_load }, 212 233 { "log", 213 true, " <filename>",234 true, "Save a copy of the current output to a file", "<filename>", 214 235 false, 1, -1, WR_COMPLETER_NONE, 215 236 wr_cmd_log }, 216 237 { "ls", 217 true, " <path>",238 true, "List the current directory, or a path", "[<path>]", 218 239 true, 0, -1, WR_COMPLETER_DIRECTORY, 219 240 wr_cmd_ls }, 220 241 { "me", 221 true, " <chat>",242 true, "Say text as action chat", "<chat>", 222 243 true, 1, 0, WR_COMPLETER_NICKNAME, 223 244 wr_cmd_me }, 224 245 { "mkdir", 225 true, " <path>",246 true, "Create a new directory", "<path>", 226 247 true, 1, -1, WR_COMPLETER_FILENAME, 227 248 wr_cmd_mkdir }, 228 249 { "move", 229 true, "<path> <path>",250 true, WR_CMD_MV_DESCRIPTION, WR_CMD_MV_USAGE, 230 251 true, 2, -1, WR_COMPLETER_FILENAME, 231 252 wr_cmd_mv }, 232 253 { "msg", 233 true, " <user> <message>",254 true, "Send a private message to the user", "<user> <message>", 234 255 true, 2, 1, WR_COMPLETER_NICKNAME, 235 256 wr_cmd_msg }, 236 257 { "mv", 237 true, "<path> <path>",258 true, WR_CMD_MV_DESCRIPTION, WR_CMD_MV_USAGE, 238 259 true, 2, -1, WR_COMPLETER_FILENAME, 239 260 wr_cmd_mv }, 240 261 { "news", 241 true, " [-<number> | -ALL]",262 true, "Print parts or all of the server news", "[-<number> | -ALL]", 242 263 true, 0, -1, WR_COMPLETER_NONE, 243 264 wr_cmd_news }, 244 265 { "nick", 245 true, " <nick>",266 true, "Set your current nick name", "<nick>", 246 267 false, 1, 0, WR_COMPLETER_NICKNAME, 247 268 wr_cmd_nick }, 248 269 { "open", 249 true, "[-l <login>] [-p <password>] [-P <port>] <server>",270 true, WR_CMD_OPEN_DESCRIPTION, WR_CMD_OPEN_USAGE, 250 271 false, 1, -1, WR_COMPLETER_NONE, 251 272 wr_cmd_open }, 252 273 { "ping", 253 true, " ",274 true, "Ping the server to determine latency", "", 254 275 true, 0, -1, WR_COMPLETER_NONE, 255 276 wr_cmd_ping }, 256 277 { "post", 257 true, " <message>",278 true, "Post a new message to the server news", "<message>", 258 279 true, 1, 0, WR_COMPLETER_NICKNAME, 259 280 wr_cmd_post }, 260 281 { "privchat", 261 true, " [<user>]",282 true, "Create a private chat, optionally inviting the user", "[<user>]", 262 283 true, 0, -1, WR_COMPLETER_NICKNAME, 263 284 wr_cmd_privchat }, 264 285 { "put", 265 true, " <path>",286 true, "Upload the path to the current working directory", "<path>", 266 287 true, 1, -1, WR_COMPLETER_LOCAL_FILENAME, 267 288 wr_cmd_put }, 268 289 { "pwd", 269 true, " ",290 true, "Print the current working directory", "", 270 291 true, 0, -1, WR_COMPLETER_NONE, 271 292 wr_cmd_pwd }, 272 293 { "quit", 273 true, "",294 true, WR_CMD_QUIT_DESCRIPTION, WR_CMD_QUIT_USAGE, 274 295 false, 0, -1, WR_COMPLETER_NONE, 275 296 wr_cmd_quit }, 276 297 { "remove", 277 true, "<path>",298 true, WR_CMD_RM_DESCRIPTION, WR_CMD_RM_USAGE, 278 299 true, 1, -1, WR_COMPLETER_FILENAME, 279 300 wr_cmd_rm }, 280 301 { "reply", 281 true, " <message>",302 true, "Send a private message to the last user who messaged you", "<message>", 282 303 true, 1, 0, WR_COMPLETER_NICKNAME, 283 304 wr_cmd_reply }, 284 305 { "rm", 285 true, "<path>",306 true, WR_CMD_RM_DESCRIPTION, WR_CMD_RM_USAGE, 286 307 true, 1, -1, WR_COMPLETER_FILENAME, 287 308 wr_cmd_rm }, 288 309 { "save", 289 true, " <bookmark>",310 true, "Save a bookmark to the ~/.wire/ directory", "<bookmark>", 290 311 false, 1, -1, WR_COMPLETER_BOOKMARK, 291 312 wr_cmd_save }, 292 313 { "say", 293 false, " <chat>",314 false, "Say text", "<chat>", 294 315 true, 1, 0, WR_COMPLETER_NICKNAME, 295 316 wr_cmd_say }, 296 317 { "search", 297 true, " <query>",318 true, "Search files", "<query>", 298 319 true, 1, -1, WR_COMPLETER_FILENAME, 299 320 wr_cmd_search }, 300 321 { "server", 301 false, "[-l <login>] [-p <password>] [-P <port>] <server>",322 false, WR_CMD_OPEN_DESCRIPTION, WR_CMD_OPEN_USAGE, 302 323 false, 1, -1, WR_COMPLETER_NONE, 303 324 wr_cmd_open }, 304 325 { "serverinfo", 305 true, " ",326 true, "Print server info", "", 306 327 true, 0, -1, WR_COMPLETER_NONE, 307 328 wr_cmd_serverinfo }, 308 329 { "start", 309 true, " <transfer>",330 true, "Start the transfer", "<transfer>", 310 331 true, 1, -1, WR_COMPLETER_NONE, 311 332 wr_cmd_start }, 312 333 { "stat", 313 true, " <path>",334 true, "Print file info for the path", "<path>", 314 335 true, 1, -1, WR_COMPLETER_FILENAME, 315 336 wr_cmd_stat }, 316 337 { "status", 317 true, " <status>",338 true, "Set your current status message", "<status>", 318 339 false, 1, 0, WR_COMPLETER_NONE, 319 340 wr_cmd_status }, 320 341 { "stop", 321 true, " <transfer>",342 true, "Stop the transfer", "<transfer>", 322 343 true, 1, -1, WR_COMPLETER_NONE, 323 344 wr_cmd_stop }, 324 345 { "timestamp", 325 true, " [<format>]",346 true, "Set or disable the timestamp", "[<format>]", 326 347 false, 0, 0, WR_COMPLETER_NONE, 327 348 wr_cmd_timestamp }, 328 349 { "topic", 329 true, " [<topic>]",350 true, "Set or print the chat topic", "[<topic>]", 330 351 true, 0, 0, WR_COMPLETER_NICKNAME, 331 352 wr_cmd_topic }, 332 353 { "type", 333 true, " <path> (folder | uploads | dropbox)",354 true, "Set the folder type for the path", "<path> (folder | uploads | dropbox)", 334 355 true, 2, -1, WR_COMPLETER_FILENAME, 335 356 wr_cmd_type }, 336 357 { "unignore", 337 true, " [<ignore> | <nick>]",358 true, "Remove the user or the ignore from the ignore list", "[<ignore> | <nick>]", 338 359 false, 0, -1, WR_COMPLETER_IGNORE, 339 360 wr_cmd_unignore }, 340 361 { "uptime", 341 true, " ",362 true, "Print uptime statistics for wire", "", 342 363 false, 0, -1, WR_COMPLETER_NONE, 343 364 wr_cmd_uptime }, 344 365 { "version", 345 true, " ",366 true, "Print version information for wire", "", 346 367 false, 0, -1, WR_COMPLETER_NONE, 347 368 wr_cmd_version }, 348 369 { "who", 349 true, " ",370 true, "Print the user list", "", 350 371 true, 0, -1, WR_COMPLETER_NONE, 351 372 wr_cmd_who }, 352 373 { "whois", 353 false, "<user>",374 false, WR_CMD_INFO_DESCRIPTION, WR_CMD_INFO_USAGE, 354 375 true, 1, -1, WR_COMPLETER_NICKNAME, 355 376 wr_cmd_info }, … … 437 458 } 438 459 460 wr_printf_prefix(WI_STR("%s: %s"), 461 wr_commands[index].name, wr_commands[index].description); 462 439 463 wr_printf_prefix(WI_STR("Usage: %s %s"), 440 464 wr_commands[index].name, wr_commands[index].usage); … … 578 602 579 603 static void wr_cmd_charset(wi_array_t *arguments) { 580 wi_string_encoding_t *encoding; 581 wi_string_t *charset; 582 wi_integer_t options; 583 584 charset = WI_ARRAY(arguments, 0); 585 options = WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE; 586 encoding = wi_string_encoding_init_with_charset(wi_string_encoding_alloc(), 587 charset, 588 options); 589 590 if(!encoding) { 591 wr_printf_prefix(WI_STR("charset: Could not use charset \"%@\": %m"), charset); 592 } else { 593 wi_release(wr_client_string_encoding); 594 wr_client_string_encoding = wi_retain(encoding); 595 596 wr_printf_prefix(WI_STR("Using character set %@"), 597 charset); 598 } 599 600 wi_release(encoding); 604 if(!wr_set_charset(WI_ARRAY(arguments, 0))) 605 wr_printf_prefix(WI_STR("charset: Could not use charset \"%@\": %m"), WI_ARRAY(arguments, 0)); 601 606 } 602 607 … … 694 699 695 700 /* 701 /download <path> 702 */ 703 704 static void wr_cmd_download(wi_array_t *arguments) { 705 wr_transfers_set_download_path(WI_ARRAY(arguments, 0)); 706 } 707 708 709 710 /* 696 711 /echo <text> 697 712 */ … … 786 801 787 802 path = wi_string_by_normalizing_path(WI_ARRAY(arguments, 0)); 788 string = wi_string_init_with_contents_of_file(wi_string_alloc(), wi_string_by_normalizing_path(path));803 string = wi_string_init_with_contents_of_file(wi_string_alloc(), path); 789 804 790 805 if(string) { … … 1416 1431 1417 1432 /* 1418 /say <chat> 1419 */ 1420 1421 static void wr_cmd_say(wi_array_t *arguments) { 1422 wi_string_t *chat; 1423 1424 chat = WI_ARRAY(arguments, 0); 1425 1426 if(wr_window_is_chat(wr_current_window)) { 1427 wr_send_command(WI_STR("SAY %u%c%#@"), 1428 wr_chat_id(wr_current_window->chat), WR_FIELD_SEPARATOR, 1429 chat); 1430 } 1431 else if(wr_window_is_user(wr_current_window)) { 1432 wr_send_command(WI_STR("MSG %u%c%#@"), 1433 wr_user_id(wr_current_window->user), WR_FIELD_SEPARATOR, 1434 chat); 1435 1436 wr_wprint_say(wr_current_window, wr_nick, chat); 1437 } 1438 } 1439 1440 1441 1442 /* 1443 /search <query> 1444 */ 1445 1446 static void wr_cmd_search(wi_array_t *arguments) { 1447 wr_files_clear(); 1448 1449 wr_send_command(WI_STR("SEARCH %#@"), WI_ARRAY(arguments, 0)); 1450 } 1451 1452 1453 1454 /* 1455 /serverinfo 1456 */ 1457 1458 static void wr_cmd_serverinfo(wi_array_t *arguments) { 1459 wr_print_server_info(); 1460 } 1461 1462 1463 1464 /* 1465 /save <bookmark> 1466 */ 1433 /save <bookmark> 1434 */ 1467 1435 1468 1436 static void wr_cmd_save(wi_array_t *arguments) { 1469 1437 wi_file_t *file; 1470 1438 wi_string_t *path, *login, *password, *port; 1471 1439 1472 1440 path = wi_user_home(); 1473 1441 wi_string_append_path_component(path, WI_STR(WR_WIRE_PATH)); … … 1475 1443 1476 1444 file = wi_file_for_writing(path); 1477 1445 1478 1446 if(!file) { 1479 1447 wr_printf_prefix(WI_STR("save: %@: %m"), path); 1480 1448 1481 1449 return; 1482 1450 } … … 1484 1452 wi_file_write(file, WI_STR("charset %@\n"), wi_string_encoding_charset(wr_client_string_encoding)); 1485 1453 wi_file_write(file, WI_STR("timestamp %@\n"), wr_timestamp_format); 1454 wi_file_write(file, WI_STR("download %@\n"), wr_download_path); 1486 1455 wi_file_write(file, WI_STR("nick %@\n"), wr_nick); 1487 1456 1488 1457 if(wi_string_length(wr_status) > 0) 1489 1458 wi_file_write(file, WI_STR("status %@\n"), wr_status); 1490 1459 1491 1460 if(wr_icon_path) 1492 1461 wi_file_write(file, WI_STR("icon %@\n"), wr_icon_path); … … 1508 1477 port = NULL; 1509 1478 1510 wi_file_write(file, WI_STR("open % @ %#@ %#@ %#@\n"), wr_host, login, password, port);1511 } 1512 1479 wi_file_write(file, WI_STR("open %#@ %#@ %#@ %@\n"), login, password, port, wr_host); 1480 } 1481 1513 1482 wr_printf_prefix(WI_STR("save: \"%@\" saved"), path); 1483 } 1484 1485 1486 1487 /* 1488 /say <chat> 1489 */ 1490 1491 static void wr_cmd_say(wi_array_t *arguments) { 1492 wi_string_t *chat; 1493 1494 chat = WI_ARRAY(arguments, 0); 1495 1496 if(wr_window_is_chat(wr_current_window)) { 1497 wr_send_command(WI_STR("SAY %u%c%#@"), 1498 wr_chat_id(wr_current_window->chat), WR_FIELD_SEPARATOR, 1499 chat); 1500 } 1501 else if(wr_window_is_user(wr_current_window)) { 1502 wr_send_command(WI_STR("MSG %u%c%#@"), 1503 wr_user_id(wr_current_window->user), WR_FIELD_SEPARATOR, 1504 chat); 1505 1506 wr_wprint_say(wr_current_window, wr_nick, chat); 1507 } 1508 } 1509 1510 1511 1512 /* 1513 /search <query> 1514 */ 1515 1516 static void wr_cmd_search(wi_array_t *arguments) { 1517 wr_files_clear(); 1518 1519 wr_send_command(WI_STR("SEARCH %#@"), WI_ARRAY(arguments, 0)); 1520 } 1521 1522 1523 1524 /* 1525 /serverinfo 1526 */ 1527 1528 static void wr_cmd_serverinfo(wi_array_t *arguments) { 1529 wr_print_server_info(); 1514 1530 } 1515 1531 … … 1636 1652 1637 1653 static void wr_cmd_timestamp(wi_array_t *arguments) { 1638 if(wi_array_count(arguments) == 0) { 1639 wi_release(wr_timestamp_format); 1640 wr_timestamp_format = wi_retain(WI_STR("")); 1641 } else { 1642 wi_release(wr_timestamp_format); 1643 wr_timestamp_format = wi_retain(WI_ARRAY(arguments, 0)); 1644 } 1645 1646 wr_printf_prefix(WI_STR("Using timestamp format %@"), 1647 wr_timestamp_format); 1654 if(wi_array_count(arguments) == 0) 1655 wr_windows_set_timestamp_format(WI_STR("")); 1656 else 1657 wr_windows_set_timestamp_format(WI_ARRAY(arguments, 0)); 1648 1658 } 1649 1659 wire/trunk/wire/files.c
r5161 r5181 203 203 204 204 if(globpaths) { 205 glob_enumerator = wi_array_data_enumerator( wr_files_glob(path));205 glob_enumerator = wi_array_data_enumerator(globpaths); 206 206 207 while((globpath = wi_enumerator_next_data(glob_enumerator))) 208 wi_array_add_data(array, wr_files_full_path(globpath)); 207 while((globpath = wi_enumerator_next_data(glob_enumerator))) { 208 if(wi_string_length(globpath) > 0) 209 wi_array_add_data(array, wr_files_full_path(globpath)); 210 } 209 211 } 210 212 } … … 320 322 321 323 dir->count = wi_array_count(wr_files); 322 dir->entries = wi_malloc(sizeof(struct dirent ) * (dir->count + 1));324 dir->entries = wi_malloc(sizeof(struct dirent *) * (dir->count + 1)); 323 325 324 326 for(i = 0; i < dir->count; i++) { 325 327 file = WI_ARRAY(wr_files, i); 326 328 327 329 dir->entries[i] = wi_malloc(sizeof(struct dirent)); 328 dir->entries[i]->d_ino = 0;329 dir->entries[i]->d_reclen = 0;330 dir->entries[i]->d_ino = random
