+/* write config value in file f in a dotconfig-like manner. Return 0
+ * on success. */
+static int confnode_menuconfig_dotconfig_write(const struct confnode *n, FILE *f)
+{
+ const struct confnode *c;
+ int val;
+
+ if (fprintf(f, "#\n# -- %s\n#\n", n->prompt) < 0)
+ return -1;
+
+ val = confnode_get_value(n, NULL, 0);
+ if (val < 0)
+ return -1;
+
+ if (val == 0) {
+ if (fprintf(f, "# CONFIG_%s is not set\n", n->name) < 0)
+ return -1;
+ return 0;
+ }
+
+ if (fprintf(f, "CONFIG_%s=y\n", n->name) < 0)
+ return -1;
+
+ TAILQ_FOREACH(c, &n->children, next) {
+ if (confnode_dotconfig_write(c, f) < 0)
+ return -1;
+ }
+ return 0;
+}
+