Compare commits

..

No commits in common. "dc8a4036c834c20d8fdea9d49cb2b178d3a2fec2" and "477267e278f8207d895edde400d525074fc5cc0f" have entirely different histories.

4 changed files with 19 additions and 19 deletions

View File

@ -8,8 +8,8 @@
#ifndef __UTIL_H__ #ifndef __UTIL_H__
#define __UTIL_H__ #define __UTIL_H__
void remove_last_part_of_path(char *szPath); void remove_name_in_path(char *szPath);
int replace_blanks_with_single_space(char *s, size_t len); int replace_multiple_space_with_one(char *s, size_t len);
char *kind_as_string(char *s, int kind, int n); char *kind_as_string(char *s, int kind, int n);
char *version_as_string(char *, long v, 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) if (rep != ERROR_SUCCESS)
return false; return false;
// remove name to get the path only // remove name to get the path only
remove_last_part_of_path(sss); remove_name_in_path(sss);
if (nnsize > 512) if (nnsize > 512)
nnsize = 512; nnsize = 512;
strncpy(szDir, sss, nnsize); strncpy(szDir, sss, nnsize);

View File

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

View File

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