MCPcopy Create free account
hub / github.com/Entware/Entware / conf_write

Function conf_write

scripts/config/confdata.c:914–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912}
913
914int conf_write(const char *name)
915{
916 FILE *out;
917 struct symbol *sym;
918 struct menu *menu;
919 const char *str;
920 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
921 char *env;
922 int i;
923 bool need_newline = false;
924
925 if (!name)
926 name = conf_get_configname();
927
928 if (!*name) {
929 fprintf(stderr, "config name is empty\n");
930 return -1;
931 }
932
933 if (is_dir(name)) {
934 fprintf(stderr, "%s: Is a directory\n", name);
935 return -1;
936 }
937
938 if (make_parent_dir(name))
939 return -1;
940
941 env = getenv("KCONFIG_OVERWRITECONFIG");
942 if (env && *env) {
943 *tmpname = 0;
944 out = fopen(name, "w");
945 } else {
946 snprintf(tmpname, sizeof(tmpname), "%s.%d.tmp",
947 name, (int)getpid());
948 out = fopen(tmpname, "w");
949 }
950 if (!out)
951 return 1;
952
953 conf_write_heading(out, &comment_style_pound);
954
955 if (!conf_get_changed())
956 sym_clear_all_valid();
957
958 menu = rootmenu.list;
959 while (menu) {
960 sym = menu->sym;
961 if (!sym) {
962 if (!menu_is_visible(menu))
963 goto next;
964 str = menu_get_prompt(menu);
965 fprintf(out, "\n"
966 "#\n"
967 "# %s\n"
968 "#\n", str);
969 need_newline = false;
970 } else if (!(sym->flags & SYMBOL_CHOICE) &&
971 !(sym->flags & SYMBOL_WRITTEN)) {

Callers 7

saveConfigMethod · 0.85
saveConfigAsMethod · 0.85
do_exitFunction · 0.85
conf_saveFunction · 0.85
conf_saveFunction · 0.85
handle_exitFunction · 0.85
mainFunction · 0.85

Calls 13

conf_get_confignameFunction · 0.85
is_dirFunction · 0.85
make_parent_dirFunction · 0.85
conf_write_headingFunction · 0.85
conf_get_changedFunction · 0.85
sym_clear_all_validFunction · 0.85
menu_is_visibleFunction · 0.85
menu_get_promptFunction · 0.85
sym_calc_valueFunction · 0.85
is_sameFunction · 0.85
conf_messageFunction · 0.85

Tested by

no test coverage detected