-extern char *ad_path __P((char *, int));
-extern int ad_mode __P((char *, int));
-extern int ad_mkdir __P((char *, int));
-extern int ad_open __P((char *, int, int, int, struct adouble *));
-extern int ad_refresh __P((struct adouble *));
+extern int ad_setfuid __P((const uid_t ));
+extern uid_t ad_getfuid __P((void ));
+
+extern char *ad_dir __P((const char *));
+extern char *ad_path __P((const char *, int));
+extern char *ad_path_osx __P((const char *, int));
+extern char *ad_path_ads __P((const char *, int));
+extern char *ad_path_sfm __P((const char *, int));
+
+extern int ad_mode __P((const char *, int));
+extern int ad_mkdir __P((const char *, int));
+extern void ad_init __P((struct adouble *, int, int ));
+
+extern int ad_open __P((const char *, int, int, int, struct adouble *));
+extern int ad_refresh __P((struct adouble *));
+extern int ad_stat __P((const char *, struct stat *));
+extern int ad_metadata __P((const char *, int, struct adouble *));
+
+#define ad_open_metadata(name, flags, mode, adp)\
+ ad_open(name, ADFLAGS_MD|(flags), O_RDWR |(mode), 0666, (adp))
+
+#define ad_close_metadata(adp) ad_close( (adp), ADFLAGS_MD)
+
+/* build a resource fork mode from the data fork mode:
+ * remove X mode and extend header to RW if R or W (W if R for locking),
+ */
+#ifndef ATACC
+#ifndef __inline__
+#define __inline__
+#endif
+static __inline__ mode_t ad_hf_mode (mode_t mode)
+{
+ mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
+ /* fnctl lock need write access */
+ if ((mode & S_IRUSR))
+ mode |= S_IWUSR;
+ if ((mode & S_IRGRP))
+ mode |= S_IWGRP;
+ if ((mode & S_IROTH))
+ mode |= S_IWOTH;
+
+ /* if write mode set add read mode */
+ if ((mode & S_IWUSR))
+ mode |= S_IRUSR;
+ if ((mode & S_IWGRP))
+ mode |= S_IRGRP;
+ if ((mode & S_IWOTH))
+ mode |= S_IROTH;
+
+ return mode;
+}
+#else
+extern mode_t ad_hf_mode __P((mode_t ));
+#endif