home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff297.lzh / WriteIcon / writeicon.c < prev   
C/C++ Source or Header  |  1989-12-29  |  15KB  |  388 lines

  1. /***************************************************************************
  2. *                      WriteIcon V1.0 by Dan Burris
  3. ***************************************************************************/
  4. /*  Here is a tool that will write you an Icon by path and name, and can
  5.     be changed easily to another Icon type and Image, by using Icon2C by
  6.     Carol Scheppner (on Fred Fish #56), or can be hacked into your program
  7.     to have it generate Icon files for the files that that program saves.
  8.     
  9.     This code is hereby released as Public domain,and do what you will with
  10.     it, just don't do anything malicious, and don't blame me!
  11.     
  12.     The following are compiling instructions for Manx.
  13.  
  14.             cc +c +d writeicon.c
  15.             ln writeicon.o -lc32
  16. */
  17.  
  18.  
  19. #include <exec/types.h>
  20. #include <intuition/intuition.h>
  21. #include <intuition/intuitionbase.h>
  22. #include <workbench/workbench.h>
  23. #include <workbench/startup.h>
  24.  
  25. #define bufSize 512
  26. #define INBUFSZ 40
  27. #define CLEAR '\012'
  28.  
  29. /* Other Stuff */
  30. extern UBYTE *OpenLibrary();
  31. struct IntuitionBase *IntuitionBase;
  32. struct GfxBase       *GfxBase;
  33. struct DosBase       *DosBase;
  34. struct IconBase         *IconBase;
  35.  
  36. BOOL fromWB;
  37. char sbuf[INBUFSZ];
  38. char nbuf[INBUFSZ];
  39.  
  40.  
  41.  
  42. /* If you are using Lattice, ignore the comments below about changing
  43.   the the Image structure(s) and dig up the Lattice compile and Blink
  44.   instructions you need. 
  45.  */
  46.  
  47. /*
  48.    Definitions for Project Icon begin's here.  The code that follows came
  49.    almost straight out of Carol Scheppner's program, Icon2c.  You may use that 
  50.    program ( on Fred Fish #56) and cut and paste the code that it generates
  51.    in place of this diskobject structure, then change the image structure(s)
  52.    declaration from "USHORT  image1[] = {"  to   "struct Image image1[] = {",
  53.    and change the "(USHORT *)&imageData1," in the same image structure to  
  54.    "&imageData1[0],"       (if there is a 2nd Image, do the same for it!)
  55.    then recompile with manx. It currently has the Project Icon from the 
  56.    Fish disks of a book that opens on one click, uses :c/less read a text file.
  57. */
  58. /* Start cut and paste after this comment! */
  59.  
  60.  
  61. USHORT  imageData1[] = {
  62.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  63.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5540, 0x0000,
  64.  0x0000, 0x0000, 0x0000, 0x455F, 0xD555, 0x5540, 0x0000,
  65.  0x0000, 0x0000, 0x0000, 0x4556, 0xD555, 0x5545, 0x0000,
  66.  0x0000, 0x0000, 0x0000, 0x4556, 0x67D7, 0xD547, 0x0000,
  67.  0x0000, 0x0000, 0x0000, 0x4556, 0x6767, 0x6547, 0x0000,
  68.  0x0000, 0x0000, 0x0000, 0x4556, 0x6666, 0x4547, 0x0000,
  69.  0x0000, 0x0000, 0x0000, 0x4556, 0xC666, 0x7547, 0x0000,
  70.  0x0000, 0x0000, 0x0000, 0x455F, 0xC7C7, 0xC547, 0x0000,
  71.  0x0000, 0x0000, 0x0000, 0x4554, 0x1505, 0x0547, 0x0000,
  72.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  73.  0x0000, 0x0000, 0x0000, 0x45FD, 0x7575, 0x5547, 0x0000,
  74.  0x0000, 0x0000, 0x0000, 0x45CC, 0x5171, 0x5547, 0x0000,
  75.  0x0000, 0x0000, 0x0000, 0x45C4, 0x7571, 0x7D47, 0x0000,
  76.  0x0000, 0x0000, 0x0000, 0x45F5, 0x7171, 0xCD47, 0x0000,
  77.  0x0000, 0x0000, 0x0000, 0x45C1, 0x7171, 0xFC47, 0x0000,
  78.  0x0000, 0x0000, 0x0000, 0x45C5, 0x7171, 0xC047, 0x0000,
  79.  0x0000, 0x0000, 0x0000, 0x45E5, 0x7979, 0x7D47, 0x0000,
  80.  0x0000, 0x0000, 0x0000, 0x4505, 0x4141, 0x4147, 0x0000,
  81.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  82.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  83.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  84.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  85.  0x0000, 0x0000, 0x0000, 0x4555, 0x5540, 0x0147, 0x0000,
  86.  0x0000, 0x0000, 0x0000, 0x4555, 0x5555, 0x5547, 0x0000,
  87.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000,
  88.  0x0000, 0x0000, 0x0000, 0x2FFF, 0xFFFF, 0xFFFF, 0x0000,
  89.  0x0000, 0x0000, 0x0000, 0x1555, 0x5555, 0x5555, 0x0000,
  90.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  91. /**/
  92.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFF8, 0x0000,
  93.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFF8, 0x0000,
  94.  0x0000, 0x0000, 0x0001, 0xFFF0, 0x7FFF, 0xFFFF, 0xC000,
  95.  0x0000, 0x0000, 0x0001, 0xFFF9, 0x3FFF, 0xFFFF, 0xC000,
  96.  0x0000, 0x0000, 0x0001, 0xFFF9, 0x9C3C, 0x3FFB, 0xC000,
  97.  0x0000, 0x0000, 0x0001, 0xFFF9, 0x9999, 0x9FFB, 0xC000,
  98.  0x0000, 0x0000, 0x0001, 0xFFF9, 0x9999, 0xFFFB, 0xC000,
  99.  0x0000, 0x0000, 0x0001, 0xFFF9, 0x3999, 0x9FFB, 0xC000,
  100.  0x0000, 0x0000, 0x0001, 0xFFF0, 0x7C3C, 0x3FFB, 0xC000,
  101.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  102.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  103.  0x0000, 0x0000, 0x0001, 0xFE03, 0xCF8F, 0xFFFB, 0xC000,
  104.  0x0000, 0x0000, 0x0001, 0xFF33, 0xFFCF, 0xFFFB, 0xC000,
  105.  0x0000, 0x0000, 0x0001, 0xFF3F, 0x8FCF, 0x87FB, 0xC000,
  106.  0x0000, 0x0000, 0x0001, 0xFF0F, 0xCFCF, 0x33FB, 0xC000,
  107.  0x0000, 0x0000, 0x0001, 0xFF3F, 0xCFCF, 0x03FB, 0xC000,
  108.  0x0000, 0x0000, 0x0001, 0xFF3F, 0xCFCF, 0x3FFB, 0xC000,
  109.  0x0000, 0x0000, 0x0001, 0xFE1F, 0x8787, 0x87FB, 0xC000,
  110.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  111.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  112.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  113.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  114.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  115.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  116.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  117.  0x0000, 0x0000, 0x0001, 0xFFFF, 0xFFFF, 0xFFFB, 0xC000,
  118.  0x0000, 0x0000, 0x0001, 0xF800, 0x0000, 0x0003, 0xC000,
  119.  0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xC000,
  120.  0x0000, 0x0000, 0x0000, 0x7FFF, 0xFFFF, 0xFFFF, 0xC000,
  121. /**/
  122.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  123.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  124.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  125.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  126.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  127.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  128.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  129.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  130.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  131.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  132.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  133.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  134.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  135.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  136.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  137.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  138.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  139.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  140.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  141.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  142.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  143.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  144.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  145.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  146.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  147.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  148.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  149.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  150.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  151. /**/
  152.  };
  153.  
  154. struct Image  image1[] = {  
  155.  0,  /* LeftEdge */
  156.  0,  /* TopEdge */
  157.  98,  /* Width */
  158.  29,  /* Height */
  159.  3,  /* Depth */
  160.  &imageData1[0], /* ImageData */
  161.  0xFF,  /* PlanePick */
  162.  0x0,  /* PlaneOnOff */
  163.  0,  /* [NextImage] */
  164.  };
  165.  
  166. USHORT  imageData2[] = {
  167.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  168.  0x2AAA, 0xAAAA, 0xAAA8, 0x0555, 0x5555, 0x5555, 0x0000,
  169.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  170.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  171.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  172.  0x37EA, 0xAAAA, 0xAAE0, 0x03EA, 0xAAAA, 0xAABB, 0x0000,
  173.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  174.  0x37FF, 0xFFFF, 0xFFFE, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  175.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  176.  0x37D5, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  177.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  178.  0x3755, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  179.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  180.  0x3755, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  181.  0x37FF, 0xFFFF, 0xFFE0, 0x03FF, 0xFFFF, 0xFFFB, 0x0000,
  182.  0x3755, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  183.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  184.  0x37D5, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  185.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  186.  0x3755, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  187.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  188.  0x3755, 0x5555, 0x557E, 0xBFAA, 0xAAAA, 0xAABB, 0x0000,
  189.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  190.  0x37FF, 0xFFFF, 0xFFE0, 0x03FF, 0xFFFF, 0xFFFB, 0x0000,
  191.  0x37FF, 0xFF5F, 0xFFFE, 0xBFFF, 0xFEBF, 0xFFFB, 0x0000,
  192.  0x37FF, 0xFFFF, 0xFFFE, 0xBFFF, 0xFFFF, 0xFFFB, 0x0000,
  193.  0x3000, 0x0000, 0x0000, 0x8000, 0x0000, 0x0003, 0x0000,
  194.  0x2AAA, 0xAAAA, 0xAAA8, 0x0555, 0x5555, 0x5555, 0x0000,
  195.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  196. /**/
  197.  0xFFFF, 0xFFFF, 0xFFFE, 0x1FFF, 0xFFFF, 0xFFFF, 0xC000,
  198.  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC000,
  199.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  200.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  201.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  202.  0xF800, 0x0000, 0x001F, 0xFC15, 0x5555, 0x5547, 0xC000,
  203.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  204.  0xF800, 0x0000, 0x0001, 0xC055, 0x5555, 0x5547, 0xC000,
  205.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  206.  0xF82A, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  207.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  208.  0xF8AA, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  209.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  210.  0xF8AA, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  211.  0xF800, 0x0000, 0x001F, 0xFC00, 0x0000, 0x0007, 0xC000,
  212.  0xF8AA, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  213.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  214.  0xF82A, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  215.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  216.  0xF8AA, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  217.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  218.  0xF8AA, 0xAAAA, 0xAA81, 0xC055, 0x5555, 0x5547, 0xC000,
  219.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  220.  0xF800, 0x0000, 0x001F, 0xFC00, 0x0000, 0x0007, 0xC000,
  221.  0xF800, 0x00A0, 0x0001, 0xC000, 0x0140, 0x0007, 0xC000,
  222.  0xF800, 0x0000, 0x0001, 0xC000, 0x0000, 0x0007, 0xC000,
  223.  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC000,
  224.  0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC000,
  225.  0xFFFF, 0xFFFF, 0xFFFE, 0x1FFF, 0xFFFF, 0xFFFF, 0xC000,
  226. /**/
  227.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  228.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  229.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  230.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  231.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  232.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  233.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  234.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  235.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  236.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  237.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  238.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  239.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  240.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  241.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  242.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  243.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  244.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  245.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  246.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  247.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  248.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  249.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  250.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  251.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  252.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  253.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  254.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  255.  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  256. /**/
  257.  };
  258.  
  259.  struct Image  image2[] = {
  260.  0,  /* LeftEdge */
  261.  0,  /* TopEdge */
  262.  98,  /* Width */
  263.  29,  /* Height */
  264.  3,  /* Depth */
  265.  &imageData2[0],  /* ImageData */
  266.  0xFF,  /* PlanePick */
  267.  0x0,  /* PlaneOnOff */
  268.  0,  /* [NextImage] */
  269.  };
  270.  
  271. struct DiskObject diskObject = {
  272.  WB_DISKMAGIC,   /* do_Magic */
  273.  WB_DISKVERSION, /* do_Version */
  274.  
  275. /* Embedded Gadget Structure */
  276.  0,  /* [NextGadget] */
  277.  21,  /* LeftEdge */
  278.  11,  /* TopEdge */
  279.  98,  /* Width */
  280.  29,  /* Height */
  281.  0x6,  /* Flags */
  282.  0x3,  /* Activation */
  283.  0x1,  /* GadgetType */
  284.  (APTR)&image1, /* GadgetRender */
  285.  (APTR)&image2, /* SelectRender */
  286.  NULL,     /* GadgetText */
  287.  0x0,  /* MutualExclude */
  288.  0x0,  /* [SpecialInfo] */
  289.  0,  /* GadgetID */
  290.  0x0,  /* [UserData] */
  291.  
  292. /* Rest of DiskObject structure */
  293.  0x4,  /* do_Type */
  294.  "SYS:c/less",   /* do_Default Tool */
  295.  0x0,  /* [do_ToolTypes] */
  296.  0xFFFFFFF0,  /* do_CurrentX */
  297.  0x0,  /* do_CurrentY */
  298.  0x0,  /* [do_DrawerData] */
  299.  0x0,  /* [do_ToolWindow] */
  300.  0x0,  /* do_StackSize */
  301.  };
  302.  
  303. /* End your cut and paste here! */
  304.  
  305.     
  306. main(argc, argv)
  307. int argc;
  308. char **argv;
  309.  
  310.  
  311.    {
  312.    LONG            file;
  313.    char            *filename;
  314.    int l;
  315.  
  316.  
  317. IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L);
  318.      if(IntuitionBase == NULL)
  319.           cleanexit("Can't open intuition.library\n");
  320.  
  321. GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L);
  322.     if(GfxBase == NULL)
  323.          cleanexit("Can't open graphics.library\n");
  324.     
  325. IconBase = (struct IconBase *)OpenLibrary("icon.library", 0L);
  326.     if(IconBase == NULL)
  327.             cleanexit("Can't open icon.library\n");
  328.       
  329.       
  330.    if(argc > 1)                 /* Passed filename via command line  */
  331.       {
  332.       filename = argv[1];
  333.       }
  334.    else
  335.       {
  336.         printf("\n\n\n");
  337.  
  338.       printf("\n\n       WriteIcon V1.0 © 1989 By Dan Burris\n\n ");    
  339.       printf("       Enter Path/Filename for Icon (without .info): ");
  340.       l = gets(&nbuf[0]);
  341.  
  342.       if(l==0)                /* No filename - Exit */
  343.          {
  344.          cleanexit("\nIcon not saved, filename required\n");
  345.          }
  346.       else
  347.          {
  348.          filename = &nbuf[0];
  349.          }
  350.       }
  351.  
  352.    printf("\nSaving...\n");
  353.  
  354.  
  355.       if(!(PutDiskObject(filename,&diskObject)))
  356.          {
  357.          cleanexit("Error saving icon\n");
  358.          }
  359.          printf("Icon saved\n");
  360.  
  361.         cleanexit("Done\n");
  362.    }
  363.  
  364.  
  365. cleanexit(s)
  366.    char  *s;
  367.    {
  368.    if(*s) printf(s);
  369.    if ((fromWB)&&(*s))    /* Wait so user can read messages */
  370.       {
  371.       printf("\nPRESS RETURN TO EXIT\n");
  372.       gets(&sbuf[0]);
  373.       }
  374.    cleanup();
  375.    exit();
  376.    }
  377.  
  378. cleanup()
  379.    {
  380.    if (IntuitionBase) CloseLibrary(IntuitionBase);
  381.    if (GfxBase) CloseLibrary(GfxBase);
  382.    if (IconBase) CloseLibrary(IconBase);
  383.    }
  384.  
  385.  
  386.  
  387.  
  388.