/*----------------------------------------------------------------------*
* File: init.C
*----------------------------------------------------------------------*
*
* All portions of code are copyright by their respective author/s.
* Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
* - original version
* Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
* - extensive modifications
* Copyright (c) 1996 Chuck Blake <cblake@BBN.COM>
* Copyright (c) 1997 mj olesen <olesen@me.queensu.ca>
* Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
* Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
* - extensive modifications
* Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de>
* Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*---------------------------------------------------------------------*/
/*
* Initialisation routines.
*/
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
#include "rxvtutil.h"
#include "init.h"
#include "keyboard.h"
#include <limits>
#include <signal.h>
#include <fcntl.h>
#ifdef HAVE_XMU
# include <X11/Xmu/CurUtil.h>
#endif
#ifdef HAVE_XSETLOCALE
# define X_LOCALE
# include <X11/Xlocale.h>
#else
# include <locale.h>
#endif
#ifdef HAVE_NL_LANGINFO
# include <langinfo.h>
#endif
#ifdef HAVE_STARTUP_NOTIFICATION
# define SN_API_NOT_YET_FROZEN
# include <libsn/sn-launchee.h>
#endif
#ifdef DISPLAY_IS_IP
/* On Solaris link with -lsocket and -lnsl */
#include <sys/types.h>
#include <sys/socket.h>
/* these next two are probably only on Sun (not Solaris) */
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#ifdef HAVE_SYS_BYTEORDER_H
#include <sys/byteorder.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/if_arp.h>
static char * ecb_cold
rxvt_network_display (const char *display)
{
char buffer[1024], *rval = NULL;
struct ifconf ifc;
struct ifreq *ifr;
int i, skfd;
if (display[0] != ':' && strncmp (display, "unix:", 5))
return (char *) display; /* nothing to do */
ifc.ifc_len = sizeof (buffer); /* Get names of all ifaces */
ifc.ifc_buf = buffer;
if ((skfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror ("socket");
return NULL;
}
if (ioctl (skfd, SIOCGIFCONF, &ifc) < 0)
{
perror ("SIOCGIFC
|