string_utils: add remove_trailing_slashes()

parent 9809fcfc
...@@ -217,13 +217,6 @@ out: ...@@ -217,13 +217,6 @@ out:
return values[i]; return values[i];
} }
extern void remove_trailing_slashes(char *p)
{
int l = strlen(p);
while (--l >= 0 && (p[l] == '/' || p[l] == '\n'))
p[l] = '\0';
}
/* /*
* Sets the process title to the specified title. Note that this may fail if * Sets the process title to the specified title. Note that this may fail if
* the kernel doesn't support PR_SET_MM_MAP (kernels <3.18). * the kernel doesn't support PR_SET_MM_MAP (kernels <3.18).
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#ifndef __LXC_INITUTILS_H #ifndef __LXC_INITUTILS_H
#define __LXC_INITUTILS_H #define __LXC_INITUTILS_H
#include "config.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h> #include <inttypes.h>
...@@ -31,12 +33,12 @@ ...@@ -31,12 +33,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h>
#include "config.h" #include "string_utils.h"
#define DEFAULT_VG "lxc" #define DEFAULT_VG "lxc"
#define DEFAULT_THIN_POOL "lxc" #define DEFAULT_THIN_POOL "lxc"
...@@ -70,7 +72,6 @@ struct prctl_mm_map { ...@@ -70,7 +72,6 @@ struct prctl_mm_map {
extern const char *lxc_global_config_value(const char *option_name); extern const char *lxc_global_config_value(const char *option_name);
extern void remove_trailing_slashes(char *p);
extern int setproctitle(char *title); extern int setproctitle(char *title);
#endif /* __LXC_INITUTILS_H */ #endif /* __LXC_INITUTILS_H */
...@@ -978,3 +978,10 @@ int lxc_is_line_empty(const char *line) ...@@ -978,3 +978,10 @@ int lxc_is_line_empty(const char *line)
return 0; return 0;
return 1; return 1;
} }
void remove_trailing_slashes(char *p)
{
int l = strlen(p);
while (--l >= 0 && (p[l] == '/' || p[l] == '\n'))
p[l] = '\0';
}
...@@ -111,5 +111,6 @@ extern int lxc_char_right_gc(const char *buffer, size_t len); ...@@ -111,5 +111,6 @@ extern int lxc_char_right_gc(const char *buffer, size_t len);
extern char *lxc_trim_whitespace_in_place(char *buffer); extern char *lxc_trim_whitespace_in_place(char *buffer);
extern int lxc_is_line_empty(const char *line); extern int lxc_is_line_empty(const char *line);
extern void remove_trailing_slashes(char *p);
#endif /* __LXC_STRING_UTILS_H */ #endif /* __LXC_STRING_UTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment