Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / iffparse / idtostr.c
blob33bc84f17fa6fac70e714f9ff5cb101d0191d250
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "iffparse_intern.h"
8 /*****************************************************************************
10 NAME */
11 #include <proto/iffparse.h>
13 AROS_LH2(STRPTR, IDtoStr,
15 /* SYNOPSIS */
16 AROS_LHA(LONG , id, D0),
17 AROS_LHA(STRPTR, buf, A0),
19 /* LOCATION */
20 struct Library *, IFFParseBase, 45, IFFParse)
22 /* FUNCTION
24 INPUTS
25 id - pointer to an IFF chunk identfication code.
26 buf - buffer into which the id will be stored. Should at least be 5 bytes.
28 RESULT
29 buf - pointer to the supplied buffer.
31 NOTES
32 Assumes that the supplied ID is stored in local byte order.
34 EXAMPLE
35 // Print the ID of the current contextnode
37 UBYTE buf[5];
38 struct ContextNode *cn;
40 if (cn = CurrentChunk(iff)
41 printf
43 "ID of current chunk: %s\n",
44 IDtoStr(cn->cn_ID)
48 BUGS
50 SEE ALSO
52 INTERNALS
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 UBYTE *idbuf = (UBYTE*)&id;
60 (void) IFFParseBase;
62 /* If CPU is little endian, then we must "rotate" when writing to the string */
64 #if (AROS_BIG_ENDIAN == 0)
65 buf[0] = idbuf[3];
66 buf[1] = idbuf[2];
67 buf[2] = idbuf[1];
68 buf[3] = idbuf[0];
69 #else
70 /* Big endian CPU: no problems */
72 buf[0] = idbuf[0];
73 buf[1] = idbuf[1];
74 buf[2] = idbuf[2];
75 buf[3] = idbuf[3];
76 #endif
78 buf[4] = 0;
80 return buf;
82 AROS_LIBFUNC_EXIT
83 } /* IDtoStr */