]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_attr.c
massive commenting/autoconf changes
[netatalk.git] / libatalk / adouble / ad_attr.c
1 /*
2  * $Id: ad_attr.c,v 1.3 2001-06-29 14:14:46 rufustfirefly 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   else if (ad->ad_version == AD_VERSION2)
21     memcpy(attr, ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR,
22            sizeof(u_int16_t));
23   else 
24     return -1;
25
26   return 0;
27 }
28
29 int ad_setattr(const struct adouble *ad, const u_int16_t attr)
30 {
31   if (ad->ad_version == AD_VERSION1)
32     memcpy(ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR, &attr,
33            sizeof(attr));
34   else if (ad->ad_version == AD_VERSION2)
35     memcpy(ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, &attr,
36            sizeof(attr));
37   else 
38     return -1;
39
40   return 0;
41 }