version 1.2, 2015/04/20 18:10:36
|
version 1.3, 2015/04/20 18:20:37
|
|
|
#endif | #endif |
MI_Result WSBuf_AddLit( | MI_Result WSBuf_AddLit( |
WSBuf* buf, | WSBuf* buf, |
const MI_Char* str, |
const ZChar* str, |
MI_Uint32 size) | MI_Uint32 size) |
{ | { |
MI_Uint32 n; | MI_Uint32 n; |
|
n = size * sizeof(ZChar); |
/* If enough capacity, add string inline */ |
|
n = size * sizeof(MI_Char); |
|
| |
if (n + buf->position < buf->page->u.s.size) | if (n + buf->position < buf->page->u.s.size) |
{ | { |
char* data = (char*)(buf->page + 1) + buf->position; | char* data = (char*)(buf->page + 1) + buf->position; |
memcpy(data, str, n); | memcpy(data, str, n); |
((MI_Char*)data)[size] = 0; |
((ZChar*)data)[size] = 0; |
| |
buf->position += n; | buf->position += n; |
return MI_RESULT_OK; | return MI_RESULT_OK; |
|
|
#endif | #endif |
MI_Result WSBuf_AddLit1( | MI_Result WSBuf_AddLit1( |
WSBuf* buf, | WSBuf* buf, |
MI_Char c1) |
ZChar c1) |
{ | { |
|
# if !defined(CONFIG_FAVORSIZE) |
|
|
const MI_Uint32 SIZE = sizeof(c1); | const MI_Uint32 SIZE = sizeof(c1); |
| |
if (SIZE + buf->position < buf->page->u.s.size) | if (SIZE + buf->position < buf->page->u.s.size) |
{ | { |
MI_Char* data = (MI_Char*)(((char*)(buf->page + 1)) + buf->position); |
ZChar* data = (ZChar*)(((char*)(buf->page + 1)) + buf->position); |
data[0] = c1; | data[0] = c1; |
data[1] = '\0'; | data[1] = '\0'; |
buf->position += SIZE; | buf->position += SIZE; |
return MI_RESULT_OK; | return MI_RESULT_OK; |
} | } |
else |
|
{ |
# endif |
return __WSBuf_AddLit(buf, &c1, 1); | return __WSBuf_AddLit(buf, &c1, 1); |
} | } |
} |
|
| |
#if !defined(WSBUF_DISABLE_INLINING) | #if !defined(WSBUF_DISABLE_INLINING) |
INLINE | INLINE |
#endif | #endif |
MI_Result WSBuf_AddLit2( | MI_Result WSBuf_AddLit2( |
WSBuf* buf, | WSBuf* buf, |
MI_Char c1, |
ZChar c1, |
MI_Char c2) |
ZChar c2) |
{ | { |
|
# if !defined(CONFIG_FAVORSIZE) |
|
|
const MI_Uint32 SIZE = 2 * sizeof(c1); | const MI_Uint32 SIZE = 2 * sizeof(c1); |
| |
if (SIZE + buf->position < buf->page->u.s.size) | if (SIZE + buf->position < buf->page->u.s.size) |
{ | { |
MI_Char* data = (MI_Char*)(((char*)(buf->page + 1)) + buf->position); |
ZChar* data = (ZChar*)(((char*)(buf->page + 1)) + buf->position); |
data[0] = c1; | data[0] = c1; |
data[1] = c2; | data[1] = c2; |
data[2] = '\0'; | data[2] = '\0'; |
buf->position += SIZE; | buf->position += SIZE; |
return MI_RESULT_OK; | return MI_RESULT_OK; |
} | } |
else |
|
|
# endif |
|
|
{ | { |
MI_Char str[2]; |
ZChar str[2]; |
str[0] = c1; | str[0] = c1; |
str[1] = c2; | str[1] = c2; |
return __WSBuf_AddLit(buf, str, 2); | return __WSBuf_AddLit(buf, str, 2); |
|
|
#endif | #endif |
MI_Result WSBuf_AddLit3( | MI_Result WSBuf_AddLit3( |
WSBuf* buf, | WSBuf* buf, |
MI_Char c1, |
ZChar c1, |
MI_Char c2, |
ZChar c2, |
MI_Char c3) |
ZChar c3) |
{ | { |
|
# if !defined(CONFIG_FAVORSIZE) |
|
|
const MI_Uint32 SIZE = 3 * sizeof(c1); | const MI_Uint32 SIZE = 3 * sizeof(c1); |
| |
if (SIZE + buf->position < buf->page->u.s.size) | if (SIZE + buf->position < buf->page->u.s.size) |
{ | { |
MI_Char* data = (MI_Char*)(((char*)(buf->page + 1)) + buf->position); |
ZChar* data = (ZChar*)(((char*)(buf->page + 1)) + buf->position); |
data[0] = c1; | data[0] = c1; |
data[1] = c2; | data[1] = c2; |
data[2] = c3; | data[2] = c3; |
|
|
buf->position += SIZE; | buf->position += SIZE; |
return MI_RESULT_OK; | return MI_RESULT_OK; |
} | } |
else |
|
|
# endif |
|
|
{ | { |
MI_Char str[3]; |
ZChar str[3]; |
str[0] = c1; | str[0] = c1; |
str[1] = c2; | str[1] = c2; |
str[2] = c3; | str[2] = c3; |
|
|
#endif | #endif |
MI_Result WSBuf_AddLit4( | MI_Result WSBuf_AddLit4( |
WSBuf* buf, | WSBuf* buf, |
MI_Char c1, |
ZChar c1, |
MI_Char c2, |
ZChar c2, |
MI_Char c3, |
ZChar c3, |
MI_Char c4) |
ZChar c4) |
{ | { |
|
# if !defined(CONFIG_FAVORSIZE) |
|
|
const MI_Uint32 SIZE = 4 * sizeof(c1); | const MI_Uint32 SIZE = 4 * sizeof(c1); |
| |
if (SIZE + buf->position < buf->page->u.s.size) | if (SIZE + buf->position < buf->page->u.s.size) |
{ | { |
MI_Char* data = (MI_Char*)(((char*)(buf->page + 1)) + buf->position); |
ZChar* data = (ZChar*)(((char*)(buf->page + 1)) + buf->position); |
data[0] = c1; | data[0] = c1; |
data[1] = c2; | data[1] = c2; |
data[2] = c3; | data[2] = c3; |
|
|
buf->position += SIZE; | buf->position += SIZE; |
return MI_RESULT_OK; | return MI_RESULT_OK; |
} | } |
else |
|
|
# endif |
|
|
{ | { |
MI_Char str[4]; |
ZChar str[4]; |
str[0] = c1; | str[0] = c1; |
str[1] = c2; | str[1] = c2; |
str[2] = c3; | str[2] = c3; |
|
|
#endif | #endif |
MI_Result WSBuf_AddStringNoEncoding( | MI_Result WSBuf_AddStringNoEncoding( |
WSBuf* buf, | WSBuf* buf, |
const MI_Char* str) |
const ZChar* str) |
{ | { |
return WSBuf_AddLit(buf, str, (MI_Uint32)Zlen(str)); |
return WSBuf_AddLit(buf, str, (MI_Uint32)Tcslen(str)); |
} | } |
| |
#endif /* _omi_wsman_wsbufinline_h */ | #endif /* _omi_wsman_wsbufinline_h */ |