Made socket code for detecting running instances working under Windows.
Fixed compile warnings under Windows. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@810 ea778897-0a13-0410-b9d1-a72fbfd435f5master
parent
3b9a342452
commit
8dede470b1
|
@ -1,3 +1,12 @@
|
|||
2006-09-11 Enrico Tröger <enrico.troeger@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@uvena.de>
|
||||
|
||||
* src/sci_cb.c, src/keybindings.c, src/callbacks.c:
|
||||
|
|
|
@ -46,8 +46,9 @@
|
|||
#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 @@ void dialogs_show_open_file ()
|
|||
}
|
||||
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
static GtkWidget *add_file_open_extra_widget()
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
|
@ -215,6 +217,7 @@ static GtkWidget *add_file_open_extra_widget()
|
|||
|
||||
return vbox;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* This shows the file selection dialog to save a file. */
|
||||
|
|
|
@ -71,7 +71,7 @@ binclean:
|
|||
$(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
|
||||
|
|
75
src/socket.c
75
src/socket.c
|
@ -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>
|
||||
|
||||
|
@ -37,12 +42,25 @@
|
|||
|
||||
|
||||
|
||||
#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 @@ gint socket_init(gint argc, gchar **argv)
|
|||
#ifdef G_OS_WIN32
|
||||
HANDLE hmutex;
|
||||
|
||||
socket_init_win32();
|
||||
hmutex = CreateMutexA(NULL, FALSE, "Geany");
|
||||
if (! hmutex)
|
||||
{
|
||||
|
@ -135,7 +154,9 @@ gint socket_finalize(void)
|
|||
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 @@ gint socket_finalize(void)
|
|||
}
|
||||
|
||||
|
||||
#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 @@ static gint socket_fd_connect_unix(const gchar *path)
|
|||
}
|
||||
|
||||
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,11 +233,8 @@ static gint socket_fd_open_unix(const gchar *path)
|
|||
}
|
||||
|
||||
return sock;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static gint socket_fd_close(gint fd)
|
||||
{
|
||||
|
@ -247,16 +251,12 @@ static gint socket_fd_open_inet(gushort port)
|
|||
{
|
||||
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 @@ static gint socket_fd_connect_inet(gushort port)
|
|||
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 @@ static gint socket_fd_connect_inet(gushort port)
|
|||
|
||||
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 @@ static gint socket_fd_check_io(gint fd, GIOCondition cond)
|
|||
{
|
||||
struct timeval timeout;
|
||||
fd_set fds;
|
||||
#ifdef G_OS_UNIX
|
||||
gint flags;
|
||||
#endif
|
||||
|
||||
timeout.tv_sec = 60;
|
||||
timeout.tv_usec = 0;
|
||||
|
|
|
@ -46,9 +46,10 @@ static void
|
|||
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. */
|
||||
|
@ -751,6 +752,8 @@ void ui_build_show_hide(gint idx)
|
|||
}
|
||||
|
||||
|
||||
#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 @@ static GtkWidget *create_build_menu_tex(gint idx)
|
|||
|
||||
return menu;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ui_treeviews_show_hide(gboolean force)
|
||||
|
|
|
@ -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 @@ void win32_show_font_dialog(void)
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue