#include <netdb.h>
#include <lopsub.h>
+#include "server_cmd.lsg.h"
#include "server.cmdline.h"
#include "para.h"
#include "error.h"
}
EXPORT_SERVER_CMD_HANDLER(init);
-/**
- * Flags for the check command.
- *
- * \sa com_check().
- */
-enum com_check_flags {
- /** Check the audio file table. */
- CHECK_AFT = 1,
- /** Check the mood table. */
- CHECK_MOODS = 2,
- /** Check the playlist table. */
- CHECK_PLAYLISTS = 4,
- /** Check the attribute table against the audio file table. */
- CHECK_ATTS = 8
-};
-
-int com_check(struct command_context *cc)
+static int com_check(struct command_context *cc, struct lls_parse_result *lpr)
{
- unsigned flags = 0;
- int i, ret;
+ const struct lls_opt_result *r_a = SERVER_CMD_OPT_RESULT(CHECK, AFT, lpr);
+ const struct lls_opt_result *r_A = SERVER_CMD_OPT_RESULT(CHECK, ATTRIBUTE, lpr);
+ const struct lls_opt_result *r_m = SERVER_CMD_OPT_RESULT(CHECK, MOOD, lpr);
+ const struct lls_opt_result *r_p = SERVER_CMD_OPT_RESULT(CHECK, PLAYLIST, lpr);
+ bool noopt = !lls_opt_given(r_a) && !lls_opt_given(r_A)
+ && !lls_opt_given(r_m) && !lls_opt_given(r_p);
+ int ret;
- for (i = 1; i < cc->argc; i++) {
- const char *arg = cc->argv[i];
- if (arg[0] != '-')
- break;
- if (!strcmp(arg, "--")) {
- i++;
- break;
- }
- if (!strcmp(arg, "-a")) {
- flags |= CHECK_AFT;
- continue;
- }
- if (!strcmp(arg, "-A")) {
- flags |= CHECK_ATTS;
- continue;
- }
- if (!strcmp(arg, "-p")) {
- flags |= CHECK_PLAYLISTS;
- continue;
- }
- if (!strcmp(arg, "-m")) {
- flags |= CHECK_MOODS;
- continue;
- }
- return -E_AFS_SYNTAX;
- }
- if (i < cc->argc)
- return -E_AFS_SYNTAX;
- if (!flags)
- flags = ~0U;
- if (flags & CHECK_AFT) {
+ if (noopt || lls_opt_given(r_a)) {
ret = send_callback_request(aft_check_callback, NULL,
afs_cb_result_handler, cc);
if (ret < 0)
return ret;
}
- if (flags & CHECK_ATTS) {
+ if (noopt || lls_opt_given(r_A)) {
ret = send_callback_request(attribute_check_callback, NULL,
afs_cb_result_handler, cc);
if (ret < 0)
return ret;
}
- if (flags & CHECK_PLAYLISTS) {
+ if (noopt || lls_opt_given(r_p)) {
ret = send_callback_request(playlist_check_callback,
NULL, afs_cb_result_handler, cc);
if (ret < 0)
return ret;
}
- if (flags & CHECK_MOODS) {
+ if (noopt || lls_opt_given(r_m)) {
ret = send_callback_request(mood_check_callback, NULL,
afs_cb_result_handler, cc);
if (ret < 0)
}
return 1;
}
+EXPORT_SERVER_CMD_HANDLER(check);
/**
* The afs event dispatcher.
H: This adds new attributes to the attribute table. At most 64
H: attributes may be defined.
---
-N: check
-P: AFS_READ
-D: Run integrity checks against osl tables.
-U: check [-a] [-A] [-m] [-p]
-H: Check the audio file table, the attribute table, the mood definitions
-H: and all defined playlists. Report any inconsistencies.
-H:
-H: Options:
-H:
-H: -a Run audio file table checks. Checks for entries in the audio file
-H: table which are not present in the file system. Moreover, it checks
-H: whether the lyrics id and all entries in the audio file table are
-H: valid.
-H:
-H: -A Check the attribute table against the afs attribute bitmask of
-H: each audio file in the audio file table. Reports audio files
-H: whose attribute bitmask is invalid, i.e., has a bit set which
-H: does not correspond to any attribute of the attribute table.
-H:
-H: -m Run syntax checks on all defined moods in the mood table.
-H:
-H: -p Check all playlists for lines that correspond to files not contained
-H: in the audio file table.
-H:
-H: If called without arguments, all checks are run.
----
N: rmatt
P: AFS_READ | AFS_WRITE
D: Remove attribute(s).
Print what is being done.
[/help]
+[subcommand check]
+ purpose = run integrity checks on database tables
+ aux_info = AFS_READ
+ [description]
+ If no options are given, all checks are run.
+ [/description]
+ [option aft]
+ short_opt = a
+ summary = run audio file table checks
+ [help]
+ Report stale paths and invalid image and lyrics ids of the audio
+ file table.
+ [/help]
+ [option attribute]
+ short_opt = A
+ summary = check for invalid attributes
+ [help]
+ Report audio files whose attribute bitmask is invalid, i.e., has a bit
+ set which does not correspond to any attribute of the attribute table.
+ [/help]
+ [option mood]
+ short_opt = m
+ summary = check for invalid mood definitions
+ [help]
+ Run syntax checks on all moods of the mood table.
+ [/help]
+ [option playlist]
+ short_opt = p
+ summary = find invalid paths in playlists
+ [help]
+ Check all playlists for paths not contained in the audio file table.
+ [/help]
+
[subcommand ff]
purpose = jump N seconds forward or backward
synopsis = n[-]