home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / AMISL083.ZIP / REMOVE.C < prev    next >
C/C++ Source or Header  |  1992-04-19  |  3KB  |  119 lines

  1. /************************************************************************/
  2. /*                                    */
  3. /* REMOVE.C    Remove a specific AMIS-compliant TSR            */
  4. /* Public Domain 1992 Ralf Brown                    */
  5. /* Version 0.80                             */
  6. /* Last Edit: 4/19/92                            */
  7. /*                                                                      */
  8. /* Must be compiled in a large data model (compact recommended)        */
  9. /* ex.  TCC -mc REMOVE FINDTSRS.OBJ UNINSTAL.OBJ            */
  10. /*                                    */
  11. /************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <conio.h>
  16. #include <ctype.h>
  17. #include <string.h>
  18. #include <dos.h>
  19.  
  20. extern int find_TSRs(char *mpx_numbers, char *manuf, char *name) ;
  21. extern int AMIS_uninstall(int mpx_number) ;
  22.  
  23. /************************************************************************/
  24.  
  25. void usage(void)
  26. {
  27.    printf("Usage:\tREMOVE product\n") ;
  28.    printf("\tREMOVE manufacturer product\n") ;
  29.    printf("\t\tboth <manufacturer> and <product> may be abbreviated\n") ;
  30.    exit(1) ;
  31. }
  32.  
  33. /************************************************************************/
  34.  
  35. int main(int argc,char **argv)
  36. {
  37.    char mpx_numbers[256] ;
  38.    union REGS regs ;
  39.    int found, i, status ;
  40.    char *manuf, *name ;
  41.    char far *sig ;
  42.       
  43.    printf("REMOVE\tPublic Domain 1992 Ralf Brown\n") ;
  44.    if (argc == 1 || argc > 3)
  45.       usage() ;
  46.    if (argc == 2)
  47.       {
  48.       manuf = NULL ;
  49.       name = argv[1] ;
  50.       }
  51.    else
  52.       {
  53.       manuf = argv[1] ;
  54.       name = argv[2] ;
  55.       }
  56.    found = find_TSRs(mpx_numbers,manuf,name) ;    
  57.    switch (found)
  58.       {
  59.       case 0:
  60.      printf("No matching TSR found\n") ;
  61.      break ;
  62.       default:
  63.      printf("The specified name matches the following TSRs:\n") ;
  64.      printf("   Manufact  Product\n") ;
  65.      printf("   -------- --------\n") ;
  66.      for (i = 0 ; i < found ; i++)
  67.         {
  68.         regs.h.ah = mpx_numbers[i] ;
  69.         regs.h.al = 0 ;
  70.         int86(0x2D,®s,®s) ;
  71.         sig = MK_FP(regs.x.dx,regs.x.di) ;
  72.         printf("   %8.8s %8.8s\n",sig,sig+8) ;
  73.         }
  74.      printf("Remove all? [Y/N] ") ;
  75.      fflush(stdout) ;
  76.      if (toupper(getch()) != 'Y')
  77.         break ;
  78.      printf("\n") ;
  79.      /* fall through */
  80.       case 1:
  81.      for (i = 0 ; i < found ; i++)
  82.         {
  83.         regs.h.ah = mpx_numbers[i] ;
  84.         regs.h.al = 0 ;
  85.         int86(0x2D,®s,®s) ;    /* get TSR signature */
  86.         sig = MK_FP(regs.x.dx,regs.x.di) ;
  87.         printf("Attempting removal of %8.8s %8.8s.... ",sig,sig+8) ;
  88.         status = AMIS_uninstall(mpx_numbers[i]) ;
  89.         switch(status)
  90.            {
  91.            case 0:
  92.               printf("removal service not supported.\n") ;
  93.               break ;
  94.            case 1:
  95.               printf("removal unsuccessful.\n") ;
  96.               break ;
  97.            case 2:
  98.               printf("will remove itself when able.\n") ;
  99.               break ;
  100.            case 5:
  101.               printf("can't remove now, try again.\n") ;
  102.               break ;
  103.            case 3:  /* no resident remover, TSR still enabled */
  104.            case 4:  /* no resident remover, TSR now disabled */
  105.               /* these cases were handled by AMIS_uninstall */
  106.               /* fall through to 0xFF */
  107.            case 0xFF:
  108.               printf("successfully removed.\n") ;
  109.               break ;
  110.            default:
  111.               printf("unknown return code %2.02X\n",status) ;
  112.               break ;
  113.            }
  114.         }
  115.      break ;
  116.       }
  117.    return 0 ;
  118. }
  119.