{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
};
char *arg = query->data;
int num_admissible, ret, ret2;
* \param size The size of \a buf.
* \param fd_ptr A pointer to the file descriptor.
*
- * This function is used as the \a max_size handler in a \ref para_buffer
- * structure. If used this way, it is called by \ref para_printf() whenever
- * the buffer passed to para_printf() is about to exceed its maximal size.
- *
* This function creates a shared memory area large enough to hold
* the content given by \a buf and \a size and sends the identifier
* of this area to the file descriptor given by \a fd_ptr.
int sc_send_result(struct osl_object *result, void *private);
int pass_buffer_as_shm(char *buf, size_t size, void *fd_ptr);
+
+/** Structure passed to the AFS max_size handler. */
+struct afs_max_size_handler_data {
+ /** Local socket connecting the command handler and the AFS process. */
+ int fd;
+};
+
+/**
+ * Standard max_size handler for AFS commands.
+ *
+ * \param buf Contains (part of) the AFS command output.
+ * \param size The number of bytes in \a buf.
+ * \param private Pointer to a \ref afs_max_size_handler_data structure.
+ *
+ * Whenever the output of an AFS command exceeds the maximal size of a shared
+ * memory area, the max size handler of the para_buffer which holds the command
+ * output is called with \a private being a pointer to a structure of type
+ * afs_max_size_handler_data.
+ *
+ * \return The return value of the underlying call to \ref
+ * pass_buffer_as_shm().
+ */
+_static_inline_ int afs_max_size_handler(char *buf, size_t size, void *private)
+{
+ struct afs_max_size_handler_data *amshd = private;
+ return pass_buffer_as_shm(buf, size, &amshd->fd);
+}
+
__noreturn void afs_init(uint32_t cookie, int socket_fd);
void afs_event(enum afs_events event, struct para_buffer *pb,
void *data);
{
struct ls_options *opts = query->data;
char *p, *pattern_start = (char *)query->data + sizeof(*opts);
- struct para_buffer b = {.max_size = shm_get_shmmax(),
+ struct para_buffer b = {
+ .max_size = shm_get_shmmax(),
.flags = (opts->mode == LS_MODE_PARSER)? PBF_SIZE_PREFIX : 0,
- .max_size_handler = pass_buffer_as_shm, .private_data = &fd};
+ .max_size_handler = afs_max_size_handler,
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ }
+ };
int i = 0, ret;
time_t current_time;
char afsi_buf[AFSI_SIZE];
uint32_t flags = read_u32(buf + CAB_FLAGS_OFFSET);
struct afs_info default_afsi = {.last_played = 0};
- struct para_buffer msg = {.max_size = shm_get_shmmax(),
- .max_size_handler = pass_buffer_as_shm, .private_data = &fd};
+ struct para_buffer msg = {
+ .max_size = shm_get_shmmax(),
+ .max_size_handler = afs_max_size_handler,
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ }
+ };
uint16_t afhi_offset, chunks_offset;
hash = (unsigned char *)buf + CAB_HASH_OFFSET;
.pb = {
.max_size = shm_get_shmmax(),
.private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .max_size_handler = afs_max_size_handler
}
};
int ret, ret2 = 0;
.pb = {
.max_size = shm_get_shmmax(),
.private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .max_size_handler = afs_max_size_handler
}
};
int ret;
.pb = {
.max_size = shm_get_shmmax(),
.private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .max_size_handler = afs_max_size_handler
}
};
int ret;
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler
};
int ret = para_printf(&pb, "checking audio file table...\n");
.flags = *(unsigned *) query->data,
.pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler
}
};
int ret = 1, ret2 = 0;
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler
};
size_t len;
struct osl_row *row;
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
};
int ret;
.num_removed = 0,
.pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
}
};
int ret, ret2 = 0;
.flags = *(uint32_t *)query->data,
.pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
}
};
struct pattern_match_data pmd = {
struct rmblob_data rmbd = {
.pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
}
};
struct pattern_match_data pmd = {
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler
};
int ret = para_printf(&pb, "checking moods...\n");
{
struct para_buffer pb = {
.max_size = shm_get_shmmax(),
- .private_data = &fd,
- .max_size_handler = pass_buffer_as_shm
+ .private_data = &(struct afs_max_size_handler_data) {
+ .fd = fd,
+ },
+ .max_size_handler = afs_max_size_handler,
};
int ret = para_printf(&pb, "checking playlists...\n");