From: Rob F. <rob...@us...> - 2002-10-11 03:14:02
|
Update of /cvsroot/gaim/gaim/src/protocols/irc In directory usw-pr-cvs1:/tmp/cvs-serv28946/src/protocols/irc Modified Files: irc.c Added Files: Makefile.mingw Log Message: Yeah this will probably break a lot of shit knowing my luck. But hey, I really don't care what people thnk. --- NEW FILE: Makefile.mingw --- # # Makefile.mingw # # Description: Makefile for win32 (mingw) version of libirc # # # PATHS # INCLUDE_DIR := . GTK_TOP := ../../../../win32-dev/gtk_2_0 GAIM_TOP := ../../.. IRC_ROOT := . GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir ## ## VARIABLE DEFINITIONS ## TARGET = libirc VERSION := $(shell cat $(GAIM_TOP)/VERSION) # Compiler Options CC = gcc CFLAGS = -O2 -Werror -Wall -mno-cygwin -fnative-struct DEFINES = -DAIM_BUILDDATE=\"`date +%Y%m%d`\" \ -DAIM_BUILDTIME=\"`date +%H%M%S`\" \ -DVERSION=\"$(VERSION)\" \ -DHAVE_CONFIG_H # 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 ## ## INCLUDE MAKEFILES ## ## ## INCLUDE PATHS ## INCLUDE_PATHS += -I$(IRC_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) LIB_PATHS = -L$(GTK_TOP)/lib \ -L$(GAIM_TOP)/src ## ## SOURCES, OBJECTS ## C_SRC = irc.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 # -liberty ## ## 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 $(IRC_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).def: $(OBJECTS) dlltool --dllname $(TARGET).dll -z $(TARGET).def \ $(OBJECTS) $(TARGET).base: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib gcc -mdll -o junk.tmp -Wl,--base-file,$@ $(OBJECTS) $(LIB_PATHS) $(LIBS) rm -rf junk.tmp $(TARGET).exp: $(TARGET).def $(TARGET).base dlltool --dllname $(TARGET).dll --base-file $(TARGET).base \ --output-exp $(TARGET).exp --def $(TARGET).def rm -rf $(TARGET).base $(TARGET).dll: $(OBJECTS) $(TARGET).exp $(GAIM_TOP)/src/gaim.lib dlltool -D $(TARGET).dll -d $(TARGET).def -l $(TARGET).lib gcc -mdll -o $(TARGET).dll $(OBJECTS) -Wl,$(TARGET).exp $(LIB_PATHS) $(LIBS) rm -rf $(TARGET).exp ## ## CLEAN RULES ## clean: rm -rf *.o rm -rf $(TARGET).dll rm -rf $(TARGET).lib rm -rf $(TARGET).def Index: irc.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/irc/irc.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- irc.c 10 Oct 2002 07:00:33 -0000 1.96 +++ irc.c 11 Oct 2002 03:13:59 -0000 1.97 @@ -25,8 +25,13 @@ #include <config.h> -#include <fcntl.h> +#ifndef _WIN32 #include <unistd.h> +#else +#include <winsock.h> +#endif + +#include <fcntl.h> #include <errno.h> #include <string.h> #include <stdlib.h> @@ -39,6 +44,10 @@ #include "gaim.h" #include "proxy.h" +#ifdef _WIN32 +#include "win32dep.h" +#endif + #include "pixmaps/protocols/irc/irc_icon.xpm" #define IRC_BUF_LEN 4096 @@ -47,6 +56,10 @@ #define USEROPT_SERV 0 #define USEROPT_PORT 1 +/* for win32 compatability */ +G_MODULE_IMPORT GSList *connections; + + struct dcc_chat { struct gaim_connection *gc; @@ -64,6 +77,7 @@ char *name; int len; int watcher; + int awatcher; char ip[12]; int port; int fd; @@ -119,7 +133,11 @@ static int irc_write(int fd, char *data, int len) { debug_printf("IRC C: %s", data); +#ifndef _WIN32 return write(fd, data, len); +#else + return send(fd, data, len, 0); +#endif } static struct conversation *irc_find_chat(struct gaim_connection *gc, char *name) @@ -435,7 +453,11 @@ int n = 0, l; struct conversation *convo; debug_printf("THIS IS TOO MUCH EFFORT\n"); +#ifndef _WIN32 n = read (chat->fd, buffer, IRC_BUF_LEN); +#else + n = recv (chat->fd, buffer, IRC_BUF_LEN, 0); +#endif if (n > 0) { @@ -461,8 +483,6 @@ } static void irc_file_transfer_do(struct gaim_connection *gc, struct irc_file_transfer *ift) { - struct irc_data *id = (struct irc_data *)gc->proto_data; - /* Ok, we better be receiving some crap here boyeee */ if (transfer_in_do(ift->xfer, ift->fd, ift->name, ift->len)) { gaim_input_remove(ift->watcher); @@ -471,6 +491,19 @@ } +void irc_read_dcc_ack (gpointer data, gint source, GaimInputCondition condition) { + struct irc_file_transfer *ift = data; + struct irc_data *id = (struct irc_data *)ift->gc->proto_data; + int len; + guint32 ack; + + printf("I got here.\n"); + len = recv(source, (char *)&ack, 4, MSG_PEEK); + printf("Len is: %d\n", len); + printf("Ack is: %d\n", ack); + recv(source, (char *)&ack, 4, 0); +} + void dcc_send_callback (gpointer data, gint source, GaimInputCondition condition) { struct irc_file_transfer *ift = data; struct irc_data *id = (struct irc_data *)ift->gc->proto_data; @@ -488,6 +521,8 @@ return; } +// ift->awatcher = gaim_input_add(ift->fd, GAIM_INPUT_READ, irc_read_dcc_ack, ift); + if (transfer_out_do(ift->xfer, ift->fd, 0)) { gaim_input_remove(ift->watcher); ift->watcher = 0; @@ -1323,7 +1358,11 @@ gchar buf[1024]; gboolean off; +#ifndef _WIN32 i = read(idata->fd, buf, 1024); +#else + i = recv(idata->fd, buf, 1024, 0); +#endif if (i <= 0) { hide_login_progress_error(gc, "Read error"); signoff(gc); @@ -1374,7 +1413,11 @@ char buf[IRC_BUF_LEN]; if (!g_slist_find(connections, gc)) { +#ifndef _WIN32 close(source); +#else + closesocket(source); +#endif return; } @@ -1490,7 +1533,11 @@ if (gc->inpa) gaim_input_remove(gc->inpa); +#ifndef _WIN32 close(idata->fd); +#else + closesocket(idata->fd); +#endif g_free(gc->proto_data); } @@ -2011,7 +2058,6 @@ ift->xfer = transfer_out_add(gc, ift->sn); } - static struct irc_file_transfer *find_ift_by_xfer(struct gaim_connection *gc, struct file_transfer *xfer) { @@ -2030,7 +2076,6 @@ } static void irc_file_transfer_data_chunk(struct gaim_connection *gc, struct file_transfer *xfer, const char *data, int len) { - struct irc_data *id = (struct irc_data *)gc->proto_data; struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); guint32 pos; @@ -2113,10 +2158,7 @@ static void irc_file_transfer_in(struct gaim_connection *gc, struct file_transfer *xfer, int offset) { - struct irc_data *id = (struct irc_data *)gc->proto_data; struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); - struct sockaddr_in addr; - char *ip = (char *)malloc(32); ift->xfer = xfer; proxy_connect(ift->ip, ift->port, dcc_recv_callback, ift); @@ -2149,7 +2191,7 @@ chat->inpa = gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, chat); - snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", + g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", chat->ip_address, chat->port); irc_send_im (gc, who, buf, -1, 0); } @@ -2196,7 +2238,7 @@ static struct prpl *my_protocol = NULL; -void irc_init(struct prpl *ret) +G_MODULE_EXPORT void irc_init(struct prpl *ret) { struct proto_user_opt *puo; ret->protocol = PROTO_IRC; @@ -2240,8 +2282,7 @@ } #ifndef STATIC - -void *gaim_prpl_init(struct prpl* prpl) +G_MODULE_EXPORT void gaim_prpl_init(struct prpl* prpl) { irc_init(prpl); prpl->plug->desc.api_version = PLUGIN_API_VERSION; |