]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_size.c
Back-port from trunk: Don't link to -lcom_err, -lresolv, and -l?
[netatalk.git] / libatalk / adouble / ad_size.c
1 /*
2  * $Id: ad_size.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
3  *
4  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
5  * All rights reserved. See COPYRIGHT.
6  *
7  * if we could depend upon inline functions, this would be one.
8  */
9
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif /* HAVE_CONFIG_H */
13
14 #include <stdio.h>
15 #ifdef HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif /* HAVE_UNISTD_H */
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <syslog.h>
21
22 #include <atalk/adouble.h>
23
24 off_t ad_size(const struct adouble *ad, const u_int32_t eid)
25 {
26   if (eid == ADEID_DFORK) {
27     struct stat st;
28     
29     if (fstat(ad_dfileno(ad), &st) < 0)
30       return 0;
31     return st.st_size;
32   }  
33
34   return ad_getentrylen(ad, eid);
35