mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2026-04-07 17:33:33 +00:00
move remove_name_in_path() into util.c
add version_as_string() to util.c
This commit is contained in:
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)
|
||||
{
|
||||
@@ -32,4 +46,14 @@ 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;
|
||||
}
|
||||
Reference in New Issue
Block a user