From: ayin Date: Fri, 14 Sep 2007 17:10:33 +0000 (+0000) Subject: Move rxvt_network_display to init.C and remove netdisp.{C,h}. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=243e52a610a14788deee31c6b14acda6b1f76d39;p=dana%2Furxvt.git Move rxvt_network_display to init.C and remove netdisp.{C,h}. --- diff --git a/src/Makefile.in b/src/Makefile.in index 62232e7b..d5275a9b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ first_rule: all dummy: COMMON = \ - background.o command.o rxvtfont.o init.o logging.o main.o misc.o netdisp.o \ + background.o command.o rxvtfont.o init.o logging.o main.o misc.o \ ptytty.o proxy.o screen.o scrollbar.o scrollbar-next.o scrollbar-rxvt.o \ scrollbar-xterm.o scrollbar-plain.o xdefaults.o encoding.o \ rxvttoolkit.o rxvtutil.o iom.o keyboard.o fdpass.o @PERL_O@ @@ -175,9 +175,6 @@ main.o: salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h misc.o: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h rxvtutil.h misc.o: rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h callback.h misc.o: salloc.h rxvtperl.h hookinc.h rsinc.h -netdisp.o: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h -netdisp.o: rxvtutil.h rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h -netdisp.o: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h proxy.o: ../config.h ptytty.h libptytty.h ptytty_conf.h rxvt.h rxvtlib.h proxy.o: optinc.h feature.h encoding.h rxvtutil.h rxvtfont.h rxvttoolkit.h proxy.o: iom.h iom_conf.h callback.h salloc.h rxvtperl.h hookinc.h rsinc.h @@ -273,9 +270,6 @@ main.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h keyboard.h misc.lo: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h misc.lo: rxvtutil.h rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h misc.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h -netdisp.lo: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h -netdisp.lo: rxvtutil.h rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h -netdisp.lo: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h proxy.lo: ../config.h ptytty.h libptytty.h ptytty_conf.h rxvt.h rxvtlib.h proxy.lo: optinc.h feature.h encoding.h rxvtutil.h rxvtfont.h rxvttoolkit.h proxy.lo: iom.h iom_conf.h callback.h salloc.h rxvtperl.h hookinc.h rsinc.h diff --git a/src/init.C b/src/init.C index 0dcc224c..c606ed39 100644 --- a/src/init.C +++ b/src/init.C @@ -7,6 +7,9 @@ * - original version * Copyright (c) 1994 Robert Nation * - extensive modifications + * Copyright (c) 1996 Chuck Blake + * Copyright (c) 1997 mj olesen + * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications * Copyright (c) 1999 D J Hawkey Jr @@ -40,6 +43,94 @@ #include +#ifdef DISPLAY_IS_IP +/* On Solaris link with -lsocket and -lnsl */ +#include +#include + +/* these next two are probably only on Sun (not Solaris) */ +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif +#ifdef HAVE_SYS_BYTEORDER_H +#include +#endif + +#include +#include +#include +#include + +static char * +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 ("SIOCGIFCONF"); + close (skfd); + return NULL; + } + + for (i = 0, ifr = ifc.ifc_req; + i < (ifc.ifc_len / sizeof (struct ifreq)); + i++, ifr++) + { + struct ifreq ifr2; + + strcpy (ifr2.ifr_name, ifr->ifr_name); + + if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) + { + unsigned long addr; + struct sockaddr_in *p_addr; + + p_addr = (struct sockaddr_in *) &ifr2.ifr_addr; + addr = htonl ((unsigned long)p_addr->sin_addr.s_addr); + + /* + * not "0.0.0.0" or "127.0.0.1" - so format the address + */ + if (addr && addr != 0x7F000001) + { + char *colon = strchr (display, ':'); + + if (colon == NULL) + colon = ":0.0"; + + rval = rxvt_malloc (strlen (colon) + 16); + sprintf (rval, "%d.%d.%d.%d%s", + (int) ((addr >> 030) & 0xFF), + (int) ((addr >> 020) & 0xFF), + (int) ((addr >> 010) & 0xFF), + (int) (addr & 0xFF), colon); + break; + } + } + } + + close (skfd); + + return rval; +} +#endif + const char *const def_colorName[] = { COLOR_FOREGROUND, diff --git a/src/netdisp.C b/src/netdisp.C deleted file mode 100644 index ff96c8e2..00000000 --- a/src/netdisp.C +++ /dev/null @@ -1,111 +0,0 @@ -/*----------------------------------------------------------------------* - * File: netdisp.C - *----------------------------------------------------------------------* - * - * All portions of code are copyright by their respective author/s. - * Copyright (c) 1996 Chuck Blake - * - original version - * Copyright (c) 1997 mj olesen - * Copyright (c) 1997,1998 Oezguer Kesim - * - * 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 2 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. - *----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------* - * support for resolving the actual IP number of the host for remote - * DISPLAYs. When the display is local (i.e. :0), we add support for - * sending the first non-loopback interface IP number as the DISPLAY - * instead of just sending the incorrect ":0". This way telnet/rlogin - * shells can actually get the correct information into DISPLAY for - * xclients. - *----------------------------------------------------------------------*/ - -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ - -#ifdef DISPLAY_IS_IP -#include "netdisp.h" - -/*----------------------------------------------------------------------*/ -/* return NULL a pointer to buffer which may be freed */ -char * -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 ("SIOCGIFCONF"); - close (skfd); - return NULL; - } - - for (i = 0, ifr = ifc.ifc_req; - i < (ifc.ifc_len / sizeof (struct ifreq)); - i++, ifr++) - { - struct ifreq ifr2; - - strcpy (ifr2.ifr_name, ifr->ifr_name); - - if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) - { - unsigned long addr; - struct sockaddr_in *p_addr; - - p_addr = (struct sockaddr_in *) &ifr2.ifr_addr; - addr = htonl ((unsigned long)p_addr->sin_addr.s_addr); - - /* - * not "0.0.0.0" or "127.0.0.1" - so format the address - */ - if (addr && addr != 0x7F000001) - { - char *colon = strchr (display, ':'); - - if (colon == NULL) - colon = ":0.0"; - - rval = rxvt_malloc (strlen (colon) + 16); - sprintf (rval, "%d.%d.%d.%d%s", - (int) ((addr >> 030) & 0xFF), - (int) ((addr >> 020) & 0xFF), - (int) ((addr >> 010) & 0xFF), - (int) (addr & 0xFF), colon); - break; - } - } - } - - close (skfd); - - return rval; -} -#endif /* DISPLAY_IS_IP */ -/*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/netdisp.h b/src/netdisp.h deleted file mode 100644 index 0d4c4f57..00000000 --- a/src/netdisp.h +++ /dev/null @@ -1,16 +0,0 @@ -/* On Solaris link with -lsocket and -lnsl */ -#include -#include - -/* these next two are probably only on Sun (not Solaris) */ -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif -#ifdef HAVE_SYS_BYTEORDER_H -#include -#endif - -#include -#include -#include -#include