Mercurial > pidgin
view libfaim/aim_tlv.c @ 142:fbabd28795d2
[gaim-migrate @ 152]
Added auto-load for plugins. Rob pointed out this might be a bad idea: what
if plugins modify the buddy list; the plugins are loaded before signon, thus
before the buddy list appears. That would cause errors; then when the list
does appear, the plugin doesn't work right because it didn't start off well.
My response:
EWarmenhoven: there are ways around that
EWarmenhoven: in gaim_plugin_init you could have:
EWarmenhoven:
if (blist) {
do_the_normal_thing();
} else {
gaim_signal_connect(handle, event_signon, now_the_buddy_list_is_here, NULL);
}
EWarmenhoven: and actually, that's the way it should be for all plugins that
modify the buddy list, because there will be at least one point during
execution that it could be loaded when the person is signed off (and i'm not
talking about when they first start it up, i'm talking about when they choose
'sign off' instead of 'close' in the buddy list menu)
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 20 Apr 2000 00:12:58 +0000 |
parents | 68b230f8da5f |
children | 6ced2f1c8b24 |
line wrap: on
line source
#include <aim.h> struct aim_tlv_t *aim_grabtlv(u_char *src) { struct aim_tlv_t *dest = NULL; dest = aim_createtlv(); dest->type = src[0] << 8; dest->type += src[1]; dest->length = src[2] << 8; dest->length += src[3]; dest->value = (u_char *) malloc(dest->length*sizeof(u_char)); memset(dest->value, 0, dest->length*sizeof(u_char)); memcpy(dest->value, &(src[4]), dest->length*sizeof(u_char)); return dest; } struct aim_tlv_t *aim_grabtlvstr(u_char *src) { struct aim_tlv_t *dest = NULL; dest = aim_createtlv(); dest->type = src[0] << 8; dest->type += src[1]; dest->length = src[2] << 8; dest->length += src[3]; dest->value = (u_char *) malloc((dest->length+1)*sizeof(u_char)); memset(dest->value, 0, (dest->length+1)*sizeof(u_char)); memcpy(dest->value, &(src[4]), dest->length*sizeof(u_char)); dest->value[dest->length] = '\0'; return dest; } int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv) { int i=0; dest[i++] = newtlv->type >> 8; dest[i++] = newtlv->type & 0x00FF; dest[i++] = newtlv->length >> 8; dest[i++] = newtlv->length & 0x00FF; memcpy(&(dest[i]), newtlv->value, newtlv->length); i+=newtlv->length; return i; } struct aim_tlv_t *aim_createtlv(void) { struct aim_tlv_t *newtlv = NULL; newtlv = (struct aim_tlv_t *)malloc(sizeof(struct aim_tlv_t)); memset(newtlv, 0, sizeof(struct aim_tlv_t)); return newtlv; } int aim_freetlv(struct aim_tlv_t **oldtlv) { if (!oldtlv) return -1; if (!*oldtlv) return -1; if ((*oldtlv)->value) free((*oldtlv)->value); free(*(oldtlv)); (*oldtlv) = NULL; return 0; } int aim_puttlv_16(u_char *buf, u_short t, u_short v) { int curbyte=0; curbyte += aimutil_put16(buf+curbyte, t&0xffff); curbyte += aimutil_put16(buf+curbyte, 0x0002); curbyte += aimutil_put16(buf+curbyte, v&0xffff); return curbyte; }