);
}
-static int make_status_items(struct ls_data *d, struct para_buffer *pb)
-{
+static int make_status_items(struct audio_file_data *afd,
+ struct afs_info *afsi, char *path, long score,
+ HASH_TYPE *hash)
+{
+ struct ls_data d = {
+ .afhi = afd->afhi, /* struct copy */
+ .afsi = *afsi,
+ .path = path,
+ .score = score,
+ .hash = hash
+ };
struct ls_options opts = {
.flags = LS_FLAG_FULL_PATH | LS_FLAG_ADMISSIBLE_ONLY,
.mode = LS_MODE_VERBOSE,
};
+ struct para_buffer pb = {.max_size = VERBOSE_LS_OUTPUT_SIZE - 1};
time_t current_time;
+ int ret;
time(¤t_time);
- return print_list_item(d, &opts, pb, current_time);
+ ret = print_list_item(&d, &opts, &pb, current_time); /* frees info string */
+ afd->afhi.info_string = NULL;
+ if (ret < 0)
+ goto out;
+ strncpy(afd->verbose_ls_output, pb.buf, VERBOSE_LS_OUTPUT_SIZE);
+ afd->verbose_ls_output[VERBOSE_LS_OUTPUT_SIZE - 1] = '\0';
+out:
+ free(pb.buf);
+ return ret;
}
/**
save_afsi(&new_afsi, &afsi_obj); /* in-place update */
load_chunk_table(&afd->afhi, chunk_table_obj.data);
- {
- struct ls_data d = {
- .afhi = afd->afhi, /* struct copy */
- .afsi = old_afsi,
- .path = path,
- .score = score,
- .hash = file_hash
- };
- struct para_buffer pb = {.max_size = VERBOSE_LS_OUTPUT_SIZE - 1};
- ret = make_status_items(&d, &pb); /* frees info string */
- afd->afhi.info_string = NULL;
- if (ret < 0)
- goto err;
- strncpy(afd->verbose_ls_output, pb.buf, VERBOSE_LS_OUTPUT_SIZE);
- afd->verbose_ls_output[VERBOSE_LS_OUTPUT_SIZE - 1] = '\0';
- free(pb.buf);
- }
+ ret = make_status_items(afd, &old_afsi, path, score, file_hash);
+ if (ret < 0)
+ goto err;
aced.aft_row = aft_row;
aced.old_afsi = &old_afsi;
afs_event(AFSI_CHANGE, NULL, &aced);