Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / rexxsyslib / createargstring.c
blob77b4ea7cebe87b1302cd689a5b7a4f444bbe6975
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "rexxsyslib_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <clib/rexxsyslib_protos.h>
16 AROS_LH2(UBYTE *, CreateArgstring,
18 /* SYNOPSIS */
19 AROS_LHA(CONST UBYTE *, string, A0),
20 AROS_LHA(ULONG , length, D0),
22 /* LOCATION */
23 struct RxsLib *, RexxSysBase, 21, RexxSys)
25 /* FUNCTION
26 This function will create a RexxArg structure and copy the supplied
27 string into it.
29 INPUTS
30 string - String to copy into the RexxArg structure
31 length - Length of the string to copy.
33 RESULT
34 Will return a pointer the string part of the allocated RexxArg
35 structure.
37 NOTES
38 Pointer to the string returned by this function may be used as a
39 null terminated C string but should be considered read-only.
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 DeleteArgstring(), LengthArgstring()
48 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 /* size is the length of the memory to allocate: size of RexxArg without Buff + length of string + 1 */
56 ULONG size = sizeof(struct RexxArg) - 8 + length + 1;
57 struct RexxArg *ra = (struct RexxArg *)AllocMem(size, MEMF_PUBLIC|MEMF_CLEAR);
58 ULONG hash = 0;
59 int i;
61 if (ra == NULL) ReturnPtr("CreateArgstring", UBYTE *, NULL);
63 ra->ra_Size = size;
64 ra->ra_Length = length;
65 /* FIXME: Maybe the next two fields only need to be intialized on m68k? */
66 /* Initialize the depricated fields to a sane value for compatibility under AmigaOS */
67 ra->ra_Depricated1 = 1<<1 | 1<<2 | 1<<6; /* Was ra_Flags = NSF_ALPHA | NSF_EXT */
68 for (i=0; i<length; i++)
69 hash += string[i];
70 ra->ra_Depricated2 = (UBYTE)(hash & 255); /* Was ra_Hash */
71 CopyMem(string, ra->ra_Buff, length);
72 *(ra->ra_Buff + length) = '\0';
74 ReturnPtr("CreateArgString", UBYTE *, ra->ra_Buff);
75 AROS_LIBFUNC_EXIT
76 } /* CreateArgstring */