xaizek / pms (License: GPLv3+) (since 2018-12-07)
Older version of Practical Music Search written in C++.
Commit 030fa3524b1af1135a96f48133949fe88542ba93

Implement debug(), printing to stderr.
Author: Kim Tore Jensen
Author date (UTC): 2014-09-28 14:54
Committer name: Kim Tore Jensen
Committer date (UTC): 2014-09-28 14:54
Parent(s): 21d968dfe5a3e92f44678110e43f70bd782fbde2
Signing key:
Tree: f3c5857121b49f6ee2cc57ae6f8fff5a3ae74301
File Lines added Lines deleted
src/input.c 3 5
src/pms.c 12 0
src/pms.h 6 0
File src/input.c changed (mode: 100644) (index 136cc5d..c38e446)
... ... static int input_command_append_multiplier(int multiplier) {
58 58 multiplier = (command.multiplier*10)+multiplier; multiplier = (command.multiplier*10)+multiplier;
59 59 if (multiplier > command.multiplier) { if (multiplier > command.multiplier) {
60 60 command.multiplier = multiplier; command.multiplier = multiplier;
61 console("InputMultiplier set to %d", command.multiplier);
62 61 } }
63 62 return command.multiplier; return command.multiplier;
64 63 } }
65 64
66 65 static void input_command_append_movement(int movement) { static void input_command_append_movement(int movement) {
67 66 command.movement = movement; command.movement = movement;
68 console("InputMovement set to %d", command.movement);
69 67 } }
70 68
71 69 static void input_command_append_action(int action) { static void input_command_append_action(int action) {
72 70 command.action = action; command.action = action;
73 console("InputAction set to %d", command.action);
74 71 if (command.action != INPUT_ACTION_GO) { if (command.action != INPUT_ACTION_GO) {
75 72 input_command_append_movement(INPUT_MOVEMENT_NA); input_command_append_movement(INPUT_MOVEMENT_NA);
76 73 } }
 
... ... command_t * input_get() {
98 95 } }
99 96 if ((i = input_char_get_action(ch)) != INPUT_ACTION_NONE) { if ((i = input_char_get_action(ch)) != INPUT_ACTION_NONE) {
100 97 if (command.action != INPUT_ACTION_NONE && command.action != i) { if (command.action != INPUT_ACTION_NONE && command.action != i) {
101 console("Invalid input sequence, resetting.");
98 debug("Invalid input sequence with double actions (%d, %d), resetting.\n", command.action, i);
102 99 input_reset(); input_reset();
100 return NULL;
103 101 } }
104 102 if (command.action == INPUT_ACTION_NONE) { if (command.action == INPUT_ACTION_NONE) {
105 103 input_command_append_action(i); input_command_append_action(i);
 
... ... command_t * input_get() {
117 115 } }
118 116
119 117 int input_handle(command_t * command) { int input_handle(command_t * command) {
120 console("input_handle(): multiplier=%d, movement=%d, action=%d", command->multiplier, command->movement, command->action);
118 debug("input_handle(): multiplier=%d, movement=%d, action=%d\n", command->multiplier, command->movement, command->action);
121 119 if (command->action == INPUT_ACTION_QUIT) { if (command->action == INPUT_ACTION_QUIT) {
122 120 shutdown(); shutdown();
123 121 return 0; return 0;
File src/pms.c changed (mode: 100644) (index 646d9a7..911a4dc)
... ... struct pms_state_t * pms_state = NULL;
32 32
33 33 static pthread_mutex_t status_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t status_mutex = PTHREAD_MUTEX_INITIALIZER;
34 34
35 void debug(const char * format, ...) {
36
37 va_list ap;
38
39 if (options->debug) {
40 va_start(ap, format);
41 vfprintf(stderr, format, ap);
42 va_end(ap);
43 }
44 }
45
35 46 void reset_options() { void reset_options() {
36 47
37 48 if (options == NULL) { if (options == NULL) {
 
... ... void reset_options() {
47 58 options->port = 0; options->port = 0;
48 59 options->timeout = 2000; options->timeout = 2000;
49 60 options->console_size = 1024; options->console_size = 1024;
61 options->debug = true;
50 62
51 63 } }
52 64
File src/pms.h changed (mode: 100644) (index 516900f..dabaa58)
... ... struct options_t {
47 47 unsigned int port; unsigned int port;
48 48 unsigned int timeout; unsigned int timeout;
49 49 unsigned int console_size; unsigned int console_size;
50 bool debug;
50 51
51 52 }; };
52 53
 
... ... void fatal(int exitcode, const char * format, ...);
66 67 */ */
67 68 void shutdown(); void shutdown();
68 69
70 /**
71 * Print a debug message to stderr
72 */
73 void debug(const char * format, ...);
74
69 75 /** /**
70 76 * Lock MPD status object * Lock MPD status object
71 77 */ */
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/pms

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/pms

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master