Browse Source

+ hostname display on ncurses header bar

tth 1 year ago
parent
commit
c848ebd12d
1 changed files with 12 additions and 1 deletions
  1. 12
    1
      viz/curses/ecran.c

+ 12
- 1
viz/curses/ecran.c View File

@@ -1,6 +1,8 @@
1 1
 #include  <stdio.h>
2 2
 #include  <stdlib.h>
3 3
 #include  <string.h>
4
+#include  <sys/utsname.h>
5
+
4 6
 #include  <getopt.h>
5 7
 #include  <ncurses.h>
6 8
 
@@ -24,9 +26,10 @@ standend();
24 26
 int fond_ecran(char *title)
25 27
 {
26 28
 char		*tp;
29
+struct utsname	utsn;
30
+int		foo;
27 31
 
28 32
 #if TRACE
29
-int     foo;
30 33
 char    buffer[200];
31 34
 #endif
32 35
 
@@ -41,6 +44,14 @@ sprintf(buffer, " ecran %dx%d ", COLS, LINES);
41 44
 foo = strlen(buffer);
42 45
 mvaddstr(0, COLS-2-foo, buffer);
43 46
 #endif
47
+
48
+/* get and display hostname */
49
+foo = uname(&utsn);
50
+if ( !foo )	{
51
+	mvaddstr(0, 2+strlen(tp), "on");
52
+	mvaddstr(0, 5+strlen(tp), utsn.nodename);
53
+	}
54
+
44 55
 standend();
45 56
 refresh();
46 57
 

Loading…
Cancel
Save