~ubuntu-branches/ubuntu/wily/geany/wily

« back to all changes in this revision

Viewing changes to src/socket.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      socket.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2006-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
 
 *      Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
 
4
 *      Copyright 2006-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
5
 *      Copyright 2006-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
6
 *      Copyright 2006 Hiroyuki Yamamoto (author of Sylpheed)
7
7
 *
8
8
 *      This program is free software; you can redistribute it and/or modify
19
19
 *      along with this program; if not, write to the Free Software
20
20
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
21
 *
22
 
 * $Id: socket.c 5292 2010-10-07 14:10:32Z ntrel $
 
22
 * $Id: socket.c 5975 2011-09-30 11:14:23Z ntrel $
23
23
 */
24
24
 
25
25
/*
93
93
 
94
94
#ifdef G_OS_WIN32
95
95
#define REMOTE_CMD_PORT         49876
96
 
#define SOCKET_IS_VALID(s)      (G_LIKELY((s) != INVALID_SOCKET))
 
96
#define SOCKET_IS_VALID(s)      ((s) != INVALID_SOCKET)
97
97
#else
98
 
#define SOCKET_IS_VALID(s)      (G_LIKELY((s) >= 0))
 
98
#define SOCKET_IS_VALID(s)      ((s) >= 0)
99
99
#define INVALID_SOCKET          (-1)
100
100
#endif
101
101
#define BUFFER_LENGTH 4096
410
410
        real_path = g_strdup_printf("%s%cgeany_socket.%08x",
411
411
                g_get_tmp_dir(), G_DIR_SEPARATOR, g_random_int());
412
412
 
413
 
        if (utils_is_file_writeable(real_path) != 0)
 
413
        if (utils_is_file_writable(real_path) != 0)
414
414
        {       /* if real_path is not writable for us, fall back to ~/.config/geany/geany_socket_*_* */
415
415
                /* instead of creating a symlink and print a warning */
416
416
                g_warning("Socket %s could not be written, using %s as fallback.", real_path, path);
468
468
        gchar val;
469
469
 
470
470
        sock = socket(AF_INET, SOCK_STREAM, 0);
471
 
        if (! SOCKET_IS_VALID(sock))
 
471
        if (G_UNLIKELY(! SOCKET_IS_VALID(sock)))
472
472
        {
473
473
                geany_debug("fd_open_inet(): socket() failed: %d\n", WSAGetLastError());
474
474
                return -1;
511
511
        struct sockaddr_in addr;
512
512
 
513
513
        sock = socket(AF_INET, SOCK_STREAM, 0);
514
 
        if (! SOCKET_IS_VALID(sock))
 
514
        if (G_UNLIKELY(! SOCKET_IS_VALID(sock)))
515
515
        {
516
516
                geany_debug("fd_connect_inet(): socket() failed: %d\n", WSAGetLastError());
517
517
                return -1;