Lines Matching refs:buf

68 file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, unichar **ubuf, size_t…  in file_encoding()  argument
86 if (looks_ascii(buf, nbytes, *ubuf, ulen)) { in file_encoding()
90 } else if (looks_utf8_with_BOM(buf, nbytes, *ubuf, ulen) > 0) { in file_encoding()
94 } else if (file_looks_utf8(buf, nbytes, *ubuf, ulen) > 1) { in file_encoding()
99 } else if ((ucs_type = looks_ucs16(buf, nbytes, *ubuf, ulen)) != 0) { in file_encoding()
108 } else if (looks_latin1(buf, nbytes, *ubuf, ulen)) { in file_encoding()
112 } else if (looks_extended(buf, nbytes, *ubuf, ulen)) { in file_encoding()
117 from_ebcdic(buf, nbytes, nbuf); in file_encoding()
221 looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, in looks_ascii() argument
229 int t = text_chars[buf[i]]; in looks_ascii()
234 ubuf[(*ulen)++] = buf[i]; in looks_ascii()
241 looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) in looks_latin1() argument
248 int t = text_chars[buf[i]]; in looks_latin1()
253 ubuf[(*ulen)++] = buf[i]; in looks_latin1()
260 looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, in looks_extended() argument
268 int t = text_chars[buf[i]]; in looks_extended()
273 ubuf[(*ulen)++] = buf[i]; in looks_extended()
291 file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) in file_looks_utf8() argument
302 if ((buf[i] & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */ in file_looks_utf8()
308 if (text_chars[buf[i]] != T) in file_looks_utf8()
312 ubuf[(*ulen)++] = buf[i]; in file_looks_utf8()
313 } else if ((buf[i] & 0x40) == 0) { /* 10xxxxxx never 1st byte */ in file_looks_utf8()
318 if ((buf[i] & 0x20) == 0) { /* 110xxxxx */ in file_looks_utf8()
319 c = buf[i] & 0x1f; in file_looks_utf8()
321 } else if ((buf[i] & 0x10) == 0) { /* 1110xxxx */ in file_looks_utf8()
322 c = buf[i] & 0x0f; in file_looks_utf8()
324 } else if ((buf[i] & 0x08) == 0) { /* 11110xxx */ in file_looks_utf8()
325 c = buf[i] & 0x07; in file_looks_utf8()
327 } else if ((buf[i] & 0x04) == 0) { /* 111110xx */ in file_looks_utf8()
328 c = buf[i] & 0x03; in file_looks_utf8()
330 } else if ((buf[i] & 0x02) == 0) { /* 1111110x */ in file_looks_utf8()
331 c = buf[i] & 0x01; in file_looks_utf8()
341 if ((buf[i] & 0x80) == 0 || (buf[i] & 0x40)) in file_looks_utf8()
344 c = (c << 6) + (buf[i] & 0x3f); in file_looks_utf8()
362 looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, in looks_utf8_with_BOM() argument
365 if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) in looks_utf8_with_BOM()
366 return file_looks_utf8(buf + 3, nbytes - 3, ubuf, ulen); in looks_utf8_with_BOM()
372 looks_ucs16(const unsigned char *buf, size_t nbytes, unichar *ubuf, in looks_ucs16() argument
381 if (buf[0] == 0xff && buf[1] == 0xfe) in looks_ucs16()
383 else if (buf[0] == 0xfe && buf[1] == 0xff) in looks_ucs16()
394 ubuf[(*ulen)++] = buf[i + 1] + 256 * buf[i]; in looks_ucs16()
396 ubuf[(*ulen)++] = buf[i] + 256 * buf[i + 1]; in looks_ucs16()
493 from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out) in from_ebcdic() argument
498 out[i] = ebcdic_to_ascii[buf[i]]; in from_ebcdic()