#include <inttypes.h>
#include <sys/stat.h>
#include <time.h>
#include <openobex/obex.h>
#include "obexftp.h"
#include "object.h"
#include "uuid.h"
Data Structures | |
struct | stat_entry_t |
struct | cache_object |
struct | obexftp_client_t |
Defines | |
#define | OBEX_TRANS_USB 6 |
#define | OBEXFTP_LEADING_SLASH 0x01 |
#define | OBEXFTP_TRAILING_SLASH 0x02 |
#define | OBEXFTP_SPLIT_SETPATH 0x04 |
#define | OBEXFTP_CONN_HEADER 0x08 |
#define | OBEXFTP_USE_LEADING_SLASH(x) ((x & OBEXFTP_LEADING_SLASH) != 0) |
#define | OBEXFTP_USE_TRAILING_SLASH(x) ((x & OBEXFTP_TRAILING_SLASH) != 0) |
#define | OBEXFTP_USE_SPLIT_SETPATH(x) ((x & OBEXFTP_SPLIT_SETPATH) != 0) |
#define | OBEXFTP_USE_CONN_HEADER(x) ((x & OBEXFTP_CONN_HEADER) != 0) |
#define | DEFAULT_OBEXFTP_QUIRKS (OBEXFTP_LEADING_SLASH | OBEXFTP_TRAILING_SLASH | OBEXFTP_SPLIT_SETPATH | OBEXFTP_CONN_HEADER) |
#define | DEFAULT_CACHE_TIMEOUT 180 |
#define | DEFAULT_CACHE_MAXSIZE 10240 |
#define | OBEX_SYNC_SERVICE 0x1104 |
#define | OBEX_PUSH_SERVICE 0x1105 |
#define | OBEX_FTP_SERVICE 0x1106 |
#define | obexftp_discover_bt() obexftp_discover_bt_src(NULL) |
#define | obexftp_browse_bt(device, service) obexftp_browse_bt_src(NULL, device, service) |
#define | obexftp_browse_bt_ftp(device) obexftp_browse_bt_src(NULL, device, OBEX_FTP_SERVICE) |
#define | obexftp_browse_bt_push(device) obexftp_browse_bt_src(NULL, device, OBEX_PUSH_SERVICE) |
#define | obexftp_browse_bt_sync(device) obexftp_browse_bt_src(NULL, device, OBEX_SYNC_SERVICE) |
#define | obexftp_connect(cli, device, port) obexftp_connect_uuid(cli, device, port, UUID_FBS, sizeof(UUID_FBS)) |
#define | obexftp_connect_ftp(cli, device, port) obexftp_connect_uuid(cli, device, port, UUID_FBS, sizeof(UUID_FBS)) |
#define | obexftp_connect_push(cli, device, port) obexftp_connect_uuid(cli, device, port, NULL, 0) |
#define | obexftp_connect_sync(cli, device, port) obexftp_connect_uuid(cli, device, port, UUID_IRMC, sizeof(UUID_IRMC)) |
#define | obexftp_chpath(cli, name) obexftp_setpath(cli, name, 0) |
#define | obexftp_mkpath(cli, name) obexftp_setpath(cli, name, 1) |
#define | obexftp_cdup(cli) obexftp_setpath(cli, NULL, 0) |
#define | obexftp_cdtop(cli) obexftp_setpath(cli, "", 0) |
#define | obexftp_get(cli, localname, remotename) obexftp_get_type(cli, NULL, localname, remotename) |
#define | obexftp_list(cli, localname, remotename) obexftp_get_type(cli, XOBEX_LISTING, localname, remotename) |
#define | obexftp_get_capability(cli, localname, remotename) obexftp_get_type(cli, XOBEX_CAPABILITY, localname, remotename) |
Typedefs | |
typedef cache_object | cache_object_t |
Functions | |
obexftp_client_t * | obexftp_open (int transport, obex_ctrans_t *ctrans, obexftp_info_cb_t infocb, void *infocb_data) |
Create an obexftp client. | |
void | obexftp_close (obexftp_client_t *cli) |
Close an obexftp client and free the resources. | |
char ** | obexftp_discover (int transport) |
Device discovery wrapper for a named transport. | |
char ** | obexftp_discover_bt_src (const char *src) |
int | obexftp_browse_bt_src (const char *src, const char *addr, int svclass) |
int | obexftp_connect_uuid (obexftp_client_t *cli, const char *device, int port, const uint8_t uuid[], uint32_t uuid_len) |
Do simple connect as client. | |
int | obexftp_connect_src (obexftp_client_t *cli, const char *src, const char *device, int port, const uint8_t uuid[], uint32_t uuid_len) |
Connect this ObexFTP client using a given source address by sending an OBEX CONNECT request. | |
int | obexftp_disconnect (obexftp_client_t *cli) |
Disconnect this ObexFTP client by sending an OBEX DISCONNECT request. | |
int | obexftp_setpath (obexftp_client_t *cli, const char *name, int create) |
Send OBEX SETPATH request (multiple requests if split path flag is set). | |
int | obexftp_get_type (obexftp_client_t *cli, const char *type, const char *localname, const char *remotename) |
Send an OBEX GET with optional TYPE. | |
int | obexftp_put_file (obexftp_client_t *cli, const char *filename, const char *remotename) |
Send an OBEX PUT, optionally with (some) SETPATHs for a local file. | |
int | obexftp_put_data (obexftp_client_t *cli, const char *data, int size, const char *remotename) |
Send memory data by OBEX PUT, optionally with (some) SETPATHs. | |
int | obexftp_del (obexftp_client_t *cli, const char *name) |
Send an OBEX PUT with empty file name (delete). | |
int | obexftp_info (obexftp_client_t *cli, uint8_t opcode) |
Send a custom Siemens OBEX app info opcode. | |
int | obexftp_rename (obexftp_client_t *cli, const char *sourcename, const char *targetname) |
Send an custom Siemens OBEX rename request. | |
void * | obexftp_opendir (obexftp_client_t *cli, const char *name) |
Prepare a directory for reading. | |
int | obexftp_closedir (void *dir) |
Close a directory after reading. | |
stat_entry_t * | obexftp_readdir (void *dir) |
Read the next entry from an open directory. | |
stat_entry_t * | obexftp_stat (obexftp_client_t *cli, const char *name) |
Stat a directory entry. |
ObexFTP library - language bindings for OBEX file transfer.
Copyright (c) 2002-2007 Christian W. Zuckschwerdt <zany@triq.net>
ObexFTP is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with ObexFTP. If not, see <http://www.gnu.org/>.
#define DEFAULT_CACHE_MAXSIZE 10240 |
#define DEFAULT_CACHE_TIMEOUT 180 |
#define DEFAULT_OBEXFTP_QUIRKS (OBEXFTP_LEADING_SLASH | OBEXFTP_TRAILING_SLASH | OBEXFTP_SPLIT_SETPATH | OBEXFTP_CONN_HEADER) |
#define OBEX_FTP_SERVICE 0x1106 |
#define OBEX_PUSH_SERVICE 0x1105 |
#define OBEX_SYNC_SERVICE 0x1104 |
#define OBEX_TRANS_USB 6 |
#define obexftp_browse_bt | ( | device, | |||
service | ) | obexftp_browse_bt_src(NULL, device, service) |
#define obexftp_browse_bt_ftp | ( | device | ) | obexftp_browse_bt_src(NULL, device, OBEX_FTP_SERVICE) |
#define obexftp_browse_bt_push | ( | device | ) | obexftp_browse_bt_src(NULL, device, OBEX_PUSH_SERVICE) |
#define obexftp_browse_bt_sync | ( | device | ) | obexftp_browse_bt_src(NULL, device, OBEX_SYNC_SERVICE) |
#define obexftp_cdtop | ( | cli | ) | obexftp_setpath(cli, "", 0) |
#define obexftp_cdup | ( | cli | ) | obexftp_setpath(cli, NULL, 0) |
#define obexftp_chpath | ( | cli, | |||
name | ) | obexftp_setpath(cli, name, 0) |
#define OBEXFTP_CONN_HEADER 0x08 |
#define obexftp_connect | ( | cli, | |||
device, | |||||
port | ) | obexftp_connect_uuid(cli, device, port, UUID_FBS, sizeof(UUID_FBS)) |
#define obexftp_connect_ftp | ( | cli, | |||
device, | |||||
port | ) | obexftp_connect_uuid(cli, device, port, UUID_FBS, sizeof(UUID_FBS)) |
#define obexftp_connect_push | ( | cli, | |||
device, | |||||
port | ) | obexftp_connect_uuid(cli, device, port, NULL, 0) |
#define obexftp_connect_sync | ( | cli, | |||
device, | |||||
port | ) | obexftp_connect_uuid(cli, device, port, UUID_IRMC, sizeof(UUID_IRMC)) |
#define obexftp_discover_bt | ( | ) | obexftp_discover_bt_src(NULL) |
#define obexftp_get | ( | cli, | |||
localname, | |||||
remotename | ) | obexftp_get_type(cli, NULL, localname, remotename) |
#define obexftp_get_capability | ( | cli, | |||
localname, | |||||
remotename | ) | obexftp_get_type(cli, XOBEX_CAPABILITY, localname, remotename) |
#define OBEXFTP_LEADING_SLASH 0x01 |
#define obexftp_list | ( | cli, | |||
localname, | |||||
remotename | ) | obexftp_get_type(cli, XOBEX_LISTING, localname, remotename) |
#define obexftp_mkpath | ( | cli, | |||
name | ) | obexftp_setpath(cli, name, 1) |
#define OBEXFTP_SPLIT_SETPATH 0x04 |
#define OBEXFTP_TRAILING_SLASH 0x02 |
#define OBEXFTP_USE_CONN_HEADER | ( | x | ) | ((x & OBEXFTP_CONN_HEADER) != 0) |
#define OBEXFTP_USE_LEADING_SLASH | ( | x | ) | ((x & OBEXFTP_LEADING_SLASH) != 0) |
#define OBEXFTP_USE_SPLIT_SETPATH | ( | x | ) | ((x & OBEXFTP_SPLIT_SETPATH) != 0) |
#define OBEXFTP_USE_TRAILING_SLASH | ( | x | ) | ((x & OBEXFTP_TRAILING_SLASH) != 0) |
typedef struct cache_object cache_object_t |
int obexftp_browse_bt_src | ( | const char * | src, | |
const char * | addr, | |||
int | svclass | |||
) |
void obexftp_close | ( | obexftp_client_t * | cli | ) |
Close an obexftp client and free the resources.
cli | the obexftp_client_t to be shut done and free'd. It's save to pass NULL here. |
int obexftp_closedir | ( | void * | dir | ) |
Close a directory after reading.
The stat entry is a cache object so we do nothing.
int obexftp_connect_src | ( | obexftp_client_t * | cli, | |
const char * | src, | |||
const char * | device, | |||
int | port, | |||
const uint8_t | uuid[], | |||
uint32_t | uuid_len | |||
) |
Connect this ObexFTP client using a given source address by sending an OBEX CONNECT request.
cli | an obexftp_client_t created by obexftp_open(). | |
src | optional local source interface address (transport specific) | |
device | the device address to connect to (transport specific) | |
port | the port/channel for the device address | |
uuid | UUID string for CONNECT (no default) | |
uuid_len | length of the UUID string (excluding terminating zero) |
int obexftp_connect_uuid | ( | obexftp_client_t * | cli, | |
const char * | device, | |||
int | port, | |||
const uint8_t | uuid[], | |||
uint32_t | uuid_len | |||
) |
Do simple connect as client.
cli | an obexftp_client_t created by obexftp_open(). | |
device | the device address to connect to (transport specific) | |
port | the port/channel for the device address | |
uuid | UUID string for CONNECT (no default) | |
uuid_len | length of the UUID string (excluding terminating zero) |
int obexftp_del | ( | obexftp_client_t * | cli, | |
const char * | name | |||
) |
Send an OBEX PUT with empty file name (delete).
cli | an obexftp_client_t created by obexftp_open(). | |
name | the remote filename/foldername to be removed. |
int obexftp_disconnect | ( | obexftp_client_t * | cli | ) |
Disconnect this ObexFTP client by sending an OBEX DISCONNECT request.
cli | an obexftp_client_t created by obexftp_open(). |
char** obexftp_discover | ( | int | transport | ) |
Device discovery wrapper for a named transport.
transport | a transport from the OBEX_TRANS_x enum. |
char** obexftp_discover_bt_src | ( | const char * | src | ) |
int obexftp_get_type | ( | obexftp_client_t * | cli, | |
const char * | type, | |||
const char * | localname, | |||
const char * | remotename | |||
) |
Send an OBEX GET with optional TYPE.
Directories will be changed into first if split path quirk is set.
cli | an obexftp_client_t created by obexftp_open(). | |
type | OBEX TYPE of the request | |
localname | optional file to write | |
remotename | OBEX NAME to request |
int obexftp_info | ( | obexftp_client_t * | cli, | |
uint8_t | opcode | |||
) |
Send a custom Siemens OBEX app info opcode.
cli | an obexftp_client_t created by obexftp_open(). | |
opcode | the info opcode, 0x01 to inquire installed memory, 0x02 to get free memory |
obexftp_client_t* obexftp_open | ( | int | transport, | |
obex_ctrans_t * | ctrans, | |||
obexftp_info_cb_t | infocb, | |||
void * | infocb_data | |||
) |
Create an obexftp client.
transport | the transport type that will be used | |
ctrans | optional custom transport (don't use) | |
infocb | optional info callback | |
infocb_data | optional info callback data |
void* obexftp_opendir | ( | obexftp_client_t * | cli, | |
const char * | name | |||
) |
Prepare a directory for reading.
int obexftp_put_data | ( | obexftp_client_t * | cli, | |
const char * | data, | |||
int | size, | |||
const char * | remotename | |||
) |
Send memory data by OBEX PUT, optionally with (some) SETPATHs.
cli | an obexftp_client_t created by obexftp_open(). | |
data | data to send | |
size | length of the data | |
remotename | remote name to write |
int obexftp_put_file | ( | obexftp_client_t * | cli, | |
const char * | filename, | |||
const char * | remotename | |||
) |
Send an OBEX PUT, optionally with (some) SETPATHs for a local file.
cli | an obexftp_client_t created by obexftp_open(). | |
filename | local file to send | |
remotename | remote name to write |
stat_entry_t* obexftp_readdir | ( | void * | dir | ) |
Read the next entry from an open directory.
int obexftp_rename | ( | obexftp_client_t * | cli, | |
const char * | sourcename, | |||
const char * | targetname | |||
) |
Send an custom Siemens OBEX rename request.
cli | an obexftp_client_t created by obexftp_open(). | |
sourcename | remote filename to be renamed | |
targetname | remote target filename |
int obexftp_setpath | ( | obexftp_client_t * | cli, | |
const char * | name, | |||
int | create | |||
) |
Send OBEX SETPATH request (multiple requests if split path flag is set).
cli | an obexftp_client_t created by obexftp_open(). | |
name | path to change into | |
create | flag whether to create missing folders or fail |
stat_entry_t* obexftp_stat | ( | obexftp_client_t * | cli, | |
const char * | name | |||
) |
Stat a directory entry.