* No need to update the status items as the AFSI_CHANGE event will
* recreate them.
*/
- afs_event(AFSI_CHANGE, NULL, &aced);
+ ret = afs_event(AFSI_CHANGE, NULL, &aced);
+ if (ret < 0)
+ goto out;
ret = save_afd(afd);
out:
free(afd->afhi.chunk_table);
if (pb) { /* hs trumps pb, remove pb */
if (flags & ADD_FLAG_VERBOSE)
para_printf(&msg, "removing %s\n", path);
- afs_event(AUDIO_FILE_REMOVE, &msg, pb);
+ ret = afs_event(AUDIO_FILE_REMOVE, &msg, pb);
+ if (ret < 0)
+ goto out;
ret = osl(osl_del_row(audio_file_table, pb));
if (ret < 0)
goto out;
&objs[AFTCOL_PATH]));
if (ret < 0)
goto out;
- afs_event(AUDIO_FILE_RENAME, &msg, hs);
+ ret = afs_event(AUDIO_FILE_RENAME, &msg, hs);
+ if (ret < 0)
+ goto out;
if (!(flags & ADD_FLAG_FORCE))
goto out;
}
&objs[AFTCOL_CHUNKS]));
if (ret < 0)
goto out;
- afs_event(AFHI_CHANGE, &msg, row);
+ ret = afs_event(AFHI_CHANGE, &msg, row);
+ if (ret < 0)
+ goto out;
goto out;
}
/* new entry, use default afsi */
objs[AFTCOL_AFSI].size = AFSI_SIZE;
save_afsi(&default_afsi, &objs[AFTCOL_AFSI]);
ret = osl(osl_add_and_get_row(audio_file_table, objs, &aft_row));
- afs_event(AUDIO_FILE_ADD, &msg, aft_row);
+ ret = afs_event(AUDIO_FILE_ADD, &msg, aft_row);
out:
if (ret < 0)
para_printf(&msg, "could not add %s\n", path);
save_afsi(&new_afsi, &obj); /* in-place update */
aced.aft_row = row;
aced.old_afsi = &old_afsi;
- afs_event(AFSI_CHANGE, &tad->pb, &aced);
- return 1;
+ return afs_event(AFSI_CHANGE, &tad->pb, &aced);
}
static int com_touch_callback(int fd, const struct osl_object *query)
if (crd->flags & RM_FLAG_VERBOSE)
para_printf(&crd->pb, "removing %s\n", name);
- afs_event(AUDIO_FILE_REMOVE, &crd->pb, row);
+ ret = afs_event(AUDIO_FILE_REMOVE, &crd->pb, row);
+ if (ret < 0)
+ return ret;
ret = osl(osl_del_row(audio_file_table, row));
if (ret < 0)
para_printf(&crd->pb, "cannot remove %s\n", name);
para_printf(&cad->pb, "copied afsi to %s\n", name);
aced.aft_row = row;
aced.old_afsi = &old_afsi;
- afs_event(AFSI_CHANGE, &cad->pb, &aced);
- return 1;
+ return afs_event(AFSI_CHANGE, &cad->pb, &aced);
}
static int com_cpsi_callback(int fd, const struct osl_object *query)
new_afsi.attributes |= cad->add_mask;
new_afsi.attributes &= ~cad->del_mask;
save_afsi(&new_afsi, &obj); /* in-place update */
- afs_event(AFSI_CHANGE, &cad->pb, &aced);
- return 1;
+ return afs_event(AFSI_CHANGE, &cad->pb, &aced);
}
static int com_setatt_callback(int fd, const struct osl_object *query)
return ret;
}
+struct aft_check_atts_data {
+ uint64_t att_mask;
+ struct para_buffer *pb;
+};
+
+static int check_atts_of_audio_file(struct osl_row *row, void *data)
+{
+ struct aft_check_atts_data *acad = data;
+ int ret;
+ struct afs_info afsi;
+ char *path;
+ uint64_t bad_bits;
+
+ ret = get_afsi_of_row(row, &afsi);
+ if (ret < 0) {
+ para_printf(acad->pb, "cannot get afsi\n");
+ return ret;
+ }
+ bad_bits = afsi.attributes & ~acad->att_mask;
+ if (bad_bits == 0) /* OK */
+ return 0;
+ ret = get_audio_file_path_of_row(row, &path);
+ if (ret < 0) {
+ para_printf(acad->pb, "cannot get path\n");
+ return ret;
+ }
+ para_printf(acad->pb, "invalid attribute bits (%" PRIu64 "): %s\n",
+ bad_bits, path);
+ /* return success to keep looping */
+ return 1;
+}
+
+/**
+ * Iterate over all audio files and check the attribute bit mask.
+ *
+ * \param att_mask The mask of all valid attributes.
+ * \param pb Used for reporting inconsistencies.
+ *
+ * This reads the attribute bit mask of each audio file from the afs info
+ * structure stored in the audio file table and verifies that all set bits are
+ * also turned on in \a att_mask, i.e., correspond to an attribute of the
+ * attribute table. Audio files for which this is not the case are reported via
+ * \a pb.
+ *
+ * \return Standard. Inconsistencies are not regarded as errors.
+ *
+ * \sa \ref attribute_check_callback().
+ */
+int aft_check_attributes(uint64_t att_mask, struct para_buffer *pb)
+{
+ struct aft_check_atts_data acad = {.att_mask = att_mask, .pb = pb};
+
+ para_printf(pb, "checking attributes, mask: %" PRIx64 "\n", att_mask);
+ return audio_file_loop(&acad, check_atts_of_audio_file);
+}
+
/**
* Close the audio file table.
*