X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.h;h=791b1098e79fefce2b72229986d564f76c652ad0;hp=27a6f4849aced6cac50ea2e9ce7e4b0e36ee1693;hb=c922647daed3dd022be11980063b5fb816d8c091;hpb=ce9ee1fb2847b1603c4382c82aef95121f0e3d07 diff --git a/src/common/utils.h b/src/common/utils.h index 27a6f4849..791b1098e 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,29 +1,19 @@ /* - * Copyright (C) 2012 - David Goulet + * Copyright (C) 2012 David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _COMMON_UTILS_H #define _COMMON_UTILS_H -#include -#include -#include #include +#include #include +#include #include +#include #include @@ -31,10 +21,6 @@ #define MEBI_LOG2 20 #define GIBI_LOG2 30 -char *utils_partial_realpath(const char *path, char *resolved_path, - size_t size); -char *utils_expand_path(const char *path); -char *utils_expand_path_keep_symlink(const char *path); int utils_create_pipe(int *dst); int utils_create_pipe_cloexec(int *dst); int utils_create_pipe_cloexec_nonblock(int *dst); @@ -53,7 +39,10 @@ int utils_get_count_order_u32(uint32_t x); int utils_get_count_order_u64(uint64_t x); const char *utils_get_home_dir(void); char *utils_get_user_home_dir(uid_t uid); -size_t utils_get_current_time_str(const char *format, char *dst, size_t len); + +size_t utils_get_current_time_str(const char *format, char *dst, size_t len) + ATTR_FORMAT_STRFTIME(1); + int utils_get_group_id(const char *name, bool warn, gid_t *gid); char *utils_generate_optstring(const struct option *long_options, size_t opt_count); @@ -64,5 +53,20 @@ int utils_show_help(int section, const char *page_name, const char *help_msg); int utils_get_memory_available(size_t *value); int utils_get_memory_total(size_t *value); int utils_change_working_directory(const char *path); +enum lttng_error_code utils_user_id_from_name( + const char *user_name, uid_t *user_id); +enum lttng_error_code utils_group_id_from_name( + const char *group_name, gid_t *group_id); + +/* + * Parse `str` as an unsigned long long value. + * + * Return 0 on success. Return -1 on failure which can be because: + * + * - `str` is zero length + * - `str` contains invalid + */ +int utils_parse_unsigned_long_long(const char *str, + unsigned long long *value); #endif /* _COMMON_UTILS_H */