[BACK]Return to uname.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / uname

Diff for /src/usr.bin/uname/uname.c between version 1.2 and 1.3

version 1.2, 1996/06/26 05:42:07 version 1.3, 1998/02/24 00:06:00
Line 35 
Line 35 
 static char rcsid[] = "$OpenBSD$";  static char rcsid[] = "$OpenBSD$";
 #endif /* not lint */  #endif /* not lint */
   
   #include <sys/param.h>
 #include <stdio.h>  #include <stdio.h>
 #include <locale.h>  #include <locale.h>
 #include <unistd.h>  #include <unistd.h>
 #include <sys/utsname.h>  #include <sys/utsname.h>
   #include <sys/sysctl.h>
 #include <err.h>  #include <err.h>
   
 static void usage();  static void usage();
Line 49 
Line 51 
 #define PRINT_VERSION   0x08  #define PRINT_VERSION   0x08
 #define PRINT_MACHINE   0x10  #define PRINT_MACHINE   0x10
 #define PRINT_ALL       0x1f  #define PRINT_ALL       0x1f
   #define PRINT_PROCESSOR 0x20
   
 int  int
 main(argc, argv)  main(argc, argv)
Line 62 
Line 65 
   
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
   
         while ((c = getopt(argc,argv,"amnrsv")) != -1 ) {          while ((c = getopt(argc,argv,"amnrsvp")) != -1 ) {
                 switch ( c ) {                  switch ( c ) {
                 case 'a':                  case 'a':
                         print_mask |= PRINT_ALL;                          print_mask |= PRINT_ALL;
Line 82 
Line 85 
                 case 'v':                  case 'v':
                         print_mask |= PRINT_VERSION;                          print_mask |= PRINT_VERSION;
                         break;                          break;
                   case 'p':
                           print_mask |= PRINT_PROCESSOR;
                           break;
                 default:                  default:
                         usage();                          usage();
                         /* NOTREACHED */                          /* NOTREACHED */
Line 122 
Line 128 
                 if (space++) putchar(' ');                  if (space++) putchar(' ');
                 fputs(u.machine, stdout);                  fputs(u.machine, stdout);
         }          }
           if (print_mask & PRINT_PROCESSOR) {
                   char buf[1024];
                   size_t len;
                   int mib[2];
   
                   if (space++) putchar(' ');
                   mib[0] = CTL_HW;
                   mib[1] = HW_MODEL;
                   len = sizeof(buf);
                   if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
                           err(1, "sysctl");
                   printf("%.*s", len, buf);
           }
         putchar('\n');          putchar('\n');
   
         exit(0);          exit(0);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3