Libiriver

Libiriver —

Synopsis


#include <iriver.h>


int         ifp_get_capacity                (usb_dev_handle *dh);
int         ifp_get_free                    (usb_dev_handle *dh);
int         ifp_upload_file                 (usb_dev_handle *dh,
                                             const char *name,
                                             const char *fn);
int         ifp_delete_file                 (usb_dev_handle *dh,
                                             const char *name);
int         ifp_empty_dir                   (usb_dev_handle *dh,
                                             const char *name);
int         ifp_delete_dir                  (usb_dev_handle *dh,
                                             const char *name);
int         ifp_make_dir                    (usb_dev_handle *dh,
                                             const char *name);
int         ifp_download_file               (usb_dev_handle *dh,
                                             const char *name,
                                             const char *fn);
int         ifp_battery_condition           (usb_dev_handle *dh);
float       ifp_firmware_version            (usb_dev_handle *dh);
int         ifp_init                        (usb_dev_handle **dh,
                                             int init_type);
void        ifp_release                     (usb_dev_handle *dh);
int         ifp_ls                          (usb_dev_handle *dh,
                                             const char *name,
                                             ifp_file_info **p);
int         ifp_firmware_update             (usb_dev_handle **dh,
                                             char *name);
int         ifp_format                      (usb_dev_handle *dh);
const char* ifp_error_to_string             (int error);
int         ifp_get_info                    (usb_dev_handle *dh,
                                             const char *name,
                                             ifp_file_info **p);
int         ifp_model_name                  (usb_dev_handle *dh,
                                             char *string);
void        ifp_free_file_list              (ifp_file_info **first);

Description

Details

ifp_get_capacity ()

int         ifp_get_capacity                (usb_dev_handle *dh);

dh : a usb_dev_handle
Returns : The total space of the iRiver expressed in bytes

ifp_get_free ()

int         ifp_get_free                    (usb_dev_handle *dh);

dh : a usb_dev_handle
Returns : The available space of the iRiver expressed in bytes

ifp_upload_file ()

int         ifp_upload_file                 (usb_dev_handle *dh,
                                             const char *name,
                                             const char *fn);

Uploads fn on the iRiver where it will be name

dh : a usb_dev_handle
name : name of the file on the iRiver
fn : nome of the local file to upload
Returns : IRIVER_OK if foo successful, IRIVER_NO_FREE_SPACE if there is not enough free space to upload the file, IRIVER_LOCAL_FILE_OPEN error if problems opening the local file occurred, IRIVER_CANNOT_SEND_FILENAME if there were problems communicating with the iRiver, IRIVER_DIRECTORY_EXISTS if name exists and is a directory, IRIVER_FILE_EXISTS if name exists and is a file.

ifp_delete_file ()

int         ifp_delete_file                 (usb_dev_handle *dh,
                                             const char *name);

Removes a file from the iRiver

dh : a usb_dev_handle
name : name of the file to be removed
Returns : IRIVER_OK if successful, IRIVER_FILE_NOT_FOUND if the file doesn't exist, IRIVER_CANNOT_SEND_FILE_NAME if there were problems communicating with the iRiver.

ifp_empty_dir ()

int         ifp_empty_dir                   (usb_dev_handle *dh,
                                             const char *name);

Checks to see if a directory is empty or not

dh : a usb_dev_handle
name : name of a directory
Returns : TRUE if empty, FALSE if not or IRIVER_DIRECTORY_NOT_FOUND if the dir is not found and IRIVER_CANNOT_SEND_FILENAM if there were problems communicating with the iRiver

ifp_delete_dir ()

int         ifp_delete_dir                  (usb_dev_handle *dh,
                                             const char *name);

Removes a directory. The directory must be empty

dh : a usb_dev_handle
name : name of the directory to be removed
Returns : IRIVER_OK if successful, IRIVER_DIRECTORY_NOT_FOUND if name is not found or is a regular file, IRIVER_DIRECTORY_NOT_EMPTY if the directory is not empty, IRIVER_CANNOT_SEND_FILENAME in case of other I/O problems.

ifp_make_dir ()

int         ifp_make_dir                    (usb_dev_handle *dh,
                                             const char *name);

Creates a directory on the iRiver

dh : a usb_dev_handle
name : name of the directory to be created
Returns : IRIVER_OK if successful, IRIVER_FILE_EXISTS or IRIVER_DIRECTORY_EXISTS if name exists and IRIVER_CANNOT_SEND_FILENAME if I/O problems occurred.

ifp_download_file ()

int         ifp_download_file               (usb_dev_handle *dh,
                                             const char *name,
                                             const char *fn);

Downloads a file (name) from the iRiver and stores it in fn.

dh : a usb_dev_handle
name : the file name on the iRiver do be downloaded
fn : the name of the local file to download to
Returns : IRIVER_OK if successful, IRIVER_LOCAL_FILE_OPEN_ERROR if errors happened opening or reading the local file, IRIVER_CANNOT_SEND_FILE_NAME if errors communicating with the iRiver happened, IRIVER_FILE_NOT_FOUND if name could not be found.

ifp_battery_condition ()

int         ifp_battery_condition           (usb_dev_handle *dh);

Checks the battery status of the iRiver

dh : a usb_dev_handle
Returns : positive integer if battery is fine.

ifp_firmware_version ()

float       ifp_firmware_version            (usb_dev_handle *dh);

Returns a number containing the firmware revision of the iRiver

dh : a usb_dev_handle
Returns :: firmware revision

ifp_init ()

int         ifp_init                        (usb_dev_handle **dh,
                                             int init_type);

This function has to be called before every other ifp_* call as it takes care of finding and initializing the device.

Returns: IRIVER_OK if successful, IRIVER_NO_USB_BUS if no usb busses were found, IRIVER_NO_DEVICE if no usb devices were found, IRIVER_NO_IFP if no iRiver devices were found.

dh : a usb_dev_handle
init_type : IRIVER_INIT or IRIVER_REINIT
Returns : the error code of the operation

ifp_release ()

void        ifp_release                     (usb_dev_handle *dh);

Releases all the usb resources previously claimed with ifp_init()

dh : a usb_dev_handle

ifp_ls ()

int         ifp_ls                          (usb_dev_handle *dh,
                                             const char *name,
                                             ifp_file_info **p);

This function retrieves all files in the directory specified by name and fills in the p parameter with the infos about every entry

dh : a usb_dev_handle
name : name of the directory to retrieve a listing for
p : the list that will contain all of the directory entries
Returns : IRIVER_OK if successful, IRIVER_CANNOT_SEND_FILENAME if problems with the iRiver occurred, IRIVER_DIRECTORY_NOT_FOUND if name is not a directory or does not exist.

ifp_firmware_update ()

int         ifp_firmware_update             (usb_dev_handle **dh,
                                             char *name);

Upgrades the iRiver's firmware.

dh : a usb_dev_handle
name : name of the firmware file to upgrade the iRiver to
Returns : IRIVER_OK if successful, IRIVER_UPLOAD_ERROR if the upload of the firmware did not work, IRIVER_FILE_EXISTS if the firmware file is already on the iRiver, IRIVER_FIRMWARE_BASENAME_INCORRECT if the firmware file is not correct.

ifp_format ()

int         ifp_format                      (usb_dev_handle *dh);

Formats the iRiver completely

dh : a usb_dev_handle
Returns : IRIVER_OK

ifp_error_to_string ()

const char* ifp_error_to_string             (int error);

Returns a descriptive string for the error codes returned by the ifp_ functions

error : error code
Returns : a non free-able string

ifp_get_info ()

int         ifp_get_info                    (usb_dev_handle *dh,
                                             const char *name,
                                             ifp_file_info **p);

Function to retrieve information about a file. (size, mime, filetype)

dh : a usb_dev_handle
name : name of the file or directory to retrieve the info about
p : ifp_file_info structure that will hold the information
Returns : IRIVER_OK if successful, IRIVER_FILE_NOT_FOUND if name can't be found, IRIVER_CANNOT_SEND_FILENAME if name can't be even sent to the iRiver

ifp_model_name ()

int         ifp_model_name                  (usb_dev_handle *dh,
                                             char *string);

Fills string with the model name of the iRiver

dh : a usb_dev_handle
string : name of the string
Returns : IRIVER_OK

ifp_free_file_list ()

void        ifp_free_file_list              (ifp_file_info **first);

This functions walks through a whole ifp_file_info list and frees every element. *first will be set to NULL

first : list to be freed