提交 32001591 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!35 utils: add prefix for utils function

Merge pull request !35 from lifeng_isula/master_fix_util
...@@ -31,7 +31,7 @@ Buffer *buffer_alloc(size_t initial_size) ...@@ -31,7 +31,7 @@ Buffer *buffer_alloc(size_t initial_size)
return NULL; return NULL;
} }
buf = util_common_calloc_s(sizeof(Buffer)); buf = lcr_util_common_calloc_s(sizeof(Buffer));
if (buf == NULL) { if (buf == NULL) {
return NULL; return NULL;
} }
...@@ -104,7 +104,7 @@ static int buffer_grow(Buffer *buf, size_t minimum_size) ...@@ -104,7 +104,7 @@ static int buffer_grow(Buffer *buf, size_t minimum_size)
return -1; return -1;
} }
tmp = util_common_calloc_s(new_size); tmp = lcr_util_common_calloc_s(new_size);
if (tmp == NULL) { if (tmp == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
return -1; return -1;
......
...@@ -40,7 +40,7 @@ static int files_limit_checker(const char *value) ...@@ -40,7 +40,7 @@ static int files_limit_checker(const char *value)
long long limit = 0; long long limit = 0;
int ret = 0; int ret = 0;
ret = util_safe_llong(value, &limit); ret = lcr_util_safe_llong(value, &limit);
if (ret) { if (ret) {
ret = -1; ret = -1;
} }
...@@ -75,7 +75,7 @@ static int check_console_log_filesize(const char *value) ...@@ -75,7 +75,7 @@ static int check_console_log_filesize(const char *value)
return ret; return ret;
} }
if (parse_byte_size_string(value, &tmp) == 0 && tmp >= min) { if (lcr_parse_byte_size_string(value, &tmp) == 0 && tmp >= min) {
ret = 0; ret = 0;
} }
...@@ -94,7 +94,7 @@ static int check_oom_score_adj(const char *value) ...@@ -94,7 +94,7 @@ static int check_oom_score_adj(const char *value)
return ret; return ret;
} }
if (util_safe_int(value, &tmp) == 0 && tmp >= min && tmp <= max) { if (lcr_util_safe_int(value, &tmp) == 0 && tmp >= min && tmp <= max) {
ret = 0; ret = 0;
} }
lcr_set_error_message(LCR_ERR_RUNTIME, "Invalid value %s, range for oom score adj is [%d, %d]", value, min, max); lcr_set_error_message(LCR_ERR_RUNTIME, "Invalid value %s, range for oom score adj is [%d, %d]", value, min, max);
...@@ -110,7 +110,7 @@ static int check_console_log_filerotate(const char *value) ...@@ -110,7 +110,7 @@ static int check_console_log_filerotate(const char *value)
return ret; return ret;
} }
if (util_safe_uint(value, &tmp) == 0) { if (lcr_util_safe_uint(value, &tmp) == 0) {
ret = 0; ret = 0;
} }
...@@ -124,7 +124,7 @@ static int check_rootfs_mount(const char *value) ...@@ -124,7 +124,7 @@ static int check_rootfs_mount(const char *value)
return -1; return -1;
} }
if (!dir_exists(value)) { if (!lcr_util_dir_exists(value)) {
lcr_set_error_message(LCR_ERR_RUNTIME, "Container rootfs mount path '%s' is not exist", value); lcr_set_error_message(LCR_ERR_RUNTIME, "Container rootfs mount path '%s' is not exist", value);
return -1; return -1;
} }
...@@ -273,18 +273,18 @@ struct lcr_list *create_lcr_list_node(const char *key, const char *value) ...@@ -273,18 +273,18 @@ struct lcr_list *create_lcr_list_node(const char *key, const char *value)
struct lcr_list *node = NULL; struct lcr_list *node = NULL;
lcr_config_item_t *entry = NULL; lcr_config_item_t *entry = NULL;
node = util_common_calloc_s(sizeof(*node)); node = lcr_util_common_calloc_s(sizeof(*node));
if (node == NULL) { if (node == NULL) {
return NULL; return NULL;
} }
entry = util_common_calloc_s(sizeof(*entry)); entry = lcr_util_common_calloc_s(sizeof(*entry));
if (entry == NULL) { if (entry == NULL) {
free(node); free(node);
return NULL; return NULL;
} }
entry->name = util_strdup_s(key); entry->name = lcr_util_strdup_s(key);
entry->value = util_strdup_s(value); entry->value = lcr_util_strdup_s(value);
node->elem = entry; node->elem = entry;
return node; return node;
...@@ -434,7 +434,7 @@ static int trans_oci_process_init_groups(const oci_runtime_spec_process *proc, s ...@@ -434,7 +434,7 @@ static int trans_oci_process_init_groups(const oci_runtime_spec_process *proc, s
} }
size_t total_len = (LCR_NUMSTRLEN64 + 1) * proc->user->additional_gids_len; size_t total_len = (LCR_NUMSTRLEN64 + 1) * proc->user->additional_gids_len;
char *gids = util_common_calloc_s(total_len); char *gids = lcr_util_common_calloc_s(total_len);
if (gids == NULL) { if (gids == NULL) {
goto out; goto out;
} }
...@@ -539,7 +539,7 @@ static int trans_oci_process_env_and_cap(const oci_runtime_spec_process *proc, s ...@@ -539,7 +539,7 @@ static int trans_oci_process_env_and_cap(const oci_runtime_spec_process *proc, s
size_t i; size_t i;
for (i = 0; i < proc->env_len; i++) { for (i = 0; i < proc->env_len; i++) {
char *replaced = util_string_replace(" ", SPACE_MAGIC_STR, proc->env[i]); char *replaced = lcr_util_string_replace(" ", SPACE_MAGIC_STR, proc->env[i]);
if (replaced == NULL) { if (replaced == NULL) {
ERROR("memory allocation error"); ERROR("memory allocation error");
goto out; goto out;
...@@ -590,7 +590,7 @@ static int trans_oci_process_prlimit(const oci_runtime_spec_process *proc, struc ...@@ -590,7 +590,7 @@ static int trans_oci_process_prlimit(const oci_runtime_spec_process *proc, struc
char buf_key[30] = { 0 }; char buf_key[30] = { 0 };
char buf_value[60] = { 0 }; char buf_value[60] = { 0 };
size_t j; size_t j;
char *type = util_strdup_s(lr->type); char *type = lcr_util_strdup_s(lr->type);
// Lower case type,eg. RLIMIT_NOFILE -> RLIMIT_nofile // Lower case type,eg. RLIMIT_NOFILE -> RLIMIT_nofile
for (j = strlen("RLIMIT_"); j < strlen(type); j++) { for (j = strlen("RLIMIT_"); j < strlen(type); j++) {
...@@ -699,7 +699,7 @@ struct lcr_list *trans_oci_process(const oci_runtime_spec_process *proc) ...@@ -699,7 +699,7 @@ struct lcr_list *trans_oci_process(const oci_runtime_spec_process *proc)
{ {
struct lcr_list *conf = NULL; struct lcr_list *conf = NULL;
conf = util_common_calloc_s(sizeof(struct lcr_list)); conf = lcr_util_common_calloc_s(sizeof(struct lcr_list));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -770,7 +770,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru ...@@ -770,7 +770,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru
int nret; int nret;
if (is_root_readonly(root)) { if (is_root_readonly(root)) {
value = util_strdup_s("ro"); value = lcr_util_strdup_s("ro");
} }
if ((linux != NULL) && linux->rootfs_propagation != NULL) { if ((linux != NULL) && linux->rootfs_propagation != NULL) {
...@@ -781,7 +781,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru ...@@ -781,7 +781,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru
goto out; goto out;
} }
newsize = strlen(linux->rootfs_propagation) + strlen(value) + APPEND_COMMA_END_SIZE; newsize = strlen(linux->rootfs_propagation) + strlen(value) + APPEND_COMMA_END_SIZE;
nret = mem_realloc((void **)&tmpvalue, newsize, value, strlen(value)); nret = lcr_mem_realloc((void **)&tmpvalue, newsize, value, strlen(value));
if (nret < 0) { if (nret < 0) {
ERROR("Out of memory"); ERROR("Out of memory");
goto out; goto out;
...@@ -793,7 +793,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru ...@@ -793,7 +793,7 @@ static int trans_oci_root_rootfs_options(const oci_runtime_spec_root *root, stru
goto out; goto out;
} }
} else { } else {
value = util_strdup_s(linux->rootfs_propagation); value = lcr_util_strdup_s(linux->rootfs_propagation);
} }
} }
...@@ -815,7 +815,7 @@ struct lcr_list *trans_oci_root(const oci_runtime_spec_root *root, const oci_run ...@@ -815,7 +815,7 @@ struct lcr_list *trans_oci_root(const oci_runtime_spec_root *root, const oci_run
{ {
struct lcr_list *conf = NULL; struct lcr_list *conf = NULL;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -887,12 +887,12 @@ static char *trans_mount_to_lxc_options(const defs_mount *mount) ...@@ -887,12 +887,12 @@ static char *trans_mount_to_lxc_options(const defs_mount *mount)
lxc_options = isdir ? ",create=dir" : ",create=file"; lxc_options = isdir ? ",create=dir" : ",create=file";
prefix = util_string_join(",", (const char **)mount->options, mount->options_len); prefix = lcr_util_string_join(",", (const char **)mount->options, mount->options_len);
if (prefix == NULL) { if (prefix == NULL) {
prefix = util_strdup_s("defaults"); prefix = lcr_util_strdup_s("defaults");
} }
result = util_string_append(lxc_options, prefix); result = lcr_util_string_append(lxc_options, prefix);
free(prefix); free(prefix);
return result; return result;
...@@ -926,15 +926,15 @@ static char *get_mount_readmode_options(const defs_mount *mount, const char *typ ...@@ -926,15 +926,15 @@ static char *get_mount_readmode_options(const defs_mount *mount, const char *typ
if (is_mount_type_cgroup(type)) { if (is_mount_type_cgroup(type)) {
if (readonly) { if (readonly) {
options = util_strdup_s("ro:force"); options = lcr_util_strdup_s("ro:force");
} else { } else {
options = util_strdup_s("rw:force"); options = lcr_util_strdup_s("rw:force");
} }
} else { } else {
if (readonly) { if (readonly) {
options = util_strdup_s("ro"); options = lcr_util_strdup_s("ro");
} else { } else {
options = util_strdup_s("rw"); options = lcr_util_strdup_s("rw");
} }
} }
...@@ -996,12 +996,12 @@ static struct lcr_list *trans_mount_entry_to_lxc(const defs_mount *mount) ...@@ -996,12 +996,12 @@ static struct lcr_list *trans_mount_entry_to_lxc(const defs_mount *mount)
char *replaced_dest = NULL; char *replaced_dest = NULL;
int ret; int ret;
char *replaced_source = util_string_replace(" ", SPACE_MAGIC_STR, mount->source); char *replaced_source = lcr_util_string_replace(" ", SPACE_MAGIC_STR, mount->source);
if (replaced_source == NULL) { if (replaced_source == NULL) {
ERROR("memory allocation error"); ERROR("memory allocation error");
goto err_out; goto err_out;
} }
replaced_dest = util_string_replace(" ", SPACE_MAGIC_STR, mount->destination); replaced_dest = lcr_util_string_replace(" ", SPACE_MAGIC_STR, mount->destination);
if (replaced_dest == NULL) { if (replaced_dest == NULL) {
ERROR("memory allocation error"); ERROR("memory allocation error");
free(replaced_source); free(replaced_source);
...@@ -1117,7 +1117,7 @@ struct lcr_list *trans_oci_mounts(const oci_runtime_spec *c) ...@@ -1117,7 +1117,7 @@ struct lcr_list *trans_oci_mounts(const oci_runtime_spec *c)
bool system_container = is_system_container(c); bool system_container = is_system_container(c);
bool external_rootfs = is_external_rootfs(c); bool external_rootfs = is_external_rootfs(c);
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -1169,7 +1169,7 @@ static int trans_one_oci_id_mapping(struct lcr_list *conf, const char *typ, cons ...@@ -1169,7 +1169,7 @@ static int trans_one_oci_id_mapping(struct lcr_list *conf, const char *typ, cons
if (nret < 0 || (size_t)nret >= sizeof(subid)) { if (nret < 0 || (size_t)nret >= sizeof(subid)) {
return -1; return -1;
} }
nret = util_atomic_write_file(path, subid); nret = lcr_util_atomic_write_file(path, subid);
if (nret < 0) { if (nret < 0) {
return -1; return -1;
} }
...@@ -1208,7 +1208,7 @@ static struct lcr_list *trans_oci_id_mapping(const oci_runtime_config_linux *l) ...@@ -1208,7 +1208,7 @@ static struct lcr_list *trans_oci_id_mapping(const oci_runtime_config_linux *l)
struct lcr_list *conf = NULL; struct lcr_list *conf = NULL;
int nret = 0; int nret = 0;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -1852,7 +1852,7 @@ static struct lcr_list *trans_oci_resources(const oci_runtime_config_linux_resou ...@@ -1852,7 +1852,7 @@ static struct lcr_list *trans_oci_resources(const oci_runtime_config_linux_resou
{ {
struct lcr_list *conf = NULL; struct lcr_list *conf = NULL;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -1912,7 +1912,7 @@ static char *trans_oci_namespace_to_lxc(const char *typ) ...@@ -1912,7 +1912,7 @@ static char *trans_oci_namespace_to_lxc(const char *typ)
for (p = namespaces_map; p != NULL && p->ns_name != NULL; p++) { for (p = namespaces_map; p != NULL && p->ns_name != NULL; p++) {
if (strcmp(typ, p->ns_name) == 0) { if (strcmp(typ, p->ns_name) == 0) {
return util_strdup_s(p->lxc_name); return lcr_util_strdup_s(p->lxc_name);
} }
} }
return NULL; return NULL;
...@@ -1926,7 +1926,7 @@ static struct lcr_list *trans_oci_namespaces(const oci_runtime_config_linux *l) ...@@ -1926,7 +1926,7 @@ static struct lcr_list *trans_oci_namespaces(const oci_runtime_config_linux *l)
size_t i; size_t i;
oci_runtime_defs_linux_namespace_reference *ns = NULL; oci_runtime_defs_linux_namespace_reference *ns = NULL;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -1970,7 +1970,7 @@ static struct lcr_list *trans_oci_mask_ro_paths(const oci_runtime_config_linux * ...@@ -1970,7 +1970,7 @@ static struct lcr_list *trans_oci_mask_ro_paths(const oci_runtime_config_linux *
size_t i; size_t i;
char *path = NULL; char *path = NULL;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -2020,7 +2020,7 @@ static struct lcr_list *trans_oci_linux_devices(const oci_runtime_config_linux * ...@@ -2020,7 +2020,7 @@ static struct lcr_list *trans_oci_linux_devices(const oci_runtime_config_linux *
oci_runtime_defs_linux_device *device = NULL; oci_runtime_defs_linux_device *device = NULL;
char buf_value[POPULATE_DEVICE_SIZE] = { 0 }; char buf_value[POPULATE_DEVICE_SIZE] = { 0 };
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -2089,15 +2089,15 @@ static inline bool is_seccomp_action_errno(const char *value) ...@@ -2089,15 +2089,15 @@ static inline bool is_seccomp_action_errno(const char *value)
static char *seccomp_trans_action(const char *action) static char *seccomp_trans_action(const char *action)
{ {
if (is_seccomp_action_kill(action)) { if (is_seccomp_action_kill(action)) {
return util_strdup_s("kill"); return lcr_util_strdup_s("kill");
} else if (is_seccomp_action_trap(action)) { } else if (is_seccomp_action_trap(action)) {
return util_strdup_s("trap"); return lcr_util_strdup_s("trap");
} else if (is_seccomp_action_allow(action)) { } else if (is_seccomp_action_allow(action)) {
return util_strdup_s("allow"); return lcr_util_strdup_s("allow");
} else if (is_seccomp_action_trace(action)) { } else if (is_seccomp_action_trace(action)) {
return util_strdup_s("trace 1"); return lcr_util_strdup_s("trace 1");
} else if (is_seccomp_action_errno(action)) { } else if (is_seccomp_action_errno(action)) {
return util_strdup_s("errno 1"); return lcr_util_strdup_s("errno 1");
} }
return NULL; return NULL;
...@@ -2164,11 +2164,11 @@ static char *get_hostarch(void) ...@@ -2164,11 +2164,11 @@ static char *get_hostarch(void)
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (i == 0 || i == 1 || i == 2) { if (i == 0 || i == 1 || i == 2) {
if (strcmp(uts.machine, arch_type[i].arch) == 0) { if (strcmp(uts.machine, arch_type[i].arch) == 0) {
return util_strdup_s(arch_type[i].value); return lcr_util_strdup_s(arch_type[i].value);
} }
} else { } else {
if (strncmp(uts.machine, arch_type[i].arch, (size_t)(arch_type[i].num)) == 0) { if (strncmp(uts.machine, arch_type[i].arch, (size_t)(arch_type[i].num)) == 0) {
return util_strdup_s(arch_type[i].value); return lcr_util_strdup_s(arch_type[i].value);
} }
} }
} }
...@@ -2209,7 +2209,7 @@ static char *seccomp_trans_arch(const char *arch) ...@@ -2209,7 +2209,7 @@ static char *seccomp_trans_arch(const char *arch)
if (strcmp(arch_type[i].arch, "SCMP_ARCH_AUTO") == 0) { if (strcmp(arch_type[i].arch, "SCMP_ARCH_AUTO") == 0) {
return get_hostarch(); return get_hostarch();
} else if (strcmp(arch, arch_type[i].arch) == 0) { } else if (strcmp(arch, arch_type[i].arch) == 0) {
return util_strdup_s(arch_type[i].value); return lcr_util_strdup_s(arch_type[i].value);
} }
} }
return NULL; return NULL;
...@@ -2320,7 +2320,7 @@ static struct lcr_list *trans_oci_linux_sysctl(const json_map_string_string *sys ...@@ -2320,7 +2320,7 @@ static struct lcr_list *trans_oci_linux_sysctl(const json_map_string_string *sys
struct lcr_list *node = NULL; struct lcr_list *node = NULL;
size_t i; size_t i;
conf = util_common_calloc_s(sizeof(*conf)); conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -2457,7 +2457,7 @@ struct lcr_list *trans_oci_linux(const oci_runtime_config_linux *l, char **secco ...@@ -2457,7 +2457,7 @@ struct lcr_list *trans_oci_linux(const oci_runtime_config_linux *l, char **secco
int ret = 0; int ret = 0;
struct lcr_list *tmp = NULL; struct lcr_list *tmp = NULL;
struct lcr_list *conf = util_common_calloc_s(sizeof(*conf)); struct lcr_list *conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -2532,7 +2532,7 @@ struct lcr_list *trans_annotations(const json_map_string_string *anno) ...@@ -2532,7 +2532,7 @@ struct lcr_list *trans_annotations(const json_map_string_string *anno)
size_t len; size_t len;
int ret = 0; int ret = 0;
struct lcr_list *conf = util_common_calloc_s(sizeof(*conf)); struct lcr_list *conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
...@@ -2606,7 +2606,7 @@ static int add_needed_net_conf(struct lcr_list *conf) ...@@ -2606,7 +2606,7 @@ static int add_needed_net_conf(struct lcr_list *conf)
/* get needed lxc conf */ /* get needed lxc conf */
struct lcr_list *get_needed_lxc_conf() struct lcr_list *get_needed_lxc_conf()
{ {
struct lcr_list *conf = util_common_calloc_s(sizeof(*conf)); struct lcr_list *conf = lcr_util_common_calloc_s(sizeof(*conf));
if (conf == NULL) { if (conf == NULL) {
return NULL; return NULL;
} }
......
...@@ -67,7 +67,7 @@ void lcr_set_error_message(lcr_errno_t errcode, const char *format, ...) ...@@ -67,7 +67,7 @@ void lcr_set_error_message(lcr_errno_t errcode, const char *format, ...)
return; return;
} }
g_lcr_error.errcode = errcode; g_lcr_error.errcode = errcode;
g_lcr_error.errmsg = util_strdup_s(errbuf); g_lcr_error.errmsg = lcr_util_strdup_s(errbuf);
} }
void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...) void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...)
...@@ -88,7 +88,7 @@ void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...) ...@@ -88,7 +88,7 @@ void lcr_try_set_error_message(lcr_errno_t errcode, const char *format, ...)
return; return;
} }
g_lcr_error.errcode = errcode; g_lcr_error.errcode = errcode;
g_lcr_error.errmsg = util_strdup_s(errbuf); g_lcr_error.errmsg = lcr_util_strdup_s(errbuf);
} }
void lcr_append_error_message(lcr_errno_t errcode, const char *format, ...) void lcr_append_error_message(lcr_errno_t errcode, const char *format, ...)
...@@ -107,7 +107,7 @@ void lcr_append_error_message(lcr_errno_t errcode, const char *format, ...) ...@@ -107,7 +107,7 @@ void lcr_append_error_message(lcr_errno_t errcode, const char *format, ...)
return; return;
} }
g_lcr_error.errcode = errcode; g_lcr_error.errcode = errcode;
result = util_string_append(g_lcr_error.errmsg, errbuf); result = lcr_util_string_append(g_lcr_error.errmsg, errbuf);
if (result == NULL) { if (result == NULL) {
g_lcr_error.errcode = LCR_ERR_MEMOUT; g_lcr_error.errcode = LCR_ERR_MEMOUT;
return; return;
......
...@@ -118,15 +118,15 @@ struct lcr_container_info *lcr_container_info_get(const char *name, const char * ...@@ -118,15 +118,15 @@ struct lcr_container_info *lcr_container_info_get(const char *name, const char *
run_flag = (strcmp(st, "STOPPED") != 0); run_flag = (strcmp(st, "STOPPED") != 0);
/* Now it makes sense to allocate memory */ /* Now it makes sense to allocate memory */
info = util_common_calloc_s(sizeof(*info)); info = lcr_util_common_calloc_s(sizeof(*info));
if (info == NULL) { if (info == NULL) {
nret = -1; nret = -1;
goto put_and_finish; goto put_and_finish;
} }
info->init = -1; info->init = -1;
info->running = run_flag; info->running = run_flag;
info->name = util_strdup_s(name); info->name = lcr_util_strdup_s(name);
info->state = util_strdup_s(st); info->state = lcr_util_strdup_s(st);
if (run_flag) { if (run_flag) {
info->init = c->init_pid(c); info->init = c->init_pid(c);
} }
...@@ -204,7 +204,7 @@ static int create_partial(const struct lxc_container *c) ...@@ -204,7 +204,7 @@ static int create_partial(const struct lxc_container *c)
// $lxcpath + '/' + $name + '/partial' + \0 // $lxcpath + '/' + $name + '/partial' + \0
len = strlen(c->config_path) + strlen(c->name) + 10; len = strlen(c->config_path) + strlen(c->name) + 10;
char *path = util_common_calloc_s(len); char *path = lcr_util_common_calloc_s(len);
if (path == NULL) { if (path == NULL) {
ERROR("Out of memory in create_partial"); ERROR("Out of memory in create_partial");
return -1; return -1;
...@@ -216,7 +216,7 @@ static int create_partial(const struct lxc_container *c) ...@@ -216,7 +216,7 @@ static int create_partial(const struct lxc_container *c)
goto out_free; goto out_free;
} }
fd = util_open(path, O_RDWR | O_CREAT | O_EXCL, DEFAULT_SECURE_FILE_MODE); fd = lcr_util_open(path, O_RDWR | O_CREAT | O_EXCL, DEFAULT_SECURE_FILE_MODE);
if (fd < 0) { if (fd < 0) {
SYSERROR("Error creating partial file: %s", path); SYSERROR("Error creating partial file: %s", path);
goto out_free; goto out_free;
...@@ -251,7 +251,7 @@ static void remove_partial(const struct lxc_container *c) ...@@ -251,7 +251,7 @@ static void remove_partial(const struct lxc_container *c)
// $lxcpath + '/' + $name + '/partial' + \0 // $lxcpath + '/' + $name + '/partial' + \0
len = strlen(c->config_path) + strlen(c->name) + 10; len = strlen(c->config_path) + strlen(c->name) + 10;
char *path = util_common_calloc_s(len); char *path = lcr_util_common_calloc_s(len);
if (path == NULL) { if (path == NULL) {
ERROR("Out of memory in remove_partial"); ERROR("Out of memory in remove_partial");
return; return;
...@@ -371,7 +371,7 @@ static bool wait_start_pid(pid_t pid, int rfd, const char *name, const char *pat ...@@ -371,7 +371,7 @@ static bool wait_start_pid(pid_t pid, int rfd, const char *name, const char *pat
ssize_t size_read = 0; ssize_t size_read = 0;
char buffer[BUFSIZ] = { 0 }; char buffer[BUFSIZ] = { 0 };
ret = wait_for_pid(pid); ret = lcr_wait_for_pid(pid);
if (ret == 0) { if (ret == 0) {
return true; return true;
} }
...@@ -1036,7 +1036,7 @@ static char *lcr_get_config_item(struct lxc_container *c, const char *key, bool ...@@ -1036,7 +1036,7 @@ static char *lcr_get_config_item(struct lxc_container *c, const char *key, bool
goto out; goto out;
} }
cret = util_common_calloc_s((len + 1) * sizeof(char)); cret = lcr_util_common_calloc_s((len + 1) * sizeof(char));
if (cret == NULL) { if (cret == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
goto out; goto out;
...@@ -1079,7 +1079,7 @@ static bool lcr_get_console_config_items(struct lxc_container *c, struct lcr_con ...@@ -1079,7 +1079,7 @@ static bool lcr_get_console_config_items(struct lxc_container *c, struct lcr_con
if (item == NULL) { if (item == NULL) {
DEBUG("Log rotate is NULL"); DEBUG("Log rotate is NULL");
} else { } else {
if (util_safe_uint(item, &trotate) == 0) { if (lcr_util_safe_uint(item, &trotate) == 0) {
config->log_rotate = trotate; config->log_rotate = trotate;
} else { } else {
ERROR("trans to uint failed"); ERROR("trans to uint failed");
...@@ -1226,7 +1226,7 @@ int lcr_log_init(const char *name, const char *file, const char *priority, const ...@@ -1226,7 +1226,7 @@ int lcr_log_init(const char *name, const char *file, const char *priority, const
lconf.priority = priority ? priority : "ERROR"; lconf.priority = priority ? priority : "ERROR";
} else { } else {
/* File has prefix "fifo:", */ /* File has prefix "fifo:", */
full_path = util_string_split_prefix(pre_len, file); full_path = lcr_util_string_split_prefix(pre_len, file);
lconf.file = full_path; lconf.file = full_path;
lconf.driver = "fifo"; lconf.driver = "fifo";
lconf.priority = priority; lconf.priority = priority;
......
...@@ -55,7 +55,7 @@ static inline void add_array_elem(char **array, size_t total, size_t *pos, const ...@@ -55,7 +55,7 @@ static inline void add_array_elem(char **array, size_t total, size_t *pos, const
if (*pos + 1 >= total - 1) { if (*pos + 1 >= total - 1) {
return; return;
} }
array[*pos] = util_strdup_s(elem); array[*pos] = lcr_util_strdup_s(elem);
*pos += 1; *pos += 1;
} }
...@@ -507,10 +507,10 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs) ...@@ -507,10 +507,10 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs)
clear_error_message(&g_lcr_error); clear_error_message(&g_lcr_error);
(void)memset(lcs, 0x00, sizeof(struct lcr_container_state)); (void)memset(lcs, 0x00, sizeof(struct lcr_container_state));
lcs->name = util_strdup_s(c->name); lcs->name = lcr_util_strdup_s(c->name);
state = c->state(c); state = c->state(c);
lcs->state = state ? util_strdup_s(state) : util_strdup_s("-"); lcs->state = state ? lcr_util_strdup_s(state) : lcr_util_strdup_s("-");
if (c->is_running(c)) { if (c->is_running(c)) {
lcs->init = c->init_pid(c); lcs->init = c->init_pid(c);
...@@ -549,7 +549,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct ...@@ -549,7 +549,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
size_t j = 0; size_t j = 0;
size_t args_len = PARAM_NUM; size_t args_len = PARAM_NUM;
if (util_check_inherited(true, -1) != 0) { if (lcr_util_check_inherited(true, -1) != 0) {
COMMAND_ERROR("Close inherited fds failed"); COMMAND_ERROR("Close inherited fds failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -560,7 +560,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct ...@@ -560,7 +560,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
params = util_common_calloc_s(args_len * sizeof(char *)); params = lcr_util_common_calloc_s(args_len * sizeof(char *));
if (params == NULL) { if (params == NULL) {
COMMAND_ERROR("Out of memory"); COMMAND_ERROR("Out of memory");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -661,7 +661,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request ...@@ -661,7 +661,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request
} }
if (pid == (pid_t)0) { if (pid == (pid_t)0) {
if (util_null_stdfds() < 0) { if (lcr_util_null_stdfds() < 0) {
COMMAND_ERROR("Failed to close fds"); COMMAND_ERROR("Failed to close fds");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -676,7 +676,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request ...@@ -676,7 +676,7 @@ bool do_attach(const char *name, const char *path, const struct lcr_exec_request
close(pipefd[1]); close(pipefd[1]);
status = wait_for_pid_status(pid); status = lcr_wait_for_pid_status(pid);
if (status < 0) { if (status < 0) {
ERROR("Failed to wait lxc-attach"); ERROR("Failed to wait lxc-attach");
goto close_out; goto close_out;
...@@ -707,7 +707,7 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star ...@@ -707,7 +707,7 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star
char *params[PARAM_NUM] = { NULL }; char *params[PARAM_NUM] = { NULL };
size_t i = 0; size_t i = 0;
if (util_check_inherited(true, -1) != 0) { if (lcr_util_check_inherited(true, -1) != 0) {
COMMAND_ERROR("Close inherited fds failed"); COMMAND_ERROR("Close inherited fds failed");
} }
......
...@@ -73,7 +73,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens) ...@@ -73,7 +73,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens)
} }
if (!oci_spec->annotations) { if (!oci_spec->annotations) {
oci_spec->annotations = util_common_calloc_s(sizeof(json_map_string_string)); oci_spec->annotations = lcr_util_common_calloc_s(sizeof(json_map_string_string));
if (!oci_spec->annotations) { if (!oci_spec->annotations) {
ERROR("Out of memory"); ERROR("Out of memory");
nret = -1; nret = -1;
...@@ -88,7 +88,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens) ...@@ -88,7 +88,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens)
} }
new_size = (oci_spec->annotations->len + new_lens) * sizeof(char *); new_size = (oci_spec->annotations->len + new_lens) * sizeof(char *);
old_size = oci_spec->annotations->len * sizeof(char *); old_size = oci_spec->annotations->len * sizeof(char *);
nret = mem_realloc((void **)&fkey, new_size, oci_spec->annotations->keys, old_size); nret = lcr_mem_realloc((void **)&fkey, new_size, oci_spec->annotations->keys, old_size);
if (nret) { if (nret) {
ERROR("Failed to realloc memory for files limit variables"); ERROR("Failed to realloc memory for files limit variables");
nret = -1; nret = -1;
...@@ -96,7 +96,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens) ...@@ -96,7 +96,7 @@ static int realloc_annotations(oci_runtime_spec *oci_spec, size_t new_lens)
} }
oci_spec->annotations->keys = fkey; oci_spec->annotations->keys = fkey;
nret = mem_realloc((void **)&fval, new_size, oci_spec->annotations->values, old_size); nret = lcr_mem_realloc((void **)&fval, new_size, oci_spec->annotations->values, old_size);
if (nret) { if (nret) {
ERROR("Failed to realloc memory for files limit variables"); ERROR("Failed to realloc memory for files limit variables");
nret = -1; nret = -1;
...@@ -123,7 +123,7 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai ...@@ -123,7 +123,7 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai
goto out; goto out;
} }
fpos = (int)(anno->len - 1); fpos = (int)(anno->len - 1);
anno->keys[fpos] = util_strdup_s("log.console.file"); anno->keys[fpos] = lcr_util_strdup_s("log.console.file");
anno->values[fpos] = NULL; anno->values[fpos] = NULL;
} }
...@@ -136,14 +136,14 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai ...@@ -136,14 +136,14 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai
if (anno->values[fpos]) { if (anno->values[fpos]) {
free(anno->values[fpos]); free(anno->values[fpos]);
} }
anno->values[fpos] = util_strdup_s(default_path); anno->values[fpos] = lcr_util_strdup_s(default_path);
} }
if (strcmp("none", anno->values[fpos]) == 0) { if (strcmp("none", anno->values[fpos]) == 0) {
DEBUG("Disable console log."); DEBUG("Disable console log.");
ret = 0; ret = 0;
goto out; goto out;
} }
if (util_ensure_path(&realpath, anno->values[fpos])) { if (lcr_util_ensure_path(&realpath, anno->values[fpos])) {
ERROR("Invalid log path: %s, error: %s.", anno->values[fpos], strerror(errno)); ERROR("Invalid log path: %s, error: %s.", anno->values[fpos], strerror(errno));
goto out; goto out;
} }
...@@ -351,7 +351,7 @@ static int lcr_spec_write_seccomp_line(int fd, const char *seccomp) ...@@ -351,7 +351,7 @@ static int lcr_spec_write_seccomp_line(int fd, const char *seccomp)
len = strlen("lxc.seccomp.profile") + 3 + strlen(seccomp) + 1; len = strlen("lxc.seccomp.profile") + 3 + strlen(seccomp) + 1;
line = util_common_calloc_s(len * sizeof(char)); line = lcr_util_common_calloc_s(len * sizeof(char));
if (line == NULL) { if (line == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
goto cleanup; goto cleanup;
...@@ -389,13 +389,13 @@ static char *lcr_save_seccomp_file(const char *bundle, const char *seccomp_conf) ...@@ -389,13 +389,13 @@ static char *lcr_save_seccomp_file(const char *bundle, const char *seccomp_conf)
goto cleanup; goto cleanup;
} }
nret = util_ensure_path(&real_seccomp, seccomp); nret = lcr_util_ensure_path(&real_seccomp, seccomp);
if (nret < 0) { if (nret < 0) {
ERROR("Failed to ensure path %s", seccomp); ERROR("Failed to ensure path %s", seccomp);
goto cleanup; goto cleanup;
} }
fd = util_open(real_seccomp, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE); fd = lcr_util_open(real_seccomp, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
if (fd == -1) { if (fd == -1) {
SYSERROR("Create file %s failed", real_seccomp); SYSERROR("Create file %s failed", real_seccomp);
goto cleanup; goto cleanup;
...@@ -426,7 +426,7 @@ static struct lcr_container_info *info_new(struct lcr_container_info **info, siz ...@@ -426,7 +426,7 @@ static struct lcr_container_info *info_new(struct lcr_container_info **info, siz
length = (*size + 1) * sizeof(struct lcr_container_info); length = (*size + 1) * sizeof(struct lcr_container_info);
nret = mem_realloc((void **)&n, length, (void *)(*info), (*size) * sizeof(struct lcr_container_info)); nret = lcr_mem_realloc((void **)&n, length, (void *)(*info), (*size) * sizeof(struct lcr_container_info));
if (nret < 0) { if (nret < 0) {
return NULL; return NULL;
} }
...@@ -592,8 +592,8 @@ int lcr_containers_info_get(const char *lcrpath, struct lcr_container_info **inf ...@@ -592,8 +592,8 @@ int lcr_containers_info_get(const char *lcrpath, struct lcr_container_info **inf
goto put_container; goto put_container;
} }
in->running = run_flag; in->running = run_flag;
in->name = util_strdup_s(name); in->name = lcr_util_strdup_s(name);
in->state = util_strdup_s(st); in->state = lcr_util_strdup_s(st);
if (run_flag) { if (run_flag) {
in->init = c->init_pid(c); in->init = c->init_pid(c);
} }
...@@ -671,7 +671,7 @@ struct lcr_list *lcr_oci2lcr(const struct lxc_container *c, oci_runtime_spec *co ...@@ -671,7 +671,7 @@ struct lcr_list *lcr_oci2lcr(const struct lxc_container *c, oci_runtime_spec *co
{ {
struct lcr_list *lcr_conf = NULL; struct lcr_list *lcr_conf = NULL;
lcr_conf = util_common_calloc_s(sizeof(*lcr_conf)); lcr_conf = lcr_util_common_calloc_s(sizeof(*lcr_conf));
if (lcr_conf == NULL) { if (lcr_conf == NULL) {
goto out_free; goto out_free;
} }
...@@ -722,13 +722,13 @@ static int lcr_open_config_file(const char *bundle) ...@@ -722,13 +722,13 @@ static int lcr_open_config_file(const char *bundle)
goto out; goto out;
} }
nret = util_ensure_path(&real_config, config); nret = lcr_util_ensure_path(&real_config, config);
if (nret < 0) { if (nret < 0) {
ERROR("Failed to ensure path %s", config); ERROR("Failed to ensure path %s", config);
goto out; goto out;
} }
fd = util_open(real_config, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE); fd = lcr_util_open(real_config, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
if (fd == -1) { if (fd == -1) {
ERROR("Create file %s failed, %s", real_config, strerror(errno)); ERROR("Create file %s failed, %s", real_config, strerror(errno));
lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed, %s", real_config, strerror(errno)); lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed, %s", real_config, strerror(errno));
...@@ -756,7 +756,7 @@ static char *escape_string_encode(const char *src) ...@@ -756,7 +756,7 @@ static char *escape_string_encode(const char *src)
return NULL; return NULL;
} }
dst = util_common_calloc_s(2 * len + 1); dst = lcr_util_common_calloc_s(2 * len + 1);
if (dst == NULL) { if (dst == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
return NULL; return NULL;
...@@ -814,7 +814,7 @@ static int lcr_spec_write_config(int fd, const struct lcr_list *lcr_conf) ...@@ -814,7 +814,7 @@ static int lcr_spec_write_config(int fd, const struct lcr_list *lcr_conf)
goto cleanup; goto cleanup;
} }
len = strlen(item->name) + 3 + strlen(item->value) + 1; len = strlen(item->name) + 3 + strlen(item->value) + 1;
line = util_common_calloc_s(len); line = lcr_util_common_calloc_s(len);
if (line == NULL) { if (line == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
goto cleanup; goto cleanup;
...@@ -866,7 +866,7 @@ char *lcr_get_bundle(const char *lcrpath, const char *name) ...@@ -866,7 +866,7 @@ char *lcr_get_bundle(const char *lcrpath, const char *name)
/* bundle = lcrpath + '/' + name + '\0' */ /* bundle = lcrpath + '/' + name + '\0' */
len = strlen(lcrpath) + strlen(name) + 2; len = strlen(lcrpath) + strlen(name) + 2;
bundle = util_common_calloc_s(len); bundle = lcr_util_common_calloc_s(len);
if (bundle == NULL) { if (bundle == NULL) {
ERROR("Out of memory"); ERROR("Out of memory");
goto cleanup; goto cleanup;
...@@ -961,12 +961,12 @@ static int lcr_write_file(const char *path, const char *data, size_t len) ...@@ -961,12 +961,12 @@ static int lcr_write_file(const char *path, const char *data, size_t len)
return -1; return -1;
} }
if (util_ensure_path(&real_path, path) < 0) { if (lcr_util_ensure_path(&real_path, path) < 0) {
ERROR("Failed to ensure path %s", path); ERROR("Failed to ensure path %s", path);
goto out_free; goto out_free;
} }
fd = util_open(real_path, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE); fd = lcr_util_open(real_path, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
if (fd == -1) { if (fd == -1) {
ERROR("Create file %s failed", real_path); ERROR("Create file %s failed", real_path);
lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed", real_path); lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed", real_path);
......
...@@ -28,7 +28,7 @@ struct lcr_list; ...@@ -28,7 +28,7 @@ struct lcr_list;
#define SAFE_MALLOC(P, size, ret) \ #define SAFE_MALLOC(P, size, ret) \
do { \ do { \
(P) = util_common_calloc_s((size)); \ (P) = lcr_util_common_calloc_s((size)); \
if ((P) == NULL) { \ if ((P) == NULL) { \
ERROR("Out of memory"); \ ERROR("Out of memory"); \
(ret) = false; \ (ret) = false; \
......
...@@ -52,7 +52,7 @@ void engine_set_log_prefix(const char *prefix) ...@@ -52,7 +52,7 @@ void engine_set_log_prefix(const char *prefix)
} }
free(g_engine_log_prefix); free(g_engine_log_prefix);
g_engine_log_prefix = util_strdup_s(prefix); g_engine_log_prefix = lcr_util_strdup_s(prefix);
} }
/* engine free log prefix */ /* engine free log prefix */
...@@ -100,7 +100,7 @@ static int open_fifo(const char *fifo_path) ...@@ -100,7 +100,7 @@ static int open_fifo(const char *fifo_path)
return nret; return nret;
} }
fifo_fd = util_open(fifo_path, O_RDWR | O_NONBLOCK, 0); fifo_fd = lcr_util_open(fifo_path, O_RDWR | O_NONBLOCK, 0);
if (fifo_fd == -1) { if (fifo_fd == -1) {
COMMAND_ERROR("Open fifo %s failed: %s", fifo_path, strerror(errno)); COMMAND_ERROR("Open fifo %s failed: %s", fifo_path, strerror(errno));
return -1; return -1;
...@@ -185,11 +185,11 @@ int engine_log_enable(const struct engine_log_config *log) ...@@ -185,11 +185,11 @@ int engine_log_enable(const struct engine_log_config *log)
} }
free(g_engine_log_module); free(g_engine_log_module);
g_engine_log_module = util_strdup_s(log->name); g_engine_log_module = lcr_util_strdup_s(log->name);
full_path = util_strdup_s(log->file); full_path = lcr_util_strdup_s(log->file);
nret = util_build_dir(full_path); nret = lcr_util_build_dir(full_path);
if (nret != 0) { if (nret != 0) {
COMMAND_ERROR("failed to create dir for log file"); COMMAND_ERROR("failed to create dir for log file");
goto out; goto out;
...@@ -262,7 +262,7 @@ static char *parse_timespec_to_human() ...@@ -262,7 +262,7 @@ static char *parse_timespec_to_human()
return NULL; return NULL;
} }
return util_strdup_s(date_time); return lcr_util_strdup_s(date_time);
} }
/* use to add log to driver */ /* use to add log to driver */
......
此差异已折叠。
...@@ -154,55 +154,40 @@ extern "C" { ...@@ -154,55 +154,40 @@ extern "C" {
{ SIGRTMAX - 1, "RTMAX-1" }, { SIGRTMAX, "RTMAX" }, \ { SIGRTMAX - 1, "RTMAX-1" }, { SIGRTMAX, "RTMAX" }, \
} }
bool file_exists(const char *path); int lcr_wait_for_pid(pid_t pid);
bool dir_exists(const char *path); int lcr_wait_for_pid_status(pid_t pid);
int wait_for_pid(pid_t pid); char *lcr_util_string_join(const char *sep, const char **parts, size_t len);
int wait_for_pid_status(pid_t pid);
char *util_string_join(const char *sep, const char **parts, size_t len);
int util_mkdir_p(const char *dir, mode_t mode);
char **lcr_string_split_and_trim(const char *str, char _sep); char **lcr_string_split_and_trim(const char *str, char _sep);
void lcr_free_array(void **array); void lcr_free_array(void **array);
int lcr_grow_array(void ***array, size_t *capacity, size_t new_size, size_t capacity_increment); int lcr_grow_array(void ***array, size_t *capacity, size_t new_size, size_t capacity_increment);
size_t lcr_array_len(void **array); size_t lcr_array_len(void **array);
int mem_realloc(void **newptr, size_t newsize, void *oldptr, size_t oldsize); int lcr_mem_realloc(void **newptr, size_t newsize, void *oldptr, size_t oldsize);
bool util_valid_cmd_arg(const char *arg); int lcr_util_safe_strtod(const char *numstr, double *converted);
int util_safe_ullong(const char *numstr, unsigned long long *converted); int lcr_util_safe_uint(const char *numstr, unsigned int *converted);
int util_safe_strtod(const char *numstr, double *converted); int lcr_parse_byte_size_string(const char *s, int64_t *converted);
int util_safe_uint(const char *numstr, unsigned int *converted); bool lcr_util_dir_exists(const char *path);
int parse_byte_size_string(const char *s, int64_t *converted); int lcr_util_ensure_path(char **confpath, const char *path);
bool util_dir_exists(const char *path); int lcr_util_recursive_rmdir(const char *dirpath, int recursive_depth);
int util_ensure_path(char **confpath, const char *path); char *lcr_util_string_replace(const char *needle, const char *replacement, const char *haystack);
int util_recursive_rmdir(const char *dirpath, int recursive_depth); int lcr_util_open(const char *filename, int flags, mode_t mode);
char *util_string_replace(const char *needle, const char *replacement, const char *haystack);
int util_open(const char *filename, int flags, mode_t mode); void *lcr_util_common_calloc_s(size_t size);
int lcr_util_safe_int(const char *numstr, int *converted);
FILE *util_fopen(const char *filename, const char *mode); int lcr_util_check_inherited(bool closeall, int fd_to_ignore);
char *lcr_util_string_append(const char *post, const char *pre);
void *util_common_calloc_s(size_t size); char *lcr_util_string_split_prefix(size_t prefix_len, const char *file);
int util_safe_int(const char *numstr, int *converted);
int util_check_inherited(bool closeall, int fd_to_ignore); int lcr_util_build_dir(const char *name);
char *util_string_append(const char *post, const char *pre); ssize_t lcr_util_write_nointr(int fd, const void *buf, size_t count);
char *util_string_split_prefix(size_t prefix_len, const char *file); ssize_t lcr_util_read_nointr(int fd, void *buf, size_t count);
int util_build_dir(const char *name); size_t lcr_util_array_len(char **array);
ssize_t util_write_nointr(int fd, const void *buf, size_t count);
ssize_t util_read_nointr(int fd, void *buf, size_t count); int lcr_util_safe_llong(const char *numstr, long long *converted);
void util_free_array(char **array); char *lcr_util_strdup_s(const char *src);
int lcr_util_null_stdfds(void);
int util_sig_parse(const char *signame);
bool util_valid_signal(int sig); int lcr_util_atomic_write_file(const char *filepath, const char *content);
size_t util_array_len(char **array);
const char *str_skip_str(const char *str, const char *skip);
int util_array_append(char ***array, const char *element);
int util_safe_llong(const char *numstr, long long *converted);
char *util_strdup_s(const char *src);
int util_null_stdfds(void);
bool util_copy_file(const char *src_file, const char *dst_file, mode_t mode);
bool util_write_file(const char *filepath, const char *content, size_t len, bool add_newline, mode_t mode);
int util_atomic_write_file(const char *filepath, const char *content);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册