# HG changeset patch # User Luke Schierer # Date 1077909927 0 # Node ID 43dec50d8d5132cb9801b4727d243fc7c7606b32 # Parent 8ae61bbc479f9845a9ccf442298bf2291b684ca0 [gaim-migrate @ 9078] " An update to com_err on debian appears to have broken the ability of the zephyr plugin to compile with krb4. Here's a patch, tested against comerr-dev 2.1-1.34+1.35-WIP-2004.01.31-1 in debian, and an older version of com_err local to MIT, that fixes this. I haven't tested this against non-kerberized zephyr, or against other versions of com_err. A lot of the comerr (error table) related code appears to be unnecessary. This also fixes two other issues: 1) Upon each login, every entry in the "Anyone" group was getting added to the Buddies group. I didn't notice this earlier, since I usually don't restart gaim very often. 2) No more compile warnings. This also replaces occurrences of ZGetSender and ZGetRealm with gaim_zephyr_get_sender and gaim_zephyr_get_realm(), in preparation for getting gaim to alternately use an external program, "tzc" to talk to zephyr." --Arun A Tharuvai, aka, the lone gaim zepher user committer: Tailor Script diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/ZCkAuth.c --- a/src/protocols/zephyr/ZCkAuth.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/ZCkAuth.c Fri Feb 27 19:25:27 2004 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: warmenhoven $ + * $Author: lschiere $ * * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -53,7 +53,7 @@ our_checksum = des_quad_cksum(notice->z_packet, NULL, notice->z_default_format+ strlen(notice->z_default_format)+1- - notice->z_packet, 0, cred.session); + notice->z_packet, 0, (C_Block *)cred.session); #endif /* if mismatched checksum, then the packet was corrupted */ return ((our_checksum == notice->z_checksum) ? ZAUTH_YES : ZAUTH_FAILED); diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/ZFmtAuth.c --- a/src/protocols/zephyr/ZFmtAuth.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/ZFmtAuth.c Fri Feb 27 19:25:27 2004 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: warmenhoven $ + * $Author: lschiere $ * * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -43,7 +43,7 @@ newnotice.z_checksum = 0; #else newnotice.z_checksum = - (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session); + (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, (C_Block*)session); #endif if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, NULL, NULL)) != ZERR_NONE) diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/ZMkAuth.c --- a/src/protocols/zephyr/ZMkAuth.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/ZMkAuth.c Fri Feb 27 19:25:27 2004 +0000 @@ -10,12 +10,12 @@ * For copying and distribution information, see the file * "mit-copyright.h". */ -/* $Id: ZMkAuth.c 8940 2004-02-07 17:40:57Z lschiere $ */ +/* $Id: ZMkAuth.c 9078 2004-02-27 19:25:27Z lschiere $ */ #include #ifndef lint -static const char rcsid_ZMakeAuthentication_c[] = "$Id: ZMkAuth.c 8940 2004-02-07 17:40:57Z lschiere $"; +static const char rcsid_ZMakeAuthentication_c[] = "$Id: ZMkAuth.c 9078 2004-02-27 19:25:27Z lschiere $"; #endif #ifdef ZEPHYR_USES_KERBEROS @@ -84,11 +84,11 @@ if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, __Zephyr_realm, &cred)) != 0) return result; - checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, cred.session); + checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, (C_Block *)cred.session); checksum ^= des_quad_cksum(cend, NULL, buffer + *len - cend, 0, - cred.session); + (C_Block *)cred.session); checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len, - 0, cred.session); + 0, (C_Block *)cred.session); notice->z_checksum = checksum; ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum); diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/et_name.c --- a/src/protocols/zephyr/et_name.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/et_name.c Fri Feb 27 19:25:27 2004 +0000 @@ -5,9 +5,14 @@ */ #include -#include "error_table.h" +/* #include "error_table.h" */ #include "mit-sipb-copyright.h" + +#define ERRCODE_RANGE 8 /* # of bits to shift table number */ +#define BITS_PER_CHAR 6 /* # bits to shift per character in name */ + + #ifndef lint static const char copyright[] = "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology"; diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/init_et.c --- a/src/protocols/zephyr/init_et.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/init_et.c Fri Feb 27 19:25:27 2004 +0000 @@ -10,40 +10,41 @@ */ #include -#include "error_table.h" +/* #include "error_table.h" */ #include "mit-sipb-copyright.h" #ifndef lint static const char rcsid_init_et_c[] = "$Header$"; #endif - +/* struct foobar { struct et_list etl; struct error_table et; }; - +*/ extern struct et_list * _et_list; -int init_error_table(msgs, base, count) - const char * const * msgs; - int base; - int count; -{ - struct foobar * new_et; +/* int init_error_table(msgs, base, count) */ +/* const char * const * msgs; */ +/* int base; */ +/* int count; */ +/* { */ +/* struct foobar * new_et; */ - if (!base || !count || !msgs) - return 0; +/* if (!base || !count || !msgs) */ +/* return 0; */ - new_et = (struct foobar *) malloc(sizeof(struct foobar)); - if (!new_et) - return errno; /* oops */ - new_et->etl.table = &new_et->et; - new_et->et.msgs = msgs; - new_et->et.base = base; - new_et->et.n_msgs= count; +/* new_et = (struct foobar *) malloc(sizeof(struct foobar)); */ +/* if (!new_et) */ +/* return errno; /\* oops *\/ */ +/* new_et->etl.table = &new_et->et; */ +/* new_et->et.msgs = msgs; */ +/* new_et->et.base = base; */ +/* new_et->et.n_msgs= count; */ - new_et->etl.next = _et_list; - _et_list = &new_et->etl; - return 0; -} +/* new_et->etl.next = _et_list; */ +/* _et_list = &new_et->etl; */ +/* return 0; */ +/* } */ + diff -r 8ae61bbc479f -r 43dec50d8d51 src/protocols/zephyr/zephyr.c --- a/src/protocols/zephyr/zephyr.c Fri Feb 27 17:59:41 2004 +0000 +++ b/src/protocols/zephyr/zephyr.c Fri Feb 27 19:25:27 2004 +0000 @@ -72,6 +72,7 @@ return;\ } +static const char *local_zephyr_normalize(const char *); static const char *zephyr_normalize(const GaimAccount *, const char *); /* this is so bad, and if Zephyr weren't so fucked up to begin with I @@ -121,6 +122,18 @@ g_free(zt); } +static const char* gaim_zephyr_get_sender() { + /* will be useful once this plugin can use a backend other + than libzephyr */ + return ZGetSender(); +} + +static const char* gaim_zephyr_get_realm() { + /* will be useful once this plugin can use a backend other + than libzephyr */ + return ZGetRealm(); +} + /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or * wildcards in each field of zt1. */ static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2) @@ -329,7 +342,7 @@ { GList *curr; for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { - if (!g_ascii_strcasecmp(zephyr_normalize(NULL, who), (char*)curr->data)) { + if (!g_ascii_strcasecmp(local_zephyr_normalize(who), (char*)curr->data)) { g_free((char*)curr->data); pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); return TRUE; @@ -386,11 +399,11 @@ char *buf, *buf2; char *send_inst; char *realmptr; - char *sendertmp; GaimConversation *gconv1; GaimConvChat *gcc; char *ptr = notice.z_message + strlen(notice.z_message) + 1; int len = notice.z_message_len - ((int)ptr - (int)notice.z_message); + char *sendertmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); GaimConvImFlags flags = 0; if (len > 0) { buf = g_malloc(len + 1); @@ -426,7 +439,7 @@ sendertmp = g_strdup_printf("%s",notice.z_sender); if ((realmptr = strchr(sendertmp,'@')) != NULL) { realmptr++; - if (!g_ascii_strcasecmp(realmptr,ZGetRealm())) { + if (!g_ascii_strcasecmp(realmptr,gaim_zephyr_get_realm())) { realmptr--; sprintf(realmptr,"%c",'\0'); send_inst = g_strdup_printf("%s %s",sendertmp, @@ -443,7 +456,7 @@ gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account); gcc = gaim_conversation_get_chat_data(gconv1); - gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); + /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */ for(gltmp = gaim_conv_chat_get_users(gcc);gltmp;gltmp=gltmp->next) { if (!g_ascii_strcasecmp(gltmp->data,sendertmp) ) found = 1; @@ -514,7 +527,7 @@ continue; if(b->account->gc == zgc) { const char *chk; - chk = zephyr_normalize(b->account, b->name); + chk = local_zephyr_normalize(b->name); /* doesn't matter if this fails or not; we'll just move on to the next one */ ZRequestLocations(chk, &ald, UNACKED, ZAUTH); free(ald.user); @@ -572,15 +585,14 @@ if (buff[0]) { triple = g_strsplit(buff, ",", 3); if (triple[0] && triple[1] ) { - /* char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"), ZGetRealm()); */ - char *tmp = g_strdup_printf("%s",ZGetSender()); + char *tmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); char *atptr; sub.zsub_class = triple[0]; sub.zsub_classinst = triple[1]; if(triple[2] == NULL) { recip = g_malloc0(1); } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { - recip = g_strdup_printf("%s",ZGetSender()); + recip = g_strdup_printf("%s",gaim_zephyr_get_sender()); } else if (!g_ascii_strcasecmp(triple[2], "*")) { /* wildcard * form of class,instance,* */ @@ -594,7 +606,7 @@ * If realm is local realm, blank recipient, else * @REALM-NAME */ - char *realmat = g_strdup_printf("@%s", ZGetRealm()); + char *realmat = g_strdup_printf("@%s", gaim_zephyr_get_realm()); if (!g_ascii_strcasecmp(atptr, realmat)) recip = g_malloc0(1); else @@ -667,11 +679,11 @@ z_call_s(ZInitialize(), "Couldn't initialize zephyr"); z_call_s(ZOpenPort(NULL), "Couldn't open port"); - z_call_s(ZSetLocation(gaim_account_get_string(zgc->account,"exposure_level",EXPOSE_REALMVIS)), "Couldn't set location"); + z_call_s(ZSetLocation((char *)gaim_account_get_string(zgc->account,"exposure_level",EXPOSE_REALMVIS)), "Couldn't set location"); sub.zsub_class = "MESSAGE"; sub.zsub_classinst = "PERSONAL"; - sub.zsub_recipient = ZGetSender(); + sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); /* we don't care if this fails. i'm lying right now. */ if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { @@ -711,7 +723,7 @@ if (triple[2] != NULL) { if (!g_ascii_strcasecmp(triple[2], "")) { fprintf(fd, "%s,%s,*\n", triple[0], triple[1]); - } else if (!g_ascii_strcasecmp(triple[2], ZGetSender())) { + } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) { fprintf(fd, "%s,%s,%%me%%\n",triple[0],triple[1]); } else { fprintf(fd, "%s\n", zt->name); @@ -756,7 +768,7 @@ /* We should only strip the realm name if the principal is in the user's realm */ - if (!g_ascii_strcasecmp(ptr2,ZGetRealm())) { + if (!g_ascii_strcasecmp(ptr2,gaim_zephyr_get_realm())) { *ptr = '\0'; } } @@ -814,7 +826,18 @@ b = gaim_buddy_new(zgc->account, buddy, NULL); gaim_blist_add_buddy(b, NULL, group, NULL); } - +} + +static void zephyr_add_buddies(GaimConnection *gc, GList* buddies) { + GaimGroup *group; + if (!(group = gaim_find_group(_("Anyone")))) { + group = gaim_group_new(_("Anyone")); + gaim_blist_add_group(group, NULL); + } + while (buddies) { + zephyr_add_buddy(gc, buddies->data, group); + buddies = buddies->next; + } } static void zephyr_remove_buddy(GaimConnection *gc, const char *buddy, const char *group) { @@ -826,6 +849,17 @@ fprintf(stderr,"attempt to remove non-existent buddy %s\n",buddy); } +static void zephyr_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { + GaimBuddy *b; + while(buddies) { + if ((b=gaim_find_buddy(zgc->account,buddies->data))) { + gaim_blist_remove_buddy(b); + } else { + fprintf(stderr,"attempt to remove non-existent buddy %s\n",(char *)buddies->data); + } + } +} + static int zephyr_chat_send(GaimConnection *gc, int id, const char *im) { ZNotice_t notice; @@ -850,8 +884,8 @@ gconv1 = gaim_find_conversation_with_account(zt->name,zgc->account); gcc = gaim_conversation_get_chat_data(gconv1); - if(!(inst = gaim_conv_chat_get_topic(gcc))) - inst = notice.z_class_inst; + if(!(inst = (char *)gaim_conv_chat_get_topic(gcc))) + inst = (char *)notice.z_class_inst; bzero((char *)¬ice, sizeof(notice)); notice.z_kind = ACKED; @@ -860,9 +894,9 @@ notice.z_class = zt->class; notice.z_class_inst = inst; if (!g_ascii_strcasecmp(zt->recipient, "*")) - notice.z_recipient = zephyr_normalize(gc->account, ""); + notice.z_recipient = local_zephyr_normalize(""); else - notice.z_recipient = zephyr_normalize(gc->account, zt->recipient); + notice.z_recipient = local_zephyr_normalize(zt->recipient); notice.z_sender = 0; notice.z_default_format = "Class $class, Instance $instance:\n" @@ -915,11 +949,25 @@ if (!g_ascii_strcasecmp(orig, "")) { buf[0] = '\0'; return buf; + } else { + g_snprintf(buf,80,"%s",orig); + } + return buf; +} + + +static const char *local_zephyr_normalize(const char *orig) +{ + static char buf[80]; + if (!g_ascii_strcasecmp(orig, "")) { + buf[0] = '\0'; + return buf; } + if (strchr(orig, '@')) { g_snprintf(buf, 80, "%s", orig); } else { - g_snprintf(buf, 80, "%s@%s", orig, ZGetRealm()); + g_snprintf(buf,80,"%s@%s",orig,gaim_zephyr_get_realm()); } return buf; } @@ -928,12 +976,12 @@ { ZAsyncLocateData_t ald; - if (ZRequestLocations(zephyr_normalize(gc->account, who), &ald, UNACKED, ZAUTH) + if (ZRequestLocations(local_zephyr_normalize(who), &ald, UNACKED, ZAUTH) != ZERR_NONE) { return; } pending_zloc_names = g_list_append(pending_zloc_names, - g_strdup(zephyr_normalize(gc->account, who))); + g_strdup(local_zephyr_normalize(who))); } static GList *zephyr_buddy_menu(GaimConnection *gc, const char *who) @@ -1015,7 +1063,7 @@ return; if (!g_ascii_strcasecmp(recip, "%me%")) - recip = ZGetSender(); + recip = gaim_zephyr_get_sender(); zt1 = new_triple(classname, instname, recip); zt2 = find_sub_by_triple(zt1); @@ -1060,7 +1108,7 @@ zephyr_triple *zt; GaimConversation *gconv; GaimConvChat* gcc; - char* sender = ZGetSender(); + char* sender = (char *)gaim_zephyr_get_sender(); zt = find_sub_by_id(id); gconv = gaim_find_conversation_with_account(zt->name,zgc->account); @@ -1099,9 +1147,9 @@ NULL, NULL, zephyr_add_buddy, - NULL, + zephyr_add_buddies, zephyr_remove_buddy, - NULL, + zephyr_remove_buddies, NULL, NULL, NULL,