diff options
author | Timo Sirainen <cras@irssi.org> | 2002-11-11 08:01:22 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-11-11 08:01:22 +0000 |
commit | be1cd41a349ec77dcbb149e393e75209d1d0b9f0 (patch) | |
tree | b44bb67a95b49112ece3480d1b559ab7116a685a /src/irc/dcc | |
parent | 087e5ee52580bd6286dd3036a74033cfab2049bf (diff) | |
download | irssi-be1cd41a349ec77dcbb149e393e75209d1d0b9f0.zip |
Fixes to allow -append and -prepend work when there's only one file being
sent to wanted nick + typo bugfix.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2997 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/dcc')
-rw-r--r-- | src/irc/dcc/dcc-queue.c | 53 | ||||
-rw-r--r-- | src/irc/dcc/dcc-send.c | 18 |
2 files changed, 36 insertions, 35 deletions
diff --git a/src/irc/dcc/dcc-queue.c b/src/irc/dcc/dcc-queue.c index 9fa037d8..677bc07b 100644 --- a/src/irc/dcc/dcc-queue.c +++ b/src/irc/dcc/dcc-queue.c @@ -41,13 +41,12 @@ int dcc_queue_old(const char *nick, const char *servertag) for (i = 0; i < queuelist->len; i++) { GSList *qlist = g_ptr_array_index(queuelist, i); - if (qlist == NULL) - continue; - - /* skip stub */ - for (qlist = qlist->next; qlist != NULL; qlist = qlist->next) { + for (; qlist != NULL; qlist = qlist->next) { DCC_QUEUE_REC *rec = qlist->data; + if (rec == NULL) + continue; + if (*nick != '\0' && g_strcasecmp(nick, rec->nick) != 0) continue; @@ -81,6 +80,16 @@ int dcc_queue_new(void) return i; } +static void dcc_queue_free_rec(DCC_QUEUE_REC *rec) +{ + if (rec != NULL) { + g_free(rec->servertag); + g_free(rec->nick); + g_free(rec->file); + g_free(rec); + } +} + void dcc_queue_free(int queue) { GSList **qlist; @@ -88,18 +97,12 @@ void dcc_queue_free(int queue) g_assert(queue >= 0 && queue < queuelist->len); qlist = (GSList **) &g_ptr_array_index(queuelist, queue); - g_assert(*qlist != NULL && (*qlist)->next == NULL); - - g_slist_free(*qlist); - *qlist = NULL; -} + while (*qlist != NULL) { + DCC_QUEUE_REC *rec = (*qlist)->data; -static void dcc_queue_free_rec(DCC_QUEUE_REC *rec) -{ - g_free(rec->servertag); - g_free(rec->nick); - g_free(rec->file); - g_free(rec); + *qlist = (*qlist)->next; + dcc_queue_free_rec(rec); + } } /* add an element to queue. element will have nick/servertag/fname/chat as data. @@ -127,9 +130,10 @@ void dcc_queue_add(int queue, int mode, const char *nick, const char *fname, *qlist = g_slist_append(*qlist, rec); } -/* removes the head or the tail from the queue, but not the stub. returns the - number of elements removed from the queue (0 or 1). if remove_head is - non-zero, the head is removed. otherwise the tail is removed */ +/* removes the head or the tail from the queue. returns the number of + elements removed from the queue (0 or 1). if remove_head is non-zero, + the head is removed (or actually stub is removed and the current head + becomes the stub), otherwise the tail is removed. */ static int dcc_queue_remove_entry(int queue, int remove_head) { DCC_QUEUE_REC *rec; @@ -141,7 +145,7 @@ static int dcc_queue_remove_entry(int queue, int remove_head) if (*qlist == NULL || (*qlist)->next == NULL) return 0; - rec = remove_head ? (*qlist)->next->data : g_slist_last(*qlist)->data; + rec = remove_head ? (*qlist)->data : g_slist_last(*qlist)->data; *qlist = g_slist_remove(*qlist, rec); dcc_queue_free_rec(rec); @@ -192,13 +196,10 @@ static void sig_dcc_destroyed(CHAT_DCC_REC *dcc) for (i = 0; i < queuelist->len; i++) { GSList *qlist = g_ptr_array_index(queuelist, i); - if (qlist == NULL) - continue; - - for (qlist = qlist->next; qlist != NULL; qlist = qlist->next) { + for (; qlist != NULL; qlist = qlist->next) { DCC_QUEUE_REC *rec = qlist->data; - if (rec->chat == dcc) + if (rec != NULL && rec->chat == dcc) rec->chat = NULL; } } @@ -216,7 +217,7 @@ void dcc_queue_deinit(void) int i; for (i = 0; i < queuelist->len; i++) - while (dcc_queue_remove_head(i) != 0) ; + dcc_queue_free(i); g_ptr_array_free(queuelist, TRUE); diff --git a/src/irc/dcc/dcc-send.c b/src/irc/dcc/dcc-send.c index 472d5c5d..25545a05 100644 --- a/src/irc/dcc/dcc-send.c +++ b/src/irc/dcc/dcc-send.c @@ -18,11 +18,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <glob.h> - #include "module.h" #include "signals.h" #include "commands.h" @@ -37,8 +32,10 @@ #include "dcc-chat.h" #include "dcc-queue.h" +#include <glob.h> + #ifndef GLOB_TILDE -# define GLOBL_TILDE 0 +# define GLOB_TILDE 0 /* unsupported */ #endif static int dcc_send_one_file(int queue, const char *target, const char *fname, @@ -161,13 +158,16 @@ static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server, if (g_hash_table_lookup(optlist, "rmhead") != NULL) { queue = dcc_queue_old(nick, servertag); - dcc_queue_remove_head(queue); + if (queue != -1) + dcc_queue_remove_head(queue); } else if (g_hash_table_lookup(optlist, "rmtail") != NULL) { queue = dcc_queue_old(nick, servertag); - dcc_queue_remove_tail(queue); + if (queue != -1) + dcc_queue_remove_tail(queue); } else if (g_hash_table_lookup(optlist, "flush") != NULL) { queue = dcc_queue_old(nick, servertag); - while (dcc_queue_remove_head(queue)) ; + if (queue != -1) + dcc_queue_free(queue); } else { if (g_hash_table_lookup(optlist, "append") != NULL) mode = DCC_QUEUE_APPEND; |