string_utils: make all helpers hidden

parent 0c397861
...@@ -330,55 +330,77 @@ LDADD = liblxc.la \ ...@@ -330,55 +330,77 @@ LDADD = liblxc.la \
if ENABLE_TOOLS if ENABLE_TOOLS
lxc_attach_SOURCES = tools/lxc_attach.c \ lxc_attach_SOURCES = tools/lxc_attach.c \
tools/arguments.c tools/arguments.h \
rexec.c rexec.h \ rexec.c rexec.h \
tools/arguments.c tools/arguments.h string_utils.c string_utils.h
lxc_autostart_SOURCES = tools/lxc_autostart.c \ lxc_autostart_SOURCES = tools/lxc_autostart.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_cgroup_SOURCES = tools/lxc_cgroup.c \ lxc_cgroup_SOURCES = tools/lxc_cgroup.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_config_SOURCES = tools/lxc_config.c \ lxc_config_SOURCES = tools/lxc_config.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_console_SOURCES = tools/lxc_console.c \ lxc_console_SOURCES = tools/lxc_console.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_destroy_SOURCES = tools/lxc_destroy.c \ lxc_destroy_SOURCES = tools/lxc_destroy.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_device_SOURCES = tools/lxc_device.c \ lxc_device_SOURCES = tools/lxc_device.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_execute_SOURCES = tools/lxc_execute.c \ lxc_execute_SOURCES = tools/lxc_execute.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_freeze_SOURCES = tools/lxc_freeze.c \ lxc_freeze_SOURCES = tools/lxc_freeze.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_info_SOURCES = tools/lxc_info.c \ lxc_info_SOURCES = tools/lxc_info.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_monitor_SOURCES = tools/lxc_monitor.c \ lxc_monitor_SOURCES = tools/lxc_monitor.c \
tools/arguments.c tools/arguments.h \
macro.h \ macro.h \
tools/arguments.c tools/arguments.h string_utils.c string_utils.h
lxc_ls_SOURCES = tools/lxc_ls.c \ lxc_ls_SOURCES = tools/lxc_ls.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_copy_SOURCES = tools/lxc_copy.c \ lxc_copy_SOURCES = tools/lxc_copy.c \
tools/arguments.c tools/arguments.h \ tools/arguments.c tools/arguments.h \
storage/storage_utils.c storage/storage_utils.h storage/storage_utils.c storage/storage_utils.h \
string_utils.c string_utils.h
lxc_start_SOURCES = tools/lxc_start.c \ lxc_start_SOURCES = tools/lxc_start.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_stop_SOURCES = tools/lxc_stop.c \ lxc_stop_SOURCES = tools/lxc_stop.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_top_SOURCES = tools/lxc_top.c \ lxc_top_SOURCES = tools/lxc_top.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_unfreeze_SOURCES = tools/lxc_unfreeze.c \ lxc_unfreeze_SOURCES = tools/lxc_unfreeze.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_unshare_SOURCES = tools/lxc_unshare.c \ lxc_unshare_SOURCES = tools/lxc_unshare.c \
tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h \
syscall_numbers.h \ syscall_numbers.h \
syscall_wrappers.h \ syscall_wrappers.h
tools/arguments.c tools/arguments.h
lxc_wait_SOURCES = tools/lxc_wait.c \ lxc_wait_SOURCES = tools/lxc_wait.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_create_SOURCES = tools/lxc_create.c \ lxc_create_SOURCES = tools/lxc_create.c \
tools/arguments.c tools/arguments.h \ tools/arguments.c tools/arguments.h \
storage/storage_utils.c storage/storage_utils.h storage/storage_utils.c storage/storage_utils.h \
string_utils.c string_utils.h
lxc_snapshot_SOURCES = tools/lxc_snapshot.c \ lxc_snapshot_SOURCES = tools/lxc_snapshot.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h
lxc_checkpoint_SOURCES = tools/lxc_checkpoint.c \ lxc_checkpoint_SOURCES = tools/lxc_checkpoint.c \
tools/arguments.c tools/arguments.h tools/arguments.c tools/arguments.h \
string_utils.c string_utils.h1
endif endif
if ENABLE_COMMANDS if ENABLE_COMMANDS
...@@ -401,6 +423,7 @@ lxc_monitord_SOURCES = cmd/lxc_monitord.c \ ...@@ -401,6 +423,7 @@ lxc_monitord_SOURCES = cmd/lxc_monitord.c \
mainloop.c mainloop.h \ mainloop.c mainloop.h \
monitor.c monitor.h \ monitor.c monitor.h \
process_utils.c process_utils.h \ process_utils.c process_utils.h \
string_utils.c string_utils.h \
syscall_numbers.h \ syscall_numbers.h \
utils.c utils.h utils.c utils.h
lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
......
...@@ -15,18 +15,17 @@ ...@@ -15,18 +15,17 @@
#endif #endif
/* convert variadic argument lists to arrays (for execl type argument lists) */ /* convert variadic argument lists to arrays (for execl type argument lists) */
extern char **lxc_va_arg_list_to_argv(va_list ap, size_t skip, int do_strdup); __hidden extern char **lxc_va_arg_list_to_argv(va_list ap, size_t skip, int do_strdup);
extern const char **lxc_va_arg_list_to_argv_const(va_list ap, size_t skip); __hidden extern const char **lxc_va_arg_list_to_argv_const(va_list ap, size_t skip);
/* /*
* Some simple string functions; if they return pointers, they are allocated * Some simple string functions; if they return pointers, they are allocated
* buffers. * buffers.
*/ */
extern char *lxc_string_replace(const char *needle, const char *replacement, __hidden extern char *lxc_string_replace(const char *needle, const char *replacement,
const char *haystack); const char *haystack);
extern bool lxc_string_in_array(const char *needle, const char **haystack); __hidden extern bool lxc_string_in_array(const char *needle, const char **haystack);
extern char *lxc_string_join(const char *sep, const char **parts, __hidden extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_prefix);
bool use_as_prefix);
/* /*
* Normalize and split path: Leading and trailing / are removed, multiple * Normalize and split path: Leading and trailing / are removed, multiple
* / are compactified, .. and . are resolved (.. on the top level is considered * / are compactified, .. and . are resolved (.. on the top level is considered
...@@ -38,69 +37,68 @@ extern char *lxc_string_join(const char *sep, const char **parts, ...@@ -38,69 +37,68 @@ extern char *lxc_string_join(const char *sep, const char **parts,
* ./bar/baz/.. -> { bar, NULL } * ./bar/baz/.. -> { bar, NULL }
* foo//bar -> { foo, bar, NULL } * foo//bar -> { foo, bar, NULL }
*/ */
extern char **lxc_normalize_path(const char *path); __hidden extern char **lxc_normalize_path(const char *path);
/* remove multiple slashes from the path, e.g. ///foo//bar -> /foo/bar */ /* remove multiple slashes from the path, e.g. ///foo//bar -> /foo/bar */
extern char *lxc_deslashify(const char *path); __hidden extern char *lxc_deslashify(const char *path);
extern char *lxc_append_paths(const char *first, const char *second); __hidden extern char *lxc_append_paths(const char *first, const char *second);
/* /*
* Note: the following two functions use strtok(), so they will never * Note: the following two functions use strtok(), so they will never
* consider an empty element, even if two delimiters are next to * consider an empty element, even if two delimiters are next to
* each other. * each other.
*/ */
extern bool lxc_string_in_list(const char *needle, const char *haystack, __hidden extern bool lxc_string_in_list(const char *needle, const char *haystack, char sep);
char sep); __hidden extern char **lxc_string_split(const char *string, char sep);
extern char **lxc_string_split(const char *string, char sep); __hidden extern char **lxc_string_split_and_trim(const char *string, char sep);
extern char **lxc_string_split_and_trim(const char *string, char sep); __hidden extern char **lxc_string_split_quoted(char *string);
extern char **lxc_string_split_quoted(char *string);
/* Append string to NULL-terminated string array. */ /* Append string to NULL-terminated string array. */
extern int lxc_append_string(char ***list, char *entry); __hidden extern int lxc_append_string(char ***list, char *entry);
/* Some simple array manipulation utilities */ /* Some simple array manipulation utilities */
typedef void (*lxc_free_fn)(void *); typedef void (*lxc_free_fn)(void *);
typedef void *(*lxc_dup_fn)(void *); typedef void *(*lxc_dup_fn)(void *);
extern int lxc_grow_array(void ***array, size_t *capacity, size_t new_size, __hidden extern int lxc_grow_array(void ***array, size_t *capacity, size_t new_size,
size_t capacity_increment); size_t capacity_increment);
extern void lxc_free_array(void **array, lxc_free_fn element_free_fn); __hidden extern void lxc_free_array(void **array, lxc_free_fn element_free_fn);
extern size_t lxc_array_len(void **array); __hidden extern size_t lxc_array_len(void **array);
extern void **lxc_append_null_to_array(void **array, size_t count); __hidden extern void **lxc_append_null_to_array(void **array, size_t count);
extern void remove_trailing_newlines(char *l); __hidden extern void remove_trailing_newlines(char *l);
/* Helper functions to parse numbers. */ /* Helper functions to parse numbers. */
extern int lxc_safe_uint(const char *numstr, unsigned int *converted); __hidden extern int lxc_safe_uint(const char *numstr, unsigned int *converted);
extern int lxc_safe_int(const char *numstr, int *converted); __hidden extern int lxc_safe_int(const char *numstr, int *converted);
extern int lxc_safe_long(const char *numstr, long int *converted); __hidden extern int lxc_safe_long(const char *numstr, long int *converted);
extern int lxc_safe_long_long(const char *numstr, long long int *converted); __hidden extern int lxc_safe_long_long(const char *numstr, long long int *converted);
extern int lxc_safe_ulong(const char *numstr, unsigned long *converted); __hidden extern int lxc_safe_ulong(const char *numstr, unsigned long *converted);
extern int lxc_safe_uint64(const char *numstr, uint64_t *converted, int base); __hidden extern int lxc_safe_uint64(const char *numstr, uint64_t *converted, int base);
/* Handles B, kb, MB, GB. Detects overflows and reports -ERANGE. */ /* Handles B, kb, MB, GB. Detects overflows and reports -ERANGE. */
extern int parse_byte_size_string(const char *s, int64_t *converted); __hidden extern int parse_byte_size_string(const char *s, int64_t *converted);
/* /*
* Concatenate all passed-in strings into one path. Do not fail. If any piece * Concatenate all passed-in strings into one path. Do not fail. If any piece
* is not prefixed with '/', add a '/'. * is not prefixed with '/', add a '/'.
*/ */
__attribute__((sentinel)) extern char *must_concat(size_t *len, const char *first, ...); __hidden __attribute__((sentinel)) extern char *must_concat(size_t *len, const char *first, ...);
__attribute__((sentinel)) extern char *must_make_path(const char *first, ...); __hidden __attribute__((sentinel)) extern char *must_make_path(const char *first, ...);
__attribute__((sentinel)) extern char *must_append_path(char *first, ...); __hidden __attribute__((sentinel)) extern char *must_append_path(char *first, ...);
/* Return copy of string @entry. Do not fail. */ /* Return copy of string @entry. Do not fail. */
extern char *must_copy_string(const char *entry); __hidden extern char *must_copy_string(const char *entry);
/* Re-allocate a pointer, do not fail */ /* Re-allocate a pointer, do not fail */
extern void *must_realloc(void *orig, size_t sz); __hidden extern void *must_realloc(void *orig, size_t sz);
extern int lxc_char_left_gc(const char *buffer, size_t len); __hidden extern int lxc_char_left_gc(const char *buffer, size_t len);
extern int lxc_char_right_gc(const char *buffer, size_t len); __hidden extern int lxc_char_right_gc(const char *buffer, size_t len);
extern char *lxc_trim_whitespace_in_place(char *buffer); __hidden extern char *lxc_trim_whitespace_in_place(char *buffer);
extern int lxc_is_line_empty(const char *line); __hidden extern int lxc_is_line_empty(const char *line);
extern void remove_trailing_slashes(char *p); __hidden extern void remove_trailing_slashes(char *p);
static inline bool is_empty_string(const char *s) static inline bool is_empty_string(const char *s)
{ {
......
...@@ -31,7 +31,8 @@ lxc_test_raw_clone_SOURCES = lxc_raw_clone.c \ ...@@ -31,7 +31,8 @@ lxc_test_raw_clone_SOURCES = lxc_raw_clone.c \
lxctest.h \ lxctest.h \
../lxc/namespace.c ../lxc/namespace.h \ ../lxc/namespace.c ../lxc/namespace.h \
../lxc/process_utils.c ../lxc/process_utils.h ../lxc/process_utils.c ../lxc/process_utils.h
../lxc/utils.c ../lxc/utils.h ../lxc/utils.c ../lxc/utils.h \
../lxc/string_utils.c ../lxc/string_utils.h
lxc_test_reboot_SOURCES = reboot.c lxc_test_reboot_SOURCES = reboot.c
lxc_test_saveconfig_SOURCES = saveconfig.c lxc_test_saveconfig_SOURCES = saveconfig.c
lxc_test_share_ns_SOURCES = share_ns.c \ lxc_test_share_ns_SOURCES = share_ns.c \
...@@ -44,7 +45,8 @@ lxc_test_startone_SOURCES = startone.c ...@@ -44,7 +45,8 @@ lxc_test_startone_SOURCES = startone.c
lxc_test_state_server_SOURCES = state_server.c \ lxc_test_state_server_SOURCES = state_server.c \
lxctest.h \ lxctest.h \
../lxc/compiler.h ../lxc/compiler.h
lxc_test_utils_SOURCES = lxc-test-utils.c lxctest.h lxc_test_utils_SOURCES = lxc-test-utils.c lxctest.h \
../lxc/string_utils.c ../lxc/string_utils.h
AM_CFLAGS=-DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \ AM_CFLAGS=-DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
-DLXCPATH=\"$(LXCPATH)\" \ -DLXCPATH=\"$(LXCPATH)\" \
......
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