6 outstanding_snacs is a list of aim_snac_t structs. A SNAC should be added
7 whenever a new SNAC is sent and it should remain in the list until the
8 response for it has been receieved.
14 struct aim_snac_t *aim_outstanding_snacs = NULL;
15 u_long aim_snac_nextid = 0x00000001;
17 u_long aim_newsnac(struct aim_snac_t *newsnac)
19 struct aim_snac_t *local = NULL;
21 local = (struct aim_snac_t *)malloc(sizeof(struct aim_snac_t));
22 memcpy(local, newsnac, sizeof(struct aim_snac_t));
24 local->issuetime = time(&local->issuetime);
26 if (aim_outstanding_snacs!=NULL)
28 struct aim_snac_t *cur = aim_outstanding_snacs;
30 if (cur->next == NULL)
36 for (;cur->next!=NULL; cur=cur->next)
43 aim_outstanding_snacs = local;
44 aim_outstanding_snacs->next = NULL;
50 /* FIXME: there's a bug in here... just don't have more than two outstanding
51 SNACs and you'll be ok */
52 struct aim_snac_t *aim_remsnac(u_long id)
54 struct aim_snac_t *cur = aim_outstanding_snacs;
60 struct aim_snac_t *ret = NULL;
61 for(;(cur->next!=NULL) && (cur->id != id);cur=cur->next)
76 aim_outstanding_snacs = NULL;
86 This is for cleaning up old SNACs that either don't get replies or
87 a reply was never received for. Garabage collection. Plain and simple.
89 maxage is the _minimum_ age in seconds to keep SNACs
92 int aim_cleansnacs(int maxage)
94 struct aim_snac_t *cur = aim_outstanding_snacs;
97 curtime = time(&curtime);
102 if ( (cur) && (((cur->issuetime) + maxage) < curtime))
104 printf("aimsnac: WARNING purged obsolete snac %ul\n", (unsigned int) cur->id);
106 aim_remsnac(cur->id);