mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2025-04-11 00:33:45 +01:00
Compare commits
No commits in common. "main" and "v0.11.0" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -51,9 +51,6 @@ Module.symvers
|
|||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
# Task Runner
|
|
||||||
.task/
|
|
||||||
|
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
test*
|
test*
|
71
Taskfile.yml
71
Taskfile.yml
@ -1,71 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
dotenv: ['.env']
|
|
||||||
|
|
||||||
vars:
|
|
||||||
PROGRAM: vmrcli
|
|
||||||
SHELL: pwsh
|
|
||||||
|
|
||||||
CC: gcc
|
|
||||||
|
|
||||||
SRC_DIR: src
|
|
||||||
INC_DIR: include
|
|
||||||
OBJ_DIR: obj
|
|
||||||
BIN_DIR: bin
|
|
||||||
|
|
||||||
CPPFLAGS: -I{{.INC_DIR}} -MMD -MP {{if eq .LOG_USE_COLOR "yes"}}-DLOG_USE_COLOR{{end}}
|
|
||||||
|
|
||||||
CFLAGS: -O -Wall -W -pedantic -ansi -std=c2x
|
|
||||||
LDFLAGS: -Llib
|
|
||||||
LDLIBS: -lm
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
default:
|
|
||||||
desc: Build vmrcli for Windows
|
|
||||||
deps: [build]
|
|
||||||
|
|
||||||
build:
|
|
||||||
desc: Build vmrcli for Windows
|
|
||||||
deps: [link]
|
|
||||||
|
|
||||||
link:
|
|
||||||
desc: Link all files in obj/ for Windows
|
|
||||||
deps: [compile]
|
|
||||||
cmds:
|
|
||||||
- |
|
|
||||||
{{.SHELL}} -Command "
|
|
||||||
if (!(Test-Path -Path '{{.BIN_DIR}}')) {
|
|
||||||
New-Item -ItemType Directory -Path '{{.BIN_DIR}}'
|
|
||||||
}
|
|
||||||
|
|
||||||
{{.CC}} {{.LDFLAGS}} {{.OBJ_DIR}}/*.o {{.LDLIBS}} -o {{.BIN_DIR}}/{{.PROGRAM}}.exe"
|
|
||||||
sources:
|
|
||||||
- '{{.OBJ_DIR}}/**'
|
|
||||||
generates:
|
|
||||||
- '{{.BIN_DIR}}/{{.PROGRAM}}.exe'
|
|
||||||
|
|
||||||
compile:
|
|
||||||
desc: Compile all files in src/ and include/ for Windows
|
|
||||||
cmds:
|
|
||||||
- |
|
|
||||||
{{.SHELL}} -Command "
|
|
||||||
if (!(Test-Path -Path '{{.OBJ_DIR}}')) {
|
|
||||||
New-Item -ItemType Directory -Path '{{.OBJ_DIR}}'
|
|
||||||
}
|
|
||||||
|
|
||||||
Get-ChildItem -Path '{{.SRC_DIR}}' -Filter '*.c' |
|
|
||||||
ForEach-Object { \$_.Name -replace '\.c$', '' } |
|
|
||||||
ForEach-Object { {{.CC}} {{.CPPFLAGS}} {{.CFLAGS}} -c {{.SRC_DIR}}/\$_.c -o {{.OBJ_DIR}}/\$_.o }"
|
|
||||||
sources:
|
|
||||||
- '{{.SRC_DIR}}/**'
|
|
||||||
- '{{.INC_DIR}}/**'
|
|
||||||
generates:
|
|
||||||
- '{{.OBJ_DIR}}/**'
|
|
||||||
|
|
||||||
clean:
|
|
||||||
desc: Remove all files in obj/ and bin/
|
|
||||||
cmds:
|
|
||||||
- |
|
|
||||||
{{.SHELL}} -Command "
|
|
||||||
if (Test-Path -Path '{{.OBJ_DIR}}') { Remove-Item -Path '{{.OBJ_DIR}}' -Recurse -Force }
|
|
||||||
if (Test-Path -Path '{{.BIN_DIR}}') { Remove-Item -Path '{{.BIN_DIR}}' -Recurse -Force }"
|
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include "VoicemeeterRemote.h"
|
#include "VoicemeeterRemote.h"
|
||||||
|
|
||||||
#define IS_64_BIT sizeof(void *) == 8
|
|
||||||
|
|
||||||
PT_VMR create_interface();
|
PT_VMR create_interface();
|
||||||
|
|
||||||
#endif /* __IVMR_H__ */
|
#endif /* __IVMR_H__ */
|
17
makefile
17
makefile
@ -1,53 +1,38 @@
|
|||||||
# Program name
|
|
||||||
program = vmrcli
|
program = vmrcli
|
||||||
|
|
||||||
# Compiler
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
# Directories
|
|
||||||
SRC_DIR := src
|
SRC_DIR := src
|
||||||
OBJ_DIR := obj
|
OBJ_DIR := obj
|
||||||
BIN_DIR := bin
|
BIN_DIR := bin
|
||||||
|
|
||||||
# Executable and source/object files
|
|
||||||
EXE := $(BIN_DIR)/$(program).exe
|
EXE := $(BIN_DIR)/$(program).exe
|
||||||
SRC := $(wildcard $(SRC_DIR)/*.c)
|
SRC := $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||||
|
|
||||||
# Conditional compilation flags for logging
|
|
||||||
LOG_USE_COLOR ?= yes
|
LOG_USE_COLOR ?= yes
|
||||||
ifeq ($(LOG_USE_COLOR), yes)
|
ifeq ($(LOG_USE_COLOR), yes)
|
||||||
CPPFLAGS := -Iinclude -MMD -MP -DLOG_USE_COLOR
|
CPPFLAGS := -Iinclude -MMD -MP -DLOG_USE_COLOR
|
||||||
else
|
else
|
||||||
CPPFLAGS := -Iinclude -MMD -MP
|
CPPFLAGS := -Iinclude -MMD -MP
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Compiler and linker flags
|
|
||||||
CFLAGS = -O -Wall -W -pedantic -ansi -std=c2x
|
CFLAGS = -O -Wall -W -pedantic -ansi -std=c2x
|
||||||
LDFLAGS := -Llib
|
LDFLAGS := -Llib
|
||||||
LDLIBS := -lm
|
LDLIBS := -lm
|
||||||
|
|
||||||
# Phony targets
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
# Default target
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
|
|
||||||
# Link the executable
|
|
||||||
$(EXE): $(OBJ) | $(BIN_DIR)
|
$(EXE): $(OBJ) | $(BIN_DIR)
|
||||||
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
||||||
|
|
||||||
# Compile source files to object files
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Create necessary directories
|
|
||||||
$(BIN_DIR) $(OBJ_DIR):
|
$(BIN_DIR) $(OBJ_DIR):
|
||||||
pwsh -Command New-Item -Path $@ -ItemType Directory
|
pwsh -Command New-Item -Path $@ -ItemType Directory
|
||||||
|
|
||||||
# Clean up generated files
|
|
||||||
clean:
|
clean:
|
||||||
pwsh -Command Remove-Item -Recurse $(BIN_DIR), $(OBJ_DIR) -force
|
pwsh -Command Remove-Item -Recurse $(EXE), $(OBJ_DIR) -force
|
||||||
|
|
||||||
# Include dependency files
|
|
||||||
-include $(OBJ:.o=.d)
|
-include $(OBJ:.o=.d)
|
||||||
|
@ -81,7 +81,7 @@ static long initialize_dll_interfaces(PT_VMR vmr)
|
|||||||
return -100;
|
return -100;
|
||||||
}
|
}
|
||||||
// use right dll according to O/S type
|
// use right dll according to O/S type
|
||||||
if (IS_64_BIT)
|
if (sizeof(void *) == 8)
|
||||||
strncat(dll_fullpath, DLL64_NAME, DLL_FULLPATH_SZ - strlen(DLL64_NAME) - 1);
|
strncat(dll_fullpath, DLL64_NAME, DLL_FULLPATH_SZ - strlen(DLL64_NAME) - 1);
|
||||||
else
|
else
|
||||||
strncat(dll_fullpath, DLL32_NAME, DLL_FULLPATH_SZ - strlen(DLL32_NAME) - 1);
|
strncat(dll_fullpath, DLL32_NAME, DLL_FULLPATH_SZ - strlen(DLL32_NAME) - 1);
|
||||||
|
@ -118,7 +118,7 @@ void log_set_quiet(bool enable)
|
|||||||
|
|
||||||
int log_add_callback(log_LogFn fn, void *udata, int level)
|
int log_add_callback(log_LogFn fn, void *udata, int level)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CALLBACKS; ++i)
|
for (int i = 0; i < MAX_CALLBACKS; i++)
|
||||||
{
|
{
|
||||||
if (!L.callbacks[i].fn)
|
if (!L.callbacks[i].fn)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ void log_log(int level, const char *file, int line, const char *fmt, ...)
|
|||||||
va_end(ev.ap);
|
va_end(ev.ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_CALLBACKS && L.callbacks[i].fn; ++i)
|
for (int i = 0; i < MAX_CALLBACKS && L.callbacks[i].fn; i++)
|
||||||
{
|
{
|
||||||
Callback *cb = &L.callbacks[i];
|
Callback *cb = &L.callbacks[i];
|
||||||
if (level >= cb->level)
|
if (level >= cb->level)
|
||||||
|
@ -92,7 +92,7 @@ bool is_comment(char *s)
|
|||||||
*/
|
*/
|
||||||
struct quickcommand *command_in_quickcommands(const char *command_key, const struct quickcommand *quickcommands, int n)
|
struct quickcommand *command_in_quickcommands(const char *command_key, const struct quickcommand *quickcommands, int n)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(command_key, quickcommands[i].name) == 0)
|
if (strcmp(command_key, quickcommands[i].name) == 0)
|
||||||
{
|
{
|
||||||
|
13
src/vmrcli.c
13
src/vmrcli.c
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = optind; i < argc; ++i)
|
for (int i = optind; i < argc; i++)
|
||||||
{
|
{
|
||||||
parse_input(vmr, argv[i]);
|
parse_input(vmr, argv[i]);
|
||||||
}
|
}
|
||||||
@ -240,11 +240,11 @@ static void usage()
|
|||||||
static enum kind set_kind(char *kval)
|
static enum kind set_kind(char *kval)
|
||||||
{
|
{
|
||||||
if (strcmp(kval, "basic") == 0)
|
if (strcmp(kval, "basic") == 0)
|
||||||
return IS_64_BIT ? BASICX64 : BASIC;
|
return sizeof(void *) == 8 ? BASICX64 : BASIC;
|
||||||
else if (strcmp(kval, "banana") == 0)
|
else if (strcmp(kval, "banana") == 0)
|
||||||
return IS_64_BIT ? BANANAX64 : BANANA;
|
return sizeof(void *) == 8 ? BANANAX64 : BANANA;
|
||||||
else if (strcmp(kval, "potato") == 0)
|
else if (strcmp(kval, "potato") == 0)
|
||||||
return IS_64_BIT ? POTATOX64 : POTATO;
|
return sizeof(void *) == 8 ? POTATOX64 : POTATO;
|
||||||
else
|
else
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -266,11 +266,12 @@ static void interactive(PT_VMR vmr, bool with_prompt)
|
|||||||
printf(">> ");
|
printf(">> ");
|
||||||
while (fgets(input, MAX_LINE, stdin) != NULL)
|
while (fgets(input, MAX_LINE, stdin) != NULL)
|
||||||
{
|
{
|
||||||
input[(len = strcspn(input, "\n"))] = 0;
|
input[strcspn(input, "\n")] = 0;
|
||||||
if (len == 1 && toupper(input[0]) == 'Q')
|
if ((len = strlen(input)) == 1 && toupper(input[0]) == 'Q')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
parse_input(vmr, input);
|
parse_input(vmr, input);
|
||||||
|
memset(input, 0, len); /* reset input buffer */
|
||||||
|
|
||||||
if (with_prompt)
|
if (with_prompt)
|
||||||
printf(">> ");
|
printf(">> ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user