This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ut_strupr
- acpi_ut_stricmp
- acpi_ut_safe_strcpy
- acpi_ut_safe_strcat
- acpi_ut_safe_strncat
- acpi_ut_safe_strncpy
1
2
3
4
5
6
7
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10
11 #define _COMPONENT ACPI_UTILITIES
12 ACPI_MODULE_NAME("utnonansi")
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 void acpi_ut_strlwr(char *src_string)
30 {
31 char *string;
32
33 ACPI_FUNCTION_ENTRY();
34
35 if (!src_string) {
36 return;
37 }
38
39
40
41 for (string = src_string; *string; string++) {
42 *string = (char)tolower((int)*string);
43 }
44 }
45
46
47
48
49
50
51
52
53
54
55
56
57
58 void acpi_ut_strupr(char *src_string)
59 {
60 char *string;
61
62 ACPI_FUNCTION_ENTRY();
63
64 if (!src_string) {
65 return;
66 }
67
68
69
70 for (string = src_string; *string; string++) {
71 *string = (char)toupper((int)*string);
72 }
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 int acpi_ut_stricmp(char *string1, char *string2)
91 {
92 int c1;
93 int c2;
94
95 do {
96 c1 = tolower((int)*string1);
97 c2 = tolower((int)*string2);
98
99 string1++;
100 string2++;
101 }
102 while ((c1 == c2) && (c1));
103
104 return (c1 - c2);
105 }
106
107 #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) || defined (ACPI_DEBUG_OUTPUT)
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 u8 acpi_ut_safe_strcpy(char *dest, acpi_size dest_size, char *source)
129 {
130
131 if (strlen(source) >= dest_size) {
132 return (TRUE);
133 }
134
135 strcpy(dest, source);
136 return (FALSE);
137 }
138
139 u8 acpi_ut_safe_strcat(char *dest, acpi_size dest_size, char *source)
140 {
141
142 if ((strlen(dest) + strlen(source)) >= dest_size) {
143 return (TRUE);
144 }
145
146 strcat(dest, source);
147 return (FALSE);
148 }
149
150 u8
151 acpi_ut_safe_strncat(char *dest,
152 acpi_size dest_size,
153 char *source, acpi_size max_transfer_length)
154 {
155 acpi_size actual_transfer_length;
156
157 actual_transfer_length = ACPI_MIN(max_transfer_length, strlen(source));
158
159 if ((strlen(dest) + actual_transfer_length) >= dest_size) {
160 return (TRUE);
161 }
162
163 strncat(dest, source, max_transfer_length);
164 return (FALSE);
165 }
166
167 void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
168 {
169
170
171 strncpy(dest, source, dest_size);
172 dest[dest_size - 1] = 0;
173 }
174
175 #endif