2 * Copyright (c) 2010-2011 Matthias Rustler
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include <aros/debug.h>
29 #include "identify_intern.h"
31 static CONST_STRPTR commands
[] =
90 static LONG
findcommand(TEXT
*);
92 /*****************************************************************************
95 #include <proto/identify.h>
97 AROS_LH4(ULONG
, IdFormatString
,
100 AROS_LHA(STRPTR
, string
, A0
),
101 AROS_LHA(STRPTR
, buffer
, A1
),
102 AROS_LHA(ULONG
, len
, D0
),
103 AROS_LHA(struct TagItem
*, tags
, A2
),
106 struct IdentifyBaseIntern
*, IdentifyBase
, 11, Identify
)
109 The buffer will be filled with the format string until
110 the format string terminates or the buffer size is reached.
112 The format string may contain format tags, which are
113 surrounded by dollar signs. Doing so, the printf formattings
114 are kept for a following printf.
116 Format tags are case sensitive!
118 If you want to write a dollar sign, then double it: '$$'.
120 These format tags are known:
177 For their meanings, see the include file.
180 String -- (STRPTR) Format string
182 Buffer -- (STRPTR) Buffer to be filled with the result
183 until the format string terminates or the buffer
186 Length -- (ULONG) Length of the buffer, including the
189 Tags -- (struct TagItem *) For future compatibility.
190 You must provide NULL or a pointer to TAG_DONE.
195 Length -- (ULONG) Length of the buffer that really
199 Remember that, unlike RawDoFmt(), the format tags must be
200 surrounded, i.e. started and ended, by a dollar sign '$'.
203 "Your CPU is a $CPU$ with $CPUCLOCK$ MHz"
208 IdHardware(), IdEstimateFormatSize()
215 *****************************************************************************/
225 CONST_STRPTR toinsert
;
228 if (from
== NULL
|| to
== NULL
|| len
< 1)
235 while (len
> 0 && *from
)
246 else if ((commandindex
= findcommand(from
)) != -1)
248 toinsert
= IdHardware(commandindex
, NULL
);
249 cpycnt
= strlen(toinsert
);
254 memcpy(to
, toinsert
, cpycnt
);
255 from
+= strlen(commands
[commandindex
]);
271 } /* IdFormatString */
274 static LONG
findcommand(TEXT
*t
)
278 for (i
= 0; i
< sizeof commands
/ sizeof (STRPTR
); i
++)
280 if (strncmp(t
, commands
[i
], strlen(commands
[i
])) == 0)