summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-07-14 14:31:43 +0200
committerJoe <bousset.rudy@gmail.com>2022-07-14 14:31:43 +0200
commit31fca6120ac66b88002d8cbbdb27989b432e0e21 (patch)
tree1f30f3525cd8c197d73d071e489b2f44aa3741ce /src
parentUpdate (diff)
downloadmpdview-31fca6120ac66b88002d8cbbdb27989b432e0e21.tar.gz
mpdview-31fca6120ac66b88002d8cbbdb27989b432e0e21.tar.bz2
mpdview-31fca6120ac66b88002d8cbbdb27989b432e0e21.tar.xz
mpdview-31fca6120ac66b88002d8cbbdb27989b432e0e21.tar.zst
mpdview-31fca6120ac66b88002d8cbbdb27989b432e0e21.zip
opts
Diffstat (limited to 'src')
-rw-r--r--src/c_defines.h10
-rw-r--r--src/c_mpdview.c36
-rw-r--r--src/c_mpdview.h9
3 files changed, 40 insertions, 15 deletions
diff --git a/src/c_defines.h b/src/c_defines.h
index 47d03b6..7a32d9b 100644
--- a/src/c_defines.h
+++ b/src/c_defines.h
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* mpdview: src/c_defines.h
- * Sun, 03 Jul 2022 15:31:30 +0200
+ * Thu, 14 Jul 2022 14:06:21 +0200
* Joe
*/
@@ -67,9 +67,11 @@ enum ret_e {
RET_ERR
};
-#define BUFF_SIZE 262144
-#define PROGNAME "mpdview"
+#define VERSION "v0.1"
+#define PROGNAME "mpdview"
-#define DEF_MUSIC_DIR "/home/jozan/mu"
+#define OPTSTRING "hvV"
+
+#define DEF_MUSIC_DIR "/var/mpd/music"
#endif /* __C_DEFINES_H__ */
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 46e11ed..7089d36 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -66,7 +66,7 @@
#include "c_mpdview.h"
static struct mpdview_s *
-c_create_view(void)
+c_create_view(bool_t verbose)
{
struct mpdview_s* view;
@@ -78,6 +78,7 @@ c_create_view(void)
view->status = NULL;
view->song = NULL;
view->state = MPD_STATE_UNKNOWN;
+ view->verbose = verbose;
return (view);
}
@@ -178,15 +179,32 @@ c_get_current_dir(struct mpdview_s* v)
int
main
(int argc,
- const char* argv[],
- const char* envp[])
+ char* const argv[])
{
struct mpdview_s* view;
+ bool_t verbose;
+ char c;
- (void)argc;
- (void)argv;
- (void)envp;
- view = c_create_view();
+ verbose = FALSE;
+ while ((c = getopt(argc, argv, OPTSTRING)) != -1) {
+ if (c == 'h') {
+ /* TODO: usage(); */
+ dprintf(STDOUT_FILENO, "help\n");
+ return (EXIT_SUCCESS);
+ }
+ else if (c == 'v') {
+ verbose = TRUE;
+ }
+ else if (c == 'V') {
+ dprintf(STDOUT_FILENO, "%s %s\n", PROGNAME, VERSION);
+ return (EXIT_SUCCESS);
+ }
+ else if (c == '?') {
+ /* TODO: usage(); */
+ return (EXIT_FAILURE);
+ }
+ }
+ view = c_create_view(verbose);
if (view == NULL) {
return (EXIT_FAILURE);
}
@@ -205,7 +223,9 @@ main
return (EXIT_FAILURE);
}
c_get_current_dir(view);
- dprintf(STDOUT_FILENO, "%s\n", view->current_dir);
+ if (view->verbose == TRUE) {
+ dprintf(STDOUT_FILENO, "%s\n", view->current_dir);
+ }
}
c_destroy_mpdview(&view);
return (EXIT_SUCCESS);
diff --git a/src/c_mpdview.h b/src/c_mpdview.h
index a96df4a..289fa29 100644
--- a/src/c_mpdview.h
+++ b/src/c_mpdview.h
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* mpdview: src/c_mpdview.h
- * Sun, 03 Jul 2022 03:31:56 +0200
+ * Thu, 14 Jul 2022 14:22:17 +0200
* Joe
*/
@@ -52,13 +52,16 @@
#include <mpd/song.h>
#include <mpd/status.h>
+#include "c_defines.h"
+
struct mpdview_s {
struct mpd_connection* conn;
struct mpd_status* status;
struct mpd_song* song;
enum mpd_state state;
- char music_dir[PATH_MAX];
- char current_dir[PATH_MAX];
+ char music_dir[PATH_MAX];
+ char current_dir[PATH_MAX];
+ bool_t verbose;
};
#endif /* __C_MPDVIEW_H__ */