diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-03-05 04:50:32 +0000 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-03-05 04:50:32 +0000 |
| commit | 24cec7a35072ac50e1fe902a925e69330866dbca (patch) | |
| tree | f60bb7c38b0b952e074f9b8f8d1cef758d7f8ec8 /src/Utility | |
| parent | 5ed5a6ecc749e8b557ea62f04a444e203f4e48f6 (diff) | |
| download | omnisearch-24cec7a35072ac50e1fe902a925e69330866dbca.tar.gz | |
Diffstat (limited to 'src/Utility')
| -rw-r--r-- | src/Utility/Display.c | 72 | ||||
| -rw-r--r-- | src/Utility/Utility.c | 8 |
2 files changed, 40 insertions, 40 deletions
diff --git a/src/Utility/Display.c b/src/Utility/Display.c index 492e998..9737757 100644 --- a/src/Utility/Display.c +++ b/src/Utility/Display.c @@ -5,42 +5,42 @@ #include <strings.h> char *pretty_display_url(const char *input) { - if (!input) return NULL; - - const char *start = input; - - const char *protocol_pos = strstr(input, "://"); - if (protocol_pos) { - start = protocol_pos + 3; - } - - if (strncasecmp(start, "www.", 4) == 0) { - start += 4; - } - - size_t input_len = strlen(start); - char temp[512]; - strncpy(temp, start, sizeof(temp) - 1); - temp[sizeof(temp) - 1] = '\0'; - - if (input_len > 0 && temp[input_len - 1] == '/') { - temp[input_len - 1] = '\0'; - } - - char *output = (char *)malloc(strlen(temp) * 3 + 1); - if (!output) return NULL; - - size_t j = 0; - for (size_t i = 0; temp[i] != '\0'; i++) { - if (temp[i] == '/') { - output[j++] = ' '; - output[j++] = '>'; - output[j++] = ' '; - } else { - output[j++] = (char)tolower((unsigned char)temp[i]); - } + if (!input) return NULL; + + const char *start = input; + + const char *protocol_pos = strstr(input, "://"); + if (protocol_pos) { + start = protocol_pos + 3; + } + + if (strncasecmp(start, "www.", 4) == 0) { + start += 4; + } + + size_t input_len = strlen(start); + char temp[512]; + strncpy(temp, start, sizeof(temp) - 1); + temp[sizeof(temp) - 1] = '\0'; + + if (input_len > 0 && temp[input_len - 1] == '/') { + temp[input_len - 1] = '\0'; + } + + char *output = (char *)malloc(strlen(temp) * 3 + 1); + if (!output) return NULL; + + size_t j = 0; + for (size_t i = 0; temp[i] != '\0'; i++) { + if (temp[i] == '/') { + output[j++] = ' '; + output[j++] = '>'; + output[j++] = ' '; + } else { + output[j++] = (char)tolower((unsigned char)temp[i]); } - output[j] = '\0'; + } + output[j] = '\0'; - return output; + return output; } diff --git a/src/Utility/Utility.c b/src/Utility/Utility.c index 8e5af92..07fa1da 100644 --- a/src/Utility/Utility.c +++ b/src/Utility/Utility.c @@ -1,8 +1,8 @@ #include "Utility.h" int hex_to_int(char c) { - if (c >= '0' && c <= '9') return c - '0'; - if (c >= 'a' && c <= 'f') return c - 'a' + 10; - if (c >= 'A' && c <= 'F') return c - 'A' + 10; - return -1; + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + return -1; } |
