home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / veridata.zip / vmode.c < prev    next >
Text File  |  1995-02-19  |  3KB  |  108 lines

  1. /*
  2.  * vmode.c (utilities for the Veridata EL-486S/25e notebook)
  3.  * Time-stamp: <04 Aug 94 (15:07:59) by pive@ruca.ua.ac.be>
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. #include "veridata.h"
  9.  
  10. void usage(char *name)
  11. {
  12.    fprintf(stderr,"Usage: %s ",name);
  13.    fprintf(stderr,"-b on|off -i on|off -s on|off -t on|off -d timeout -h\n");
  14.    fprintf(stderr,"\t-b -> backlight\n");
  15.    fprintf(stderr,"\t-i -> inverse video\n");
  16.    fprintf(stderr,"\t-s -> serial port 0\n");
  17.    fprintf(stderr,"\t-t -> turbo mode (why would you use this?)\n");
  18.    fprintf(stderr,"\t-d -> harddisk timeout value in seconds\n");
  19.    fprintf(stderr,"\t      (0<= timeout <= 1200) (0 is no timeout)\n");
  20.    fprintf(stderr,"\t-h -> this screen\n");
  21. }
  22.  
  23. void print_status()
  24. {
  25.    unsigned int status;
  26.  
  27.    status=_inp8(VERIDATA_PORT);
  28.    printf("notebook status:\n");
  29.    printf("\tturbo mode:\t%s\n",(status&CPU_FAST)?"on":"off");
  30.    printf("\tbacklight:\t%s\n",(status&BACKLIGHT_ON)?"on":"off");
  31.    printf("\tserial 0:\t%s\n",(status&COM1_ENABLE)?"enabled":"disabled");
  32.    printf("\tvideo mode:\t%s\n",(status&INVERSE_ON)?"inverse":"normal");
  33.    /* it works, but is not usefull
  34.    printf("\tblank mode:\t%s\n",(status&BLANK_OFF)?"normal":"blank");
  35.    */
  36.    printf("\tpower mode:\t%s\n",(status&POWER_EXT)?"extern":"intern");
  37.    printf("\tpower level:\t");
  38.    switch (status & POWER_MASK) {
  39.    case POWER_OK:
  40.       printf("ok\n"); 
  41.       break;
  42.    case POWER_LVL1:
  43.       printf("level 1\n"); 
  44.       break;
  45.    case POWER_LVL2:
  46.       printf("level 2\n"); 
  47.       break;
  48.    }
  49. }
  50.  
  51. main(int argc, char *argv[])
  52. {
  53.    unsigned int status,i;
  54.    int          sec;
  55.    extern char  *optarg;
  56.    extern int   optind;
  57.  
  58.    /* initialise the status variable, clear bit 6 and 7 */
  59.    status=_inp8(VERIDATA_PORT) & SAFETY_MASK;
  60.  
  61.    /* parse the commandline arguments */
  62.    while ((i=getopt(argc,argv,"b:d:i:s:t:h")) != -1)
  63.       switch(i) {
  64.       case 'b':
  65.         if (!strcmp(optarg,"off"))
  66.            status &= ~BACKLIGHT_ON;
  67.         else
  68.            status |= BACKLIGHT_ON;
  69.         break;
  70.       case 'd':
  71.         if ((sscanf(optarg,"%i",&sec)) && (0 <= sec) && (sec <= 1200)) {
  72.            sec=sec/5;
  73.            _outp8(sec,HDD_TIMEOUT_PORT);
  74.            _outp8(HDD_NOTIFY_VALUE,HDD_NOTIFY_PORT);
  75.            printf("Using new harddisk timeout: %i sec\n",sec*5);
  76.         } else {
  77.            usage(argv[0]);
  78.            exit(0);
  79.         }
  80.         break;
  81.       case 'i':
  82.         if (!strcmp(optarg,"off"))
  83.            status &= ~INVERSE_ON;
  84.         else
  85.            status |= INVERSE_ON;
  86.         break;
  87.       case 's':
  88.         if (!strcmp(optarg,"off"))
  89.            status &= ~COM1_ENABLE;
  90.         else
  91.            status |= COM1_ENABLE;
  92.         break;
  93.       case 't': 
  94.         if (!strcmp(optarg,"off")) {
  95.            printf("Why on earth, would you use this?\n");
  96.            status &= ~CPU_FAST;
  97.         } else
  98.            status |= CPU_FAST;
  99.         break;
  100.       case 'h':
  101.       default:
  102.         usage(argv[0]);
  103.         exit(0);
  104.       }
  105.    _outp8(VERIDATA_PORT,status);
  106.    print_status();
  107. }
  108.