free(pb->buf);
}
-static void com_select_callback(int fd, const struct osl_object *query)
+static int com_select_callback(int fd, const struct osl_object *query)
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
num_admissible);
out:
flush_and_free_pb(&pb);
+ return 0;
}
int com_select(struct command_context *cc)
exit(EXIT_FAILURE);
}
-static void create_tables_callback(int fd, const struct osl_object *query)
+static int create_tables_callback(int fd, const struct osl_object *query)
{
uint32_t table_mask = *(uint32_t *)query->data;
int i, ret;
if (ret < 0)
para_printf(&pb, "%s\n", para_strerror(-ret));
flush_and_free_pb(&pb);
+ return 0;
}
int com_init(struct command_context *cc)
*
* \sa send_callback_request().
*/
-typedef void callback_function(int fd, const struct osl_object *);
+typedef int callback_function(int fd, const struct osl_object *);
/**
* Callbacks send chunks to data back to the command handler. Pointers to
int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi);
int get_audio_file_path_of_row(const struct osl_row *row, char **path);
int audio_file_loop(void *private_data, osl_rbtree_loop_func *func);
-void aft_check_callback(int fd, __a_unused const struct osl_object *query);
+int aft_check_callback(int fd, __a_unused const struct osl_object *query);
/* playlist */
int playlist_open(char *name);
void playlist_close(void);
-void playlist_check_callback(int fd, __a_unused const struct osl_object *query);
+int playlist_check_callback(int fd, __a_unused const struct osl_object *query);
/** evaluates to 1 if x < y, to -1 if x > y and to 0 if x == y */
#define NUM_COMPARE(x, y) ((int)((x) < (y)) - (int)((x) > (y)))
return ret;
}
-static void com_ls_callback(int fd, const struct osl_object *query)
+static int com_ls_callback(int fd, const struct osl_object *query)
{
struct ls_options *opts = query->data;
char *p, *pattern_start = (char *)query->data + sizeof(*opts);
free(opts->data);
free(opts->data_ptr);
free(opts->patterns);
+ return 0;
}
/*
ADD_FLAG_ALL = 8,
};
-static void com_add_callback(int fd, const struct osl_object *query)
+static int com_add_callback(int fd, const struct osl_object *query)
{
char *buf = query->data, *path;
struct osl_row *pb, *aft_row;
if (ret < 0)
para_printf(&msg, "%s\n", para_strerror(-ret));
flush_and_free_pb(&msg);
+ return 0;
}
/** Used by com_add(). */
uint32_t flags;
};
-static void path_brother_callback(int fd, const struct osl_object *query)
+static int path_brother_callback(int fd, const struct osl_object *query)
{
char *path = query->data;
struct osl_row *path_brother;
int ret = aft_get_row_of_path(path, &path_brother);
if (ret < 0)
- return;
- pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&path_brother,
+ return ret;
+ return pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&path_brother,
sizeof(path_brother));
}
-static void hash_sister_callback(int fd, const struct osl_object *query)
+static int hash_sister_callback(int fd, const struct osl_object *query)
{
unsigned char *hash = query->data;
struct osl_row *hash_sister;
hash_sister = find_hash_sister(hash);
if (!hash_sister)
- return;
- pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&hash_sister,
+ return 0;
+ return pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&hash_sister,
sizeof(hash_sister));
}
return 1;
}
-static void com_touch_callback(int fd, const struct osl_object *query)
+static int com_touch_callback(int fd, const struct osl_object *query)
{
struct touch_action_data tad = {.cto = query->data,
.pb = {
else if (pmd.num_matches == 0)
para_printf(&tad.pb, "no matches\n");
flush_and_free_pb(&tad.pb);
+ return 0;
}
int com_touch(struct command_context *cc)
return ret;
}
-static void com_rm_callback(int fd, const struct osl_object *query)
+static int com_rm_callback(int fd, const struct osl_object *query)
{
struct com_rm_action_data crd = {.flags = *(uint32_t *)query->data,
.pb = {
ret = for_each_matching_row(&pmd);
if (ret < 0) {
para_printf(&crd.pb, "%s\n", para_strerror(-ret));
- return;
+ return 0;
}
if ((pmd.num_matches == 0) && !(crd.flags & RM_FLAG_FORCE))
para_printf(&crd.pb, "no matches -- nothing removed\n");
else if (crd.flags & RM_FLAG_VERBOSE)
para_printf(&crd.pb, "removed %u files\n", pmd.num_matches);
flush_and_free_pb(&crd.pb);
+ return 0;
}
/* TODO options: -r (recursive) */
return 1;
}
-static void com_cpsi_callback(int fd, const struct osl_object *query)
+static int com_cpsi_callback(int fd, const struct osl_object *query)
{
struct cpsi_action_data cad = {
.flags = *(unsigned *)query->data,
} else
para_printf(&cad.pb, "no matches - nothing copied\n");
flush_and_free_pb(&cad.pb);
+ return 0;
}
int com_cpsi(struct command_context *cc)
return 1;
}
-static void com_setatt_callback(int fd, const struct osl_object *query)
+static int com_setatt_callback(int fd, const struct osl_object *query)
{
char *p;
int ret;
if (ret < 0)
para_printf(&cad.pb, "%s\n", para_strerror(-ret));
flush_and_free_pb(&cad.pb);
+ return 0;
}
int com_setatt(struct command_context *cc)
com_setatt_callback, afs_cb_result_handler, cc);
}
-static void afs_stat_callback(int fd, const struct osl_object *query)
+static int afs_stat_callback(int fd, const struct osl_object *query)
{
int *parser_friendly = query->data;
char *buf = *parser_friendly?
parser_friendly_status_items : status_items;
if (!buf)
- return;
- pass_buffer_as_shm(fd, SBD_OUTPUT, buf, strlen(buf));
+ return 0;
+ return pass_buffer_as_shm(fd, SBD_OUTPUT, buf, strlen(buf));
}
/**
* \param fd The afs socket.
* \param query Unused.
*
- * This function always succeeds.
+ * \return This function always returns zero.
*
* \sa com_check().
*/
-void aft_check_callback(int fd, __a_unused const struct osl_object *query)
+int aft_check_callback(int fd, __a_unused const struct osl_object *query)
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
para_printf(&pb, "checking audio file table...\n");
audio_file_loop(&pb, check_audio_file);
flush_and_free_pb(&pb);
+ return 0;
}
/**
return 1;
}
-static void com_lsatt_callback(int fd, const struct osl_object *query)
+static int com_lsatt_callback(int fd, const struct osl_object *query)
{
struct lsatt_action_data laad = {
.flags = *(unsigned *) query->data,
pmd.pm_flags |= PM_REVERSE_LOOP;
for_each_matching_row(&pmd);
flush_and_free_pb(&laad.pb);
+ return 0;
}
int com_lsatt(struct command_context *cc)
};
-static void com_addatt_callback(int fd, const struct osl_object *query)
+static int com_addatt_callback(int fd, const struct osl_object *query)
{
char *p;
int ret = 1;
if (ret < 0)
para_printf(&pb, "%s: %s\n", p, para_strerror(-ret));
flush_and_free_pb(&pb);
+ return 0;
}
int com_addatt(struct command_context *cc)
return ret;
}
-static void com_mvatt_callback(int fd, const struct osl_object *query)
+static int com_mvatt_callback(int fd, const struct osl_object *query)
{
char *old = query->data;
size_t size = strlen(old) + 1;
else
afs_event(ATTRIBUTE_RENAME, &pb, NULL);
flush_and_free_pb(&pb);
+ return 0;
}
int com_mvatt(struct command_context *cc)
return 1;
}
-static void com_rmatt_callback(int fd, const struct osl_object *query)
+static int com_rmatt_callback(int fd, const struct osl_object *query)
{
struct remove_attribute_action_data raad = {
.num_removed = 0,
else if (!raad.num_removed)
para_printf(&raad.pb, "no match -- nothing removed\n");
flush_and_free_pb(&raad.pb);
+ return 0;
}
int com_rmatt(struct command_context *cc)
return 1;
}
-static void com_lsblob_callback(struct osl_table *table,
+static int com_lsblob_callback(struct osl_table *table,
int fd, const struct osl_object *query)
{
struct lsblob_action_data lbad = {
else if (pmd.num_matches == 0 && pmd.patterns.size > 0)
para_printf(&lbad.pb, "no matches\n");
flush_and_free_pb(&lbad.pb);
+ return 0;
}
static int com_lsblob(callback_function *f, struct command_context *cc)
return (ret < 0)? ret : ret2;
}
-static void com_catblob_callback(struct osl_table *table, int fd,
+static int com_catblob_callback(struct osl_table *table, int fd,
const struct osl_object *query)
{
struct pattern_match_data pmd = {
char err_msg[] = "no matches\n";
pass_buffer_as_shm(fd, SBD_OUTPUT, err_msg, sizeof(err_msg));
}
+ return 0;
}
static int com_catblob(callback_function *f, struct command_context *cc)
return 1;
}
-static void com_rmblob_callback(struct osl_table *table, int fd,
+static int com_rmblob_callback(struct osl_table *table, int fd,
const struct osl_object *query)
{
int ret;
afs_event(BLOB_RENAME, NULL, table);
}
flush_and_free_pb(&rmbd.pb);
+ return 0;
}
static int com_rmblob(callback_function *f, struct command_context *cc)
afs_cb_result_handler, cc);
}
-static void com_addblob_callback(struct osl_table *table, int fd,
+static int com_addblob_callback(struct osl_table *table, int fd,
const struct osl_object *query)
{
struct osl_object objs[NUM_BLOB_COLUMNS];
msg_len = xasprintf(&msg, "added %s as id %u\n", name, id);
pass_buffer_as_shm(fd, SBD_OUTPUT, msg, msg_len);
free(msg);
+ return 0;
}
/* Write input from fd to dynamically allocated buffer, but maximal 10M. */
return stdin_command(cc, &arg_obj, f);
}
-static void com_mvblob_callback(struct osl_table *table, int fd,
+static int com_mvblob_callback(struct osl_table *table, int fd,
const struct osl_object *query)
{
char *src = (char *) query->data;
afs_event(BLOB_RENAME, NULL, table);
out:
flush_and_free_pb(&pb);
+ return 0;
}
static int com_mvblob(callback_function *f, struct command_context *cc)
}
#define DEFINE_BLOB_COMMAND(cmd_name, table_name, cmd_prefix) \
- static void com_ ## cmd_name ## cmd_prefix ## _callback(int fd, const struct osl_object *query) \
+ static int com_ ## cmd_name ## cmd_prefix ## _callback(int fd, const struct osl_object *query) \
{ \
return com_ ## cmd_name ## blob_callback(table_name ## _table, fd, query); \
} \
*
* \param fd The afs socket.
* \param query Unused.
+ *
+ * \return Currently this function always returns zero.
*/
-void mood_check_callback(int fd, __a_unused const struct osl_object *query)
+int mood_check_callback(int fd, __a_unused const struct osl_object *query)
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
osl_rbtree_loop(moods_table, BLOBCOL_ID, &pb,
check_mood);
flush_and_free_pb(&pb);
+ return 0;
}
static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd)
int change_current_mood(char *mood_name);
void close_current_mood(void);
-void mood_check_callback(int fd, __a_unused const struct osl_object *query);
+int mood_check_callback(int fd, __a_unused const struct osl_object *query);
*
* \param fd The afs socket.
* \param query Unused.
+ *
+ * \return Currently this function always returns zero.
*/
-void playlist_check_callback(int fd, __a_unused const struct osl_object *query)
+int playlist_check_callback(int fd, __a_unused const struct osl_object *query)
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
osl_rbtree_loop(playlists_table, BLOBCOL_ID, &pb,
check_playlist);
flush_and_free_pb(&pb);
+ return 0;
}
/**