SF.net SVN: geany: [810] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Mon Sep 11 07:41:50 UTC 2006
Revision: 810
http://svn.sourceforge.net/geany/?rev=810&view=rev
Author: eht16
Date: 2006-09-11 00:41:37 -0700 (Mon, 11 Sep 2006)
Log Message:
-----------
Made socket code for detecting running instances working under Windows.
Fixed compile warnings under Windows.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/dialogs.c
trunk/src/makefile.win32
trunk/src/socket.c
trunk/src/ui_utils.c
trunk/src/win32.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/ChangeLog 2006-09-11 07:41:37 UTC (rev 810)
@@ -1,3 +1,12 @@
+2006-09-11 Enrico Tröger <enrico.troeger at uvena.de>
+
+ * src/socket.c: Made socket code for detecting running instances
+ working under Windows.
+ * src/win32.c, src/ui_utils.c, src/dialogs.c:
+ Fixed compile warnings under Windows.
+ * src/highlighting.c: Fixed a typo.
+
+
2006-09-10 Enrico Tröger <enrico.troeger at uvena.de>
* src/sci_cb.c, src/keybindings.c, src/callbacks.c:
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/src/dialogs.c 2006-09-11 07:41:37 UTC (rev 810)
@@ -46,9 +46,10 @@
#include "keybindings.h"
+#ifndef G_OS_WIN32
static GtkWidget *add_file_open_extra_widget();
+#endif
-
/* This shows the file selection dialog to open a file. */
void dialogs_show_open_file ()
{
@@ -152,6 +153,7 @@
}
+#ifndef G_OS_WIN32
static GtkWidget *add_file_open_extra_widget()
{
GtkWidget *vbox;
@@ -215,6 +217,7 @@
return vbox;
}
+#endif
/* This shows the file selection dialog to save a file. */
Modified: trunk/src/makefile.win32
===================================================================
--- trunk/src/makefile.win32 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/src/makefile.win32 2006-09-11 07:41:37 UTC (rev 810)
@@ -71,7 +71,7 @@
$(TARGET): $(OBJS) $(RES) ../scintilla/scintilla.a ../tagmanager/tagmanager.a
$(CXX) $(OBJS) $(RES) -o $(TARGET) \
../scintilla/scintilla.a ../tagmanager/tagmanager.a $(ALL_GTK_LIBS) \
- -mwindows -limm32 -lshell32 -lole32 -luuid -lcomdlg32 -lcomctl32 -liberty
+ -mwindows -limm32 -lshell32 -lole32 -luuid -lcomdlg32 -lcomctl32 -liberty -lwsock32
deps.mak:
$(CC) -MM $(CCFLAGS) *.c >deps.mak
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/src/socket.c 2006-09-11 07:41:37 UTC (rev 810)
@@ -25,9 +25,14 @@
#ifdef HAVE_SOCKET
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
+#ifndef G_OS_WIN32
+# include <sys/socket.h>
+# include <sys/un.h>
+# include <netinet/in.h>
+#else
+# include <winsock2.h>
+# include <ws2tcpip.h>
+#endif
#include <unistd.h>
#include <fcntl.h>
@@ -38,11 +43,24 @@
#ifdef G_OS_WIN32
+#define REMOTE_CMD_PORT 49876
+#define SockDesc SOCKET
+#define SOCKET_IS_VALID(s) ((s) != INVALID_SOCKET)
+#else
+#define SockDesc gint
+#define SOCKET_IS_VALID(s) ((s) >= 0)
+#define INVALID_SOCKET (-1)
+#endif
+
+
+#ifdef G_OS_WIN32
static gint socket_fd_connect_inet (gushort port);
static gint socket_fd_open_inet (gushort port);
-#endif
+static void socket_init_win32();
+#else
static gint socket_fd_connect_unix (const gchar *path);
static gint socket_fd_open_unix (const gchar *path);
+#endif
static gint socket_fd_write (gint sock, const gchar *buf, gint len);
static gint socket_fd_write_all (gint sock, const gchar *buf, gint len);
@@ -63,6 +81,7 @@
#ifdef G_OS_WIN32
HANDLE hmutex;
+ socket_init_win32();
hmutex = CreateMutexA(NULL, FALSE, "Geany");
if (! hmutex)
{
@@ -135,7 +154,9 @@
socket_info.read_ioc = NULL;
}
-#ifndef G_OS_WIN32
+#ifdef G_OS_WIN32
+ WSACleanup();
+#else
unlink(socket_info.file_name);
g_free(socket_info.file_name);
#endif
@@ -144,19 +165,9 @@
}
-#ifdef G_OS_WIN32
-#define SockDesc SOCKET
-#define SOCKET_IS_VALID(s) ((s) != INVALID_SOCKET)
-#else
-#define SockDesc gint
-#define SOCKET_IS_VALID(s) ((s) >= 0)
-#define INVALID_SOCKET (-1)
-#endif
-
-
+#ifdef G_OS_UNIX
static gint socket_fd_connect_unix(const gchar *path)
{
-#ifdef G_OS_UNIX
gint sock;
struct sockaddr_un addr;
@@ -178,15 +189,11 @@
}
return sock;
-#else
- return -1;
-#endif
}
static gint socket_fd_open_unix(const gchar *path)
{
-#ifdef G_OS_UNIX
gint sock;
struct sockaddr_un addr;
gint val;
@@ -226,12 +233,9 @@
}
return sock;
-#else
- return -1;
+}
#endif
-}
-
static gint socket_fd_close(gint fd)
{
#ifdef G_OS_WIN32
@@ -247,16 +251,12 @@
{
SockDesc sock;
struct sockaddr_in addr;
- gint val;
+ gchar val;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (! SOCKET_IS_VALID(sock))
{
-#ifdef G_OS_WIN32
geany_debug("fd_open_inet(): socket() failed: %ld\n", WSAGetLastError());
-#else
- perror("fd_open_inet(): socket");
-#endif
return -1;
}
@@ -299,11 +299,7 @@
sock = socket(AF_INET, SOCK_STREAM, 0);
if (! SOCKET_IS_VALID(sock))
{
-#ifdef G_OS_WIN32
geany_debug("fd_connect_inet(): socket() failed: %ld\n", WSAGetLastError());
-#else
- perror("fd_connect_inet(): socket");
-#endif
return -1;
}
@@ -320,6 +316,17 @@
return sock;
}
+
+
+static void socket_init_win32()
+{
+ WSADATA wsadata;
+
+ if (WSAStartup(MAKEWORD(2, 2), &wsadata) != NO_ERROR)
+ geany_debug("WSAStartup() failed\n");
+
+ return;
+}
#endif
@@ -408,7 +415,9 @@
{
struct timeval timeout;
fd_set fds;
+#ifdef G_OS_UNIX
gint flags;
+#endif
timeout.tv_sec = 60;
timeout.tv_usec = 0;
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/src/ui_utils.c 2006-09-11 07:41:37 UTC (rev 810)
@@ -46,10 +46,11 @@
recent_file_activate_cb (GtkMenuItem *menuitem,
gpointer user_data);
+#ifndef G_OS_WIN32
static GtkWidget *create_build_menu_tex(gint idx);
static GtkWidget *create_build_menu_gen(gint idx);
+#endif
-
/* allow_override is TRUE if text can be ignored when another message has been set
* that didn't use allow_override and has not timed out. */
void ui_set_statusbar(const gchar *text, gboolean allow_override)
@@ -751,6 +752,8 @@
}
+#ifndef G_OS_WIN32
+
#define GEANY_ADD_WIDGET_ACCEL(gkey, menuitem) \
if (keys[(gkey)]->key != 0) \
gtk_widget_add_accelerator(menuitem, "activate", accel_group, \
@@ -973,6 +976,7 @@
return menu;
}
+#endif
void ui_treeviews_show_hide(gboolean force)
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2006-09-11 07:39:37 UTC (rev 809)
+++ trunk/src/win32.c 2006-09-11 07:41:37 UTC (rev 810)
@@ -40,6 +40,7 @@
#include "document.h"
#include "support.h"
#include "utils.h"
+#include "ui_utils.h"
#include "sciwrappers.h"
#include "dialogs.h"
@@ -210,7 +211,7 @@
{
gchar *editorfont = g_strdup_printf("%s %d", lf.lfFaceName,
(cf.iPointSize / 10));
- utils_set_editor_font(editorfont);
+ ui_set_editor_font(editorfont);
g_free(editorfont);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list