~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to libatalk/adouble/ad_attr.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}