]> arthur.barton.de Git - netatalk.git/commitdiff
backport from HEAD
authordidg <didg>
Sat, 10 May 2003 10:33:16 +0000 (10:33 +0000)
committerdidg <didg>
Sat, 10 May 2003 10:33:16 +0000 (10:33 +0000)
etc/afpd/appl.c
etc/afpd/auth.c
etc/afpd/catsearch.c
etc/afpd/desktop.c
etc/afpd/directory.c
etc/afpd/directory.h
etc/afpd/filedir.c
macros/iconv.m4

index c17ce29fec6df3fbb0805b795353dce8c9b99e16..c3a00189119b557d02f6dd6cee8e2d752c50e160 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: appl.c,v 1.12 2003-03-15 01:34:35 didg Exp $
+ * $Id: appl.c,v 1.12.2.1 2003-05-10 10:33:16 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -187,7 +187,7 @@ int         ibuflen, *rbuflen;
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
-    if (( dir = dirlookup( vol, did )) == NULL ) {
+    if (NULL == ( dir = dirlookup( vol, did )) ) {
         return afp_errno;
     }
 
@@ -197,7 +197,7 @@ int         ibuflen, *rbuflen;
     memcpy( appltag, ibuf, sizeof( appltag ));
     ibuf += sizeof( appltag );
 
-    if (( path = cname( vol, dir, &ibuf )) == NULL ) {
+    if (NULL == ( path = cname( vol, dir, &ibuf )) ) {
         return get_afp_errno(AFPERR_PARAM);
     }
     if ( path_isadir(path) ) {
@@ -273,14 +273,14 @@ int               ibuflen, *rbuflen;
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( did );
-    if (( dir = dirlookup( vol, did )) == NULL ) {
+    if (NULL == ( dir = dirlookup( vol, did )) ) {
         return afp_errno;
     }
 
     memcpy( creator, ibuf, sizeof( creator ));
     ibuf += sizeof( creator );
 
-    if (( path = cname( vol, dir, &ibuf )) == NULL ) {
+    if (NULL == ( path = cname( vol, dir, &ibuf )) ) {
         return get_afp_errno(AFPERR_PARAM);
     }
     if ( path_isadir(path) ) {
index 5ef217b0b5dcf283540b2c33c69b60ba13d98021..14eeb0c56c64589d9eb7739da0b2a4d1d76f9349 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.44 2003-04-16 22:45:10 samnoble Exp $
+ * $Id: auth.c,v 1.44.2.1 2003-05-10 10:33:16 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -305,7 +305,7 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void))
        uam_afpserver_action(AFP_BYTELOCK_EXT,  UAM_AFPSERVER_POSTAUTH, afp_bytelock_ext, NULL); 
         /* catsearch_ext uses the same packet as catsearch FIXME double check this, it wasn't true for enue
            enumerate_ext */
-       uam_afpserver_action(AFP_CATSEARCH_EXT, UAM_AFPSERVER_POSTAUTH, afp_catsearch, NULL); 
+       uam_afpserver_action(AFP_CATSEARCH_EXT, UAM_AFPSERVER_POSTAUTH, afp_catsearch_ext, NULL); 
        uam_afpserver_action(AFP_GETSESSTOKEN,  UAM_AFPSERVER_POSTAUTH, afp_getsession, NULL); 
        uam_afpserver_action(AFP_READ_EXT,      UAM_AFPSERVER_POSTAUTH, afp_read_ext, NULL); 
        uam_afpserver_action(AFP_WRITE_EXT,     UAM_AFPSERVER_POSTAUTH, afp_write_ext, NULL); 
index 737589e001e20de6e0bf6ab7563b2094e3711030..6432ed5bd2e47c94a41bcb4e72f0ae9f5f220ac2 100644 (file)
@@ -31,6 +31,8 @@
 #include <syslog.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <string.h>
+#include <time.h>
 
 #if STDC_HEADERS
 #include <string.h>
@@ -49,6 +51,7 @@
 #include <netatalk/endian.h>
 #include <atalk/afp.h>
 #include <atalk/adouble.h>
+#include <atalk/logger.h>
 #ifdef CNID_DB
 #include <atalk/cnid.h>
 #endif /* CNID_DB */
@@ -97,6 +100,7 @@ struct scrit {
         u_int16_t offcnt;           /* Offspring count */
        struct finderinfo finfo;    /* Finder info */
        char lname[32];             /* Long name */
+       char utf8name[256];         /* UTF8 name */
 };
 
 /*
@@ -297,6 +301,16 @@ static int crit_check(struct vol *vol, struct path *path, int cidx) {
                        if (strcasecmp(path->u_name, c1.lname) != 0)
                                goto crit_check_ret;
        } /* if (c1.rbitmap & ... */
+       
+       if ((c1.rbitmap & (1<<FILPBIT_PDINFO))) { 
+               if (c1.rbitmap & (1<<CATPBIT_PARTIAL)) {
+                       if (strcasestr(path->u_name, c1.utf8name) == NULL)
+                               goto crit_check_ret;
+               } else
+                       if (strcasecmp(path->u_name, c1.utf8name) != 0)
+                               goto crit_check_ret;
+       } /* if (c1.rbitmap & ... */
+
 
 
        /* FIXME */
@@ -436,6 +450,57 @@ static int rslt_add(struct vol *vol, char *fname, short cidx, int isdir, char **
        return 1;
 } /* rslt_add */
 
+static int rslt_add_ext ( struct vol *vol, struct path *path, char **buf, short cidx)
+{
+
+       char            *p = *buf;
+       int             ret, tbuf =0;
+       u_int16_t       resultsize;
+       int             isdir = S_ISDIR(path->st.st_mode); 
+
+       if (dstack[cidx].dir == NULL && resolve_dir(vol, cidx) == 0)
+               return 0;
+
+       p += sizeof(resultsize); /* Skip resultsize */
+       *p++ = isdir ? FILDIRBIT_ISDIR : FILDIRBIT_ISFILE;    /* IsDir ? */
+       *p++ = 0;                  /* Pad */
+       
+       if ( isdir )
+       {
+               struct dir* dir = NULL;
+
+               dir = dirsearch_byname(dstack[cidx].dir, path->u_name);
+               if (!dir) {
+                       if ((dir = adddir( vol, dstack[cidx].dir, path)) == NULL) {
+                               return 0;
+                       }
+               }
+               ret = getdirparams(vol, c1.dbitmap, path, dir, p , &tbuf ); 
+       }
+       else
+       {
+               ret = getfilparams ( vol, c1.fbitmap, path, dstack[cidx].dir, p, &tbuf);
+       }
+
+       if ( ret != AFP_OK )
+               return 0;
+
+       /* Make sure entry length is even */
+       if (tbuf & 1) {
+          *p++ = 0;
+          tbuf++;
+       }
+
+       resultsize = htons(tbuf);
+       memcpy ( *buf, &resultsize, sizeof(resultsize) );
+       
+       *buf += tbuf + 4;
+
+       return 1;
+} /* rslr_add_ext */
+       
+       
+
 #define VETO_STR \
         "./../.AppleDouble/.AppleDB/Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/.AppleDesktop/.Parent/"
 
@@ -450,7 +515,7 @@ static int rslt_add(struct vol *vol, char *fname, short cidx, int isdir, char **
  */
 #define NUM_ROUNDS 100
 static int catsearch(struct vol *vol, struct dir *dir,  
-                    int rmatches, int *pos, char *rbuf, u_int32_t *nrecs, int *rsize)
+                    int rmatches, int *pos, char *rbuf, u_int32_t *nrecs, int *rsize, int ext)
 {
        int cidx, r;
        char *fname = NULL;
@@ -558,12 +623,19 @@ static int catsearch(struct vol *vol, struct dir *dir,
 
                        /* bit 0 means that criteria has been met */
                        if (ccr & 1) {
-                               r = rslt_add(vol,  
-                                            (c1.fbitmap&(1<<FILPBIT_LNAME))|(c1.dbitmap&(1<<DIRPBIT_LNAME)) ? 
-                                                fname : NULL,  
-                                            (c1.fbitmap&(1<<FILPBIT_PDID))|(c1.dbitmap&(1<<DIRPBIT_PDID)) ? 
-                                                cidx : -1, 
-                                            S_ISDIR(path.st.st_mode), &rrbuf); 
+                               if ( ext ) { 
+                                       r = rslt_add_ext ( vol, &path, &rrbuf, cidx);
+                               }
+                               else
+                               {
+                                       r = rslt_add(vol,  
+                                                    (c1.fbitmap&(1<<FILPBIT_LNAME))|(c1.dbitmap&(1<<DIRPBIT_LNAME)) ? 
+                                                        fname : NULL,  
+                                                    (c1.fbitmap&(1<<FILPBIT_PDID))|(c1.dbitmap&(1<<DIRPBIT_PDID)) ? 
+                                                        cidx : -1, 
+                                                    S_ISDIR(path.st.st_mode), &rrbuf); 
+                               }
+                               
                                if (r == 0) {
                                        result = AFPERR_MISC;
                                        goto catsearch_end;
@@ -607,9 +679,8 @@ catsearch_end: /* Exiting catsearch: error condition */
        return result;
 } /* catsearch() */
 
-
-int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen,
-                  char *rbuf, int *rbuflen)
+int catsearch_afp(AFPObj *obj, char *ibuf, int ibuflen,
+                  char *rbuf, int *rbuflen, int ext)
 {
     struct vol *vol;
     u_int16_t   vid;
@@ -658,12 +729,23 @@ int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen,
            return AFPERR_BITMAP;
     }
 
+    if ( ext)
+           ibuf++;
+
     /* Parse file specifications */
     spec1 = ibuf;
     spec2 = ibuf + ibuf[0] + 2;
-
-    spec1 += 2; bspec1 = spec1;
-    spec2 += 2; bspec2 = spec2;
+    
+    if (ext)
+    {
+       spec1++; bspec1 = spec1;
+       spec2++; bspec2 = spec2;
+    }
+    else
+    {
+       spec1 += 2; bspec1 = spec1;
+       spec2 += 2; bspec2 = spec2;
+    }
 
     /* File attribute bits... */
     if (c1.rbitmap & (1 << FILPBIT_ATTR)) {
@@ -757,11 +839,35 @@ int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen,
                c2.lname[i] = tolower(c2.lname[i]);
 #endif
     }
-
-
+        /* UTF8 Name */
+    if (c1.rbitmap & (1 << FILPBIT_PDINFO)) {
+       char *          tmppath;
+       u_int16_t       namelen;
+
+       /* offset */
+       memcpy(&namelen, spec1, sizeof(namelen));
+       namelen = ntohs (namelen);
+
+       spec1 = bspec1+namelen+4; /* Skip Unicode Hint */
+
+       /* length */
+       memcpy(&namelen, spec1, sizeof(namelen));
+       namelen = ntohs (namelen);
+       if (namelen > 255)  /* Safeguard */
+               namelen = 255;
+
+       memcpy (c1.utf8name, spec1+2, namelen);
+       c1.utf8name[(namelen+1)] =0;
+
+       /* convert charset */   
+       tmppath = mtoupath(vol, c1.utf8name, 1);
+       memset (c1.utf8name, 0, 256);
+       memcpy (c1.utf8name, tmppath, MIN(strlen(tmppath), 255));
+    }
+    
     /* Call search */
     *rbuflen = 24;
-    ret = catsearch(vol, vol->v_dir, rmatches, &catpos[0], rbuf+24, &nrecs, &rsize);
+    ret = catsearch(vol, vol->v_dir, rmatches, &catpos[0], rbuf+24, &nrecs, &rsize, ext);
     memcpy(rbuf, catpos, sizeof(catpos));
     rbuf += sizeof(catpos);
 
@@ -779,7 +885,20 @@ int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen,
     *rbuflen += rsize;
 
     return ret;
-} /* afp_catsearch */
+} /* catsearch_afp */
+
+int afp_catsearch (AFPObj *obj, char *ibuf, int ibuflen,
+                  char *rbuf, int *rbuflen)
+{
+       return catsearch_afp( obj, ibuf, ibuflen, rbuf, rbuflen, 0);
+}
+
+
+int afp_catsearch_ext (AFPObj *obj, char *ibuf, int ibuflen,
+                  char *rbuf, int *rbuflen)
+{
+       return catsearch_afp( obj, ibuf, ibuflen, rbuf, rbuflen, 1);
+}
 
 /* FIXME: we need a clean separation between afp stubs and 'real' implementation */
 /* (so, all buffer packing/unpacking should be done in stub, everything else 
index 59a7ba8c1d685d7b645bb8cff2ce77a10ce73b81..01852083f696d5db24cfc09e120b423af3158488 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.26 2003-04-09 06:05:24 didg Exp $
+ * $Id: desktop.c,v 1.26.2.1 2003-05-10 10:33:16 didg Exp $
  *
  * See COPYRIGHT.
  *
@@ -151,7 +151,7 @@ int         ibuflen, *rbuflen;
 
     memcpy( &vid, ibuf, sizeof( vid ));
     ibuf += sizeof( vid );
-    if (( vol = getvolbyvid( vid )) == NULL ) {
+    if (NULL == ( vol = getvolbyvid( vid )) ) {
         cc = AFPERR_PARAM;
         goto addicon_err;
     }
index 9c2fdca4d86df5f779c2e481d74ddfd05266a9a4..9bb902875a63482dc8ddd1e7eeab87f5b341bb0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.71 2003-04-24 17:05:38 didg Exp $
+ * $Id: directory.c,v 1.71.2.1 2003-05-10 10:33:16 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -2135,7 +2135,7 @@ int               ibuflen, *rbuflen;
 
         case 2 :
         case 4 : /* unicode */
-            if (( gr = (struct group *)getgrgid( id )) == NULL ) {
+            if (NULL == ( gr = (struct group *)getgrgid( id ))) {
                 return( AFPERR_NOITEM );
             }
             name = gr->gr_name;
@@ -2205,7 +2205,7 @@ int               ibuflen, *rbuflen;
         switch ( sfunc ) {
         case 1 : /* unicode */
         case 3 :
-            if (( pw = (struct passwd *)getpwnam( ibuf )) == NULL ) {
+            if (NULL == ( pw = (struct passwd *)getpwnam( ibuf )) ) {
                 return( AFPERR_NOITEM );
             }
             id = pw->pw_uid;
@@ -2213,7 +2213,7 @@ int               ibuflen, *rbuflen;
 
         case 2 : /* unicode */
         case 4 :
-            if (( gr = (struct group *)getgrnam( ibuf )) == NULL ) {
+            if (NULL == ( gr = (struct group *)getgrnam( ibuf ))) {
                 return( AFPERR_NOITEM );
             }
             id = gr->gr_gid;
index 8846f975fe305565496a76d004379d937179ebe1..407264e5fdfbcaf550b161011a4a7c2269517cd3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.h,v 1.13.2.1 2003-04-28 10:12:53 didg Exp $
+ * $Id: directory.h,v 1.13.2.2 2003-05-10 10:33:16 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -230,6 +230,9 @@ extern int  afp_mapname __P((AFPObj *, char *, int, char *, int *));
 extern int     afp_enumerate __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
 extern int     afp_enumerate_ext __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
 extern int     afp_enumerate_ext2 __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
+
+/* from catsearch.c */
 extern int     afp_catsearch __P((AFPObj *, char *, int, char *, int *));
+extern int     afp_catsearch_ext __P((AFPObj *, char *, int, char *, int *));
 
 #endif
index d2400262db06a3ce4ea8d83e913b9bfcef1b6036..4917d42fb5ae61bcfde72646be7ad277ab25747c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45 2003-04-20 06:53:40 didg Exp $
+ * $Id: filedir.c,v 1.45.2.1 2003-05-10 10:33:16 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -718,7 +718,7 @@ int         ibuflen, *rbuflen;
     if (NULL == ( ddir = dirlookup( vol, did )) ) {
         return afp_errno; /*  was AFPERR_PARAM */
     }
-    if (( path = cname( vol, ddir, &ibuf )) == NULL ) {
+    if (NULL == ( path = cname( vol, ddir, &ibuf ))) {
         return( AFPERR_NOOBJ );
     }
     if ( *path->m_name != '\0' ) {
index 82f7aac4385a7370a6125a68250727f129cbd6f6..738c60de026258ebab7935a2cf31a199f0ae22c4 100644 (file)
@@ -17,7 +17,7 @@ dnl   # check for libiconv support
            CFLAGS="$CFLAGS -I$withval/include"
            LDFLAGS="$LDFLAGS -L$withval/lib"
            AC_CHECK_LIB(iconv, iconv_open, [
-                                if test "$withval" != "/usr" && "$withval" != ""; then
+                                if test "$withval" != "/usr" && test "$withval" != ""; then
                                     ICONV_CFLAGS="-I$withval/include"
                                     ICONV_LIBS ="-L$withval/lib"
                                 fi