Build fix: Missing message in LTTNG_DEPRECATED invocation
[lttng-tools.git] / src / common / utils.h
CommitLineData
81b86775 1/*
ab5be9fa 2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
81b86775 3 *
ab5be9fa 4 * SPDX-License-Identifier: GPL-2.0-only
81b86775 5 *
81b86775
DG
6 */
7
8#ifndef _COMMON_UTILS_H
9#define _COMMON_UTILS_H
10
8db0dc00 11#include <getopt.h>
159b042f 12#include <lttng/lttng-error.h>
28ab59d0 13#include <stdbool.h>
159b042f 14#include <stdint.h>
28ab59d0 15#include <sys/types.h>
159b042f 16#include <unistd.h>
70d0b120 17
18710679
JG
18#include <common/compat/directory-handle.h>
19
48a40005
SM
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
70d0b120
SM
24#define KIBI_LOG2 10
25#define MEBI_LOG2 20
26#define GIBI_LOG2 30
27
81b86775 28char *utils_expand_path(const char *path);
4b223a67 29char *utils_expand_path_keep_symlink(const char *path);
81b86775
DG
30int utils_create_pipe(int *dst);
31int utils_create_pipe_cloexec(int *dst);
094f381c 32int utils_create_pipe_cloexec_nonblock(int *dst);
81b86775 33void utils_close_pipe(int *src);
a4b92340 34char *utils_strdupdelim(const char *begin, const char *end);
b662582b 35int utils_set_fd_cloexec(int fd);
35f90c40 36int utils_create_pid_file(pid_t pid, const char *filepath);
d77dded2
JG
37int utils_mkdir(const char *path, mode_t mode, int uid, int gid);
38int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid);
40804255
JG
39int utils_stream_file_path(const char *path_name, const char *file_name,
40 uint64_t size, uint64_t count, const char *suffix,
41 char *out_stream_path, size_t stream_path_len);
5983a922 42int utils_parse_size_suffix(char const * const str, uint64_t * const size);
7010c033 43int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
cfa9a5a2 44int utils_get_count_order_u32(uint32_t x);
db5be0a3 45int utils_get_count_order_u64(uint64_t x);
4f00620d 46const char *utils_get_home_dir(void);
fb198a11 47char *utils_get_user_home_dir(uid_t uid);
26fe5938 48size_t utils_get_current_time_str(const char *format, char *dst, size_t len);
28ab59d0 49int utils_get_group_id(const char *name, bool warn, gid_t *gid);
8db0dc00
JG
50char *utils_generate_optstring(const struct option *long_options,
51 size_t opt_count);
c9cb3e7d 52int utils_create_lock_file(const char *filepath);
3d071855 53int utils_recursive_rmdir(const char *path);
93ec662e 54int utils_truncate_stream_file(int fd, off_t length);
4fc83d94 55int utils_show_help(int section, const char *page_name, const char *help_msg);
09b72f7a
FD
56int utils_get_memory_available(size_t *value);
57int utils_get_memory_total(size_t *value);
ce9ee1fb 58int utils_change_working_directory(const char *path);
159b042f
JG
59enum lttng_error_code utils_user_id_from_name(
60 const char *user_name, uid_t *user_id);
61enum lttng_error_code utils_group_id_from_name(
62 const char *group_name, gid_t *group_id);
81b86775 63
240baf2b
JR
64/*
65 * Parse `str` as an unsigned long long value.
66 *
67 * Return 0 on success. Return -1 on failure which can be because:
68 *
69 * - `str` is zero length
70 * - `str` contains invalid
71 */
240baf2b
JR
72int utils_parse_unsigned_long_long(const char *str,
73 unsigned long long *value);
74
48a40005
SM
75#if defined(__cplusplus)
76}
77#endif
78
81b86775 79#endif /* _COMMON_UTILS_H */
This page took 0.059627 seconds and 4 git commands to generate.