ret = dup(fd);
if (ret < 0)
return -ERRNO_TO_PARA_ERROR(errno);
- new_client = para_calloc(sizeof(*new_client));
+ new_client = zalloc(sizeof(*new_client));
new_client->fd = ret;
PARA_INFO_LOG("adding client on fd %d\n", new_client->fd);
new_client->item_mask = mask;
free(pfpb.buf);
}
-/**
- * Check if string is a known status item.
- *
- * \param item Buffer containing the text to check.
- *
- * \return If \a item is a valid status item, the number of that status item is
- * returned. Otherwise, this function returns \p -E_UNKNOWN_STAT_ITEM.
- */
+/* Check if the given string is a known status item and return its index. */
static int stat_item_valid(const char *item)
{
int i;
}
EXPORT_AUDIOD_CMD_HANDLER(help)
+static int com_ll(int fd, struct lls_parse_result *lpr)
+{
+ unsigned ll;
+ char *errctx;
+ const char *sev[] = {SEVERITIES};
+ const char *arg;
+ int ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx));
+
+ if (ret < 0) {
+ char *tmp = make_message("%s\n", errctx);
+ free(errctx);
+ client_write(fd, tmp);
+ free(tmp);
+ return ret;
+ }
+ if (lls_num_inputs(lpr) == 0) {
+ char *msg;
+ ll = daemon_get_loglevel();
+ msg = make_message("%s\n", sev[ll]);
+ ret = client_write(fd, msg);
+ free(msg);
+ return ret;
+ }
+ arg = lls_input(0, lpr);
+ for (ll = 0; ll < NUM_LOGLEVELS; ll++) {
+ if (!strcmp(arg, sev[ll]))
+ break;
+ }
+ if (ll >= NUM_LOGLEVELS)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ PARA_INFO_LOG("new log level: %s\n", sev[ll]);
+ daemon_set_loglevel(ll);
+ return 1;
+}
+EXPORT_AUDIOD_CMD_HANDLER(ll)
+
static int com_tasks(int fd, __a_unused struct lls_parse_result *lpr)
{
int ret;
*
* \param accept_fd The fd to accept connections on.
*
- * This is called in each iteration of the select loop. If there is an incoming
- * connection on \a accept_fd, this function reads the command sent by the peer,
+ * This is called in each iteration of the main loop of the scheduler. If there
+ * is an incoming connection, the function reads the command sent by the peer,
* checks the connecting user's permissions by using unix socket credentials
* (if supported by the OS) and calls the corresponding command handler if
* permissions are OK.
* connection to accept.
*
* \sa \ref para_accept(), \ref recv_cred_buffer().
- * */
-int handle_connect(int accept_fd)
+ */
+int dispatch_local_connection(int accept_fd)
{
int argc, ret, clifd;
char buf[MAXLINE], **argv = NULL;