remove unused file
[AROS.git] / workbench / libs / identify / idestimateformatsize.c
bloba5de6f96b177df81d499fafb1b1fe745e77fea40
1 /*
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
20 * IN THE SOFTWARE.
22 * $Id$
25 #include "identify_intern.h"
27 static STRPTR finddollar(TEXT *t);
29 /*****************************************************************************
31 NAME */
32 #include <proto/identify.h>
34 AROS_LH2(ULONG, IdEstimateFormatSize,
36 /* SYNOPSIS */
37 AROS_LHA(STRPTR , string, A0),
38 AROS_LHA(struct TagItem *, tags , A1),
40 /* LOCATION */
41 struct IdentifyBaseIntern *, IdentifyBase, 12, Identify)
43 /* FUNCTION
44 Estimates the size of the buffer that will contain the output
45 of the format string when used on IdFormatString().
47 INPUTS
48 String -- (STRPTR) Format string
49 Tags -- (struct TagItem *) Tags, currently NULL or TAG_DONE.
51 RESULT
52 Length -- (ULONG) Length of the buffer size that will
53 be able to hold the entire result.
55 TAGS
56 None yet.
58 NOTES
59 The returned size will be large enough to contain the result
60 of a IdFormatString(). It is not necessarily the size of the
61 resulting buffer (the result length of IdFormatString()).
63 EXAMPLE
65 BUGS
67 SEE ALSO
68 IdHardware(), IdFormatString()
70 INTERNALS
72 HISTORY
75 *****************************************************************************/
77 AROS_LIBFUNC_INIT
79 // no tags
81 TEXT *from = string;
82 ULONG result = 1;
84 if (from == NULL)
86 return 0;
89 while (*from)
91 if (*from == '$')
93 from++;
94 if (*from == '$')
96 from++;
97 result++;
99 else
101 from = finddollar(from);
102 result += STRBUFSIZE;
105 else
107 result++;
108 from++;
112 return result;
114 AROS_LIBFUNC_EXIT
115 } /* IdEstimateFormatSize */
118 static STRPTR finddollar(TEXT *t)
120 while (*t && *t != '$')
122 t++;
125 if (*t) // '$'
127 return t + 1;
129 else
131 return t;