move remove_name_in_path() into util.c

add version_as_string() to util.c
This commit is contained in:
2024-06-28 03:21:38 +01:00
parent 0bda368f59
commit 2740c6c82d
4 changed files with 34 additions and 19 deletions

View File

@@ -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;
}