Compare commits

...

2 Commits

Author SHA1 Message Date
dc8a4036c8 upd utility functions 2024-07-08 16:01:14 +01:00
6b7e0afb91 add get desc 2024-07-08 08:45:14 +01:00
4 changed files with 19 additions and 19 deletions

View File

@ -8,8 +8,8 @@
#ifndef __UTIL_H__
#define __UTIL_H__
void remove_name_in_path(char *szPath);
int replace_multiple_space_with_one(char *s, size_t len);
void remove_last_part_of_path(char *szPath);
int replace_blanks_with_single_space(char *s, size_t len);
char *kind_as_string(char *s, int kind, int n);
char *version_as_string(char *, long v, int n);

View File

@ -211,7 +211,7 @@ static bool registry_get_voicemeeter_folder(char *szDir)
if (rep != ERROR_SUCCESS)
return false;
// remove name to get the path only
remove_name_in_path(sss);
remove_last_part_of_path(sss);
if (nnsize > 512)
nnsize = 512;
strncpy(szDir, sss, nnsize);

View File

@ -11,24 +11,24 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "wrapper.h"
#include "util.h"
/**
* @brief Removes the last part of a path
*
* @param szPath Pointer to the path string
* @param fullpath The entire path
*/
void remove_name_in_path(char *szPath)
void remove_last_part_of_path(char *fullpath)
{
char *p = szPath;
char *p;
while (*p++)
;
while (p > szPath && *p != '\\')
p--;
if (*p == '\\')
if ((p = strrchr(fullpath, '\\')) != NULL)
{
*p = '\0';
}
}
/**
@ -38,12 +38,12 @@ void remove_name_in_path(char *szPath)
* @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 replace_blanks_with_single_space(char *s, size_t len)
{
int j = 0;
int count = 0;
if (len == 1 && (s[0] == ' ' || s[0] == '\t'))
if (len == 1 && isblank(s[0]))
{
s[0] = '\0';
return len;
@ -54,12 +54,11 @@ int replace_multiple_space_with_one(char *s, size_t len)
for (int i = 0; s[i] != '\0'; i++)
{
if (s[i] == ' ' || s[i] == '\t')
if (isblank(s[i]))
{
count++;
}
if (s[i] != ' ' && s[i] != '\t')
else
{
if (count >= 1)
{

View File

@ -182,7 +182,7 @@ int main(int argc, char *argv[])
void help()
{
puts(
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n"
"Usage: .\\vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n"
"Where: \n"
"\th: Prints the help message\n"
"\ti: Enable interactive mode\n"
@ -268,7 +268,7 @@ void parse_input(PT_VMR vmr, char *input, int len)
{
char *token;
replace_multiple_space_with_one(input, len);
replace_blanks_with_single_space(input, len);
token = strtok(input, " ");
while (token != NULL)
{
@ -340,7 +340,8 @@ void parse_command(PT_VMR vmr, char *command)
}
/**
* @brief
* @brief Get the value of a float or string parameter.
* Stores its type and value into a result struct
*
* @param vmr Pointer to the iVMR interface
* @param command A parsed 'get' command as a string