Lines Matching refs:buf

62 trim_nuls(const unsigned char *buf, size_t nbytes)  in trim_nuls()  argument
64 while (nbytes > 1 && buf[nbytes - 1] == '\0') in trim_nuls()
71 file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes, in file_ascmagic() argument
85 nbytes = trim_nuls(buf, nbytes); in file_ascmagic()
88 if (file_encoding(ms, buf, nbytes, &ubuf, &ulen, &code, &code_mime, in file_ascmagic()
92 rv = file_ascmagic_with_encoding(ms, buf, nbytes, ubuf, ulen, code, in file_ascmagic()
101 file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf, in file_ascmagic_with_encoding() argument
129 nbytes = trim_nuls(buf, nbytes); in file_ascmagic_with_encoding()
312 encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen) in encode_utf8() argument
315 unsigned char *end = buf + len; in encode_utf8()
319 if (end - buf < 1) in encode_utf8()
321 *buf++ = (unsigned char)ubuf[i]; in encode_utf8()
323 if (end - buf < 2) in encode_utf8()
325 *buf++ = (unsigned char)((ubuf[i] >> 6) + 0xc0); in encode_utf8()
326 *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80); in encode_utf8()
328 if (end - buf < 3) in encode_utf8()
330 *buf++ = (unsigned char)((ubuf[i] >> 12) + 0xe0); in encode_utf8()
331 *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80); in encode_utf8()
332 *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80); in encode_utf8()
334 if (end - buf < 4) in encode_utf8()
336 *buf++ = (unsigned char)((ubuf[i] >> 18) + 0xf0); in encode_utf8()
337 *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80); in encode_utf8()
338 *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80); in encode_utf8()
339 *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80); in encode_utf8()
341 if (end - buf < 5) in encode_utf8()
343 *buf++ = (unsigned char)((ubuf[i] >> 24) + 0xf8); in encode_utf8()
344 *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80); in encode_utf8()
345 *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80); in encode_utf8()
346 *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80); in encode_utf8()
347 *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80); in encode_utf8()
349 if (end - buf < 6) in encode_utf8()
351 *buf++ = (unsigned char)((ubuf[i] >> 30) + 0xfc); in encode_utf8()
352 *buf++ = (unsigned char)(((ubuf[i] >> 24) & 0x3f) + 0x80); in encode_utf8()
353 *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80); in encode_utf8()
354 *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80); in encode_utf8()
355 *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80); in encode_utf8()
356 *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80); in encode_utf8()
361 return buf; in encode_utf8()