/*
- * $Id: desktop.c,v 1.43 2009-10-25 09:47:03 didg Exp $
- *
* See COPYRIGHT.
*
* bug:
#include <ctype.h>
#include <errno.h>
-#include <dirent.h>
#include <atalk/adouble.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <sys/socket.h>
-#include <netatalk/at.h>
-#include <netatalk/endian.h>
+#include <arpa/inet.h>
+
#include <atalk/dsi.h>
-#include <atalk/atp.h>
-#include <atalk/asp.h>
#include <atalk/afp.h>
#include <atalk/util.h>
#include <atalk/logger.h>
+#include <atalk/globals.h>
#include "volume.h"
#include "directory.h"
#include "fork.h"
-#include "globals.h"
#include "desktop.h"
#include "mangle.h"
int afp_addicon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
{
struct vol *vol;
-#ifndef NO_DDP
- struct iovec iov[ 2 ];
-#endif
u_char fcreator[ 4 ], imh[ 12 ], irh[ 12 ], *p;
int itype, cc = AFP_OK, iovcnt = 0;
size_t buflen;
}
switch (obj->proto) {
-#ifndef NO_DDP
- case AFPPROTO_ASP:
- buflen = bsize;
- if ((asp_wrtcont(obj->handle, rbuf, &buflen) < 0) || buflen != bsize)
- return( AFPERR_PARAM );
-
-#ifdef DEBUG1
- if (obj->options.flags & OPTION_DEBUG) {
- printf("(write) len: %d\n", buflen);
- bprint(rbuf, buflen);
- }
-#endif
-
- /*
- * We're at the end of the file, add the headers, etc. */
- if ( cc == 0 ) {
- iov[ 0 ].iov_base = (caddr_t)imh;
- iov[ 0 ].iov_len = sizeof( imh );
- iov[ 1 ].iov_base = rbuf;
- iov[ 1 ].iov_len = bsize;
- iovcnt = 2;
- }
-
- /*
- * We found an icon to replace.
- */
- if ( cc > 0 ) {
- iov[ 0 ].iov_base = rbuf;
- iov[ 0 ].iov_len = bsize;
- iovcnt = 1;
- }
-
- if ( writev( si.sdt_fd, iov, iovcnt ) < 0 ) {
- LOG(log_error, logtype_afpd, "afp_addicon(%s): writev: %s", icon_dtfile(vol, fcreator), strerror(errno) );
- return( AFPERR_PARAM );
- }
- break;
-#endif /* no afp/asp */
case AFPPROTO_DSI:
{
DSI *dsi = obj->handle;
return AFP_OK;
geticon_exit:
- LOG(log_info, logtype_afpd, "afp_geticon(%s): %s", icon_dtfile(vol, fcreator), strerror(errno));
+ LOG(log_error, logtype_afpd, "afp_geticon(%s): %s", icon_dtfile(vol, fcreator), strerror(errno));
dsi_readdone(dsi);
obj->exit(EXITERR_SYS);
return AFP_OK;
char *m, *u;
size_t inplen;
size_t outlen;
- u_int16_t flags = 0;
+ u_int16_t flags;
if ( *mpath == '\0' ) {
- return( "." );
+ strcpy(upath, ".");
+ return upath;
}
/* set conversion flags */
- if (!(vol->v_flags & AFPVOL_NOHEX))
- flags |= CONV_ESCAPEHEX;
- if (!(vol->v_flags & AFPVOL_USEDOTS))
- flags |= CONV_ESCAPEDOTS;
-
- if ((vol->v_casefold & AFPVOL_MTOUUPPER))
- flags |= CONV_TOUPPER;
- else if ((vol->v_casefold & AFPVOL_MTOULOWER))
- flags |= CONV_TOLOWER;
-
- if ((vol->v_flags & AFPVOL_EILSEQ)) {
- flags |= CONV__EILSEQ;
- }
-
+ flags = vol->v_mtou_flags;
+
m = demangle(vol, mpath, did);
if (m != mpath) {
return m;
}
#ifdef DEBUG
- LOG(log_debug, logtype_afpd, "mtoupath: '%s':'%s'", mpath, upath);
+ LOG(log_debug9, logtype_afpd, "mtoupath: '%s':'%s'", mpath, upath);
#endif /* DEBUG */
return( upath );
}
{
static char mpath[ MAXPATHLEN + 2]; /* for convert_charset dest_len parameter +2 */
char *m, *u;
- u_int16_t flags = CONV_IGNORE | CONV_UNESCAPEHEX;
+ u_int16_t flags;
size_t outlen;
m = mpath;
outlen = strlen(upath);
- if ((vol->v_casefold & AFPVOL_UTOMUPPER))
- flags |= CONV_TOUPPER;
- else if ((vol->v_casefold & AFPVOL_UTOMLOWER))
- flags |= CONV_TOLOWER;
-
- if ((vol->v_flags & AFPVOL_EILSEQ)) {
- flags |= CONV__EILSEQ;
- }
+ flags = vol->v_utom_flags;
u = upath;
goto utompath_error;
}
- if (!(flags & CONV_REQMANGLE))
- flags = 0;
- else
- flags = 1;
+ flags = !!(flags & CONV_REQMANGLE);
if (utf8)
flags |= 2;
m = mangle(vol, mpath, outlen, upath, id, flags);
#ifdef DEBUG
- LOG(log_debug, logtype_afpd, "utompath: '%s':'%s':'%2.2X'", upath, m, ntohl(id));
+ LOG(log_debug9, logtype_afpd, "utompath: '%s':'%s':'%2.2X'", upath, m, ntohl(id));
#endif /* DEBUG */
return(m);
clen = min( clen, 199 );
upath = path->u_name;
- if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
+ if (check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
}
} else
adp = of->of_ad;
- if (ad_open_metadata( upath , vol_noadouble(vol) | ( (isadir) ? ADFLAGS_DIR :0),O_CREAT, adp) < 0 ) {
+ if (ad_open(adp, upath,
+ ADFLAGS_HF | ( (isadir) ? ADFLAGS_DIR : 0),
+ O_CREAT | O_RDWR,
+ 0666) < 0 ) {
return( AFPERR_ACCESS );
}
if (ad_getentryoff(adp, ADEID_COMMENT)) {
if ( (ad_get_MD_flags( adp ) & O_CREAT) ) {
if ( *path->m_name == '\0' ) {
- name = curdir->d_m_name;
+ name = (char *)curdir->d_m_name->data;
} else {
name = path->m_name;
}
} else
adp = of->of_ad;
- if ( ad_metadata( upath,( isadir) ? ADFLAGS_DIR : 0, adp) < 0 ) {
+ if ( ad_metadata( upath, ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
return( AFPERR_NOITEM );
}
char *upath;
upath = path->u_name;
- if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
+ if (check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
}
} else
adp = of->of_ad;
- if ( ad_open_metadata( upath, (isadir) ? ADFLAGS_DIR : 0, 0, adp) < 0 ) {
+ if ( ad_open(adp, upath, ADFLAGS_HF | (isadir) ? ADFLAGS_DIR : 0, 0) < 0 ) {
switch ( errno ) {
case ENOENT :
return( AFPERR_NOITEM );