static char *get_message_buffer(ScmUVector *v, u_int *size) { if (SCM_UVECTOR_IMMUTABLE_P(v)) { Scm_Error("attempted to use an immutable uniform vector as a buffer"); } *size = Scm_UVectorSizeInBytes(v); return (char *)SCM_UVECTOR_ELEMENTS(v); }
static void extract(ScmUVector *uv, char *buf, int off, int eltsize) { int size = Scm_UVectorSizeInBytes(uv); unsigned char *b = (unsigned char*)SCM_UVECTOR_ELEMENTS(uv) + off; int i; if (off < 0 || off+eltsize > size) { Scm_Error("offset %d is out of bound of the uvector.", off); } for (i=0; i<eltsize; i++) { *buf++ = *b++; } }
static const char *get_message_body(ScmObj msg, u_int *size) { if (SCM_UVECTORP(msg)) { *size = Scm_UVectorSizeInBytes(SCM_UVECTOR(msg)); return (const char*)SCM_UVECTOR_ELEMENTS(msg); } else if (SCM_STRINGP(msg)) { return Scm_GetStringContent(SCM_STRING(msg), size, NULL, NULL); } else { Scm_TypeError("socket message", "uniform vector or string", msg); *size = 0; /* dummy */ return NULL; } }
static const uint8_t* get_message_body(ScmObj msg, u_int *size) { if (SCM_UVECTORP(msg)) { *size = Scm_UVectorSizeInBytes(SCM_UVECTOR(msg)); return (const uint8_t*) SCM_UVECTOR_ELEMENTS(msg); } else if (SCM_STRINGP(msg)) { return (const uint8_t*)Scm_GetStringContent(SCM_STRING(msg), size, 0, 0); } else { Scm_TypeError("TLS message", "uniform vector or string", msg); *size = 0; return 0; } }