Align with tr104 requirement

This commit is contained in:
Vivek Kumar Dutta 2023-12-14 11:54:09 +05:30
parent 282c802308
commit 4a942dbf11
4 changed files with 41 additions and 0 deletions

View file

@ -2146,6 +2146,39 @@ int dm_file_to_buf(const char *filename, void *buf, size_t buf_size)
return ret;
}
int dm_file_copy(char *src, char *dst)
{
size_t n;
char buf[1024];
int ret = -1;
FILE *file_src = NULL, *file_dst = NULL;
if (DM_STRLEN(src) == 0 || DM_STRLEN(dst) == 0) {
return -1;
}
file_src = fopen(src, "r");
if (!file_src)
goto exit;
file_dst = fopen(dst, "w");
if (!file_dst)
goto exit;
while ((n = fread(buf, 1, sizeof(buf), file_src)) > 0) {
if (fwrite(buf, 1, n, file_dst) != n)
goto exit;
}
ret = 0;
exit:
if (file_dst)
fclose(file_dst);
if (file_src)
fclose(file_src);
return ret;
}
int check_browse_section(struct uci_section *s, void *data)
{
struct browse_args *browse_args = (struct browse_args *)data;

View file

@ -320,6 +320,7 @@ void remove_char(char *str, const char c);
char *replace_char(char *str, char find, char replace);
char *replace_str(const char *str, const char *substr, const char *replacement);
int dm_file_to_buf(const char *filename, void *buf, size_t buf_size);
int dm_file_copy(char *src, char *dst);
int check_browse_section(struct uci_section *s, void *data);
int parse_proc_intf6_line(const char *line, const char *device, char *ipstr, size_t str_len);
char *ioctl_get_ipv4(char *interface_name);

View file

@ -28,6 +28,7 @@ int dmuci_init(void)
uci_ctx = uci_alloc_context();
if (!uci_ctx)
return -1;
uci_set_confdir(uci_ctx, UCI_CONFIG_DIR);
}
return 0;

View file

@ -24,11 +24,17 @@
#include <uci.h>
#include <libubox/list.h>
#ifndef ETC_DB_CONFIG
#define ETC_DB_CONFIG "/etc/board-db/config"
#endif
#define VARSTATE_CONFIG "/var/state"
#ifndef BBFDM_CONFIG
#define BBFDM_CONFIG "/etc/bbfdm/dmmap"
#endif
#define BBFDM_SAVEDIR "/tmp/.bbfdm"
#ifndef UCI_CONFIG_DIR
#define UCI_CONFIG_DIR "/etc/config/"
#endif
#define VARSTATE_CONFDIR "/var/state/"
#define VARSTATE_SAVEDIR "/tmp/.bbfdm_var"