2024-06-27 22:06:15 +01:00
|
|
|
#include <stddef.h>
|
2024-06-28 03:21:38 +01:00
|
|
|
#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';
|
|
|
|
}
|
2024-06-27 19:18:28 +01:00
|
|
|
|
2024-06-27 22:06:15 +01:00
|
|
|
void replace_multiple_space_with_one(char *s, size_t len)
|
2024-06-27 19:18:28 +01:00
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (len == 1 && (s[0] == ' ' || s[0] == '\t'))
|
|
|
|
{
|
|
|
|
s[0] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 0; s[i] != '\0'; i++)
|
|
|
|
{
|
|
|
|
if (s[i] == ' ' || s[i] == '\t')
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s[i] != ' ' && s[i] != '\t')
|
|
|
|
{
|
|
|
|
if (count >= 1)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
s[j++] = ' ';
|
|
|
|
}
|
|
|
|
s[j++] = s[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s[j] = '\0';
|
2024-06-28 03:21:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2024-06-27 19:18:28 +01:00
|
|
|
}
|