]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_attr.c
947ba9123e562a8866c6c856411fa8a5486572b1
[netatalk.git] / libatalk / adouble / ad_attr.c
1 /*
2  * $Id: ad_attr.c,v 1.4 2002-09-29 17:39:59 didg Exp $
3  */
4
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif /* HAVE_CONFIG_H */
8
9 #include <string.h>
10 #include <atalk/adouble.h>
11
12 #define FILEIOFF_ATTR 14
13 #define AFPFILEIOFF_ATTR 2
14
15 int ad_getattr(const struct adouble *ad, u_int16_t *attr)
16 {
17   if (ad->ad_version == AD_VERSION1)
18     memcpy(attr, ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR,
19            sizeof(u_int16_t));
20 #if AD_VERSION == AD_VERSION2
21   else if (ad->ad_version == AD_VERSION2)
22     memcpy(attr, ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR,
23            sizeof(u_int16_t));
24 #endif
25   else 
26     return -1;
27
28   return 0;
29 }
30
31 int ad_setattr(const struct adouble *ad, const u_int16_t attr)
32 {
33   if (ad->ad_version == AD_VERSION1)
34     memcpy(ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR, &attr,
35            sizeof(attr));
36 #if AD_VERSION == AD_VERSION2
37   else if (ad->ad_version == AD_VERSION2)
38     memcpy(ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, &attr,
39            sizeof(attr));
40 #endif
41   else 
42     return -1;
43
44   return 0;
45 }