Mercurial > pidgin
comparison plugins/icq/queue.c @ 1309:0a766047b4fd
[gaim-migrate @ 1319]
Yay, new icqlib
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Tue, 19 Dec 2000 10:08:29 +0000 |
| parents | a97e334ecfa2 |
| children | 4c510ca3563f |
comparison
equal
deleted
inserted
replaced
| 1308:4741b5a75b9f | 1309:0a766047b4fd |
|---|---|
| 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* | 2 /* |
| 3 $Id: queue.c 1202 2000-12-04 06:22:48Z robflynn $ | 3 $Id: queue.c 1319 2000-12-19 10:08:29Z warmenhoven $ |
| 4 $Log$ | 4 $Log$ |
| 5 Revision 1.2 2000/12/04 06:22:48 robflynn | 5 Revision 1.3 2000/12/19 10:08:29 warmenhoven |
| 6 Da numba one stunna! | 6 Yay, new icqlib |
| 7 | 7 |
| 8 Revision 1.1 2000/11/28 02:22:42 warmenhoven | 8 Revision 1.12 2000/12/19 06:00:07 bills |
| 9 icq. whoop de doo | 9 moved members from ICQLINK to ICQLINK_private struct |
| 10 | |
| 11 Revision 1.11 2000/12/06 05:15:45 denis | |
| 12 Handling for mass TCP messages has been added based on patch by | |
| 13 Konstantin Klyagin <konst@konst.org.ua> | |
| 14 | |
| 15 Revision 1.10 2000/12/03 21:56:38 bills | |
| 16 fixed compilation with gcc-2.96 | |
| 10 | 17 |
| 11 Revision 1.9 2000/07/10 01:31:17 bills | 18 Revision 1.9 2000/07/10 01:31:17 bills |
| 12 oops - removed #define LIST_TRACE and #define QUEUE_DEBUG | 19 oops - removed #define LIST_TRACE and #define QUEUE_DEBUG |
| 13 | 20 |
| 14 Revision 1.8 2000/07/10 01:26:56 bills | 21 Revision 1.8 2000/07/10 01:26:56 bills |
| 42 */ | 49 */ |
| 43 | 50 |
| 44 #include <stdlib.h> | 51 #include <stdlib.h> |
| 45 #include <time.h> | 52 #include <time.h> |
| 46 | 53 |
| 54 #include "icqlib.h" | |
| 47 #include "queue.h" | 55 #include "queue.h" |
| 48 #include "list.h" | 56 #include "list.h" |
| 49 | 57 |
| 50 void icq_UDPQueueNew(ICQLINK *link) | 58 void icq_UDPQueueNew(ICQLINK *link) |
| 51 { | 59 { |
| 52 link->icq_UDPQueue = list_new(); | 60 link->d->icq_UDPQueue = list_new(); |
| 53 link->icq_UDPExpireInterval = 15; /* expire interval = 15 sec */ | 61 link->icq_UDPExpireInterval = 15; /* expire interval = 15 sec */ |
| 54 } | 62 } |
| 55 | 63 |
| 56 void icq_UDPQueuePut(ICQLINK *link, icq_Packet *p, int attempt) | 64 void icq_UDPQueuePut(ICQLINK *link, icq_Packet *p, int attempt) |
| 57 { | 65 { |
| 64 ptr->expire = time(0L)+link->icq_UDPExpireInterval; | 72 ptr->expire = time(0L)+link->icq_UDPExpireInterval; |
| 65 ptr->pack = p; | 73 ptr->pack = p; |
| 66 #ifdef QUEUE_DEBUG | 74 #ifdef QUEUE_DEBUG |
| 67 printf("enqueuing queueitem %p\n", ptr); | 75 printf("enqueuing queueitem %p\n", ptr); |
| 68 #endif | 76 #endif |
| 69 list_enqueue(link->icq_UDPQueue, ptr); | 77 list_enqueue(link->d->icq_UDPQueue, ptr); |
| 70 } | 78 } |
| 71 | 79 |
| 72 icq_Packet *icq_UDPQueueGet(ICQLINK *link) | 80 icq_Packet *icq_UDPQueueGet(ICQLINK *link) |
| 73 { | 81 { |
| 74 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->icq_UDPQueue); | 82 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->d->icq_UDPQueue); |
| 75 icq_Packet *pack = 0L; | 83 icq_Packet *pack = 0L; |
| 76 if(ptr) | 84 if(ptr) |
| 77 { | 85 { |
| 78 pack = ptr->pack; | 86 pack = ptr->pack; |
| 79 list_remove(link->icq_UDPQueue, (list_node*)ptr); | 87 list_remove(link->d->icq_UDPQueue, (list_node*)ptr); |
| 80 } | 88 } |
| 81 #ifdef QUEUE_DEBUG | 89 #ifdef QUEUE_DEBUG |
| 82 if(pack) | 90 if(pack) |
| 83 printf("icq_UDPQueueGet(cmd=0x%04X)\n", icq_PacketReadUDPOutCmd(pack)); | 91 printf("icq_UDPQueueGet(cmd=0x%04X)\n", icq_PacketReadUDPOutCmd(pack)); |
| 84 #endif | 92 #endif |
| 85 return pack; | 93 return pack; |
| 86 } | 94 } |
| 87 | 95 |
| 88 icq_Packet *icq_UDPQueuePeek(ICQLINK *link) | 96 icq_Packet *icq_UDPQueuePeek(ICQLINK *link) |
| 89 { | 97 { |
| 90 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->icq_UDPQueue); | 98 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->d->icq_UDPQueue); |
| 91 if(ptr) | 99 if(ptr) |
| 92 return ptr->pack; | 100 return ptr->pack; |
| 93 else | 101 else |
| 94 return 0L; | 102 return 0L; |
| 95 } | 103 } |
| 112 void icq_UDPQueueDelete(ICQLINK *link) | 120 void icq_UDPQueueDelete(ICQLINK *link) |
| 113 { | 121 { |
| 114 #ifdef QUEUE_DEBUG | 122 #ifdef QUEUE_DEBUG |
| 115 printf("icq_UDPQueueDelete\n"); | 123 printf("icq_UDPQueueDelete\n"); |
| 116 #endif | 124 #endif |
| 117 if(link->icq_UDPQueue) | 125 if(link->d->icq_UDPQueue) |
| 118 { | 126 { |
| 119 list_delete(link->icq_UDPQueue, _icq_UDPQueueItemFree); | 127 list_delete(link->d->icq_UDPQueue, _icq_UDPQueueItemFree); |
| 120 link->icq_UDPQueue = 0; | 128 link->d->icq_UDPQueue = 0; |
| 121 } | 129 } |
| 122 } | 130 } |
| 123 | 131 |
| 124 /* Only frees the queue */ | 132 /* Only frees the queue */ |
| 125 void icq_UDPQueueFree(ICQLINK *link) | 133 void icq_UDPQueueFree(ICQLINK *link) |
| 126 { | 134 { |
| 127 #ifdef QUEUE_DEBUG | 135 #ifdef QUEUE_DEBUG |
| 128 printf("icq_UDPQueueFree\n"); | 136 printf("icq_UDPQueueFree\n"); |
| 129 #endif | 137 #endif |
| 130 if(link->icq_UDPQueue) | 138 if(link->d->icq_UDPQueue) |
| 131 list_free(link->icq_UDPQueue, _icq_UDPQueueItemFree); | 139 list_free(link->d->icq_UDPQueue, _icq_UDPQueueItemFree); |
| 132 } | 140 } |
| 133 | 141 |
| 134 int icq_UDPQueueFindSeq(void *p, va_list data) | 142 int icq_UDPQueueFindSeq(void *p, va_list data) |
| 135 { | 143 { |
| 136 WORD seq=va_arg(data, int); | 144 WORD seq=va_arg(data, int); |
| 141 { | 149 { |
| 142 icq_UDPQueueItem *ptr; | 150 icq_UDPQueueItem *ptr; |
| 143 #ifdef QUEUE_DEBUG | 151 #ifdef QUEUE_DEBUG |
| 144 printf("icq_UDPQueueDelSeq(seq=0x%04X", seq); | 152 printf("icq_UDPQueueDelSeq(seq=0x%04X", seq); |
| 145 #endif | 153 #endif |
| 146 ptr = list_traverse(link->icq_UDPQueue, icq_UDPQueueFindSeq, seq); | 154 ptr = list_traverse(link->d->icq_UDPQueue, icq_UDPQueueFindSeq, seq); |
| 147 if(ptr) | 155 if(ptr) |
| 148 { | 156 { |
| 149 #ifdef QUEUE_DEBUG | 157 #ifdef QUEUE_DEBUG |
| 150 printf(", cmd=0x%04X",icq_PacketReadUDPOutCmd(ptr->pack)); | 158 printf(", cmd=0x%04X",icq_PacketReadUDPOutCmd(ptr->pack)); |
| 151 #endif | 159 #endif |
| 152 list_remove(link->icq_UDPQueue, ptr); | 160 list_remove(link->d->icq_UDPQueue, ptr); |
| 153 _icq_UDPQueueItemFree(ptr); | 161 _icq_UDPQueueItemFree(ptr); |
| 154 } | 162 } |
| 155 #ifdef QUEUE_DEBUG | 163 #ifdef QUEUE_DEBUG |
| 156 printf(")\n"); | 164 printf(")\n"); |
| 157 #endif | 165 #endif |
| 158 } | 166 } |
| 159 | 167 |
| 160 long icq_UDPQueueInterval(ICQLINK *link) | 168 long icq_UDPQueueInterval(ICQLINK *link) |
| 161 { | 169 { |
| 162 long interval; | 170 long interval; |
| 163 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->icq_UDPQueue); | 171 icq_UDPQueueItem *ptr = (icq_UDPQueueItem*)list_first(link->d->icq_UDPQueue); |
| 164 if(ptr) | 172 if(ptr) |
| 165 { | 173 { |
| 166 interval = ptr->expire - time(0L); | 174 interval = ptr->expire - time(0L); |
| 167 return interval>=0?interval:0; | 175 return interval>=0?interval:0; |
| 168 } | 176 } |
