home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / workbench / libs / iffparse / goodid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-03  |  1.6 KB  |  83 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: goodid.c,v 1.1 1997/02/03 16:44:24 digulla Exp $
  4.  
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "iffparse_intern.h"
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <proto/iffparse.h>
  14.  
  15.     AROS_LH1(LONG, GoodID,
  16.  
  17. /*  SYNOPSIS */
  18.     AROS_LHA(LONG, id, D0),
  19.  
  20. /*  LOCATION */
  21.     struct Library *, IFFParseBase, 43, IFFParse)
  22.  
  23. /*  FUNCTION
  24.     Determines whether an ID is valid according to the IFF specification.
  25.  
  26.     INPUTS
  27.     id - An IFF chunk ID to be tested.
  28.  
  29.     RESULT
  30.     TRUE if valid.
  31.     FALSE otherwise.
  32.  
  33.     NOTES
  34.     Assumes input to be in local byte order.
  35.  
  36.     EXAMPLE
  37.  
  38.     BUGS
  39.  
  40.     SEE ALSO
  41.  
  42.     INTERNALS
  43.  
  44.     HISTORY
  45.   27-11-96    digulla automatically created from
  46.       iffparse_lib.fd and clib/iffparse_protos.h
  47.  
  48. *****************************************************************************/
  49. {
  50.     AROS_LIBFUNC_INIT
  51.     AROS_LIBBASE_EXT_DECL(struct Library *,IFFParseBase)
  52.  
  53.     UBYTE *theId;
  54.  
  55.   /* Assure big endian before checking */
  56.     id = SwitchIfLittleEndian(id);
  57.  
  58.     theId = (UBYTE *)&id;
  59.  
  60.  
  61.     /* If the ID starts with a space, but is not all spaces, then invalid */
  62.     if((theId[0] == 0x20) && (id != 0x20202020))
  63.     return (FALSE);
  64.  
  65.     /*
  66.     Check whether the ID is within the allowed character ranges.
  67.     This loop is unrolled
  68.     */
  69.  
  70.     if( (theId[0] < 0x20) || (theId[1] > 0x7e))
  71.     return (FALSE);
  72.     if( (theId[1] < 0x20) || (theId[1] > 0x7e))
  73.     return (FALSE);
  74.     if( (theId[2] < 0x20) || (theId[2] > 0x7e))
  75.     return (FALSE);
  76.     if( (theId[3] < 0x20) || (theId[3] > 0x7e))
  77.     return (FALSE);
  78.  
  79.     return (TRUE);
  80.  
  81.     AROS_LIBFUNC_EXIT
  82. } /* GoodID */
  83.