#include "conf.h"
#include "util-device.h"
#include "util-ioctl.h"
+#include "util-misc.h"
#include "device-storage.h"
return NULL;
}
-static void ShortenString(const char *input,
- char *output, size_t output_size, char c)
-{
- const size_t str_len = strlen(input);
- size_t half = (output_size - 1) / 2;
-
- /* If the output size is an even number */
- if (half * 2 == (output_size - 1)) {
- half = half - 1;
- }
-
- size_t spaces = (output_size - 1) - (half * 2);
-
- /* Add the first half to the new string */
- snprintf(output, half+1, "%s", input);
-
- /* Add the amount of spaces wanted */
- size_t length = half;
- for (size_t i = half; i < half + spaces; i++) {
- char s[2] = "";
- snprintf(s, sizeof(s), "%c", c);
- length = strlcat(output, s, output_size);
- }
-
- snprintf(output + length, half + 1, "%s", input + (str_len - half));
-}
-
/** \internal
* \brief Shorten a device name that is to long
*
return 0;
}
+void ShortenString(const char *input,
+ char *output, size_t output_size, char c)
+{
+ const size_t str_len = strlen(input);
+ size_t half = (output_size - 1) / 2;
+
+ /* If the output size is an even number */
+ if (half * 2 == (output_size - 1)) {
+ half = half - 1;
+ }
+
+ size_t spaces = (output_size - 1) - (half * 2);
+
+ /* Add the first half to the new string */
+ snprintf(output, half+1, "%s", input);
+
+ /* Add the amount of spaces wanted */
+ size_t length = half;
+ for (size_t i = half; i < half + spaces; i++) {
+ char s[2] = "";
+ snprintf(s, sizeof(s), "%c", c);
+ length = strlcat(output, s, output_size);
+ }
+
+ snprintf(output + length, half + 1, "%s", input + (str_len - half));
+}
+
/*********************************Unittests********************************/
#ifdef UNITTESTS
void ParseSizeInit(void);
void ParseSizeDeinit(void);
+void ShortenString(const char *input,
+ char *output, size_t output_size, char c);
+
#endif /* __UTIL_MISC_H__ */