mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 21:21:53 +00:00
added uwsgi_buffer_insert()
This commit is contained in:
+10
-1
@@ -48,9 +48,18 @@ int uwsgi_buffer_ensure(struct uwsgi_buffer *ub, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uwsgi_buffer_insert(struct uwsgi_buffer *ub, size_t pos, char *buf, size_t len) {
|
||||
size_t to_move = (ub->pos-pos);
|
||||
if (uwsgi_buffer_ensure(ub, len)) return -1;
|
||||
memmove(ub->buf+pos+len, ub->buf+pos, to_move);
|
||||
memcpy(ub->buf+pos, buf, len);
|
||||
ub->pos += len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uwsgi_buffer_decapitate(struct uwsgi_buffer *ub, size_t len) {
|
||||
if (len > ub->pos) return -1;
|
||||
ub->buf = memmove(ub->buf, ub->buf + len, ub->pos-len);
|
||||
memmove(ub->buf, ub->buf + len, ub->pos-len);
|
||||
ub->pos = ub->pos-len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
*** uWSGI ***
|
||||
|
||||
Copyright (C) 2009-2012 Unbit S.a.s. <info@unbit.it>
|
||||
Copyright (C) 2009-2013 Unbit S.a.s. <info@unbit.it>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -3574,6 +3574,8 @@ int uwsgi_buffer_append_ipv4(struct uwsgi_buffer *, void *);
|
||||
int uwsgi_buffer_append_keyipv4(struct uwsgi_buffer *, char *, uint16_t, void *);
|
||||
int uwsgi_buffer_decapitate(struct uwsgi_buffer *, size_t);
|
||||
int uwsgi_buffer_append_base64(struct uwsgi_buffer *, char *, size_t);
|
||||
int uwsgi_buffer_insert(struct uwsgi_buffer *, size_t, char *, size_t);
|
||||
|
||||
ssize_t uwsgi_buffer_write_simple(struct wsgi_request *, struct uwsgi_buffer *);
|
||||
|
||||
void uwsgi_httpize_var(char *, size_t);
|
||||
|
||||
Reference in New Issue
Block a user