refactor: extract user authentication logic into dedicated service class with dependency injection

This commit is contained in:
2025-01-27 18:06:59 +00:00
parent 9c92ef06da
commit ad7ebf2e2b
10 changed files with 235 additions and 291 deletions
+9 -7
View File
@@ -10,6 +10,8 @@
#include <regex.h>
#include "http.h"
#include "url.h"
#include <stdlib.h>
#include <string.h>
void extract_urls(const char *input, char **urls, int *url_count) {
const char *pattern = "https?://[^ ]+";
@@ -29,18 +31,18 @@ void extract_urls(const char *input, char **urls, int *url_count) {
regfree(&regex);
}
void inplace_urls_markdown_style(char *input, char **urls, char **contents, int url_count) {
void inplace_urls_markdown_style(char **input, char **urls, char **contents, int url_count) {
for (int i = 0; i < url_count; i++) {
char *found = strstr(input, urls[i]);
char *found = strstr(*input, urls[i]);
if (found) {
char *new_text = (char *)malloc(strlen(input) + strlen(contents[i]) - strlen(urls[i]) + 1);
strncpy(new_text, input, found - input);
new_text[found - input] = '\0';
char *new_text = (char *)malloc(strlen(*input) + strlen(contents[i]) - strlen(urls[i]) + 1);
strncpy(new_text, *input, found - *input);
new_text[found - *input] = '\0';
strcat(new_text, contents[i]);
strcat(new_text, found + strlen(urls[i]));
free(input);
input = new_text;
free(*input);
*input = new_text;
}
}
}