1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** FileX Component */
16 /** */
17 /** Utility */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define FX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "fx_api.h"
28 #include "fx_utility.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _fx_utility_string_length_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* William E. Lamie, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function returns length of string up to the maximum length. */
44 /* */
45 /* INPUT */
46 /* */
47 /* string Pointer to string */
48 /* max_length Maximum length which can be */
49 /* returned by function */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* return length of string */
54 /* */
55 /* CALLS */
56 /* */
57 /* None */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* _fx_utility_absolute_path_get Get absolute path */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
68 /* 09-30-2020 William E. Lamie Modified comment(s), */
69 /* resulting in version 6.1 */
70 /* */
71 /**************************************************************************/
_fx_utility_string_length_get(CHAR * string,UINT max_length)72 UINT _fx_utility_string_length_get(CHAR *string, UINT max_length)
73 {
74
75 UINT length;
76
77 /* Initialize length to 0. */
78 length = 0;
79
80 /* Loop to calculate the length. */
81 while (string[length] && (length < max_length))
82 {
83
84 /* Increment the length (index). */
85 length++;
86 }
87
88 /* Return length. */
89 return(length);
90 }
91
92