[BACK]Return to dmesg.c CVS log [TXT][DIR] Up to [local] / prex-old / usr / bin / dmesg

Diff for /prex-old/usr/bin/dmesg/dmesg.c between version 1.1.1.1 and 1.1.1.1.2.1

version 1.1.1.1, 2008/06/03 10:38:47 version 1.1.1.1.2.1, 2008/08/13 17:12:34
Line 28 
Line 28 
  */   */
   
 #include <prex/prex.h>  #include <prex/prex.h>
 #include <sys/ioctl.h>  
   
 #include <unistd.h>  #include <unistd.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <termios.h>
   
 #ifdef CMDBOX  #ifdef CMDBOX
 #define main(argc, argv)        dmesg_main(argc, argv)  #define main(argc, argv)        dmesg_main(argc, argv)
Line 46 
Line 46 
         int size;          int size;
         char *buf;          char *buf;
   
         if (sys_debug(DCMD_LOGSIZE, &size) != 0)          if (sys_debug(DCMD_LOGSIZE, &size) != 0) {
                   fprintf(stderr, "dmesg: not supported\n");
                 exit(1);                  exit(1);
           }
   
         if ((buf = malloc(size)) == NULL)          if ((buf = malloc(size)) == NULL)
                 exit(1);                  exit(1);
Line 62 
Line 64 
 }  }
   
 static int  static int
 print_msg(char *buf, int size)  print_msg(char *buf, int bufsize)
 {  {
         struct winsize ws;          struct winsize ws;
         int i, cnt, ignore;          int i, row, maxrow;
         int row, maxrow;  
   
         /* Get screen size */          /* Get screen size */
         maxrow = 79;          maxrow = 79;
         if (ioctl(STDOUT_FILENO, TIOCGWINSZ, (u_long)&ws) == 0)          if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
                 maxrow = (int)ws.ws_row - 1;                  maxrow = (int)ws.ws_row - 1;
   
         /* Find message start point */  
         for (i = 0; i < size; i++) {  
                 if (buf[i] == -1)  
                         break;  
         }  
         if (i == size)  
                 return 1;  
   
         row = 0;          row = 0;
         ignore = 1;          for (i = 0; i < bufsize; i++) {
         for (cnt = 0; cnt < size; cnt++) {                  if (*buf == '\0')
                 if (buf[i] == '\n') {                          break;
                   if (*buf == '\n')
                         row++;                          row++;
                         ignore = 0;                  putc(*buf, stdout);
                 }  
                 if (!ignore)            /* skip first line */  
                         putc(buf[i], stdout);  
                 if (++i >= size)  
                         i = 0;  
                 if (row >= maxrow) {                  if (row >= maxrow) {
                         printf("--More-- ");                          printf("--More-- ");
                         getc(stdin);                          getc(stdin);
                         putchar('\n');                          putchar('\n');
                         row = 0;                          row = 0;
                 }                  }
                   buf++;
         }          }
         return 0;          return 0;
 }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.1.2.1

CVSweb