home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gfx / imagefx_sdk-2.0.lha / ImageFX_SDK / sas / examples / loaders / skeleton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  5.8 KB  |  216 lines

  1. /*
  2.  * Skeleton Loader Module, on which to base other loaders
  3.  * Written by Thomas Krehbiel
  4.  *
  5.  */
  6.  
  7. #include <scan/modall.h>
  8. #include <scan/loadsave.h>
  9.  
  10.  
  11. // this include file is created by "str" in the makefile:
  12. #include "skeleton_strings.h"
  13.  
  14.  
  15. /************************************************************************
  16.  *
  17.  * LM_Load() - Load an image from the given file
  18.  *
  19.  * Attempt to load the contents of the given file and convert it
  20.  * to 24-bits if necessary.  Should return a valid Buffer (see
  21.  * scan/buf.h) structure filled out properly.
  22.  *
  23.  * Returns a pointer to a Buffer structure if successful or
  24.  * NULL on failure, with an addition error code set by using
  25.  * SetError().
  26.  *
  27.  * Inputs:
  28.  *
  29.  *    fname    - name of file to load
  30.  *    id       - ID code (as provided by LM_Signatures below)
  31.  *    args     - Arexx arguments
  32.  *
  33.  ************************************************************************/
  34.  
  35. struct Buffer * __saveds __asm LM_Load (register __a0 char *fname,
  36.                                         register __d0 int id,
  37.                                         register __a1 LONG *args)
  38. {
  39.    if (args[0])
  40.       // FRAME number provided;  frame = atoi((char *)args[0])
  41.  
  42.    InfoRequest(TXT(M_LM_Load));
  43.    ReturnError(ERR_UserCancel, NULL);
  44. }
  45.  
  46.  
  47. /************************************************************************
  48.  *
  49.  * LM_LoadPalette() - Load a palette from file
  50.  *
  51.  * Attempts to extract palette information from the given file.
  52.  * This function should fill in the supplied Palette structure (see
  53.  * scan/loadsave.h) as best it can.  Specifically, you need to fill
  54.  * in the Depth, Count, and Table fields at least.  Others are
  55.  * optional.
  56.  *
  57.  * Return TRUE if successful, FALSE on failure with an additional
  58.  * error code set by using SetError().
  59.  *
  60.  * Inputs:
  61.  *
  62.  *    fname    - name of file to load
  63.  *    pal      - struct Palette to fill in
  64.  *    id       - ID code (as provided by LM_Signatures below)
  65.  *
  66.  ************************************************************************/
  67.  
  68. BOOL __saveds __asm LM_LoadPalette (register __a0 char *fname,
  69.                                     register __a1 struct Palette *pal,
  70.                                     register __d0 int id)
  71. {
  72.    InfoRequest(TXT(M_LM_LoadPalette));
  73.    ReturnError(ERR_NoPalette, FALSE);
  74. }
  75.  
  76.  
  77. /************************************************************************
  78.  * Format descriptor table - describes the bytes to look for at the
  79.  * beginning of a file, the name of the format, and flags.  The table
  80.  * ends with a NULL entry.
  81.  *
  82.  * See also struct LoadFormat in <scan/loadsave.h>.
  83.  *
  84.  */
  85. static
  86. struct LoadFormat loadformats[] = {
  87.    { "GUST", 4, "Guschtumple", 0 },
  88.    { NULL }
  89. };
  90.  
  91.  
  92. /************************************************************************
  93.  *
  94.  * LM_Signatures() - Return signature bytes
  95.  *
  96.  * Tell ImageFX the signature byte(s) you look for at the beginning
  97.  * of a file.  Given as an array of struct LoadFormat (see scan/loadsave.h).
  98.  *
  99.  * Return NULL if you want to use custom file identification.
  100.  *
  101.  ************************************************************************/
  102.  
  103. struct LoadFormat * __saveds LM_Signatures (void)
  104. {
  105.    return (loadformats);
  106. }
  107.  
  108.  
  109. /************************************************************************
  110.  *
  111.  * LM_CheckFile() - Custom file identification
  112.  *
  113.  * Only called if you returned NULL from LM_Signatures() above.
  114.  * You should return TRUE if you are able to load the file specified
  115.  * by "fname", or FALSE if you don't recognize it.
  116.  *
  117.  * Inputs:
  118.  *
  119.  *    fname    - name of file to check
  120.  *
  121.  ************************************************************************/
  122.  
  123. BOOL __saveds __asm LM_CheckFile (register __a0 char *fname)
  124. {
  125.    return(FALSE);
  126. }
  127.  
  128.  
  129. /**********************************************************************\
  130.  
  131.                          Standard Module Stuff
  132.  
  133. \**********************************************************************/
  134.  
  135. RXCMD RexxTable =
  136. {
  137.    NULL, NULL, "Frame/N"       // arexx args for this loader
  138. };
  139.  
  140. /************************************************************************
  141.  * Function table.  Referenced in "lib.o".
  142.  *
  143.  * The first four entries are the standard library vectors, defined
  144.  * in "lib.o", the remaining entries define functions specific to
  145.  * this module.
  146.  *
  147.  * The table ends with -1.
  148.  *
  149.  */
  150. ULONG FuncTable[] = {
  151.    (ULONG) LibOpen,
  152.    (ULONG) LibClose,
  153.    (ULONG) LibExpunge,
  154.    (ULONG) LibNull,
  155.  
  156.    (ULONG) LM_Load,
  157.    (ULONG) LM_LoadPalette,
  158.    (ULONG) LM_Signatures,
  159.    (ULONG) LM_CheckFile,
  160.  
  161.    (ULONG) 0,        // reserved
  162.    (ULONG) 0,        // reserved
  163.    (ULONG) 0,        // reserved
  164.  
  165.    (ULONG) -1L
  166. };
  167.  
  168. /************************************************************************
  169.  * ID string for this module.  References in "lib.o".
  170.  *
  171.  * Should be given in the standard 2.0 version string style.
  172.  */
  173. UBYTE LibraryID[] = "\0$VER: Skeleton 2.0.4 (15.2.95)";
  174.  
  175. /************************************************************************
  176.  * Type of module.  Referenced in "lib.o".
  177.  *
  178.  * Should be one of the NT_* defines in <scan/mod.h>
  179.  *
  180.  */
  181. UBYTE LibraryType = NT_LOADER;
  182.  
  183. /************************************************************************
  184.  * Module initialization code.  Referenced by "lib.o".
  185.  *
  186.  * This is where you would initialize the ModuleBase structure that
  187.  * is passed to you.
  188.  *
  189.  * Returns TRUE if all went well, or FALSE if something went wrong and
  190.  * the module open should fail.
  191.  *
  192.  */
  193. LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
  194. {
  195.    modbase->Language = "Loader_Skeleton";
  196.    modbase->LangCount = TXT_COUNT;
  197.    modbase->Text = Default_Strings;
  198.    modbase->CmdTable = &RexxTable;
  199.    return(TRUE);
  200. }
  201.  
  202. /************************************************************************
  203.  * Module cleanup code.  Referenced by "lib.o".
  204.  *
  205.  * This should cleanup anything you allocated or opened in UserOpen()
  206.  * above.
  207.  *
  208.  * Always return TRUE.
  209.  *
  210.  */
  211. LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
  212. {
  213.    return(TRUE);
  214. }
  215.  
  216.