]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/desktop.c
Make dot files visible by default with usedots, add invisibledots for the old behavio...
[netatalk.git] / etc / afpd / desktop.c
index 390909946f4d9be7eca8b1cbdc5229c40cc36836..dcefcc849b06dade8dddbfa5b763115df2a246be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.31 2005-04-28 20:49:41 bfernhomberg Exp $
+ * $Id: desktop.c,v 1.36 2006-09-19 01:35:45 didg Exp $
  *
  * See COPYRIGHT.
  *
@@ -315,6 +315,8 @@ static const u_char utag[] = { 0, 0, 0, 0 };
 static const u_char    ucreator[] = { 0, 0, 0, 0 };/* { 'U', 'N', 'I', 'X' };*/
 static const u_char    utype[] = { 0, 0, 0, 0 };/* { 'T', 'E', 'X', 'T' };*/
 static const short     usize = 256;
+
+#if 0
 static const u_char    uicon[] = {
     0x1F, 0xFF, 0xFC, 0x00, 0x10, 0x00, 0x06, 0x00,
     0x10, 0x00, 0x05, 0x00, 0x10, 0x00, 0x04, 0x80,
@@ -349,6 +351,7 @@ static const u_char uicon[] = {
     0x1F, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0xF0,
     0x1F, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0xF0,
 };
+#endif
 
 int afp_geticoninfo(obj, ibuf, ibuflen, rbuf, rbuflen )
 AFPObj  *obj _U_;
@@ -454,6 +457,7 @@ int ibuflen _U_, *rbuflen;
     memcpy( &bsize, ibuf, sizeof( bsize ));
     bsize = ntohs( bsize );
 
+#if 0
     if ( memcmp( fcreator, ucreator, sizeof( ucreator )) == 0 &&
             memcmp( ftype, utype, sizeof( utype )) == 0 &&
             itype == 1 &&
@@ -462,6 +466,7 @@ int ibuflen _U_, *rbuflen;
         *rbuflen = bsize;
         return( AFP_OK );
     }
+#endif
 
     if ( iconopen( vol, fcreator, O_RDONLY, 0 ) < 0) {
         return( AFPERR_NOITEM );
@@ -616,7 +621,7 @@ char *dtfile(const struct vol *vol, u_char creator[], char *ext )
 
 char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8)
 {
-    static char  upath[ MAXPATHLEN + 1];
+    static char  upath[ MAXPATHLEN + 2]; /* for convert_charset dest_len parameter +2 */
     char       *m, *u;
     size_t       inplen;
     size_t       outlen;
@@ -656,7 +661,6 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8)
         LOG(log_error, logtype_afpd, "conversion from %s to %s for %s failed.", (utf8)?"UTF8-MAC":vol->v_maccodepage, vol->v_volcodepage, mpath);
            return NULL;
     }
-    upath[outlen] = 0;
 
 #ifdef DEBUG
     LOG(log_debug, logtype_afpd, "mtoupath: '%s':'%s'", mpath, upath);
@@ -669,7 +673,7 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8)
 */
 char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8)
 {
-    static char  mpath[ MAXPATHLEN + 1];
+    static char  mpath[ MAXPATHLEN + 2]; /* for convert_charset dest_len parameter +2 */
     char        *m, *u;
     u_int16_t    flags = CONV_IGNORE | CONV_UNESCAPEHEX;
     size_t       outlen;
@@ -694,7 +698,6 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8)
        goto utompath_error;
     }
 
-    mpath[outlen] = 0; 
     if (!(flags & CONV_REQMANGLE)) 
         flags = 0;
     else
@@ -740,9 +743,7 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf)
     } else
         adp = of->of_ad;
 
-    if (ad_open( upath , vol_noadouble(vol) |
-                 (( isadir) ? ADFLAGS_HF|ADFLAGS_DIR : ADFLAGS_HF),
-                 O_RDWR|O_CREAT, 0666, adp) < 0 ) {
+    if (ad_open_metadata( upath , vol_noadouble(vol) | ( (isadir) ? ADFLAGS_DIR :0),O_CREAT, adp) < 0 ) {
         return( AFPERR_ACCESS );
     }
 
@@ -757,9 +758,9 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf)
         }
         ad_setentrylen( adp, ADEID_COMMENT, clen );
         memcpy( ad_entry( adp, ADEID_COMMENT ), ibuf, clen );
-        ad_flush( adp, ADFLAGS_HF );
+        ad_flush_metadata( adp );
     }
-    ad_close( adp, ADFLAGS_HF );
+    ad_close_metadata( adp);
     return( AFP_OK );
 }
 
@@ -808,7 +809,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
     struct ofork        *of;
     char               *upath;
     int                 isadir;
-
+    int                        clen;
 
     upath = path->u_name;
     isadir = path_isadir(path);
@@ -823,6 +824,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
     }
 
     if (!ad_getentryoff(adp, ADEID_COMMENT)) {
+        ad_close_metadata( adp );
         return AFPERR_NOITEM;
     }
     /*
@@ -830,15 +832,15 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
      */
     if ( ad_getentrylen( adp, ADEID_COMMENT ) <= 0 ||
             ad_getentrylen( adp, ADEID_COMMENT ) > 199 ) {
-        ad_close( adp, ADFLAGS_HF );
+        ad_close_metadata( adp );
         return( AFPERR_NOITEM );
     }
 
-    *rbuf++ = ad_getentrylen( adp, ADEID_COMMENT );
-    memcpy( rbuf, ad_entry( adp, ADEID_COMMENT ),
-            ad_getentrylen( adp, ADEID_COMMENT ));
-    *rbuflen = ad_getentrylen( adp, ADEID_COMMENT ) + 1;
-    ad_close( adp, ADFLAGS_HF );
+    clen = min( ad_getentrylen( adp, ADEID_COMMENT ), 128 ); /* OSX only use 128, greater kill Adobe CS2 */
+    *rbuf++ = clen;
+    memcpy( rbuf, ad_entry( adp, ADEID_COMMENT ), clen);
+    *rbuflen = clen + 1;
+    ad_close_metadata( adp);
 
     return( AFP_OK );
 }
@@ -897,9 +899,7 @@ static int ad_rmvcomment(struct vol *vol, struct path *path)
     } else
         adp = of->of_ad;
 
-    if ( ad_open( upath,
-                   (isadir) ? ADFLAGS_HF|ADFLAGS_DIR : ADFLAGS_HF,
-                  O_RDWR, 0, adp) < 0 ) {
+    if ( ad_open_metadata( upath, (isadir) ? ADFLAGS_DIR : 0, 0, adp) < 0 ) {
         switch ( errno ) {
         case ENOENT :
             return( AFPERR_NOITEM );
@@ -912,9 +912,9 @@ static int ad_rmvcomment(struct vol *vol, struct path *path)
 
     if (ad_getentryoff(adp, ADEID_COMMENT)) {
         ad_setentrylen( adp, ADEID_COMMENT, 0 );
-        ad_flush( adp, ADFLAGS_HF );
+        ad_flush_metadata( adp );
     }
-    ad_close( adp, ADFLAGS_HF );
+    ad_close_metadata( adp);
     return( AFP_OK );
 }