Ejemplo n.º 1
0
ssize_t
smbc_write(int fd,
           const void *buf,
           size_t bufsize)
{
	SMBCFILE * file = find_fd(fd);
        return smbc_getFunctionWrite(statcont)(statcont, file, buf, bufsize);
}
Ejemplo n.º 2
0
int SmbFs::fs_write(const char *, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
{
	QMutexLocker locker(&_mutex);
	size_t s;
	
	if((smbc_getFunctionLseek(_ctx))(_ctx, (SMBCFILE *)fi->fh, offset, SEEK_SET) == (off_t)-1)
		return(-errno);
	
	if((s = (smbc_getFunctionWrite(_ctx))(_ctx, (SMBCFILE *)fi->fh, (void *)buf,size)) < 0)
		return(-errno);
	
	return(s);
}
Ejemplo n.º 3
0
int
SMBC_print_file_ctx(SMBCCTX *c_file,
                    const char *fname,
                    SMBCCTX *c_print,
                    const char *printq)
{
        SMBCFILE *fid1;
        SMBCFILE *fid2;
        int bytes;
        int saverr;
        int tot_bytes = 0;
        char buf[4096];
	TALLOC_CTX *frame = talloc_stackframe();
        
        if (!c_file || !c_file->internal->initialized ||
            !c_print || !c_print->internal->initialized) {
                
                errno = EINVAL;
		TALLOC_FREE(frame);
                return -1;
                
        }
        
        if (!fname && !printq) {
                
                errno = EINVAL;
		TALLOC_FREE(frame);
                return -1;
                
        }
        
        /* Try to open the file for reading ... */
        
        if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname,
                                                       O_RDONLY, 0666)) < 0) {
                DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno));
		TALLOC_FREE(frame);
                return -1;  /* smbc_open sets errno */
        }
        
        /* Now, try to open the printer file for writing */
        
        if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print,
                                                                printq)) < 0) {
                
                saverr = errno;  /* Save errno */
                smbc_getFunctionClose(c_file)(c_file, fid1);
                errno = saverr;
		TALLOC_FREE(frame);
                return -1;
                
        }
        
        while ((bytes = smbc_getFunctionRead(c_file)(c_file, fid1,
                                                     buf, sizeof(buf))) > 0) {
                
                tot_bytes += bytes;
                
                if ((smbc_getFunctionWrite(c_print)(c_print, fid2,
                                                    buf, bytes)) < 0) {
                        
                        saverr = errno;
                        smbc_getFunctionClose(c_file)(c_file, fid1);
                        smbc_getFunctionClose(c_print)(c_print, fid2);
                        errno = saverr;
                        
                }
                
        }
        
        saverr = errno;
        
        smbc_getFunctionClose(c_file)(c_file, fid1);
        smbc_getFunctionClose(c_print)(c_print, fid2);
        
        if (bytes < 0) {
                
                errno = saverr;
		TALLOC_FREE(frame);
                return -1;
                
        }
        
	TALLOC_FREE(frame);
        return tot_bytes;
        
}