home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
100-199
/
ff137.lzh
/
Sit
/
sit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-03-20
|
5KB
|
192 lines
/************************************************************
sit.c By: Stephen Vermeulen
Copyright (C) 1987 By Stephen Vermeulen
Use this tool to set the type of an icon.
It has the following syntax:
sit file [type] [drawer]
when this is typed, sit will load the file called "file.info"
and change it to the given type and then resave it under
the old name to the disk. The allowable types are:
1 = DISK
2 = DRAWER
3 = TOOL
4 = PROJECT
5 = GARBAGE
6 = DEVICE Say what?????????????????????!!!!!!!!!!!!!!
7 = KICK
************************************************************/
#include <intuition/intuition.h>
#include <workbench/workbench.h>
#include <stdio.h>
#include <functions.h>
#define NO_ICONS 4
extern ULONG IconBase;
/************************************************************
The following routine just opens the libraries
************************************************************/
short OpenLibs()
{
short flags; /* any libraries that do not open get recorded here */
flags = 0;
IconBase = (ULONG) OpenLibrary("icon.library", 0L);
if (!IconBase) flags |= NO_ICONS;
return(flags);
}
void CloseLibs(flags)
short flags;
{
if (!(flags & NO_ICONS)) CloseLibrary(IconBase);
}
void main(argc, argv)
short argc;
char *argv[];
{
short lib_flags, icon_type;
struct DiskObject *dobj, *drawer_obj;
struct DrawerData *dd_temp;
if (argc >= 3)
{
lib_flags = OpenLibs();
if (!lib_flags)
{
if (dobj = GetDiskObject(argv[1]))
{
sscanf(argv[2], "%d", &icon_type);
if (icon_type < 1) icon_type = 1;
if (icon_type > 7) icon_type = 7;
if ((icon_type == 1) || (icon_type == 2) || (icon_type == 5))
{
/*** the user wants to make this icon into a drawer
or disk or trashcan, so check to see if the
original is one of these
***/
if ((dobj->do_Type == 1) || (dobj->do_Type == 2) || (dobj->do_Type == 5))
{
/** ok to proceed **/
dobj->do_Type = icon_type;
PutDiskObject(argv[1], dobj);
}
else
{
/*** we have to read in some extra data from a
sample Drawer, disk or trashcan icon to upgrade
this icon.
***/
if (argc == 4)
{
/** correct number of parameters **/
if (drawer_obj = GetDiskObject(argv[3]))
{
if ((drawer_obj->do_Type == 1) ||
(drawer_obj->do_Type == 2) ||
(drawer_obj->do_Type == 5))
{
/** if it is the correct type of icon **/
dd_temp = dobj->do_DrawerData;
dobj->do_DrawerData = drawer_obj->do_DrawerData;
dobj->do_Type = icon_type;
PutDiskObject(argv[1], dobj);
dobj->do_DrawerData = dd_temp;
}
else
printf("%s should be a DRAWER, DISK, or TRASHCAN icon!\n", argv[3]);
FreeDiskObject(drawer_obj);
}
}
else
printf("You need to supply a drawer icon as a template too\n");
}
}
else
{
/*** If the original was a drawer type thing we want to
dump that structure.
***/
dd_temp = dobj->do_DrawerData;
dobj->do_DrawerData = NULL;
dobj->do_Type = icon_type;
PutDiskObject(argv[1], dobj);
dobj->do_DrawerData = dd_temp;
}
FreeDiskObject(dobj);
}
}
CloseLibs(lib_flags);
}
else if (argc == 2)
{
lib_flags = OpenLibs();
if (!lib_flags)
{
if (dobj = GetDiskObject(argv[1]))
{
printf("Type %d ", dobj->do_Type);
switch(dobj->do_Type)
{
case 1:
printf("WBDISK\n");
break;
case 2:
printf("WBDRAWER\n");
break;
case 3:
printf("WBTOOL\n");
break;
case 4:
printf("WBPROJECT\n");
break;
case 5:
printf("WBGARBAGE\n");
break;
case 6:
printf("WBDEVICE\n");
break;
case 7:
printf("WBKICK\n");
break;
deafult:
printf("UNKNOWN TYPE\n");
}
FreeDiskObject(dobj);
}
}
CloseLibs(lib_flags);
}
else
{
printf("Syntax is: sit icon [newtype] [drawer|disk|trashcan]\n");
printf("newtype: 1 = disk 2 = drawer 3 = tool\n");
printf(" 4 = project 5 = garbage 6 = device 7 = kick\n");
printf("This is version 1.10\n");
printf("Written and Copyright (C) 1987 by: Stephen Vermeulen\n");
printf(" 3635 Utah Dr. N.W.,\n");
printf(" Calgary, Alberta,\n");
printf(" CANADA, T2N 4A6\n");
printf("\n (403) 282-7990\n");
printf("\nSupport more Vware, send a donation or a bug report...\n");
printf("This program may be freely distributed so long as no\n");
printf("charge is made for such distribution.\n");
}
}