mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2026-04-07 17:33:33 +00:00
extra X64 kinds added to enum kind
log message updated to reflect new kinds replace_multiple_space_with_one() now returns new line length kind_as_string() added to util.c
This commit is contained in:
37
src/util.c
37
src/util.c
@@ -1,5 +1,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include "vmr.h"
|
||||
#include "util.h"
|
||||
|
||||
void remove_name_in_path(char *szPath)
|
||||
@@ -14,7 +15,14 @@ void remove_name_in_path(char *szPath)
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
void replace_multiple_space_with_one(char *s, size_t len)
|
||||
/**
|
||||
* @brief replaces multiple newlines and tabs with single spaces
|
||||
*
|
||||
* @param s the string to be reduced
|
||||
* @param len current length of the string
|
||||
* @return int new length of the string
|
||||
*/
|
||||
int replace_multiple_space_with_one(char *s, size_t len)
|
||||
{
|
||||
int j = 0;
|
||||
int count = 0;
|
||||
@@ -22,11 +30,11 @@ void replace_multiple_space_with_one(char *s, size_t len)
|
||||
if (len == 1 && (s[0] == ' ' || s[0] == '\t'))
|
||||
{
|
||||
s[0] = '\0';
|
||||
return;
|
||||
return len;
|
||||
}
|
||||
|
||||
if (len < 2)
|
||||
return;
|
||||
return len;
|
||||
|
||||
for (int i = 0; s[i] != '\0'; i++)
|
||||
{
|
||||
@@ -46,8 +54,31 @@ void replace_multiple_space_with_one(char *s, size_t len)
|
||||
}
|
||||
}
|
||||
s[j] = '\0';
|
||||
return j;
|
||||
}
|
||||
|
||||
char *kind_as_string(char *s, enum kind kind, int n)
|
||||
{
|
||||
char *kinds[] = {
|
||||
"Basic",
|
||||
"Banana",
|
||||
"Potato",
|
||||
"Basic x64",
|
||||
"Banana x64",
|
||||
"Potato x64",
|
||||
};
|
||||
snprintf(s, n, kinds[kind - 1]);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief returns Voicemeeter's version as a string
|
||||
*
|
||||
* @param s string buffer the version will be written to
|
||||
* @param v unprocessed version as a long int
|
||||
* @param n maximum number of characters to be written to the buffer
|
||||
* @return char*
|
||||
*/
|
||||
char *version_as_string(char *s, long v, int n)
|
||||
{
|
||||
long v1 = (v & 0xFF000000) >> 24,
|
||||
|
||||
Reference in New Issue
Block a user