From 2dbf1cca9574142040eb5a5bb9b205ca95880584 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 20 Oct 2009 18:55:56 +0000 Subject: [PATCH] add dot functions to list volstatus, locations and mediatypes --- bacula/src/dird/ua_dotcmds.c | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index a0cd3e2fee..c277c64b42 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -65,6 +65,9 @@ static bool typescmd(UAContext *ua, const char *cmd); static bool backupscmd(UAContext *ua, const char *cmd); static bool levelscmd(UAContext *ua, const char *cmd); static bool getmsgscmd(UAContext *ua, const char *cmd); +static bool volstatuscmd(UAContext *ua, const char *cmd); +static bool mediatypescmd(UAContext *ua, const char *cmd); +static bool locationscmd(UAContext *ua, const char *cmd); static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd); static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd); @@ -95,6 +98,8 @@ static struct cmdstruct commands[] = { /* help */ /* can be used in runscript * { NT_(".status"), dot_status_cmd, NULL, false}, { NT_(".storage"), storagecmd, NULL, true}, { NT_(".volstatus"), volstatuscmd, NULL, true}, + { NT_(".mediatypes"), mediatypescmd, NULL, true}, + { NT_(".locations"), locationscmd, NULL, true}, { NT_(".bvfs_lsdirs"), dot_bvfs_lsdirs, NULL, true}, { NT_(".bvfs_lsfiles"),dot_bvfs_lsfiles,NULL, true}, { NT_(".bvfs_update"), dot_bvfs_update, NULL, true}, @@ -688,7 +693,40 @@ static bool sql_cmd(UAContext *ua, const char *cmd) return true; } +static int one_handler(void *ctx, int num_field, char **row) +{ + UAContext *ua = (UAContext *)ctx; + ua->send_msg("%s\n", row[0]); + return 0; +} +static bool mediatypescmd(UAContext *ua, const char *cmd) +{ + if (!open_client_db(ua)) { + return true; + } + if (!db_sql_query(ua->db, + "SELECT DISTINCT MediaType FROM MediaType ORDER BY MediaType", + one_handler, (void *)ua)) + { + ua->error_msg(_("List MediaType failed: ERR=%s\n"), db_strerror(ua->db)); + } + return true; +} + +static bool locationscmd(UAContext *ua, const char *cmd) +{ + if (!open_client_db(ua)) { + return true; + } + if (!db_sql_query(ua->db, + "SELECT DISTINCT Location FROM Location ORDER BY Location", + one_handler, (void *)ua)) + { + ua->error_msg(_("List Location failed: ERR=%s\n"), db_strerror(ua->db)); + } + return true; +} static bool levelscmd(UAContext *ua, const char *cmd) { -- 2.39.5