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

  1. /************************************************************
  2.   sit.c  By: Stephen Vermeulen
  3.  
  4.   Copyright (C) 1987 By Stephen Vermeulen
  5.  
  6.   Use this tool to set the type of an icon.
  7.  
  8.   It has the following syntax:
  9.  
  10.       sit file [type]
  11.  
  12.   when this is typed, sit will load the file called "file.info"
  13.   and change it to the given type and then resave it under
  14.   the old name to the disk.  The allowable types are:
  15.  
  16.        1 = DISK
  17.        2 = DRAWER
  18.        3 = TOOL
  19.        4 = PROJECT
  20.        5 = GARBAGE
  21.        6 = DEVICE   Say what?????????????????????!!!!!!!!!!!!!!
  22.        7 = KICK
  23. ************************************************************/
  24.  
  25. #include <intuition/intuition.h>
  26. #include <workbench/workbench.h>
  27. #include <stdio.h>
  28. #include <functions.h>
  29.  
  30. #define NO_ICONS       4
  31.  
  32. extern ULONG IconBase;
  33.  
  34. /************************************************************
  35.   The following routine just opens the libraries
  36. ************************************************************/
  37.  
  38. short OpenLibs()
  39. {
  40.   short flags; /* any libraries that do not open get recorded here */
  41.  
  42.   flags = 0;
  43.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  44.   if (!IconBase) flags |= NO_ICONS;
  45.   return(flags);
  46. }
  47.  
  48. void CloseLibs(flags)
  49. short flags;
  50. {
  51.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  52. }
  53.  
  54. void main(argc, argv)
  55. short argc;
  56. char *argv[];
  57. {
  58.   short lib_flags, icon_type;
  59.   struct DiskObject *dobj;
  60.  
  61.   if (argc == 3)
  62.   {
  63.     lib_flags  = OpenLibs();
  64.     if (!lib_flags)
  65.     {
  66.       if (dobj = GetDiskObject(argv[1]))
  67.       {
  68.         sscanf(argv[2], "%d", &icon_type);
  69.         if (icon_type < 1) icon_type = 1;
  70.         if (icon_type > 7) icon_type = 7;
  71.         dobj->do_Type = icon_type;
  72.         PutDiskObject(argv[1], dobj);
  73.         FreeDiskObject(dobj);
  74.       }
  75.     }
  76.     CloseLibs(lib_flags);
  77.   }
  78.   else if (argc == 2)
  79.   {
  80.     lib_flags  = OpenLibs();
  81.     if (!lib_flags)
  82.     {
  83.       if (dobj = GetDiskObject(argv[1]))
  84.       {
  85.         printf("Type %d ", dobj->do_Type);
  86.         switch(dobj->do_Type)
  87.         {
  88.           case 1:
  89.             printf("WBDISK\n");
  90.             break;
  91.           case 2:
  92.             printf("WBDRAWER\n");
  93.             break;
  94.           case 3:
  95.             printf("WBTOOL\n");
  96.             break;
  97.           case 4:
  98.             printf("WBPROJECT\n");
  99.             break;
  100.           case 5:
  101.             printf("WBGARBAGE\n");
  102.             break;
  103.           case 6:
  104.             printf("WBDEVICE\n");
  105.             break;
  106.           case 7:
  107.             printf("WBKICK\n");
  108.             break;
  109.           deafult:
  110.             printf("UNKNOWN TYPE\n");
  111.         }
  112.         FreeDiskObject(dobj);
  113.       }
  114.     }
  115.     CloseLibs(lib_flags);
  116.   }
  117.   else
  118.   {
  119.     printf("Syntax is: sit icon [newtype]\n");
  120.     printf("newtype:  1 = disk     2 = drawer   3 = tool\n");
  121.     printf("          4 = project  5 = garbage  6 = device  7 = kick\n");
  122.     printf("This is version 1.00\n");
  123.     printf("Written and Copyright (C) 1987 by: Stephen Vermeulen\n");
  124.     printf("                                   3635 Utah Dr. N.W.,\n");
  125.     printf("                                   Calgary, Alberta,\n");
  126.     printf("                                   CANADA, T2N 4A6\n");
  127.     printf("\n                                   (403) 282-7990\n");
  128.     printf("\nSupport more Vware, send a donation or a bug report...\n");
  129.     printf("This program may be freely distributed so long as no\n");
  130.     printf("charge is made for such distribution.\n");
  131.   }
  132. }
  133.