static int load_config_file(const char *filename, const char *acl, int required, struct sys_config *cfg) { char *data = NULL, *acl_copy = NULL; size_t size; int result = 1; LOG(LL_DEBUG, ("=== Loading %s", filename)); data = cs_read_file(filename, &size); if (data == NULL) { /* File not found or read error */ LOG(required ? LL_ERROR : LL_INFO, ("Failed to load %s", filename)); result = 0; goto clean; } /* Make a temporary copy, in case it gets overridden while loading. */ acl_copy = (acl != NULL ? strdup(acl) : NULL); if (!parse_sys_config(data, acl_copy, required, cfg)) { /* Malformed file, this is an error even if file is not required */ LOG(LL_ERROR, ("Failed to parse %s", filename)); result = 0; goto clean; } clean: free(data); free(acl_copy); return result; }
static int console_send_file(struct v7 *v7, struct cache *cache) { int ret = 0; char *logs = NULL; size_t size = 0; if (cache->file_names.len != 0) { logs = cs_read_file(cache->file_names.buf, &size); if (logs == NULL) { LOG(LL_ERROR, ("Failed to read from %s", cache->file_names.buf)); ret = -1; goto clean; } console_make_clubby_call(v7, logs); remove(cache->file_names.buf); mbuf_remove(&cache->file_names, FILENAME_LEN); } clean: if (logs != NULL) { free(logs); } return ret; }
void clubby_updater_finish(int error_code) { size_t len; char *data = cs_read_file(UPDATER_TEMP_FILE_NAME, &len); if (data == NULL) return; /* No file - no problem. */ s_clubby_reply = sj_clubby_bytes_to_reply(data, len); if (s_clubby_reply != NULL) { s_clubby_upd_status = error_code; } else { LOG(LL_ERROR, ("Found invalid reply")); } remove(UPDATER_TEMP_FILE_NAME); free(data); }