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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: idtostr.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_LH2(STRPTR, IDtoStr,
  16.  
  17. /*  SYNOPSIS */
  18.     AROS_LHA(LONG  , id, D0),
  19.     AROS_LHA(STRPTR, buf, A0),
  20.  
  21. /*  LOCATION */
  22.     struct Library *, IFFParseBase, 45, IFFParse)
  23.  
  24. /*  FUNCTION
  25.  
  26.     INPUTS
  27.     id  - pointer to an IFF chunk identfication code.
  28.     buf  -    buffer into which the id will be stored. Should at least be 5 bytes.
  29.  
  30.     RESULT
  31.     buf  -    pointer to the supplied buffer.
  32.  
  33.     NOTES
  34.     Assumes that the supplied ID is stored in local byte order.
  35.  
  36.     EXAMPLE
  37.     // Print the ID of the current contextnode
  38.  
  39.     UBYTE buf[5];
  40.     struct ContextNode *cn;
  41.  
  42.     if (cn = CurrentChunk(iff)
  43.         printf
  44.         (
  45.         "ID of current chunk: %s\n",
  46.         IDtoStr(cn->cn_ID)
  47.         );
  48.  
  49.  
  50.     BUGS
  51.  
  52.     SEE ALSO
  53.  
  54.     INTERNALS
  55.  
  56.     HISTORY
  57.   27-11-96    digulla automatically created from
  58.       iffparse_lib.fd and clib/iffparse_protos.h
  59.  
  60. *****************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.     AROS_LIBBASE_EXT_DECL(struct Library *,IFFParseBase)
  64.  
  65.     UBYTE *idbuf = (UBYTE*)&id;
  66.  
  67. /* If CPU is little endian, then we must "rotate" when writing to the string */
  68.  
  69. #if (AROS_BIG_ENDIAN == 0)
  70.     buf[0] = idbuf[3];
  71.     buf[1] = idbuf[2];
  72.     buf[2] = idbuf[1];
  73.     buf[3] = idbuf[0];
  74. #else
  75. /* Big endian CPU: no problems */
  76.  
  77.     buf[0] = idbuf[0];
  78.     buf[1] = idbuf[1];
  79.     buf[2] = idbuf[2];
  80.     buf[3] = idbuf[3];
  81. #endif
  82.  
  83.     buf[4] = 0;
  84.  
  85.     return buf;
  86.  
  87.     AROS_LIBFUNC_EXIT
  88. } /* IDtoStr */
  89.