Prefs/ScreenMode: change the way depth is selected
[AROS.git] / workbench / libs / rexxsyslib / fillrexxmsg.c
blob5b5a6834444a14c9c189de9073a38173f2bfa812
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <stdio.h>
9 #include <string.h>
10 #include "rexxsyslib_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <clib/rexxsyslib_protos.h>
17 AROS_LH3(BOOL, FillRexxMsg,
19 /* SYNOPSIS */
20 AROS_LHA(struct RexxMsg *, msgptr, A0),
21 AROS_LHA(ULONG , count , D0),
22 AROS_LHA(ULONG , mask , D1),
24 /* LOCATION */
25 struct RxsLib *, RexxSysBase, 27, RexxSys)
27 /* FUNCTION
28 This function will convert the value(s) provided in rm_Args of the
29 RexxMsg. The input can be either a string or a number.
31 INPUTS
32 msgptr - RexxMsg to create the RexxArgs for.
33 count - The number of ARGs in the rm_Args structure field that is
34 filled with a value and has to be converted.
35 mask - Bit 0-count from this mask indicate wether the value in
36 rm_Args is a string or a number. When the bit is cleared the
37 value is a pointer to a string. When it is set it is treated
38 as a signed number.
40 RESULT
41 Returns TRUE if succeeded, FALSE otherwise. When FALSE is returned all
42 memory already allocated will be Freed before returning.
44 NOTES
46 EXAMPLE
47 This code will convert a string and a number to RexxArgs:
49 struct RexxMsg *rm;
51 ...
53 rm->rm_Args[0] = "Test";
54 rm->rm_Args[1] = (UBYTE *)5;
56 if (!FillRexxMsg(rm, 2, 1<<1))
57 ...
59 BUGS
61 SEE ALSO
62 ClearRexxMsg(), CreateRexxMsg(), CreateArgstring()
64 INTERNALS
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
70 STRPTR args[16];
71 char number[20];
72 ULONG i, j;
74 for (i = 0; i < count; i++)
76 /* Is argument i an integer ? */
77 if (mask & (1<<i))
79 /* Convert int to string */
80 sprintf(number, "%ld", (long)msgptr->rm_Args[i]);
81 args[i] = (STRPTR)CreateArgstring(number, strlen(number));
83 /* Clean up if error in CreateArgstring */
84 if (args[i] == NULL)
86 for (j = 0; j < i; j++)
87 if (args[j] != NULL) DeleteArgstring((UBYTE *)args[j]);
88 ReturnBool("FillRexxMsg", FALSE);
91 else
93 /* CreateArgstring with null terminated string if pointer is not null */
94 if (msgptr->rm_Args[i] == 0) args[i] = NULL;
95 else
97 args[i] = (STRPTR)CreateArgstring(RXARG(msgptr,i), strlen(RXARG(msgptr,i)));
99 /* Clean up if error in CreateArgstring */
100 if (args[i] == NULL)
102 for (j = 0; j < i; j++)
103 if (args[j] != NULL) DeleteArgstring((UBYTE *)args[j]);
104 ReturnBool("FillRexxMsg", FALSE);
110 CopyMem(args, msgptr->rm_Args, count * sizeof(STRPTR));
111 ReturnBool("FillRexxMsg", TRUE);
112 AROS_LIBFUNC_EXIT
113 } /* FillRexxMsg */