2000-12-26 08:57:10 +03:00
/*
Unix SMB / Netbios implementation .
Version 2.0
SMB client library API definitions
Copyright ( C ) Andrew Tridgell 1998
Copyright ( C ) Richard Sharpe 2000
Copyright ( C ) John Terpsra 2000
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# ifndef _SMBCLIENT_H
# define _SMBCLIENT_H
/* Make sure we have the following includes for now ... */
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
2001-01-05 16:43:19 +03:00
# define SMBC_MAX_NAME 1023
struct smbc_dirent {
uint smbc_type ; /* Type of entity, see below */
2001-01-07 10:10:50 +03:00
uint dirlen ; /* Convenience */
2001-01-05 16:43:19 +03:00
uint namelen ;
uint commentlen ;
char * comment ; /* Points to the comment futher down */
char name [ 1 ] ;
} ;
2001-01-07 10:10:50 +03:00
/*
* Entity types
*/
2001-01-05 16:43:19 +03:00
# define SMBC_WORKGROUP 1
# define SMBC_SERVER 2
# define SMBC_FILE_SHARE 3
# define SMBC_PRINTER_SHARE 4
# define SMBC_COMMS_SHARE 5
# define SMBC_IPC_SHARE 6
# define SMBC_DIR 7
# define SMBC_FILE 8
# define SMBC_LINK 9
2000-12-26 08:57:10 +03:00
# define SMBC_FILE_MODE (S_IFREG | 0444)
# define SMBC_DIR_MODE (S_IFDIR | 0555)
typedef void ( * smbc_get_auth_data_fn ) ( char * server , char * share ,
2001-01-12 08:10:45 +03:00
char * workgroup , int wgmaxlen ,
char * username , int unmaxlen ,
char * password , int pwmaxlen ) ;
2000-12-26 08:57:10 +03:00
/*
* Init the smbc package
*/
int smbc_init ( smbc_get_auth_data_fn fn , const char * workgroup , int debug ) ;
/*
* Open a file on an SMB server , this has the same form as normal open
* but the fname is a URL of the form smb : //server/share/path
*/
int smbc_open ( const char * fname , int flags , mode_t mode ) ;
/*
* Create a file on an SMB server , similar to smbc_open
*/
int smbc_creat ( const char * fname , mode_t mode ) ;
/*
* Read from a file , what about pread ?
*/
ssize_t smbc_read ( int fd , void * buf , size_t count ) ;
/*
* Write to a file , what about pwrite ?
*/
ssize_t smbc_write ( int fd , void * buf , size_t count ) ;
/*
* Close a file by fd
*/
int smbc_close ( int fd ) ;
/*
* Unlink a file on server , share , dir , file . . .
*/
int smbc_unlink ( const char * fname ) ;
/*
* rename oname to nname . . . probably need to be on the same
* server initially . Later can copy between servers . . .
*/
int smbc_rename ( const char * oname , const char * nname ) ;
/*
* Seek to a specific location in a file on an SMB server
*/
off_t smbc_lseek ( int fd , off_t offset , int whence ) ;
/*
* Stat a file to get info via file name
*/
int smbc_stat ( const char * fname , struct stat * st ) ;
/*
* Stat a file to get info via an fd
*/
int smbc_fstat ( int fd , struct stat * st ) ;
/*
* Chown a file
*/
2001-01-06 01:32:53 +03:00
int smbc_chown ( const char * fname , uid_t owner , gid_t group ) ;
2000-12-26 08:57:10 +03:00
/*
* Chmod a file
*/
int smbc_chmod ( const char * fname , mode_t newmode ) ;
/*
* Open a directory on a URL ( server and share and dir )
*/
int smbc_opendir ( const char * fname ) ;
/*
* Close a directory
*/
int smbc_closedir ( int fd ) ;
/*
* Get a directory entry
*/
2001-01-05 16:43:19 +03:00
int smbc_getdents ( unsigned int fd , struct smbc_dirent * dirp , int count ) ;
2000-12-26 08:57:10 +03:00
2001-01-12 08:10:45 +03:00
/*
* Read a dirent in the old way
*/
struct smbc_dirent * smbc_readdir ( unsigned int fd ) ;
2000-12-26 08:57:10 +03:00
/*
* Create a directory on a server , share , dir in fname URL
*/
int smbc_mkdir ( const char * fname , mode_t mode ) ;
2001-01-12 15:48:55 +03:00
/*
* Remove a directory on a server
*/
int smbc_rmdir ( const char * fname ) ;
/*
* Get the current directory offset
*/
off_t smbc_telldir ( int fd ) ;
2000-12-26 08:57:10 +03:00
/*
* lseek on directories , rewind by smbc_lseekdir ( fd , 0 , SEEK_SET )
*/
int smbc_lseekdir ( int fd , off_t offset , int whence ) ;
/*
* Must also provide print functions . . . soon
*/
# endif