home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d107 / svtools.lha / SVTools / retool / retool.c < prev   
C/C++ Source or Header  |  1987-10-31  |  2KB  |  91 lines

  1. /************************************************************
  2.   retool.c  By: Stephen Vermeulen
  3.  
  4.   Copyright (C) 1987 By Stephen Vermeulen
  5.  
  6.   Use this tool to set the default tool string of an icon.
  7.  
  8.   It has the following syntax:
  9.  
  10.       retool file [tool]
  11.  
  12. ************************************************************/
  13.  
  14. #include <intuition/intuition.h>
  15. #include <workbench/workbench.h>
  16. #include <stdio.h>
  17. #include <functions.h>
  18.  
  19. #define NO_ICONS       4
  20.  
  21. extern ULONG IconBase;
  22.  
  23. /************************************************************
  24.   The following routine just opens the libraries
  25. ************************************************************/
  26.  
  27. short OpenLibs()
  28. {
  29.   short flags; /* any libraries that do not open get recorded here */
  30.  
  31.   flags = 0;
  32.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  33.   if (!IconBase) flags |= NO_ICONS;
  34.   return(flags);
  35. }
  36.  
  37. void CloseLibs(flags)
  38. short flags;
  39. {
  40.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  41. }
  42.  
  43. void main(argc, argv)
  44. short argc;
  45. char *argv[];
  46. {
  47.   short lib_flags, icon_type;
  48.   struct DiskObject *dobj;
  49.  
  50.   if (argc == 3)
  51.   {
  52.     lib_flags  = OpenLibs();
  53.     if (!lib_flags)
  54.     {
  55.       if (dobj = GetDiskObject(argv[1]))
  56.       {
  57.         dobj->do_DefaultTool = argv[2];
  58.         PutDiskObject(argv[1], dobj);
  59.         FreeDiskObject(dobj);
  60.       }
  61.     }
  62.     CloseLibs(lib_flags);
  63.   }
  64.   else if (argc == 2)
  65.   {
  66.     lib_flags  = OpenLibs();
  67.     if (!lib_flags)
  68.     {
  69.       if (dobj = GetDiskObject(argv[1]))
  70.       {
  71.         printf("Default Tool: %s\n", dobj->do_DefaultTool);
  72.         FreeDiskObject(dobj);
  73.       }
  74.     }
  75.     CloseLibs(lib_flags);
  76.   }
  77.   else
  78.   {
  79.     printf("Syntax is: retool icon [tool]\n");
  80.     printf("This is version 1.00\n");
  81.     printf("Written and Copyright (C) 1987 by: Stephen Vermeulen\n");
  82.     printf("                                   3635 Utah Dr. N.W.,\n");
  83.     printf("                                   Calgary, Alberta,\n");
  84.     printf("                                   CANADA, T2N 4A6\n");
  85.     printf("\n                                   (403) 282-7990\n");
  86.     printf("\nSupport more Vware, send a donation or a bug report...\n");
  87.     printf("This program may be freely distributed so long as no\n");
  88.     printf("charge is made for such distribution.\n");
  89.   }
  90. }
  91.