* return modification length
authorMichael Wallner <mike@php.net>
Wed, 13 Apr 2005 15:14:35 +0000 (15:14 +0000)
committerMichael Wallner <mike@php.net>
Wed, 13 Apr 2005 15:14:35 +0000 (15:14 +0000)
phpstr/phpstr.c
phpstr/phpstr.h

index 286a190b3669119dd146118a56ced262b18a9ec3..8d8df3ea25f383cf1e9ec1efe9f0b73d495a4654 100644 (file)
@@ -45,12 +45,13 @@ PHPSTR_API void phpstr_resize_ex(phpstr *buf, size_t len, size_t override_size)
        }
 }
 
        }
 }
 
-PHPSTR_API void phpstr_append(phpstr *buf, const char *append, size_t append_len)
+PHPSTR_API size_t phpstr_append(phpstr *buf, const char *append, size_t append_len)
 {
        phpstr_resize(buf, append_len);
        memcpy(buf->data + buf->used, append, append_len);
        buf->used += append_len;
        buf->free -= append_len;
 {
        phpstr_resize(buf, append_len);
        memcpy(buf->data + buf->used, append, append_len);
        buf->used += append_len;
        buf->free -= append_len;
+       return append_len;
 }
 
 PHPSTR_API size_t phpstr_appendf(phpstr *buf, const char *format, ...)
 }
 
 PHPSTR_API size_t phpstr_appendf(phpstr *buf, const char *format, ...)
@@ -69,13 +70,14 @@ PHPSTR_API size_t phpstr_appendf(phpstr *buf, const char *format, ...)
        return append_len;
 }
 
        return append_len;
 }
 
-PHPSTR_API void phpstr_insert(phpstr *buf, const char *insert, size_t insert_len, size_t offset)
+PHPSTR_API size_t phpstr_insert(phpstr *buf, const char *insert, size_t insert_len, size_t offset)
 {
        phpstr_resize(buf, insert_len);
        memmove(buf->data + offset + insert_len, buf->data + offset, insert_len);
        memcpy(buf->data + offset, insert, insert_len);
        buf->used += insert_len;
        buf->free -= insert_len;
 {
        phpstr_resize(buf, insert_len);
        memmove(buf->data + offset + insert_len, buf->data + offset, insert_len);
        memcpy(buf->data + offset, insert, insert_len);
        buf->used += insert_len;
        buf->free -= insert_len;
+       return insert_len;
 }
 
 PHPSTR_API size_t phpstr_insertf(phpstr *buf, size_t offset, const char *format, ...)
 }
 
 PHPSTR_API size_t phpstr_insertf(phpstr *buf, size_t offset, const char *format, ...)
@@ -94,13 +96,14 @@ PHPSTR_API size_t phpstr_insertf(phpstr *buf, size_t offset, const char *format,
        return insert_len;
 }
 
        return insert_len;
 }
 
-PHPSTR_API void phpstr_prepend(phpstr *buf, const char *prepend, size_t prepend_len)
+PHPSTR_API size_t phpstr_prepend(phpstr *buf, const char *prepend, size_t prepend_len)
 {
        phpstr_resize(buf, prepend_len);
        memmove(buf->data + prepend_len, buf->data, buf->used);
        memcpy(buf->data, prepend, prepend_len);
        buf->used += prepend_len;
        buf->free -= prepend_len;
 {
        phpstr_resize(buf, prepend_len);
        memmove(buf->data + prepend_len, buf->data, buf->used);
        memcpy(buf->data, prepend, prepend_len);
        buf->used += prepend_len;
        buf->free -= prepend_len;
+       return prepend_len;
 }
 
 PHPSTR_API size_t phpstr_prependf(phpstr *buf, const char *format, ...)
 }
 
 PHPSTR_API size_t phpstr_prependf(phpstr *buf, const char *format, ...)
index 51c2b42b8250ae71de5e5e4d5567a9b7856f4695..cb7d06a1d6b05ead57961994ff31185791fd0884 100644 (file)
@@ -79,19 +79,19 @@ PHPSTR_API void phpstr_resize_ex(phpstr *buf, size_t len, size_t override_size);
 /* append data to the phpstr */
 #define phpstr_appends(b, a) phpstr_append((b), (a), sizeof(a)-1)
 #define phpstr_appendl(b, a) phpstr_append((b), (a), strlen(a))
 /* append data to the phpstr */
 #define phpstr_appends(b, a) phpstr_append((b), (a), sizeof(a)-1)
 #define phpstr_appendl(b, a) phpstr_append((b), (a), strlen(a))
-PHPSTR_API void phpstr_append(phpstr *buf, const char *append, size_t append_len);
+PHPSTR_API size_t phpstr_append(phpstr *buf, const char *append, size_t append_len);
 PHPSTR_API size_t phpstr_appendf(phpstr *buf, const char *format, ...);
 
 /* insert data at a specific position of the phpstr */
 #define phpstr_inserts(b, i, o) phpstr_insert((b), (i), sizeof(i)-1, (o))
 #define phpstr_insertl(b, i, o) phpstr_insert((b), (i), strlen(i), (o))
 PHPSTR_API size_t phpstr_appendf(phpstr *buf, const char *format, ...);
 
 /* insert data at a specific position of the phpstr */
 #define phpstr_inserts(b, i, o) phpstr_insert((b), (i), sizeof(i)-1, (o))
 #define phpstr_insertl(b, i, o) phpstr_insert((b), (i), strlen(i), (o))
-PHPSTR_API void phpstr_insert(phpstr *buf, const char *insert, size_t insert_len, size_t offset);
+PHPSTR_API size_t phpstr_insert(phpstr *buf, const char *insert, size_t insert_len, size_t offset);
 PHPSTR_API size_t phpstr_insertf(phpstr *buf, size_t offset, const char *format, ...);
 
 /* prepend data */
 #define phpstr_prepends(b, p) phpstr_prepend((b), (p), sizeof(p)-1)
 #define phpstr_prependl(b, p) phpstr_prepend((b), (p), strlen(p))
 PHPSTR_API size_t phpstr_insertf(phpstr *buf, size_t offset, const char *format, ...);
 
 /* prepend data */
 #define phpstr_prepends(b, p) phpstr_prepend((b), (p), sizeof(p)-1)
 #define phpstr_prependl(b, p) phpstr_prepend((b), (p), strlen(p))
-PHPSTR_API void phpstr_prepend(phpstr *buf, const char *prepend, size_t prepend_len);
+PHPSTR_API size_t phpstr_prepend(phpstr *buf, const char *prepend, size_t prepend_len);
 PHPSTR_API size_t phpstr_prependf(phpstr *buf, const char *format, ...);
 
 /* get a zero-terminated string */
 PHPSTR_API size_t phpstr_prependf(phpstr *buf, const char *format, ...);
 
 /* get a zero-terminated string */