Plugin Management support C plugin

This commit is contained in:
luwenpeng
2022-07-27 18:32:22 +08:00
parent 649d29e538
commit 50111e7cd0
35 changed files with 4220 additions and 193 deletions

View File

@@ -0,0 +1,40 @@
#include <string.h>
#include <stdlib.h>
#include "plugin_manager_util.h"
char *safe_dup(const char *str)
{
if (str == NULL)
{
return NULL;
}
char *dup = safe_alloc(char, strlen(str) + 1);
memcpy(dup, str, strlen(str));
return dup;
}
void strcat_prefix_and_file(const char *prefix, const char *file, char *buff, int size)
{
char prefix_buffer[4096] = {0};
char file_buffer[4096] = {0};
char *ptr = NULL;
memcpy(prefix_buffer, prefix, strlen(prefix));
memcpy(file_buffer, file, strlen(file));
if (prefix_buffer[strlen(prefix_buffer) - 1] != '/')
{
prefix_buffer[strlen(prefix_buffer)] = '/';
}
file_buffer[strcspn(file_buffer, "\r\n")] = 0;
ptr = file_buffer;
if (file_buffer[0] == '.' && file_buffer[1] == '/')
{
ptr += 2;
}
snprintf(buff, size, "%s%s", prefix_buffer, ptr);
}