ObexFTP client API implementation.
More...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <openobex/obex.h>
#include <multicobex/multi_cobex.h>
#include "obexftp.h"
#include "client.h"
#include "object.h"
#include "obexftp_io.h"
#include "uuid.h"
#include "cache.h"
#include <common.h>
Defines |
#define | _GNU_SOURCE |
#define | O_BINARY (0) |
#define | CREATE_MODE_FILE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) |
#define | ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT |
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.
|
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_service (obexftp_client_t *cli, const char *src, const char *device, int port, int service) |
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_info (obexftp_client_t *cli, uint8_t opcode) |
| Send a custom Siemens OBEX app info opcode.
|
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_rename (obexftp_client_t *cli, const char *sourcename, const char *targetname) |
| Send an custom Siemens OBEX rename request.
|
int | obexftp_del (obexftp_client_t *cli, const char *name) |
| Send an OBEX PUT with empty file name (delete).
|
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_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.
|
char ** | obexftp_discover_bt_src (const char *src) |
char * | obexftp_bt_name_src (const char *addr, const char *src) |
int | obexftp_browse_bt_src (const char *src, const char *addr, int svclass) |
int | obexftp_sdp_register (int svclass, int channel) |
int | obexftp_sdp_unregister (int svclass) |
char ** | obexftp_discover (int transport) |
| Device discovery wrapper for a named transport.
|
Detailed Description
ObexFTP client API implementation.
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 Documentation
#define CREATE_MODE_FILE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) |
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT |
Function Documentation
int obexftp_browse_bt_src |
( |
const char * |
src, |
|
|
const char * |
addr, |
|
|
int |
svclass |
|
) |
| |
char* obexftp_bt_name_src |
( |
const char * |
addr, |
|
|
const char * |
src |
|
) |
| |
Close an obexftp client and free the resources.
- Parameters:
-
cli | the obexftp_client_t to be shut done and free'd. It's save to pass NULL here. |
Closes the given obexftp client and frees the resources. It's recommended to set the client reference to NULL afterwards.
int obexftp_connect_service |
( |
obexftp_client_t * |
cli, |
|
|
const char * |
src, |
|
|
const char * |
device, |
|
|
int |
port, |
|
|
int |
service |
|
) |
| |
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.
- Parameters:
-
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) |
- Returns:
- the result of the CONNECT request, -1 on error
- Note:
- Always use a UUID (except for OBEX PUSH)
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.
- Parameters:
-
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) |
- Returns:
- the result of the CONNECT request, -1 on error
- Note:
- Wrapper function for obexftp_connect_src()
- Warning:
- Always use a UUID (except for OBEX PUSH)
Send an OBEX PUT with empty file name (delete).
- Parameters:
-
- Returns:
- the result of the empty OBEX PUT request
Disconnect this ObexFTP client by sending an OBEX DISCONNECT request.
- Parameters:
-
- Returns:
- the result of the DISCONNECT request
char** obexftp_discover |
( |
int |
transport ) |
|
Device discovery wrapper for a named transport.
- Parameters:
-
transport | a transport from the OBEX_TRANS_x enum. |
- Returns:
- the discovery results as array of strings.
- Note:
- USB and BT only for now.
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.
- Parameters:
-
- Returns:
- the result of GET request
- Note:
- localname and remotename may be null.
Send a custom Siemens OBEX app info opcode.
- Parameters:
-
- Returns:
- the result of the app info request
Create an obexftp client.
- Parameters:
-
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 |
- Returns:
- a new allocated ObexFTP client instance, NULL on error
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.
- Parameters:
-
- Returns:
- the result of the OBEX PUT (and SETPATH) request(s).
- Note:
- A remotename must be given always.
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.
- Parameters:
-
- Returns:
- the result of the OBEX PUT (and SETPATH) request(s).
- Note:
- Puts to filename's basename if remotename is NULL or ends with a slash.
int obexftp_rename |
( |
obexftp_client_t * |
cli, |
|
|
const char * |
sourcename, |
|
|
const char * |
targetname |
|
) |
| |
Send an custom Siemens OBEX rename request.
- Parameters:
-
- Returns:
- the result of Siemens rename request
int obexftp_sdp_register |
( |
int |
svclass, |
|
|
int |
channel |
|
) |
| |
int obexftp_sdp_unregister |
( |
int |
svclass ) |
|
Send OBEX SETPATH request (multiple requests if split path flag is set).
- Parameters:
-
- Returns:
- the result of the OBEX SETPATH request(s).
- Note:
- handles NULL, "", "/" and everything else correctly.