]> arthur.barton.de Git - netatalk.git/commitdiff
code cleaning
authordidg <didg>
Sun, 29 Sep 2002 17:39:59 +0000 (17:39 +0000)
committerdidg <didg>
Sun, 29 Sep 2002 17:39:59 +0000 (17:39 +0000)
libatalk/adouble/ad_attr.c
libatalk/adouble/ad_flush.c

index d1a8af5b9cfba84b798678165880c8f0e2fac0e2..947ba9123e562a8866c6c856411fa8a5486572b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_attr.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: ad_attr.c,v 1.4 2002-09-29 17:39:59 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -17,9 +17,11 @@ int ad_getattr(const struct adouble *ad, u_int16_t *attr)
   if (ad->ad_version == AD_VERSION1)
     memcpy(attr, ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR,
           sizeof(u_int16_t));
+#if AD_VERSION == AD_VERSION2
   else if (ad->ad_version == AD_VERSION2)
     memcpy(attr, ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR,
           sizeof(u_int16_t));
+#endif
   else 
     return -1;
 
@@ -31,9 +33,11 @@ int ad_setattr(const struct adouble *ad, const u_int16_t attr)
   if (ad->ad_version == AD_VERSION1)
     memcpy(ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR, &attr,
           sizeof(attr));
+#if AD_VERSION == AD_VERSION2
   else if (ad->ad_version == AD_VERSION2)
     memcpy(ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, &attr,
           sizeof(attr));
+#endif
   else 
     return -1;
 
index 541c91591272a28f6b233883d3fc0872c4c4ef66..c5d1beb18efae47899db84131678368332d89840 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_flush.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: ad_flush.c,v 1.4 2002-09-29 17:39:59 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -49,6 +49,8 @@
 void ad_rebuild_header(struct adouble *ad)
 {
     u_int32_t          eid;
+    u_int32_t          temp;
+    
     u_int16_t          nent;
     char               *buf, *nentp;
 
@@ -56,15 +58,15 @@ void ad_rebuild_header(struct adouble *ad)
      * Rebuild any header information that might have changed.
      */
     buf = ad->ad_data;
-    ad->ad_magic = htonl( ad->ad_magic );
-    memcpy(buf, &ad->ad_magic, sizeof( ad->ad_magic ));
-    ad->ad_magic = ntohl( ad->ad_magic );
-    buf += sizeof( ad->ad_magic );
+
+    temp = htonl( ad->ad_magic );
+    memcpy(buf, &temp, sizeof( temp ));
+    buf += sizeof( temp );
     
-    ad->ad_version = htonl( ad->ad_version );
-    memcpy(buf, &ad->ad_version, sizeof( ad->ad_version ));
-    ad->ad_version = ntohl( ad->ad_version );
-    buf += sizeof( ad->ad_version );
+    temp = htonl( ad->ad_version );
+    memcpy(buf, &temp, sizeof( temp ));
+    buf += sizeof( temp );
+
     memcpy(buf, ad->ad_filler, sizeof( ad->ad_filler ));
     buf += sizeof( ad->ad_filler );
     
@@ -74,20 +76,17 @@ void ad_rebuild_header(struct adouble *ad)
       if ( ad->ad_eid[ eid ].ade_off == 0 ) {
        continue;
       }
-      eid = htonl( eid );
-      memcpy(buf, &eid, sizeof( eid ));
-      eid = ntohl( eid );
-      buf += sizeof( eid );
-      ad->ad_eid[ eid ].ade_off = htonl( ad->ad_eid[ eid ].ade_off );
-      memcpy(buf, &ad->ad_eid[ eid ].ade_off,
-            sizeof( ad->ad_eid[ eid ].ade_off ));
-      ad->ad_eid[ eid ].ade_off = ntohl( ad->ad_eid[ eid ].ade_off );
-      buf += sizeof( ad->ad_eid[ eid ].ade_off );
-      ad->ad_eid[ eid ].ade_len = htonl( ad->ad_eid[ eid ].ade_len );
-      memcpy(buf, &ad->ad_eid[ eid ].ade_len, 
-            sizeof( ad->ad_eid[ eid ].ade_len ));
-      ad->ad_eid[ eid ].ade_len = ntohl( ad->ad_eid[ eid ].ade_len );
-      buf += sizeof( ad->ad_eid[ eid ].ade_len );
+      temp = htonl( eid );
+      memcpy(buf, &temp, sizeof( temp ));
+      buf += sizeof( temp );
+
+      temp = htonl( ad->ad_eid[ eid ].ade_off );
+      memcpy(buf, &temp, sizeof( temp ));
+      buf += sizeof( temp );
+
+      temp = htonl( ad->ad_eid[ eid ].ade_len );
+      memcpy(buf, &temp, sizeof( temp ));
+      buf += sizeof( temp );
       nent++;
     }
     nent = htons( nent );