Compare commits

..

2 Commits

Author SHA1 Message Date
2740c6c82d move remove_name_in_path() into util.c
add version_as_string() to util.c
2024-06-28 03:21:38 +01:00
0bda368f59 add -h flag to help dialogue
add -h flag to Use section in README

update example markdown in README
2024-06-28 03:04:14 +01:00
6 changed files with 49 additions and 24 deletions

View File

@ -12,10 +12,13 @@
## `Use`
`./vmrcli.exe [-i] [-k] [-D] <api commands>`
```powershell
./vmrcli.exe [-h] [-i] [-k] [-D] <api commands>
```
Where:
- `h`: Prints the help dialogue.
- `i`: Enable interactive mode. If set, any api commands passed on the command line will be ignored.
- `k`: The kind of Voicemeeter (basic, banana or potato). Use this to launch the GUI.
- `D`: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL
@ -30,17 +33,23 @@ Examples:
Launch basic GUI, set log level to INFO, Toggle Strip 0 Mute, then print its new value
`./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute`
```powershell
./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute
```
Launch banana GUI, set log level to DEBUG, set Strip 0 label to podmic then print Strip 2 label
`./vmrcli.exe -kbanana -D1 strip[0].label=podmic strip[2].label`
```powershell
./vmrcli.exe -kbanana -D1 strip[0].label=podmic strip[2].label
```
## `Interactive Mode`
Running the following command in Powershell:
`./vmrcli.exe -i`
```powershell
./vmrcli.exe -i
```
Will open an interactive prompt:

View File

@ -1,6 +1,8 @@
#ifndef __UTIL_H__
#define __UTIL_H__
void remove_name_in_path(char *szPath);
void replace_multiple_space_with_one(char *s, size_t len);
char *version_as_string(char *, long v, int n);
#endif /* __UTIL_H__ */

View File

@ -1,6 +1,7 @@
#include <stdbool.h>
#include <stdio.h>
#include "cdll.h"
#include "util.h"
/*******************************************************************************/
/** GET VOICEMEETER DIRECTORY **/
@ -12,18 +13,6 @@
#define KEY_WOW64_32KEY 0x0200
#endif
void remove_name_in_path(char *szPath)
{
char *p = szPath;
while (*p++)
;
while (p > szPath && *p != '\\')
p--;
if (*p == '\\')
*p = '\0';
}
bool __cdecl registry_get_voicemeeter_folder(char *szDir)
{
char szKey[256];

View File

@ -1,4 +1,18 @@
#include <stddef.h>
#include <stdio.h>
#include "util.h"
void remove_name_in_path(char *szPath)
{
char *p = szPath;
while (*p++)
;
while (p > szPath && *p != '\\')
p--;
if (*p == '\\')
*p = '\0';
}
void replace_multiple_space_with_one(char *s, size_t len)
{
@ -32,4 +46,14 @@ void replace_multiple_space_with_one(char *s, size_t len)
}
}
s[j] = '\0';
}
char *version_as_string(char *s, long v, int n)
{
long v1 = (v & 0xFF000000) >> 24,
v2 = (v & 0x00FF0000) >> 16,
v3 = (v & 0x0000FF00) >> 8,
v4 = (v & 0x000000FF);
snprintf(s, n, "%i.%i.%i.%i", (int)v1, (int)v2, (int)v3, (int)v4);
return s;
}

View File

@ -3,6 +3,9 @@
#include <time.h>
#include "vmr.h"
#include "log.h"
#include "util.h"
#define VERSION_STR_LEN 128
long login(T_VBVMR_INTERFACE *vmr, int kind)
{
@ -43,13 +46,10 @@ long login(T_VBVMR_INTERFACE *vmr, int kind)
if (rep == 0)
{
version(vmr, &v);
long v1 = (v & 0xFF000000) >> 24,
v2 = (v & 0x00FF0000) >> 16,
v3 = (v & 0x0000FF00) >> 8,
v4 = (v & 0x000000FF);
char version_s[128];
sprintf(version_s, "%i.%i.%i.%i", (int)v1, (int)v2, (int)v3, (int)v4);
log_info("Successfully logged into the Voicemeeter API v%s", version_s);
char version_s[VERSION_STR_LEN];
log_info(
"Successfully logged into the Voicemeeter API v%s",
version_as_string(version_s, v, VERSION_STR_LEN));
clear_dirty(vmr);
}
return rep;

View File

@ -112,8 +112,9 @@ int main(int argc, char *argv[])
void help()
{
puts(
"Usage: ./vmrcli.exe [-i] [-k] [-D] <api commands>\n"
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] <api commands>\n"
"Where: \n"
"\th: Prints the help dialogue\n"
"\ti: Enable interactive mode\n"
"\tk: The kind of Voicemeeter (basic, banana, potato)\n"
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL");