// // Create an ircp client // ircp_client_t *ircp_cli_open(ircp_info_cb_t infocb) { ircp_client_t *cli; DEBUG(4, "\n"); cli = malloc(sizeof(ircp_client_t)); if(cli == NULL) return NULL; cli->infocb = infocb; cli->fd = -1; #ifdef DEBUG_TCP cli->obexhandle = OBEX_Init(OBEX_TRANS_INET, cli_obex_event, 0); #else cli->obexhandle = OBEX_Init(OBEX_TRANS_IRDA, cli_obex_event, 0); #endif if(cli->obexhandle == NULL) { goto out_err; } OBEX_SetUserData(cli->obexhandle, cli); /* Buffer for body */ cli->buf = malloc(STREAM_CHUNK); return cli; out_err: if(cli->obexhandle != NULL) OBEX_Cleanup(cli->obexhandle); free(cli); return NULL; }
obex_t *obex_open(int fd, obex_callback_t *callback, void *data) { obex_t *handle; obex_context_t *context; context = malloc(sizeof(*context)); if (!context) return NULL; memset(context, 0, sizeof(*context)); context->state = OBEX_OPEN; context->cid = CID_INVALID; handle = OBEX_Init(OBEX_TRANS_FD, obex_event, 0); if (!handle) { free(context); return NULL; } context->user_data = data; context->callback = callback; context->tx_max = sizeof(context->buf); OBEX_SetUserData(handle, context); OBEX_SetTransportMTU(handle, sizeof(context->buf), sizeof(context->buf)); if (FdOBEX_TransportSetup(handle, fd, fd, 0) < 0) { OBEX_Cleanup(handle); return NULL; } return handle; }
int obex_open(bdaddr_t *src, bdaddr_t *dst, uint8_t channel) { obex_t *handle; struct obex_context *context; if (!(context = malloc(sizeof(struct obex_context)))) return -1; if (!(handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0))) return -1; context->state = OBEX_OPEN; context->mode = OBEX_IDLE; OBEX_SetUserData(handle, context); OBEX_SetTransportMTU(handle, OBEX_MAXIMUM_MTU, OBEX_MAXIMUM_MTU); if (BtOBEX_TransportConnect(handle, src, dst, channel) < 0) return -1; obex_handles[0] = handle; return 0; }
/** Create an obexftp client. \param transport the transport type that will be used \param ctrans optional custom transport (don't use) \param infocb optional info callback \param infocb_data optional info callback data \return a new allocated ObexFTP client instance, NULL on error */ obexftp_client_t *obexftp_open(int transport, /*const*/ obex_ctrans_t *ctrans, obexftp_info_cb_t infocb, void *infocb_data) { obexftp_client_t *cli; DEBUG(3, "%s()\n", __func__); cli = calloc (1, sizeof(obexftp_client_t)); if(cli == NULL) return NULL; cli->finished = TRUE; cli->accept_timeout = 20; /* 20 seconds accept/reject timeout, default value */ if (infocb) cli->infocb = infocb; else cli->infocb = dummy_info_cb; cli->infocb_data = infocb_data; cli->quirks = DEFAULT_OBEXFTP_QUIRKS; cli->cache_timeout = DEFAULT_CACHE_TIMEOUT; cli->cache_maxsize = DEFAULT_CACHE_MAXSIZE; cli->fd = -1; cli->obexhandle = OBEX_Init(transport, cli_obex_event, 0); if(cli->obexhandle == NULL) { free(cli); return NULL; } cli->transport = transport; if ( ctrans ) { DEBUG(2, "Custom OBEX transport requested!\n"); /* OBEX_RegisterCTransport is const to ctrans ... */ if(OBEX_RegisterCTransport(cli->obexhandle, ctrans) < 0) { DEBUG(1, "Custom transport callback-registration failed\n"); } cli->ctrans = ctrans; } OBEX_SetUserData(cli->obexhandle, cli); /* Buffer for body */ cli->stream_chunk = malloc(STREAM_CHUNK); if(cli->stream_chunk == NULL) { free(cli); return NULL; } return cli; }
int Rcv(void) { /* obex_object_t* object; */ handleRcv = OBEX_Init(OBEX_TRANS_IRDA, ObexEvent, 0); IrOBEX_ServerRegister(handleRcv, "OBEX"); while (!receivingFinished) OBEX_HandleInput(handleRcv, 1); receivingFinished = 0; return 0; }
static int OBEXServer_init(OBEXServer *self, PyObject *args) { int fd; PyObject *cb_error; PyObject *cb_newrequest; PyObject *cb_requestdone; int mtu = 1024; /* todo make this a keyword arg */ if (!PyArg_ParseTuple(args, "iOOO", &fd, &cb_error, &cb_newrequest, &cb_requestdone)) { return -1; } if (!PyCallable_Check(cb_error) || !PyCallable_Check(cb_newrequest) || !PyCallable_Check(cb_requestdone)) { PyErr_SetString(PyExc_TypeError, "given callback is not callable"); return -1; } if (self->cb_error == NULL) { Py_INCREF(cb_error); self->cb_error = cb_error; } if (self->cb_newrequest == NULL) { Py_INCREF(cb_newrequest); self->cb_newrequest = cb_newrequest; } if (self->cb_requestdone == NULL) { Py_INCREF(cb_requestdone); self->cb_requestdone = cb_requestdone; } if (self->obex == NULL) { self->obex = OBEX_Init(OBEX_TRANS_FD, obexserver_event, 0); if (self->obex == NULL) { PyErr_SetString(PyExc_IOError, "error creating OBEX object"); return -1; } if (FdOBEX_TransportSetup(self->obex, fd, fd, mtu) < 0) { PyErr_SetString(PyExc_IOError, "error initialising transport"); return -1; } } OBEX_SetUserData(self->obex, self); return 0; }
int main(int argc, char **argv) { obex_object_t *object; handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0); if (argc == 1) { BtOBEX_ServerRegister(handle, NULL, OBEX_PUSH_HANDLE); printf("Waiting for connection...\n"); btobex_accept(handle); while (!finished) OBEX_HandleInput(handle, 1); } }
/* * obex_start_server() * * runs obex server fds transport */ int obexsrv_run(obexsrv_t *srv, int rfd, int wfd) { int err = 0, to; srv->handle = OBEX_Init(OBEX_TRANS_FD, obexsrv_event, 0); if (!srv->handle) { BTERROR( "OBEX_Init failed:%s", strerror(errno)); return -1; } /* init some members */ srv->sfd = -1; srv->name = NULL; srv->flags = 0; srv->buf = NULL; // set private pointer OBEX_SetUserData(srv->handle, srv); FdOBEX_TransportSetup(srv->handle, rfd, wfd, 0); for (;;) { /* request processing loop */ DBPRT("Processing request...\n"); srv->serverdone = FALSE; to = 1000; /* unlimmited - waiting for request */ while (!srv->serverdone) { if ((err = OBEX_HandleInput(srv->handle, to)) < 0) { BTERROR("Error while doing OBEX_HandleInput()"); break; } to = 5; /* processing request */ } if (srv->state == SRVSTATE_CLOSED) break; if (err < 0) break; } OBEX_Cleanup(srv->handle); srv->handle = NULL; return 0; }
int Send(char* fileName) { obex_object_t* object; int ret, exitval = 0; handleSend = OBEX_Init(OBEX_TRANS_IRDA, ObexEvent, 0); ret = IrOBEX_TransportConnect(handleSend, "OBEX"); if (ret < 0) { printf("OBEX: Sorry, unable to connect! - Stage 1 -\n"); return 1; } object = OBEX_ObjectNew(handleSend, OBEX_CMD_CONNECT); ret = RequestSync(handleSend, object, FALSE); if ((lastSendRsp != OBEX_RSP_SUCCESS) || (ret < 0)) { printf("OBEX: Sorry, unable to connect! - Stage 2 -\n"); return 1; } if ((object = BuildObjFromFile(handleSend, fileName ))) { ret = RequestSync(handleSend, object, FALSE); if ((lastSendRsp != OBEX_RSP_SUCCESS) || (ret < 0)) exitval = 1; } else exitval = 1; object = OBEX_ObjectNew(handleSend, OBEX_CMD_DISCONNECT); ret = RequestSync(handleSend, object, FALSE); if ((lastSendRsp != OBEX_RSP_SUCCESS) || (ret < 0)) exitval = 1; if (exitval == 0) printf("OBEX: PUT successful\n"); else printf("OBEX: PUT failed\n"); return exitval; }
static int get_peer_addr(char *name, struct sockaddr_storage *peer) { struct addrinfo hint = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, .ai_protocol = 0, .ai_flags = AI_ADDRCONFIG }; struct addrinfo *info; int err = getaddrinfo(name, NULL, &hint, &info); if (err) return err; memcpy(peer, info->ai_addr, info->ai_addrlen); freeaddrinfo(info); return 0; } /* * Function main (argc, ) * * Starts all the fun! * */ int main(int argc, char *argv[]) { struct sockaddr_storage peer; obex_object_t *object; int ret; printf("Send and receive files over TCP OBEX\n"); if ( ((argc < 3) || (argc > 3)) && (argc != 1) ) { printf ("Usage: %s [name] [peer]\n", argv[0]); return -1; } handle = OBEX_Init(OBEX_TRANS_INET, obex_event, 0); if (argc == 1) { printf("Waiting for files\n"); ret = TcpOBEX_ServerRegister(handle, NULL, 0); if(ret < 0) { printf("Cannot listen to socket\n"); exit(ret); } while (!finished) { ret = OBEX_HandleInput(handle, 10); if (ret == 0) { printf("Timeout waiting for connection\n"); break; } else if (ret < 0) { printf("Error waiting for connection\n"); break; } } } else { /* We are a client */ ret = get_peer_addr(argv[2], &peer); if (ret) { perror("Bad name"); exit(1); } ret = TcpOBEX_TransportConnect(handle, (struct sockaddr *) &peer, sizeof(peer)); if (ret < 0) { printf("Sorry, unable to connect!\n"); exit(1); } object = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT); ret = do_sync_request(handle, object, 0); if( (object = build_object_from_file(handle, argv[1], 0)) ) { ret = do_sync_request(handle, object, 0); } else { perror("PUT failed"); } object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT); ret = do_sync_request(handle, object, 0); printf("PUT successful\n"); } return 0; }
int main (int argc, char *argv[]) { char cmd[10]; int num, end = 0; int cobex = FALSE, tcpobex = FALSE, btobex = FALSE, r320 = FALSE, usbobex = FALSE; obex_t *handle; #ifdef HAVE_BLUETOOTH bdaddr_t bdaddr; uint8_t channel = 0; #endif #ifdef HAVE_USB obex_interface_t *obex_intf; #endif struct context global_context = {0,}; #ifndef _WIN32 char *port; obex_ctrans_t custfunc; if( (argc == 2 || argc ==3) && (strcmp(argv[1], "-s") == 0 ) ) cobex = TRUE; if( (argc == 2 || argc ==3) && (strcmp(argv[1], "-r") == 0 ) ) { cobex = TRUE; r320 = TRUE; } #endif if( (argc == 2) && (strcmp(argv[1], "-i") == 0 ) ) tcpobex = TRUE; if( (argc >= 2) && (strcmp(argv[1], "-b") == 0 ) ) btobex = TRUE; if( (argc >= 2) && (strcmp(argv[1], "-u") == 0 ) ) usbobex = TRUE; if(cobex) { #ifndef _WIN32 if(argc == 3) port = argv[2]; else port = "/dev/ttyS0"; if(r320) printf("OBEX to R320 on %s!\n", port); else printf("OBEX on %s!\n", port); custfunc.customdata = cobex_open(port, r320); if(custfunc.customdata == NULL) { printf("cobex_open() failed\n"); return -1; } if(! (handle = OBEX_Init(OBEX_TRANS_CUSTOM, obex_event, 0))) { perror( "OBEX_Init failed"); return -1; } custfunc.connect = cobex_connect; custfunc.disconnect = cobex_disconnect; custfunc.write = cobex_write; custfunc.handleinput = cobex_handle_input; custfunc.listen = cobex_connect; // Listen and connect is 100% same on cable if(OBEX_RegisterCTransport(handle, &custfunc) < 0) { printf("Custom transport callback-registration failed\n"); } #else printf("Not implemented in Win32 yet.\n"); #endif // _WIN32 } else if(tcpobex) { printf("Using TCP transport\n"); if(! (handle = OBEX_Init(OBEX_TRANS_INET, obex_event, 0))) { perror( "OBEX_Init failed"); exit(0); } } else if(btobex) { #ifndef _WIN32 switch (argc) { #ifdef HAVE_BLUETOOTH case 4: str2ba(argv[2], &bdaddr); channel = atoi(argv[3]); break; case 3: str2ba(argv[2], &bdaddr); if (bacmp(&bdaddr, BDADDR_ANY) == 0) channel = atoi(argv[2]); else channel = BT_CHANNEL; break; case 2: bacpy(&bdaddr, BDADDR_ANY); channel = BT_CHANNEL; break; #endif default: printf("Wrong number of arguments\n"); exit(0); } printf("Using Bluetooth RFCOMM transport\n"); if(! (handle = OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0))) { perror( "OBEX_Init failed"); exit(0); } #else printf("Not implemented in Win32 yet.\n"); #endif // _WIN32 } else if(usbobex) { #ifdef HAVE_USB int i, interfaces_number, intf_num; switch (argc) { case 2: printf("Using USB transport, querying available interfaces\n"); if(! (handle = OBEX_Init(OBEX_TRANS_USB, obex_event, 0))) { perror( "OBEX_Init failed"); exit(0); } interfaces_number = OBEX_FindInterfaces(handle, &obex_intf); for (i=0; i < interfaces_number; i++) printf("Interface %d: %s %s %s\n", i, obex_intf[i].usb.manufacturer, obex_intf[i].usb.product, obex_intf[i].usb.control_interface); printf("Use '%s -u interface_number' to run interactive OBEX test client\n", argv[0]); OBEX_Cleanup(handle); exit(0); break; case 3: intf_num = atoi(argv[2]); printf("Using USB transport \n"); if(! (handle = OBEX_Init(OBEX_TRANS_USB, obex_event, 0))) { perror( "OBEX_Init failed"); exit(0); } interfaces_number = OBEX_FindInterfaces(handle, &obex_intf); if (intf_num >= interfaces_number) { printf( "Invalid interface number\n"); exit(0); } obex_intf += intf_num; break; default: printf("Wrong number of arguments\n"); exit(0); } #else printf("Not compiled with USB support\n"); exit(0); #endif } else { printf("Using IrDA transport\n"); if(! (handle = OBEX_Init(OBEX_TRANS_IRDA, obex_event, 0))) { perror( "OBEX_Init failed"); exit(0); } } OBEX_SetUserData(handle, &global_context); printf( "OBEX Interactive test client/server.\n"); while (!end) { printf("> "); num = scanf("%s", cmd); switch (cmd[0] | 0x20) { case 'q': end=1; break; case 'g': get_client(handle, &global_context); break; case 't': setpath_client(handle); break; case 'p': put_client(handle); break; case 'x': push_client(handle); break; case 'c': /* First connect transport */ if(tcpobex) { if(TcpOBEX_TransportConnect(handle, NULL, 0) < 0) { printf("Transport connect error! (TCP)\n"); break; } } if(cobex) { if(OBEX_TransportConnect(handle, (void*) 1, 0) < 0) { printf("Transport connect error! (Serial)\n"); break; } } if(btobex) { #ifdef HAVE_BLUETOOTH if (bacmp(&bdaddr, BDADDR_ANY) == 0) { printf("Device address error! (Bluetooth)\n"); break; } if(BtOBEX_TransportConnect(handle, BDADDR_ANY, &bdaddr, channel) <0) { printf("Transport connect error! (Bluetooth)\n"); break; } #else printf("Transport not found! (Bluetooth)\n"); #endif } if (usbobex) { #ifdef HAVE_USB if (OBEX_InterfaceConnect(handle, obex_intf) < 0) { printf("Transport connect error! (USB)\n"); break; } #else printf("Transport not found! (USB)\n"); #endif } if (!tcpobex && !cobex && !btobex && !usbobex) { if(IrOBEX_TransportConnect(handle, IR_SERVICE) < 0) { printf("Transport connect error! (IrDA)\n"); break; } } // Now send OBEX-connect. connect_client(handle); break; case 'd': disconnect_client(handle); break; case 's': /* First register server */ if(tcpobex) { if(TcpOBEX_ServerRegister(handle, NULL, 0) < 0) { printf("Server register error! (TCP)\n"); break; } } if(cobex) { if(OBEX_ServerRegister(handle, (void*) 1, 0) < 0) { printf("Server register error! (Serial)\n"); break; } } if(btobex) { #ifdef HAVE_BLUETOOTH if(BtOBEX_ServerRegister(handle, BDADDR_ANY, channel) < 0) { printf("Server register error! (Bluetooth)\n"); break; } #else printf("Transport not found! (Bluetooth)\n"); #endif } if (usbobex) { printf("Transport not found! (USB)\n"); } if (!tcpobex && !cobex && !btobex && !usbobex) { if(IrOBEX_ServerRegister(handle, IR_SERVICE) < 0) { printf("Server register error! (IrDA)\n"); break; } } /* No process server events */ server_do(handle); break; default: printf("Unknown command %s\n", cmd); } } #ifndef _WIN32 if(cobex) cobex_close(custfunc.customdata); #endif return 0; }
obex_t *smartpen_connect(short vendor, short product) { obex_t *handle; obex_object_t *obj; int rc, num, i; struct obex_state *state; obex_interface_t *obex_intf; obex_headerdata_t hd; int size, count; char *buf; again: handle = OBEX_Init(OBEX_TRANS_USB, obex_event, 0); if (!handle) goto out; num = OBEX_EnumerateInterfaces(handle); for (i=0; i<num; i++) { obex_intf = OBEX_GetInterfaceByIndex(handle, i); if (!strcmp(obex_intf->usb.manufacturer, "Livescribe")) break; } if (i == num) { printf("No such device\n"); handle = NULL; goto out; } state = malloc(sizeof(struct obex_state)); if (!state) { handle = NULL; goto out; } memset(state, 0, sizeof(struct obex_state)); if (!swizzle_usb(vendor, product)) { handle = NULL; goto out; } rc = OBEX_InterfaceConnect(handle, obex_intf); if (rc < 0) { printf("Connect failed %d\n", rc); handle = NULL; goto out; } OBEX_SetUserData(handle, state); OBEX_SetTransportMTU(handle, 0x400, 0x400); obj = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT); hd.bs = (unsigned char *)"LivescribeService"; size = strlen((char*)hd.bs)+1; OBEX_ObjectAddHeader(handle, obj, OBEX_HDR_TARGET, hd, size, 0); rc = OBEX_Request(handle, obj); count = state->req_done; while (rc == 0 && state->req_done <= count) { OBEX_HandleInput(handle, 100); } if (rc < 0 || !state->got_connid) { printf("Retry connection...\n"); OBEX_Cleanup(handle); goto again; } buf = get_named_object(handle, "ppdata?key=pp0000", &rc); if (!buf) { printf("Retry connection...\n"); OBEX_Cleanup(handle); pen_reset(vendor, product); goto again; } out: return handle; }
/* * Function main (argc, ) * * Starts all the fun! * */ int main(int argc, char *argv[]) { obex_object_t *object; int ret; unsigned height,width; int i; DAParseArguments(argc, argv, options, sizeof(options)/sizeof(DAProgramOption), "CapShare Document Management Dock Applet\nBen Moore [email protected]\n", VERSION); DAInitialize(displayName, "wmcapshare", 60,60, argc, argv); DAMakePixmapFromData(lcdchars2_xpm, &char_buf, &char_mask, &height, &width); DAMakePixmapFromData(lcdnums_xpm, &num_buf, &num_mask, &height, &width); DAMakePixmapFromData(base_xpm, &pixmap, &mask, &height, &width); DAMakePixmapFromData(tstatfld_xpm, &tstatfld_buf, &tstatfld_mask, &height, &width); DAMakePixmapFromData(tstatfld_xpm, &blank_buf, &blank_mask, &height, &width); DAMakePixmapFromData(capshare_xpm, &capshare_pic, &capshare_mask, &height, &width); DAMakePixmapFromData(transfering_xpm, &transfer_pic, &transfer_mask, &height, &width); DAMakePixmapFromData(connected_xpm, &connect_pic, &connect_mask, &height, &width); DAMakePixmapFromData(disconnected_xpm, &disconnect_pic, &disconnect_mask, &height, &width); DAMakePixmapFromData( plane00_xpm, &plane_anim[0], &plane_animmask[1], &height, &width); DAMakePixmapFromData( plane01_xpm, &plane_anim[1], &plane_animmask[2], &height, &width); DAMakePixmapFromData( plane02_xpm, &plane_anim[2], &plane_animmask[3], &height, &width); DAMakePixmapFromData( plane03_xpm, &plane_anim[3], &plane_animmask[4], &height, &width); DAMakePixmapFromData( plane04_xpm, &plane_anim[4], &plane_animmask[5], &height, &width); DAMakePixmapFromData( plane05_xpm, &plane_anim[5], &plane_animmask[6], &height, &width); DAMakePixmapFromData( plane06_xpm, &plane_anim[6], &plane_animmask[6], &height, &width); DAMakePixmapFromData( plane07_xpm, &plane_anim[7], &plane_animmask[7], &height, &width); DAMakePixmapFromData( plane08_xpm, &plane_anim[8], &plane_animmask[8], &height, &width); DAMakePixmapFromData( plane09_xpm, &plane_anim[9], &plane_animmask[9], &height, &width); DAMakePixmapFromData( plane10_xpm, &plane_anim[10], &plane_animmask[10], &height, &width); DAMakePixmapFromData( plane11_xpm, &plane_anim[11], &plane_animmask[11], &height, &width); DAMakePixmapFromData( plane12_xpm, &plane_anim[12], &plane_animmask[12], &height, &width); DAMakePixmapFromData( plane13_xpm, &plane_anim[13], &plane_animmask[13], &height, &width); DAMakePixmapFromData( plane14_xpm, &plane_anim[14], &plane_animmask[14], &height, &width); DAMakePixmapFromData( plane15_xpm, &plane_anim[15], &plane_animmask[15], &height, &width); DAMakePixmapFromData( plane16_xpm, &plane_anim[16], &plane_animmask[16], &height, &width); DAMakePixmapFromData( plane17_xpm, &plane_anim[17], &plane_animmask[17], &height, &width); DAMakePixmapFromData( plane18_xpm, &plane_anim[18], &plane_animmask[18], &height, &width); DAMakePixmapFromData( plane19_xpm, &plane_anim[19], &plane_animmask[19], &height, &width); gc = DefaultGC(DADisplay, DefaultScreen(DADisplay)); /* string2pixmap("recieve", &tstatfld_buf); XCopyArea(DADisplay, plane_pic, pixmap, gc, 0, 0, 60, 29, 0, 15); XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42, 8, 16, 48); DASetPixmap(pixmap); XCopyArea(DADisplay, connect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45); DASetPixmap(pixmap); */ XCopyArea(DADisplay, capshare_pic, pixmap, gc, 0, 0, 60, 29, 0, 15); DAShow(); while(1) { handle = OBEX_Init(OBEX_TRANS_IRDA, obex_event, 0); printf("Waiting for files\n"); OBEX_ServerRegister(handle, "OBEX"); while (!finished) { updateDisplay(); OBEX_HandleInput(handle, 1); } finished = FALSE; } return 0; }
/* * Function main (argc, ) * * Starts all the fun! * */ int main(int argc, char *argv[]) { struct sockaddr_in peer; obex_object_t *object; int ret; printf("Send and receive files over TCP OBEX\n"); if ( ((argc < 3) || (argc > 3)) && (argc != 1) ) { printf ("Usage: %s [name] [peer]\n", argv[0]); return -1; } handle = OBEX_Init(OBEX_TRANS_INET, obex_event, 0); if (argc == 1) { printf("Waiting for files\n"); ret = InOBEX_ServerRegister(handle); if(ret < 0) { printf("Cannot listen to socket\n"); exit(ret); } while (!finished) { ret = OBEX_HandleInput(handle, 10); if (ret == 0) { printf("Timeout waiting for connection\n"); break; } else if (ret < 0) { printf("Error waiting for connection\n"); break; } } } else { /* We are a client */ get_peer_addr(argv[2], &peer); ret = OBEX_TransportConnect(handle, (struct sockaddr *) &peer, sizeof(struct sockaddr_in)); if (ret < 0) { printf("Sorry, unable to connect!\n"); exit(ret); } object = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT); ret = do_sync_request(handle, object, 0); if( (object = build_object_from_file(handle, argv[1], 0)) ) { ret = do_sync_request(handle, object, 0); } else { perror("PUT failed"); } object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT); ret = do_sync_request(handle, object, 0); printf("PUT successful\n"); } return 0; }