File: cli.h

package info (click to toggle)
bluez-alsa 4.3.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,156 kB
  • sloc: ansic: 32,301; makefile: 865; sh: 431; xml: 243; python: 236; pascal: 205
file content (66 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * BlueALSA - cli.h
 * Copyright (c) 2016-2024 Arkadiusz Bokowy
 *
 * This file is a part of bluez-alsa.
 *
 * This project is licensed under the terms of the MIT license.
 *
 */

#pragma once
#ifndef BLUEALSA_CLI_CLI_H_
#define BLUEALSA_CLI_CLI_H_

#include <stdbool.h>

#include <dbus/dbus.h>

#include "shared/dbus-client.h"
#include "shared/dbus-client-pcm.h"
#include "shared/log.h"

struct cli_config {

	/* initialized BlueALSA D-Bus context */
	struct ba_dbus_ctx dbus;

	bool quiet;
	unsigned int verbose;

};

struct cli_command {
	const char *name;
	const char *description;
	int (*func)(int argc, char *argv[]);
};

typedef bool (*cli_get_ba_services_cb)(const char *name, void *data);

void cli_get_ba_services(cli_get_ba_services_cb func, void *data, DBusError *err);
bool cli_get_ba_pcm(const char *path, struct ba_pcm *pcm, DBusError *err);

bool cli_parse_common_options(int opt);
bool cli_parse_value_on_off(const char *value, bool *out);

void cli_print_adapters(const struct ba_service_props *props);
void cli_print_profiles_and_codecs(const struct ba_service_props *props);
void cli_print_pcm_available_codecs(const struct ba_pcm *pcm, DBusError *err);
void cli_print_pcm_selected_codec(const struct ba_pcm *pcm);
void cli_print_pcm_soft_volume(const struct ba_pcm *pcm);
void cli_print_pcm_volume(const struct ba_pcm *pcm);
void cli_print_pcm_mute(const struct ba_pcm *pcm);
void cli_print_pcm_properties(const struct ba_pcm *pcm, DBusError *err);
void cli_print_usage(const char *format, ...);

#define cli_print_error(M, ...) \
	if (!config.quiet) { error(M, ##__VA_ARGS__); }
#define cmd_print_error(M, ...) \
	if (!config.quiet) { error("CMD \"%s\": " M, argv[0], ##__VA_ARGS__); }

/**
 * Global configuration. */
extern struct cli_config config;

#endif