/*
 * Skeleton Loader Module, on which to base other loaders
 *
 */

#include <scan/modall.h>
#include <scan/loadsave.h>


/************************************************************************
 * LM_Load() - Load an image from the given file
 *
 * Attempt to load the contents of the given file and convert it
 * to 24-bits if necessary.  Should return a valid Buffer (see
 * scan/buf.h) structure filled out properly.
 *
 * Returns a pointer to a Buffer structure if successful or
 * NULL on failure, with an addition error code set by using
 * SetError().
 *
 * Inputs:
 *
 *    fname    - name of file to load
 *    id       - ID code (as provided by LM_Signatures below)
 *    args     - Arexx arguments
 */

struct Buffer * __saveds __asm LM_Load (register __a0 char *fname,
                                        register __d0 int id,
                                        register __a1 LONG *args)
{
   InfoRequest("LM_Load");
   ReturnError(ERR_UserCancel, NULL);
}

/************************************************************************
 * LM_LoadPalette() - Load a palette from file
 *
 * Attempts to extract palette information from the given file.
 * This function should fill in the supplied Palette structure (see
 * scan/loadsave.h) as best it can.  Specifically, you need to fill
 * in the Depth, Count, and Table fields at least.  Others are
 * optional.
 *
 * Return TRUE if successful, FALSE on failure with an additional
 * error code set by using SetError().
 *
 * Inputs:
 *
 *    fname    - name of file to load
 *    pal      - struct Palette to fill in
 *    id       - ID code (as provided by LM_Signatures below)
 *
 */

BOOL __saveds __asm LM_LoadPalette (register __a0 char *fname,
                                    register __a1 struct Palette *pal,
                                    register __d0 int id)
{
   InfoRequest("LM_LoadPalette");
   ReturnError(ERR_NoPalette, FALSE);
}

/************************************************************************
 * Format descriptor table - describes the bytes to look for at the
 * beginning of a file, the name of the format, and flags.  The table
 * ends with a NULL entry.
 *
 * See also struct LoadFormat in <scan/loadsave.h>.
 *
 */
static
struct LoadFormat loadformats[] = {
   { "GUST", 4, "Guschtumple", 0 },
   { NULL }
};

/************************************************************************
 * LM_Signatures() - Return signature bytes
 *
 * Tell ImageFX the signature byte(s) you look for at the beginning
 * of a file.  Given as an array of struct LoadFormat (see scan/loadsave.h).
 *
 * Return NULL if you want to use custom file identification.
 *
 */

struct LoadFormat * __saveds LM_Signatures (void)
{
   return (loadformats);
}

/************************************************************************
 * LM_CheckFile() - Custom file identification
 *
 * Only called if you returned NULL from LM_Signatures() above.
 * You should return TRUE if you are able to load the file specified
 * by "fname", or FALSE if you don't recognize it.
 *
 * Inputs:
 *
 *    fname    - name of file to check
 *
 */

BOOL __saveds __asm LM_CheckFile (register __a0 char *fname)
{
   return(FALSE);
}


/**********************************************************************\

                         Standard Module Stuff

\**********************************************************************/


/************************************************************************
 * Function table.  Referenced in "lib.o".
 *
 * The first four entries are the standard library vectors, defined
 * in "lib.o", the remaining entries define functions specific to
 * this module.
 *
 * The table ends with -1.
 *
 */
ULONG FuncTable[] = {
   (ULONG) LibOpen,
   (ULONG) LibClose,
   (ULONG) LibExpunge,
   (ULONG) LibNull,

   (ULONG) LM_Load,
   (ULONG) LM_LoadPalette,
   (ULONG) LM_Signatures,
   (ULONG) LM_CheckFile,

   (ULONG) -1L
};

/************************************************************************
 * ID string for this module.  References in "lib.o".
 *
 * Should be given in the standard 2.0 version string style.
 */
UBYTE LibraryID[] = "$VER: Untitled 1.00.00 (19.6.92)";

/************************************************************************
 * Type of module.  Referenced in "lib.o".
 *
 * Should be one of the NT_* defines in <scan/mod.h>
 *
 */
UBYTE LibraryType = NT_LOADER;

/************************************************************************
 * Module initialization code.  Referenced by "lib.o".
 *
 * This is where you would initialize the ModuleBase structure that
 * is passed to you.
 *
 * Returns TRUE if all went well, or FALSE if something went wrong and
 * the module open should fail.
 *
 */
LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
{
   return(TRUE);
}

/************************************************************************
 * Module cleanup code.  Referenced by "lib.o".
 *
 * This should cleanup anything you allocated or opened in UserOpen()
 * above.
 *
 * Always return TRUE.
 *
 */
LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
{
   return(TRUE);
}

