Made built more straightforward.
[AROS.git] / workbench / c / Shell / cliVarNum.c
1 /*
2     Copyright (C) 1995-2011, The AROS Development Team. All rights reserved.
3     $Id$
4  */
5
6 #include <proto/dos.h>
7 #include "Shell.h"
8
9 LONG l2a(LONG x, STRPTR buf) /* long to ascii */
10 {
11     LONG a = (x < 0 ? -x : x);
12     LONG i = 31, j, len = 0;
13     TEXT tmp[32];
14
15     do {
16         tmp[i] = '0' + (a % 10);
17         ++len;
18     } while (i-- && (a /= 10));
19
20     if (x < 0)
21     {
22         tmp[i--] = '-';
23         ++len;
24     }
25
26     for (j = 0; j < len; ++j)
27         buf[j] = tmp[++i];
28
29     buf[j] = '\0';
30     return len;
31 }
32
33 void cliVarNum(CONST_STRPTR name, LONG value)
34 {
35     TEXT buf[32];
36     LONG len = l2a(value, buf);
37     SetVar(name, buf, len, GVF_LOCAL_ONLY);
38 }
39