int zconfig_save (zconfig_t *self, const char *filename) { assert (self); int rc = 0; if (streq (filename, "-")) // "-" means write to stdout rc = zconfig_execute (self, s_config_save, stdout); else { FILE *file; file = fopen (filename, "w"); if (file) { rc = zconfig_execute (self, s_config_save, file); fflush (file); fclose (file); // If we saved back to original file, restat it so that // the file does not appear as "changed" if (self->file && streq (filename, zconfig_filename (self))) zfile_restat (self->file); } else rc = -1; // File not writeable } return rc; }
int zconfig_save (zconfig_t *self, char *filename) { assert (self); int rc = 0; if (streq (filename, "-")) { // "-" means write to stdout rc = zconfig_execute (self, s_config_save, stdout); } else { FILE *file; file = fopen (filename, "w"); if (file) rc = zconfig_execute (self, s_config_save, file); else rc = -1; // File not writeable } return rc; }
void zconfig_fprint (zconfig_t *self, FILE *file) { zconfig_execute (self, s_config_save, file); }
/// // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int QmlZconfig::execute (zconfig_fct handler, void *arg) { return zconfig_execute (self, handler, arg); };
JNIEXPORT jint JNICALL Java_zconfig__1_1execute (JNIEnv *env, jclass c, jlong self, jlong handler, jlong arg) { jint execute_ = (jint) zconfig_execute ((zconfig_t *) self, (zconfig_fct *) handler, (void *) arg); return execute_; }
void zconfig_dump (zconfig_t *self) { zconfig_execute (self, s_config_save, stderr); }