Monitoring du Phytotron
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ecran.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/utsname.h>
  5. #include <getopt.h>
  6. #include <ncurses.h>
  7. #include "ecran.h"
  8. extern int verbosity;
  9. /* ---------------------------------------------------------------- */
  10. int message(char *txt)
  11. {
  12. static int pass = 0;
  13. #if TRACE
  14. fprintf(stderr, "%s [%s]\n", __func__, txt);
  15. #endif
  16. standout();
  17. mvhline(LINES-1, 0, '~', COLS);
  18. mvaddch(LINES-1, 0, "\\|/-"[(pass++)%4]);
  19. mvaddstr(LINES-1, 2, txt);
  20. standend();
  21. refresh();
  22. return 0;
  23. }
  24. /* ---------------------------------------------------------------- */
  25. void barre_inverse(char c, int ligne)
  26. {
  27. int foo;
  28. standout();
  29. for (foo=0; foo<COLS; foo++)
  30. mvaddch(ligne, foo, c);
  31. standend();
  32. /* refresh(); */
  33. }
  34. /* ---------------------------------------------------------------- */
  35. /* make display on the standard screen (stdscr) */
  36. int fond_ecran(char *title)
  37. {
  38. char *tp;
  39. struct utsname utsn;
  40. int foo;
  41. char buffer[200];
  42. tp = " DD2 Monitoring by tTh 2019 ";
  43. if (NULL != title) tp = title;
  44. barre_inverse(' ', 0);
  45. standout();
  46. mvaddstr(0, 2, tp);
  47. if (verbosity) {
  48. sprintf(buffer, " ecr: %dx%d ", COLS, LINES);
  49. fprintf(stderr, "%s ==> %s\n", __func__, buffer);
  50. foo = strlen(buffer);
  51. mvaddstr(0, COLS-2-foo, buffer);
  52. }
  53. /* get and display hostname */
  54. foo = uname(&utsn);
  55. if ( !foo ) {
  56. mvaddstr(0, 2+strlen(tp), "on");
  57. mvaddstr(0, 5+strlen(tp), utsn.nodename);
  58. }
  59. standend();
  60. refresh();
  61. return 0;
  62. }
  63. /* ---------------------------------------------------------------- */