FontFilePtr FontFileOpen (const char *name) { int fd; int len; BufFilePtr raw, cooked; fd = open (name, O_BINARY|O_CLOEXEC); if (fd < 0) return 0; raw = BufFileOpenRead (fd); if (!raw) { close (fd); return 0; } len = strlen (name); if (len > 2 && !strcmp (name + len - 2, ".Z")) { cooked = BufFilePushCompressed (raw); if (!cooked) { BufFileClose (raw, TRUE); return 0; } raw = cooked; #ifdef X_GZIP_FONT_COMPRESSION } else if (len > 3 && !strcmp (name + len - 3, ".gz")) { cooked = BufFilePushZIP (raw); if (!cooked) { BufFileClose (raw, TRUE); return 0; } raw = cooked; #endif #ifdef X_BZIP2_FONT_COMPRESSION } else if (len > 4 && !strcmp (name + len - 4, ".bz2")) { cooked = BufFilePushBZIP2 (raw); if (!cooked) { BufFileClose (raw, TRUE); return 0; } raw = cooked; #endif } return (FontFilePtr) raw; }
FontFilePtr FontFileOpenFd (int fd) { return (FontFilePtr) BufFileOpenRead (fd); }