| | 166 | | static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server, | | | 167 | | WI_ITEM_REC *item) | | | 168 | | { | | | 169 | | const char *servertag; | | | 170 | | char *nick, *fileargs; | | | 171 | | void *free_arg; | | | 172 | | CHAT_DCC_REC *chat; | | | 173 | | GHashTable *optlist; | | | 174 | | int queue, mode, passive; | | | 175 | | | | | 176 | | if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
| | | 177 | | PARAM_FLAG_GETREST, "dcc send",
| | | 178 | | &optlist, &nick, &fileargs)) | | | 179 | | return; | | | 180 | | | | | 181 | | chat = item_get_dcc(item); | | | 182 | | if (chat != NULL &&
| | | 183 | | (chat->mirc_ctcp || g_strcasecmp(nick, chat->nick) != 0)) | | | 184 | | chat = NULL;
| | | 185 | | | | | 186 | | if (!IS_IRC_SERVER(server) || !server->connected)
| | | 187 | | servertag = NULL;
| | | 188 | | else | | | 189 | | servertag = server->tag; | | | 190 | | | | true | 191 | | if (servertag == NULL && chat == NULL)
| | | 192 | | cmd_param_error(CMDERR_NOT_CONNECTED);
| | | 193 | | | | | 194 | | passive = g_hash_table_lookup(optlist, "passive") != NULL;
| | | 195 | | | | | 196 | | if (g_hash_table_lookup(optlist, "rmhead") != NULL) {
| | | 197 | | queue = dcc_queue_old(nick, servertag); | | | 198 | | if (queue != -1) | | | 199 | | dcc_queue_remove_head(queue); | | | 200 | | } else if (g_hash_table_lookup(optlist, "rmtail") != NULL) {
| | | 201 | | queue = dcc_queue_old(nick, servertag); | | | 202 | | if (queue != -1) | | | 203 | | dcc_queue_remove_tail(queue); | | | 204 | | } else if (g_hash_table_lookup(optlist, "flush") != NULL) {
| | | 205 | | queue = dcc_queue_old(nick, servertag); | | | 206 | | if (queue != -1) | | | 207 | | dcc_queue_free(queue); | | | 208 | | } else { | | | 209 | | if (g_hash_table_lookup(optlist, "append") != NULL)
| | | 210 | | mode = DCC_QUEUE_APPEND; | | | 211 | | else if (g_hash_table_lookup(optlist, "prepend") != NULL)
| | | 212 | | mode = DCC_QUEUE_PREPEND; | | | 213 | | else | | | 214 | | mode = DCC_QUEUE_NORMAL; | | | 215 | | | | | 216 | | if (*fileargs == '\0') | | | 217 | | cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
| | | 218 | | |
| | 92 | | | | static void dcc_send_add(const char *servertag, CHAT_DCC_REC *chat, | | | 93 | | | | const char *nick, char *fileargs, int add_mode, | | | 94 | | | | int passive) | | | 95 | | | | { | | | 96 | | | | struct stat st; | | | 97 | | | | glob_t globbuf; | | | 98 | | | | char *fname; | | | 99 | | | | int i, ret, files, flags, queue, start_new_transfer; | | | 100 | | | | | | | 101 | | | | memset(&globbuf, 0, sizeof(globbuf)); | | | 102 | | | | flags = GLOB_NOCHECK | GLOB_TILDE;
| | | 103 | | | | | | | 104 | | | | | | | 105 | | | | for (;;) { | | | 106 | | | | fname = cmd_get_quoted_param(&fileargs); | | | 107 | | | | if (*fname == '\0') | | | 108 | | | | break; | | | 109 | | | | | | | 110 | | | | if (glob(fname, flags, 0, &globbuf) < 0) | | | 111 | | | | break; | | | 112 | | | | | | | 113 | | | | | | | 114 | | | | | | | 115 | | | | flags |= GLOB_APPEND;
| | | 116 | | | | } | | | 117 | | | | | | | 118 | | | | files = 0; queue = -1; start_new_transfer = 0; | | | 119 | | | | | | | 120 | | | | | | | 121 | | | | for (i = 0; i < globbuf.gl_pathc; i++) { | | | 122 | | | | char *fname = dcc_send_get_file(globbuf.gl_pathv[i]); | | | 123 | | | | | | | 124 | | | | ret = stat(fname, &st); | | | 125 | | | | if (ret == 0 && S_ISDIR(st.st_mode)) {
| | | 126 | | | | | | | 127 | | | | errno = EISDIR;
| | | 128 | | | | ret = -1; | | | 129 | | | | } | | | 130 | | | | | | | 131 | | | | if (ret < 0) { | | | 132 | | | | signal_emit("dcc error file open", 3, | | | 133 | | | | nick, fname, errno); | | | 134 | | | | g_free(fname); | | | 135 | | | | continue; | | | 136 | | | | } | | | 137 | | | | | | | 138 | | | | if (queue < 0) { | | | 139 | | | | | | | 140 | | | | | | | 141 | | | | | | | 142 | | | | | | | 143 | | | | if (add_mode != DCC_QUEUE_NORMAL) |
|