libdsm  0.0.4-11-g223c1ba
Minimalist and read-only SMB client lib
 All Data Structures Files Functions Typedefs Enumerator Macros
Functions
smb_file.h File Reference

File operations. More...

#include "bdsm/smb_session.h"

Functions

smb_fd smb_fopen (smb_session *s, smb_tid tid, const char *path, uint32_t mod)
 Open a file on a share. More...
 
void smb_fclose (smb_session *s, smb_fd fd)
 Close an open file. More...
 
ssize_t smb_fread (smb_session *s, smb_fd fd, void *buf, size_t buf_size)
 Read from an open file. More...
 
ssize_t smb_fseek (smb_session *s, smb_fd fd, ssize_t offset, int whence)
 Sets/Moves/Get the read pointer for a given file. More...
 

Detailed Description

File operations.

Function Documentation

void smb_fclose ( smb_session s,
smb_fd  fd 
)

Close an open file.

The smb_fd is invalidated and MUST not be use it anymore. You can give it the 0 value.

Parameters
sThe session object
fdThe SMB file descriptor
smb_fd smb_fopen ( smb_session s,
smb_tid  tid,
const char *  path,
uint32_t  mod 
)

Open a file on a share.

Use this function to obtain an smb_fd, necesary for file operations

Parameters
sThe session object
tidThe tid of the share the file is in, obtained via smb_tree_connect()
pathThe path of the file to open
modThe access modes requested (example: SMB_MOD_RO)
Returns
A smb file description that can be use for further file operations or 0 in case of error
See also
smb_tree_connect
ssize_t smb_fread ( smb_session s,
smb_fd  fd,
void *  buf,
size_t  buf_size 
)

Read from an open file.

The semantics is basically the same that the unix read() one. At most 'buf_size' bytes are read from the current seek offset and copied into the memory pointed by 'buf' from the open file represented by the smb file descriptor 'fd'.

Parameters
[in]sThe session object
[in]fd[description]
[out]buf[description]
[in]buf_size[description]
Returns
The number of bytes read or -1 in case of error.
ssize_t smb_fseek ( smb_session s,
smb_fd  fd,
ssize_t  offset,
int  whence 
)

Sets/Moves/Get the read pointer for a given file.

The behavior of this function is the same as the Unix fseek() function, except the SEEK_END argument isn't supported.

This functions adjust the read the read pointer depending on the value of offset and whence.

  • If whence == SMB_SEEK_SET, the read pointer is set at 'offset'
  • If whence == SMB_SEEK_CUR, the read pointer is adjusted by 'offset'
Parameters
sThe session object
fdThe file descriptors for which the read pointer is to be adjusted
offsetSet/Adjust quantity
whenceWhich action to perform. Supported operations are SMB_SEEK_SET and SMB_SEEK_CUR
Returns
The current read pointer position