mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2025-01-18 08:41:08 +00:00
move remove_name_in_path() into util.c
add version_as_string() to util.c
This commit is contained in:
parent
0bda368f59
commit
2740c6c82d
@ -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__ */
|
13
src/cdll.c
13
src/cdll.c
@ -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];
|
||||
|
24
src/util.c
24
src/util.c
@ -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)
|
||||
{
|
||||
@ -33,3 +47,13 @@ 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;
|
||||
}
|
14
src/vmr.c
14
src/vmr.c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user