1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2017. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
/** @file string.h */
/* value which specifies "infinity" for a numeric variable */
/* value which specifies "auto" for a variable */
/* the numeric value of "infinity" */
/* value which specifies "auto" for a numeric variable */
/**
* Expand a partial path to full path.
*
* @param path Path to expand.
* @param fullpath Filled with full path.
* @param max Room in "fullpath"
*/
void ;
/**
* Fill a filename template. The following values in the string are replaced:
* %p - replaced by process id
* %h - replaced by host name
*
* @param tmpl File name template (possibly containing formatting sequences)
* @param buf Filled with resulting file name
* @param max Maximal size of destination buffer.
*/
void ;
/**
* Strip specified number of last components from file/dir path
*
* @param path The pointer of file path to be stripped
* @param num_layers The number of components to be stripped
*
* @return Pointer of the stripped dir path.
*/
char *;
/**
* Format a string to a buffer of given size, and fill the rest of the buffer
* with '\0'. Also, guarantee that the last char in the buffer is '\0'.
*
* @param buf Buffer to format the string to.
* @param size Buffer size.
* @param fmt Format string.
*/
void ;
/**
* Same as strncpy(), but guarantee that the last char in the buffer is '\0'.
*/
void ;
/**
* Return a number filled with the first characters of the string.
*/
uint64_t ;
/**
* Convert a memory units value to a string which is abbreviated if possible.
* For example:
* 1024 -> 1kb
*
* @param value Value to convert.
* @param buf Buffer to place the string.
* @param max Maximal length of the buffer.
*
* @return Pointer to 'buf', which holds the resulting string.
*/
char *;
/**
* Convert a pair of memory units values to a range string which is abbreviated
* if possible.
*
* For example:
* 1024, 4096 -> 1kb..4kb
*
* @param range_start Range start value.
* @param range_end Range end value.
* @param buf Buffer to place the string.
* @param max Maximal length of the buffer.
*
* @return Pointer to 'buf', which holds the resulting string.
*/
const char *;
/**
* Convert a string holding memory units to a numeric value.
*
* @param buf String to convert
* @param dest Numeric value of the string
*
* @return UCS_OK if successful, or error code otherwise.
*/
ucs_status_t ;
/**
* Return the numeric value of the memunits prefix.
* For example:
* 'M' -> 1048576
*/
size_t ;
/**
* Format a vararg string to a buffer of given size, and guarantee that the last
* char in the buffer is '\0'.
*
* @param buf Buffer to format the string to.
* @param size Buffer size.
* @param fmt Format string.
* @param ap Variable argument list for the format string.
*/
void ;
/**
* Format a string to a buffer of given size, and guarantee that the last char
* in the buffer is '\0'.
*
* @param buf Buffer to format the string to.
* @param size Buffer size.
* @param fmt Format string.
*/
void ;
/**
* Copy string limited by len bytes. Destination string is always ended by '\0'
*
* @param dst Destination buffer
* @param src Source string
* @param len Maximum string length to copy
*
* @return address of destination buffer
*/
char* ;
/**
* Remove whitespace characters in the beginning and end of the string, as
* detected by isspace(3). Returns a pointer to the new string (which may be a
* substring of 'str'). The original string 'str' may be modified in-place.
*
* @param str String to remove whitespaces from.
* @return Pointer to the new string, with leading/trailing whitespaces removed.
*/
char *;
/**
* Get pointer to file name in path, same as basename but do not
* modify source string.
*
* @param path Path to parse.
*
* @return file name
*/
static UCS_F_ALWAYS_INLINE const char*
/**
* Dump binary array into string in hex format. Destination string is
* always ended by '\0'.
*
* @param data Source array to dump.
* @param length Length of source array in bytes.
* @param buf Destination string.
* @param max Max length of destination string including terminating
* '\0' byte.
* @param per_line Number of bytes in source array to print per line
* or SIZE_MAX for single line.
*
* @return address of destination buffer
*/
const char *;
/**
* Convert the given flags to a string that represents them.
*
* @param str String to hold the flags string values.
* @param max Size of the string.
* @param flags Flags to be converted.
* @param str_table Conversion table - from flag value to a string.
*
* @return String that holds the representation of the given flags.
*/
const char* ;
/**
* Find the number of occurences of a char in the given string.
*
* @param str String buffer to search.
* @param c Character to search in the string.
*
* @return a value between 0 and strlen(str).
*/
size_t ;
/**
* Length of the common string from the start of two given strings.
*
* @param str1 First string buffer.
* @param str2 Second string buffer.
*
* @return a value between 0 and min(strlen(str1), strlen(str2)).
*/
size_t ;
/*
* Return the common parent directory, without the trailing slash.
* For example, for /sys/ab12 and /sys/ab23 return /sys
*
* @param path1 String pointing to first path.
* @param path2 String pointing to second path.
* @param common_path Buffer to hold the common parent path. The size of the
* buffer must be large enough to hold the longest common
* parent path, plus a '\0' terminator.
* */
void ;
/**
* Get total number of segments that are different in the two paths. Segments
* are separated by `/`. For example:
*
* path1 path2 result
* -------------------------------
* /a/b/c/d /a/x/y 4
* /a/b/c/d /a/b/c/e 2
* /a/b/c /a/b/c 0
* /a/b/c /a/b/c/d 1
*
* @param path1 String pointing to first path
* @param path2 String pointing to second path
*/
size_t ;
/**
* Convert a bitmask to a string buffer that represents it.
*
* @param mask Bitmask.
* @param strb String buffer.
*
* @return C-style string representing a bitmask filled in a string buffer.
*/
const char* ;
/**
* Find a string in a NULL-terminated array of strings.
*
* @param str String to search for.
* @param string_list NULL-terminated array of strings.
* @param case_sensitive Whether to perform case sensitive search.
*
* @return Index of the string in the array, or -1 if not found.
*/
ssize_t ;
/**
* Split a string to tokens. The given string is modified in-place.
* If the number of tokens is less than than count, the remaining variables
* are set to NULL.
*
* @param str String to split
* @param delim Delimiters to split by.
* @param count Split to this number of tokens.
* @param ... Variable argument list of pointers to strings (char **) that
* will be filled with the tokens. The number of variables must
* be equal to count.
*
* @return If the number of tokens in the string is grater than 'count', the
function returns the remainder. Otherwise, it returns NULL.
*/
char* ;
/** Quantifier suffixes for memory units ("K", "M", "G", etc) */
extern const char *ucs_memunits_suffixes;