return 0;
}
-static int pakfire_string_append(char** buffer, const char* s, const size_t l) {
+static int __pakfire_string_replace(char** buffer, const char* s, const size_t l) {
int r;
// Check how long the string is that we are holding
if (!m) {
// Copy the remaining string
- r = pakfire_string_append(&buffer, p, strlen(p));
+ r = __pakfire_string_replace(&buffer, p, strlen(p));
if (r < 0)
goto ERROR;
l = m - p;
// Copy the read string up to pattern
- r = pakfire_string_append(&buffer, p, l);
+ r = __pakfire_string_replace(&buffer, p, l);
if (r < 0)
goto ERROR;
- r = pakfire_string_append(&buffer, repl, repl_length);
+ r = __pakfire_string_replace(&buffer, repl, repl_length);
if (r < 0)
goto ERROR;
return string;
}
+/*
+ Append the given string to the buffer
+*/
+int __pakfire_string_append(char* buffer, size_t length, const char* appendix) {
+ // Check inputs
+ if (!buffer || !appendix)
+ return -EINVAL;
+
+ // How long is the existing string?
+ const size_t l = strlen(buffer);
+
+ return __pakfire_string_set(buffer + l, length - l, appendix);
+}
+
int pakfire_string_search(const char* haystack, ssize_t lhaystack,
const char* needle, ssize_t lneedle) {
// Check inputs
return 0;
}
+#define pakfire_string_append(s, appendix) \
+ __pakfire_string_append(s, sizeof(s), appendix)
+int __pakfire_string_append(char* buffer, size_t length, const char* appendix);
+
int pakfire_string_search(const char* haystack, ssize_t lhaystack,
const char* needle, ssize_t lneedle);