+#ifdef HAVE_XATTR
+ static char buf[1024];
+ int i;
+ ssize_t sz;
+
+ if((sz = getxattr(file, "user.ash-mime-type", buf, sizeof(buf) - 1)) > 0)
+ goto found;
+ if((sz = getxattr(file, "user.mime-type", buf, sizeof(buf) - 1)) > 0)
+ goto found;
+ if((sz = getxattr(file, "user.mime_type", buf, sizeof(buf) - 1)) > 0)
+ goto found;
+ if((sz = getxattr(file, "user.Content-Type", buf, sizeof(buf) - 1)) > 0)
+ goto found;
+ return(NULL);
+found:
+ for(i = 0; i < sz; i++) {
+ if((buf[sz] < 32) || (buf[sz] >= 128))
+ return(NULL);
+ }
+ buf[sz] = 0;
+ return(buf);
+#else
+ return(NULL);
+#endif