# HG changeset patch # User Mark Doliner # Date 1114393981 0 # Node ID 5727afad0fb8956242ad1bf5aa9d510428e07ef0 # Parent f38bda97f981efdce113056b897d545c6f058951 [gaim-migrate @ 12553] sf patch #991208, from Arun A Tharuvai "Here's a patch, against current CVS, to build and compile zephyr on Windows, with, or without Kerberos 4 Authentication. In order to be built (and run) with Kerberos 4 authentication, the Kerberos for Windows SDK (version 2.6.3 is the current version) (licensed under the MIT license) and runtimes, both available from http://web.mit.edu/kerberos/www/dist/index.html#KFW2.6.3 Also, USE_KRB4 should be set to true in the attached Makefile.mingw As on the UNIX side, an external 'zhm' binary needs to run for zephyr to work. Source and a win32 executable (using code from gaim's libzephyr, and also MIT's zephyr distribution), can be found at http://web.mit.edu/aatharuv/www/zhm-windows.html" I decided not to make zephyr compiled by default in Windows. If you want to compile it, I think you you can modify the root Makefile.mingw or cd to the src/protocols/zephyr/ directory and run "make -f Makefile.mingw" using make from mingw committer: Tailor Script diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/Makefile.mingw --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/protocols/zephyr/Makefile.mingw Mon Apr 25 01:53:01 2005 +0000 @@ -0,0 +1,204 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of libzephyr +# + +# +# PATHS +# + +INCLUDE_DIR := . +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +ZEPHYR_ROOT := . +KRB4_TOP := ../../../../win32-dev/kfw-2.6.3-final.fixed +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir + +USE_KRB4 := false + +## +## VARIABLE DEFINITIONS +## + +TARGET = libzephyr + +# Compiler Options + +CFLAGS = + +DEFINES = + +# Static or Plugin... +ifeq ($(TYPE),STATIC) + DEFINES += -DSTATIC + DLL_INSTALL_DIR = $(GAIM_INSTALL_DIR) +else +ifeq ($(TYPE),PLUGIN) + DLL_INSTALL_DIR = $(GAIM_INSTALL_DIR)/plugins +endif +endif + +DEFINES += -DWIN32 -DKRB5_SYSTYPES__ + +ifeq ($(USE_KRB4),true) + DEFINES += -DZEPHYR_USES_KERBEROS +endif + +## +## INCLUDE MAKEFILES +## + +include $(GAIM_TOP)/src/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += -I$(ZEPHYR_ROOT) \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(GAIM_TOP)/src \ + -I$(GAIM_TOP)/src/win32 \ + -I$(GAIM_TOP) + +ifeq ($(USE_KRB4), true) + INCLUDE_PATHS += -I$(KRB4_TOP)/inc/krb4 +endif + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(GAIM_TOP)/src + +ifeq ($(USE_KRB4), true) + LIB_PATHS+=-L$(KRB4_TOP)/lib/i386 +endif + +## +## SOURCES, OBJECTS +## + +C_SRC = ZAsyncLocate.c \ + ZCkAuth.c \ + ZCkIfNot.c \ + ZClosePort.c \ + ZCmpUID.c \ + ZCmpUIDP.c \ +ZFlsLocs.c \ +ZFlsSubs.c \ +ZFmtAuth.c \ +ZFmtList.c \ +ZFmtNotice.c \ +ZFmtRaw.c \ +ZFmtRawLst.c \ +ZFmtSmRLst.c \ +ZFmtSmRaw.c \ +ZFreeNot.c \ +ZGetLocs.c \ +ZGetSender.c \ +ZGetSubs.c \ +ZGetWGPort.c \ +ZIfNotice.c \ +ZInit.c \ +ZLocations.c \ +ZMakeAscii.c \ +ZMkAuth.c \ +ZNewLocU.c \ +ZOpenPort.c \ +ZParseNot.c \ +ZPeekIfNot.c \ +ZPeekNot.c \ +ZPeekPkt.c \ +ZPending.c \ +ZReadAscii.c \ +ZRecvNot.c \ +ZRecvPkt.c \ +ZRetSubs.c \ +ZSendList.c \ +ZSendNot.c \ +ZSendPkt.c \ +ZSendRLst.c \ +ZSendRaw.c \ +ZSetDest.c \ +ZSetFD.c \ +ZSetSrv.c \ +ZSubs.c \ +ZVariables.c \ +ZWait4Not.c \ +ZhmStat.c \ +Zinternal.c \ +error_message.c \ +et_name.c \ +init_et.c \ +zephyr_err.c \ +zephyr.c + + +OBJECTS = $(C_SRC:%.c=%.o) + + +## +## LIBRARIES +## + +LIBS = -lgtk-win32-2.0 \ + -lglib-2.0 \ + -lgdk-win32-2.0 \ + -lgmodule-2.0 \ + -lgobject-2.0 \ + -lws2_32 \ + -lintl \ + -lgaim + +ifeq ($(USE_KRB4),true) + LIBS+= -lkrbv4w32 +endif + +## +## RULES +## + +# How to make a C file + +%.o: %.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@ -c $< + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: $(TARGET).dll + +install: + cp $(ZEPHYR_ROOT)/$(TARGET).dll $(DLL_INSTALL_DIR) + + +## +## BUILD Dependencies +## + +$(GAIM_TOP)/src/gaim.lib: + $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib + +## +## BUILD DLL +## + +$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--enable-stdcall-fixup -Wl,--out-implib,$(TARGET).lib -o $(TARGET).dll + + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf $(TARGET).dll + rm -rf $(TARGET).lib diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZAsyncLocate.c --- a/src/protocols/zephyr/ZAsyncLocate.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZAsyncLocate.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Marc Horowitz * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1990,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -15,12 +15,12 @@ #include "internal.h" #ifndef lint -static const char rcsid_ZAsyncLocate_c[] = "$Id: ZAsyncLocate.c 9553 2004-04-24 09:00:37Z chipx86 $"; +static const char rcsid_ZAsyncLocate_c[] = "$Id: ZAsyncLocate.c 12553 2005-04-25 01:53:01Z thekingant $"; #endif Code_t ZRequestLocations(user, zald, kind, auth) const char *user; - register ZAsyncLocateData_t *zald; + ZAsyncLocateData_t *zald; ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */ Z_AuthProc auth; { @@ -60,8 +60,8 @@ } Code_t ZParseLocations(notice,zald,nlocs,user) - register ZNotice_t *notice; - register ZAsyncLocateData_t *zald; + ZNotice_t *notice; + ZAsyncLocateData_t *zald; int *nlocs; char **user; { @@ -160,7 +160,7 @@ } void ZFreeALD(zald) - register ZAsyncLocateData_t *zald; + ZAsyncLocateData_t *zald; { if (!zald) return; diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZGetSender.c --- a/src/protocols/zephyr/ZGetSender.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZGetSender.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: lschiere $ + * $Author: thekingant $ * * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -16,10 +16,12 @@ #ifndef lint static const char rcsid_ZGetSender_c[] = - "$Id: ZGetSender.c 10997 2004-09-18 22:25:12Z lschiere $"; + "$Id: ZGetSender.c 12553 2005-04-25 01:53:01Z thekingant $"; #endif +#ifndef WIN32 #include +#endif char *ZGetSender() { @@ -27,10 +29,15 @@ #ifdef ZEPHYR_USES_KERBEROS char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ]; static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = ""; + long int kerror; #else static char sender[128] = ""; #endif +#ifdef WIN32 + unsigned long sender_size = 127; +#endif + /* Return it if already cached */ /* if (*sender) @@ -38,19 +45,26 @@ */ #ifdef ZEPHYR_USES_KERBEROS - if (krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm) == KSUCCESS) + if ((kerror = krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm)) == KSUCCESS) { (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""), pinst, prealm); return (sender); + } else { + sprintf(sender,"%s@%s",(username?username:"unknown"),__Zephyr_realm); + return (sender); } #endif /* XXX a uid_t is a u_short (now), but getpwuid * wants an int. AARGH! */ +#ifdef WIN32 + GetUserName(sender, &sender_size); +#else pw = getpwuid((int) getuid()); if (!pw) return ("unknown"); (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm); +#endif return (sender); } diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZGetWGPort.c --- a/src/protocols/zephyr/ZGetWGPort.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZGetWGPort.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: datallah $ + * $Author: thekingant $ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -23,10 +23,18 @@ char *envptr, name[128]; FILE *fp; int wgport; - +#ifdef WIN32 + long int buffsize= 128; + char tempdir[buffsize]; +#endif envptr = getenv("WGFILE"); if (!envptr) { +#ifdef WIN32 + GetTempPath(buffsize,tempdir); + GetTempFileName(tempdir,"wg.",0,name); +#else (void) sprintf(name, "/tmp/wg.%d", getuid()); +#endif envptr = name; } if (!(fp = fopen(envptr, "r"))) diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZInit.c --- a/src/protocols/zephyr/ZInit.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZInit.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -17,13 +17,23 @@ "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZInitialize.c,v 1.17 89/05/30 18:11:25 jtkohl Exp $"; #endif +#ifdef ZEPHYR_USES_KERBEROS +#ifdef WIN32 + +#else +#include +#endif +#endif + #include "internal.h" +#ifdef WIN32 +#include +#else #include -#ifdef ZEPHYR_USES_KERBEROS -#include #endif + #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif @@ -43,7 +53,7 @@ int krbval; char d1[ANAME_SZ], d2[INST_SZ]; - initialize_krb_error_table(); + /* initialize_krb_error_table(); */ #endif initialize_zeph_error_table(); diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZLocations.c --- a/src/protocols/zephyr/ZLocations.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZLocations.c Mon Apr 25 01:53:01 2005 +0000 @@ -20,7 +20,9 @@ #include "internal.h" +#ifndef WIN32 #include +#endif extern char *getenv(); extern int errno; @@ -55,11 +57,14 @@ int retval; time_t ourtime; ZNotice_t notice, retnotice; - char *bptr[3], *p; + char *bptr[3]; #ifndef X_DISPLAY_MISSING char *display; #endif +#ifndef WIN32 char *ttyp; + char *p; +#endif struct hostent *hent; short wg_port = ZGetWGPort(); @@ -95,6 +100,9 @@ mytty[sizeof(mytty)-1] = '\0'; } else { #endif +#ifdef WIN32 + strcpy(mytty,"WinGaim"); +#else ttyp = ttyname(0); if (ttyp && *ttyp) { p = strchr(ttyp + 1, '/'); @@ -102,6 +110,7 @@ } else { strcpy(mytty, "unknown"); } +#endif #ifndef X_DISPLAY_MISSING } #endif diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZMkAuth.c --- a/src/protocols/zephyr/ZMkAuth.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZMkAuth.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,22 +4,30 @@ * Created by: Robert French * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ -/* $Id: ZMkAuth.c 9554 2004-04-24 09:02:28Z chipx86 $ */ +/* $Id: ZMkAuth.c 12553 2005-04-25 01:53:01Z thekingant $ */ #include "internal.h" #ifndef lint -static const char rcsid_ZMakeAuthentication_c[] = "$Id: ZMkAuth.c 9554 2004-04-24 09:02:28Z chipx86 $"; +static const char rcsid_ZMakeAuthentication_c[] = "$Id: ZMkAuth.c 12553 2005-04-25 01:53:01Z thekingant $"; +#endif + +#ifndef ERROR_TABLE_BASE_krb +#define ERROR_TABLE_BASE_krb (39525376L) #endif #ifdef ZEPHYR_USES_KERBEROS +#ifdef WIN32 + +#else #include +#endif static long last_authent_time = 0L; static KTEXT_ST last_authent; #endif diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZOpenPort.c --- a/src/protocols/zephyr/ZOpenPort.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZOpenPort.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -17,7 +17,11 @@ #endif #include "internal.h" +#ifdef WIN32 +#include +#else #include +#endif Code_t ZOpenPort(port) unsigned short *port; diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZSendPkt.c --- a/src/protocols/zephyr/ZSendPkt.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZSendPkt.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -18,8 +18,11 @@ #endif #include "internal.h" +#ifdef WIN32 +#include +#else #include - +#endif static int wait_for_hmack(); Code_t ZSendPacket(packet, len, waitforack) diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZVariables.c --- a/src/protocols/zephyr/ZVariables.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZVariables.c Mon Apr 25 01:53:01 2005 +0000 @@ -5,7 +5,7 @@ * Created by: Robert French * * $Source$ - * $Author: nosnilmot $ + * $Author: thekingant $ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -21,7 +21,9 @@ #include "util.h" #include +#ifndef WIN32 #include +#endif static int get_localvarfile __P((char *bfr)); static char *get_varval __P((char *fn, char *val)); @@ -38,7 +40,11 @@ if ((ret = get_varval(varfile, var)) != ZERR_NONE) return (ret); +#ifdef WIN32 + sprintf(varfile, "C:\\zephyr\\zephyr.var"); +#else sprintf(varfile, "%s/zephyr.vars", CONFDIR); +#endif return (get_varval(varfile, var)); } @@ -116,17 +122,26 @@ char *bfr; { const char *envptr; +#ifndef WIN32 struct passwd *pwd; - envptr = gaim_home_dir(); +#else + envptr = getenv("HOME"); + if (!envptr) + envptr = getenv("HOMEPATH"); + if (!envptr) + envptr = "C:\\"; +#endif if (envptr) (void) strcpy(bfr, envptr); else { +#ifndef WIN32 if (!(pwd = getpwuid((int) getuid()))) { fprintf(stderr, "Zephyr internal failure: Can't find your entry in /etc/passwd\n"); return (1); } (void) strcpy(bfr, pwd->pw_dir); +#endif } (void) strcat(bfr, "/"); @@ -174,7 +189,9 @@ while (*cp && !isspace(*cp) && (*cp != '=')) cp++; +#ifndef WIN32 #define max(a,b) ((a > b) ? (a) : (b)) +#endif if (strncasecmp(bfr, var, max(strlen(var),cp - bfr))) return(0); /* var is not the var in diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZWait4Not.c --- a/src/protocols/zephyr/ZWait4Not.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZWait4Not.c Mon Apr 25 01:53:01 2005 +0000 @@ -5,7 +5,7 @@ * Created by: * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -19,7 +19,27 @@ #endif #include "internal.h" + +#ifdef WIN32 +#include + +#ifndef ZEPHYR_USES_KERBEROS +static int gettimeofday(struct timeval* tv, struct timezone* tz){ + union { + long long ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } _now; + + GetSystemTimeAsFileTime( &(_now.ft) ); + tv->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL ); + tv->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL); + return 0; + } +#endif + +#else #include +#endif Code_t Z_WaitForNotice (notice, pred, arg, timeout) ZNotice_t *notice; @@ -43,7 +63,7 @@ FD_ZERO (&fdmask); tv.tv_sec = timeout; tv.tv_usec = 0; - gettimeofday (&t0, (struct timezone *) 0); + gettimeofday (&t0, (struct timezone *)NULL); t0.tv_sec += timeout; while (1) { FD_SET (fd, &fdmask); @@ -58,7 +78,7 @@ if (retval != ZERR_NONOTICE) /* includes ZERR_NONE */ return retval; } - gettimeofday (&tv, (struct timezone *) 0); + gettimeofday (&tv, (struct timezone *) NULL); tv.tv_usec = t0.tv_usec - tv.tv_usec; if (tv.tv_usec < 0) { tv.tv_usec += 1000000; diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/ZhmStat.c --- a/src/protocols/zephyr/ZhmStat.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/ZhmStat.c Mon Apr 25 01:53:01 2005 +0000 @@ -3,7 +3,7 @@ * * Created by: Marc Horowitz * - * $Id: ZhmStat.c 9554 2004-04-24 09:02:28Z chipx86 $ + * $Id: ZhmStat.c 12553 2005-04-25 01:53:01Z thekingant $ * * Copyright (c) 1996 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -11,7 +11,12 @@ */ #include "internal.h" + +#ifdef WIN32 +#include +#else #include +#endif #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/Zinternal.c --- a/src/protocols/zephyr/Zinternal.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/Zinternal.c Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Robert French * * $Source$ - * $Author: chipx86 $ + * $Author: thekingant $ * * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of * Technology. @@ -14,13 +14,32 @@ /* $Header$ */ #include "internal.h" +#ifdef WIN32 +#include + +#ifndef ZEPHYR_USES_KERBEROS + int gettimeofday(struct timeval* p, struct timezone* tz ){ + union { + long long ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } _now; + + GetSystemTimeAsFileTime( &(_now.ft) ); + p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL ); + p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL); + return 0; + } +#endif + +#else #include #include #include +#endif #ifndef lint static const char rcsid_Zinternal_c[] = - "$Id: Zinternal.c 9554 2004-04-24 09:02:28Z chipx86 $"; + "$Id: Zinternal.c 12553 2005-04-25 01:53:01Z thekingant $"; static const char copyright[] = "Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology."; #endif diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/internal.h --- a/src/protocols/zephyr/internal.h Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/internal.h Mon Apr 25 01:53:01 2005 +0000 @@ -1,10 +1,31 @@ #ifndef __INTERNAL_H__ #define __INTERNAL_H__ +#if 0 +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; +#endif #include -#include + +#include +#ifndef WIN32 #include +#endif + + + +#ifdef WIN32 + +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 512 +#endif + +#define ETIMEDOUT WSAETIMEDOUT +#define EADDRINUSE WSAEADDRINUSE +#endif #ifdef ZEPHYR_USES_HESIOD #include diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/sysdep.h --- a/src/protocols/zephyr/sysdep.h Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/sysdep.h Mon Apr 25 01:53:01 2005 +0000 @@ -4,7 +4,7 @@ * Created by: Greg Hudson * * $Source$ - * $Author: warmenhoven $ + * $Author: thekingant $ * $Zephyr: /mit/zephyr/src/include/zephyr/RCS/zephyr_conf.h,v 1.8 90/12/21 17:40:40 raeburn Exp $ * * Copyright (c) 1988,1991 by the Massachusetts Institute of Technology. @@ -21,7 +21,10 @@ #include #include #include +#ifndef WIN32 #include +#endif + #include #include #include @@ -163,15 +166,21 @@ /* Kerberos compatibility. */ #ifdef ZEPHYR_USES_KERBEROS # include +#ifdef WIN32 + +#else # include +#endif /* WIN32 */ # include +#ifndef WIN32 # ifndef HAVE_KRB_GET_ERR_TEXT # define krb_get_err_text(n) krb_err_txt[n] # endif +#endif /* WIN32 */ # ifndef HAVE_KRB_LOG # define krb_log log # endif -#endif +#endif /* ZEPHYR_USES_KERBEROS */ #ifdef HAVE_SYS_UIO_H # include diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/zephyr.c --- a/src/protocols/zephyr/zephyr.c Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/zephyr.c Mon Apr 25 01:53:01 2005 +0000 @@ -143,6 +143,9 @@ return;\ } +#ifdef WIN32 +extern const char *username; +#endif Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { @@ -203,16 +206,16 @@ /* just for debugging */ static void handle_unknown(ZNotice_t notice) { - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind)); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message); - gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len); + gaim_debug_error("zephyr","z_packet: %s\n", notice.z_packet); + gaim_debug_error("zephyr","z_version: %s\n", notice.z_version); + gaim_debug_error("zephyr","z_kind: %d\n", (int)(notice.z_kind)); + gaim_debug_error("zephyr","z_class: %s\n", notice.z_class); + gaim_debug_error("zephyr","z_class_inst: %s\n", notice.z_class_inst); + gaim_debug_error("zephyr","z_opcode: %s\n", notice.z_opcode); + gaim_debug_error("zephyr","z_sender: %s\n", notice.z_sender); + gaim_debug_error("zephyr","z_recipient: %s\n", notice.z_recipient); + gaim_debug_error("zephyr","z_message: %s\n", notice.z_message); + gaim_debug_error("zephyr","z_message_len: %d\n", notice.z_message_len); } @@ -325,7 +328,7 @@ } else { utf8 = g_convert(string, len, "UTF-8", zephyr->encoding, NULL, NULL, &err); if (err) { - gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message); + gaim_debug_error("zephyr", "recv conversion error: %s\n", err->message); utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); g_error_free(err); } @@ -846,7 +849,7 @@ send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); send_inst_utf8 = zephyr_recv_convert(gc,send_inst, strlen(send_inst)); if (!send_inst_utf8) { - gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst); + gaim_debug_error("zephyr","send_inst %s became null\n", send_inst); send_inst_utf8 = "malformed instance"; } @@ -1196,6 +1199,46 @@ return TRUE; } +#ifdef WIN32 + +static gint check_loc(gpointer_data) +{ + GaimBlistNode *gnode, *cnode, *bnode; + ZLocations_t locations; + int numlocs; + int one = 1; + + for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { + if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) + continue; + for (cnode = gnode->child; cnode; cnode = cnode->next) { + if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) + continue; + for (bnode = cnode->child; bnode; bnode = bnode->next) { + GaimBuddy *b = (GaimBuddy *) bnode; + + if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) + continue; + if (b->account->gc == zgc) { + char *chk; + chk = local_zephyr_normalize(b->name); + ZLocateUser(chk,&numlocs, ZAUTH); + if (numlocs) { + int i; + for(i=0;iname,1,0,0,0,0); + } + } + } + } + } + } + return TRUE; +} + +#else + static gint check_loc(gpointer data) { GaimBlistNode *gnode, *cnode, *bnode; @@ -1261,6 +1304,8 @@ return TRUE; } +#endif /* WIN32 */ + static char *get_exposure_level() { /* XXX add real error reporting */ @@ -1297,14 +1342,14 @@ struct hostent *hent; if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) { - gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n"); + gaim_debug_error("zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n"); g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost)); g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon)); return; } if (!(hent = gethostbyname(zephyr->ourhost))) { - gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",zephyr->ourhost); + gaim_debug_error("zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",zephyr->ourhost); g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon)); return; } @@ -1395,7 +1440,7 @@ if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) { - gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); + gaim_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); } zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip)); @@ -1474,6 +1519,9 @@ read_zsubs = gaim_account_get_bool(gc->account,"read_zsubs",TRUE); exposure = (gchar *)gaim_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS); +#ifdef WIN32 + username = gaim_account_get_username(account); +#endif gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; gc->proto_data = zephyr=g_new0(zephyr_account,1); @@ -2105,7 +2153,7 @@ static const char *zephyr_normalize(const GaimAccount * account, const char *orig) { /* returns the string you gave it. Maybe this function shouldn't be here */ - char * buf = g_malloc0(80); + static char buf[80]; /* gaim_debug_error("zephyr","entering zephyr_normalize\n"); */ if (!g_ascii_strcasecmp(orig, "")) { @@ -2691,19 +2739,19 @@ title = g_strdup_printf("Server subscriptions for %s", zephyr->username); if (zephyr->port == 0) { - gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving port"); + gaim_debug_error("zephyr", "error while retrieving port"); return; } if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) { /* XXX better error handling */ - gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving subscriptions from server"); + gaim_debug_error("zephyr", "error while retrieving subscriptions from server"); return; } for(i=0;i", diff -r f38bda97f981 -r 5727afad0fb8 src/protocols/zephyr/zephyr.h --- a/src/protocols/zephyr/zephyr.h Mon Apr 25 00:31:24 2005 +0000 +++ b/src/protocols/zephyr/zephyr.h Mon Apr 25 01:53:01 2005 +0000 @@ -5,7 +5,7 @@ * * $Source$ * $Author: thekingant $ - * $Id: zephyr.h 8088 2003-11-11 07:08:13Z thekingant $ + * $Id: zephyr.h 12553 2005-04-25 01:53:01Z thekingant $ * * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of * Technology. For copying and distribution information, see the @@ -20,11 +20,13 @@ #include #include -#include +#include #ifndef IPPROTO_MAX /* Make sure not already included */ +#ifndef WIN32 #include #endif +#endif /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const. * This is a public header file, so autoconf can't help us here. */ @@ -37,6 +39,16 @@ # define ZCONST #endif +#ifdef WIN32 +/* this really should be uint32_t */ +/*typedef unsigned int in_addr_t; +struct in_addr +{ + in_addr_t s_addr; +}; */ +#include +#endif + /* Service names */ #define HM_SVCNAME "zephyr-hm" #define HM_SRV_SVCNAME "zephyr-hm-srv" @@ -243,7 +255,7 @@ #define ZERR_NONE 0 /* Hostmanager wait time (in secs) */ -#define HM_TIMEOUT 10 +#define HM_TIMEOUT 1 /* Server wait time (in secs) */ #define SRV_TIMEOUT 30