Hi everybody, after having been using screen a lot on different servers, I though that beeing able to display any source address reported by ifconfig could be a nice feature.
I've made that patch, which is supposed to work for linux os (it uses ioctl to get the addresses from actives interfaces). Basicly, it adds a file to the build, which offers a AddInetInfo function, called in screen.c using the I attribute for hardstatus line. It prints on it something like "lo:127.0.0.1 eth0:10.0.2.2 wlan0:192.168.5.22" (supposing that eth0 and wlan0 are active). Thanks for comments, review and if possible a merge. Berry Octave Rev : Sorry, I just forgot the patch
Les sous-répertoires screen-4.0.3.orig/doc et screen-4.0.3/doc sont identiques. Les sous-répertoires screen-4.0.3.orig/etc et screen-4.0.3/etc sont identiques. diff -uN screen-4.0.3.orig/extern.h screen-4.0.3/extern.h --- screen-4.0.3.orig/extern.h 2003-08-22 14:27:57.000000000 +0200 +++ screen-4.0.3/extern.h 2009-07-12 11:07:43.000000000 +0200 @@ -177,6 +177,11 @@ extern int OpenPTY __P((char **)); extern void InitPTY __P((int)); +#if defined (linux) +/* inet.c */ +extern void AddInetInfo __P((char *)); +#endif + /* process.c */ extern void InitKeytab __P((void)); extern void ProcessInput __P((char *, int)); diff -uN screen-4.0.3.orig/inet.c screen-4.0.3/inet.c --- screen-4.0.3.orig/inet.c 1970-01-01 01:00:00.000000000 +0100 +++ screen-4.0.3/inet.c 2009-07-12 11:06:53.000000000 +0200 @@ -0,0 +1,68 @@ + +#if defined (linux) +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + + +#include <sys/ioctl.h> +#include <net/if.h> +#include <arpa/inet.h> + +#define BUFLEN 80 + + +void +AddInetInfo(p) +char *p; +{ + int sock = socket(AF_INET, SOCK_DGRAM,IPPROTO_IP); + struct ifconf buffer; + struct sockaddr_in * sockaddr; + int i, j = 0, buffer_size = sizeof(struct ifreq); + char buf[BUFLEN]; + + buffer.ifc_len = buffer_size; + buffer.ifc_buf = malloc(sizeof(char) * buffer_size); + + ioctl(sock, SIOCGIFCONF,&buffer); + + while (buffer.ifc_len == buffer_size) + { + buffer_size += sizeof(struct ifreq); + buffer.ifc_len = buffer_size; + buffer.ifc_buf = realloc(buffer.ifc_buf, sizeof(char) * buffer_size); + ioctl(sock, SIOCGIFCONF,&buffer); + } + + /* We have a kind of a hash with the active interfaces as key and the + inet addr as value */ + for (i = 0 ; i < buffer.ifc_len / sizeof(struct ifreq) ; i++) + { + //if (!strcmp(buffer.ifc_req[i].ifr_name, "lo")) + // continue; + + + sockaddr = (struct sockaddr_in *) &buffer.ifc_req[i].ifr_addr; + + sprintf(buf, "%s:%s", buffer.ifc_req[i].ifr_name, inet_ntoa(sockaddr->sin_addr)); + + if (j + strlen(buf) + /*3*/ 1 <= BUFLEN) + { + if (j != 0) + { +// p[j++] = ' '; +// p[j++] = ';'; + p[j++] = ' '; + } + strcpy(p + j, buf); + j += strlen(buf); + } + } + + free(buffer.ifc_buf); + close(sock); +} + +#endif + Les fichiers binaires screen-4.0.3.orig/.loadav.c.swp et screen-4.0.3/.loadav.c.swp sont différents. diff -uN screen-4.0.3.orig/Makefile.in screen-4.0.3/Makefile.in --- screen-4.0.3.orig/Makefile.in 2006-10-23 15:06:32.000000000 +0200 +++ screen-4.0.3/Makefile.in 2009-07-12 11:05:40.000000000 +0200 @@ -55,12 +55,12 @@ search.c tty.c term.c window.c utmp.c loadav.c putenv.c help.c \ termcap.c input.c attacher.c pty.c process.c display.c comm.c \ kmapdef.c acls.c braille.c braille_tsi.c logfile.c layer.c \ - sched.c teln.c nethack.c encoding.c + sched.c teln.c nethack.c encoding.c inet.c OFILES= screen.o ansi.o fileio.o mark.o misc.o resize.o socket.o \ search.o tty.o term.o window.o utmp.o loadav.o putenv.o help.o \ termcap.o input.o attacher.o pty.o process.o display.o comm.o \ kmapdef.o acls.o braille.o braille_tsi.o logfile.o layer.o \ - sched.o teln.o nethack.o encoding.o + sched.o teln.o nethack.o encoding.o inet.o all: screen diff -uN screen-4.0.3.orig/screen.c screen-4.0.3/screen.c --- screen-4.0.3.orig/screen.c 2003-09-08 16:26:41.000000000 +0200 +++ screen-4.0.3/screen.c 2009-07-12 11:06:30.000000000 +0200 @@ -2517,6 +2517,25 @@ p += strlen(p) - 1; } break; + +#if defined (linux) + case 'I': + *p = 0; + if (l > 40) + AddInetInfo(p); + if (*p) + { + qmflag = 1; + p += strlen(p) - 1; + } + else + *p = '?'; + if (!tick || tick > 10) + tick = 10; + break; +#endif + + case 'w': case 'W': { Les sous-répertoires screen-4.0.3.orig/terminfo et screen-4.0.3/terminfo sont identiques. Les sous-répertoires screen-4.0.3.orig/utf8encodings et screen-4.0.3/utf8encodings sont identiques.