*/
addicon_err:
if ( cc < 0 ) {
- if (obj->proto == AFPPROTO_DSI) {
- dsi_writeinit(obj->handle, rbuf, buflen);
- dsi_writeflush(obj->handle);
- }
+ dsi_writeinit(obj->dsi, rbuf, buflen);
+ dsi_writeflush(obj->dsi);
return cc;
}
- switch (obj->proto) {
- case AFPPROTO_DSI:
- {
- DSI *dsi = obj->handle;
+ DSI *dsi = obj->dsi;
- iovcnt = dsi_writeinit(dsi, rbuf, buflen);
+ iovcnt = dsi_writeinit(dsi, rbuf, buflen);
- /* add headers at end of file */
- if ((cc == 0) && (write(si.sdt_fd, imh, sizeof(imh)) < 0)) {
- LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
- dsi_writeflush(dsi);
- return AFPERR_PARAM;
- }
+ /* add headers at end of file */
+ if ((cc == 0) && (write(si.sdt_fd, imh, sizeof(imh)) < 0)) {
+ LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+ dsi_writeflush(dsi);
+ return AFPERR_PARAM;
+ }
- if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
- LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
- dsi_writeflush(dsi);
- return AFPERR_PARAM;
- }
+ if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
+ LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+ dsi_writeflush(dsi);
+ return AFPERR_PARAM;
+ }
- while ((iovcnt = dsi_write(dsi, rbuf, buflen))) {
- if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
- LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
- dsi_writeflush(dsi);
- return AFPERR_PARAM;
- }
- }
+ while ((iovcnt = dsi_write(dsi, rbuf, buflen))) {
+ if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
+ LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+ dsi_writeflush(dsi);
+ return AFPERR_PARAM;
}
- break;
}
close( si.sdt_fd );
#define min(a,b) ((a)<(b)?(a):(b))
rc = min( bsize, rsize );
- if ((obj->proto == AFPPROTO_DSI) && (buflen < rc)) {
- DSI *dsi = obj->handle;
+ if (buflen < rc) {
+ DSI *dsi = obj->dsi;
struct stat st;
off_t size;
isadir = path_isadir(path);
if (isadir || !(of = of_findname(path))) {
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
adp = &ad;
} else
adp = of->of_ad;
if (ad_open(adp, upath,
- ADFLAGS_HF | ( (isadir) ? ADFLAGS_DIR : 0),
- O_CREAT | O_RDWR,
+ ADFLAGS_HF | ( (isadir) ? ADFLAGS_DIR : 0) | ADFLAGS_CREATE | ADFLAGS_RDWR,
0666) < 0 ) {
return( AFPERR_ACCESS );
}
memcpy( ad_entry( adp, ADEID_COMMENT ), ibuf, clen );
ad_flush( adp );
}
- ad_close_metadata( adp);
+ ad_close(adp, ADFLAGS_HF);
return( AFP_OK );
}
upath = path->u_name;
isadir = path_isadir(path);
if (isadir || !(of = of_findname(path))) {
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
adp = &ad;
} else
adp = of->of_ad;
}
if (!ad_getentryoff(adp, ADEID_COMMENT)) {
- ad_close_metadata( adp );
+ ad_close(adp, ADFLAGS_HF);
return AFPERR_NOITEM;
}
/*
*/
if ( ad_getentrylen( adp, ADEID_COMMENT ) <= 0 ||
ad_getentrylen( adp, ADEID_COMMENT ) > 199 ) {
- ad_close_metadata( adp );
+ ad_close(adp, ADFLAGS_HF);
return( AFPERR_NOITEM );
}
*rbuf++ = clen;
memcpy( rbuf, ad_entry( adp, ADEID_COMMENT ), clen);
*rbuflen = clen + 1;
- ad_close_metadata( adp);
+ ad_close(adp, ADFLAGS_HF);
return( AFP_OK );
}
isadir = path_isadir(path);
if (isadir || !(of = of_findname(path))) {
- ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ ad_init(&ad, vol);
adp = &ad;
} else
adp = of->of_ad;
- if ( ad_open(adp, upath, ADFLAGS_HF | (isadir) ? ADFLAGS_DIR : 0, 0) < 0 ) {
+ if ( ad_open(adp, upath, ADFLAGS_HF | ADFLAGS_RDWR | ((isadir) ? ADFLAGS_DIR : 0)) < 0 ) {
switch ( errno ) {
case ENOENT :
return( AFPERR_NOITEM );
ad_setentrylen( adp, ADEID_COMMENT, 0 );
ad_flush( adp );
}
- ad_close_metadata( adp);
+ ad_close(adp, ADFLAGS_HF);
return( AFP_OK );
}