home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 376_01 / os2tool.000 / BORDER.C < prev    next >
C/C++ Source or Header  |  1992-08-08  |  3KB  |  109 lines

  1. /*
  2. * BORDER.C - Sets the colors of the border.
  3. *
  4. *
  5. * PROGRAMMER:        Martti Ylikoski
  6. * CREATED:        21.2.1991
  7. * VERSION:        1.0
  8. *
  9. */
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <ctype.h> /* isdigit requires this */
  14. #include <param.h>
  15. #include <paramstd.h>
  16. #define INCL_DOS
  17. #define INCL_VIO
  18. #include <os2.h>
  19. #include "vioclr.h"
  20. static char *progname ;
  21.  
  22. extern unsigned long pflags ;
  23.  
  24. ParamEntry pentry[12] = {
  25.      "P", &ParamSetPause, 0,
  26.      "F", &ParamSetFold, 0,
  27.      "V", &ParamSetVerbose, 0,
  28.      "R", &ParamSetReport, 0,
  29.      "S", &ParamSetSubDirs, 0,
  30.      "?", &ParamSetHelp, 1,
  31.      "H", &ParamSetHelp, 1,
  32.      "NOD", &ParamSetNoDefault, 0,
  33.      "TEST", &ParamSetTest, 0,
  34.      "Y", &ParamSetYes, 0,
  35.      "N", &ParamSetTest, 0,
  36.      "\0", NULL, 0
  37. } ;
  38.  
  39. ParamBlock params = {
  40.     "/-",   IGNORECASE | NOPRIORITY | NOTRIGGERSALLOWED ,
  41.     pentry
  42. } ;
  43.  
  44.  
  45. int main(int argc, char *argv[])
  46. {
  47. int i, fint ;
  48. USHORT bint ;
  49. VIOOVERSCAN viooverscan ;
  50. USHORT ret ;
  51.  
  52.    progname = argv[0] ;
  53.  
  54.    ParamHandle(¶ms, &argc, argv) ;
  55.  
  56.    bint = 0 ;
  57.  
  58.    if (argc != 2 || pflags & PA_HELP)
  59.    {
  60.       printf("usage: %s border-color \n", progname) ;
  61.       printf("Available colors:\n") ;
  62.       printf("       DARK_BLUE     LIGT_BLUE       BLUE\n") ;
  63.       printf("       DARK_RED      LIGHT_BLUE      RED\n") ;
  64.       printf("       DARK_GREEN    LIGHT_GREEN     GREEN\n") ;
  65.       printf("       DARK_YELLOW   LIGHT_YELLOW    YELLOW\n") ;
  66.       printf("       DARK_MAGENTA  LIGHT_MAGENTA   MAGENTA\n") ;
  67.       printf("       DARK_CYAN     LIGHT_CYAN      CYAN\n") ;
  68.       printf("       BLACK         WHITE           DARK_GREY\n") ;
  69.       printf("       LIGHT_GREY    DEFAULT\n") ;
  70.       printf(" OR an integer specifying the corresponding attribute\n" ) ;
  71.       return( 0 ) ;
  72.    }
  73.  
  74.    if ( isdigit( (int) argv[1][0]) != 0)
  75.       bint = (USHORT) atoi(argv[1]) ;
  76.    else
  77.    {
  78.       for (i = 0 ; i < (int) (sizeof(colors)/sizeof(TABLE_ENTRY)) ; i++)
  79.       {
  80.      if (strcmpi(colors[i].color, argv[1]) == 0)
  81.         bint = colors[i].cint ;
  82.       }
  83.    }
  84.  
  85.    viooverscan.cb = sizeof(VIOOVERSCAN) ;
  86.    viooverscan.type = 1 ;
  87.    if (( ret = VioGetState(&viooverscan, 0)) != 0)
  88.    {
  89.       fputs("Error in VioGetState\nExiting...\n", stderr) ;
  90.       return( 1 ) ;
  91.    }
  92. /*
  93.    if (bint == -1 )
  94.    {
  95.       fprintf(stderr,"%s: color was not valid\n", progname) ;
  96.       fprintf(stderr,"Run command without arguments to see valid parameters\n") ;
  97.       return( 1 ) ;
  98.    }
  99. */
  100.    viooverscan.color = bint ;
  101.  
  102.    if ((ret = VioSetState(&viooverscan, 0)) != 0)
  103.    {
  104.       fputs("Error in VioSetState\nExiting...\n", stderr) ;
  105.       return( 1 ) ;
  106.    }
  107.    return( 0 ) ;
  108. }
  109.