From owner-svn-ports-all@freebsd.org Sun Mar 20 14:57:57 2016 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFFD7AD74D2; Sun, 20 Mar 2016 14:57:57 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B4011CA2; Sun, 20 Mar 2016 14:57:57 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2KEvuH2052989; Sun, 20 Mar 2016 14:57:56 GMT (envelope-from jbeich@FreeBSD.org) Received: (from jbeich@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2KEvumB052986; Sun, 20 Mar 2016 14:57:56 GMT (envelope-from jbeich@FreeBSD.org) Message-Id: <201603201457.u2KEvumB052986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jbeich set sender to jbeich@FreeBSD.org using -f From: Jan Beich Date: Sun, 20 Mar 2016 14:57:56 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r411450 - head/devel/android-tools-fastboot-devel/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Mar 2016 14:57:57 -0000 Author: jbeich Date: Sun Mar 20 14:57:56 2016 New Revision: 411450 URL: https://svnweb.freebsd.org/changeset/ports/411450 Log: devel/android-tools-fastboot-devel: reconnect r403829 changes with old history Added: head/devel/android-tools-fastboot-devel/files/pkg-message.in - copied unchanged from r411449, head/devel/android-tools-fastboot/files/pkg-message.in head/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp - copied, changed from r411449, head/devel/android-tools-fastboot/files/usb_freebsd.cpp head/devel/android-tools-fastboot-devel/files/util_freebsd.cpp - copied unchanged from r411449, head/devel/android-tools-fastboot/files/util_freebsd.cpp Copied: head/devel/android-tools-fastboot-devel/files/pkg-message.in (from r411449, head/devel/android-tools-fastboot/files/pkg-message.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/android-tools-fastboot-devel/files/pkg-message.in Sun Mar 20 14:57:56 2016 (r411450, copy of r411449, head/devel/android-tools-fastboot/files/pkg-message.in) @@ -0,0 +1,7 @@ +The port installed fastboot(1) under %%PREFIX%%/bin. However, there's +a different fastboot(8) under /sbin. To avoid accidentally invoking +the wrong command make sure either to + +- adjust PATH environment variable to have fastboot(1) found first +- create a shell alias with absolute path to fastboot(1) +- create a symlink with different name in PATH e.g., under ~/bin Copied and modified: head/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp (from r411449, head/devel/android-tools-fastboot/files/usb_freebsd.cpp) ============================================================================== --- head/devel/android-tools-fastboot/files/usb_freebsd.cpp Sun Mar 20 14:52:33 2016 (r411449, copy source) +++ head/devel/android-tools-fastboot-devel/files/usb_freebsd.cpp Sun Mar 20 14:57:56 2016 (r411450) @@ -30,6 +30,8 @@ #include #include +#include + #include "usb.h" struct usb_handle { @@ -40,8 +42,24 @@ struct usb_handle { unsigned char iface; }; +class LibusbUsbTransport : public Transport { +public: + LibusbUsbTransport(std::unique_ptr handle): + h(std::move(handle)) {} + ~LibusbUsbTransport() override = default; + + ssize_t Read(void *_data, size_t len) override; + ssize_t Write(const void *_data, size_t len) override; + int Close() override; + +private: + std::unique_ptr h; + + DISALLOW_COPY_AND_ASSIGN(LibusbUsbTransport); +}; + static int -probe(usb_handle *h, ifc_match_func callback) +probe(std::unique_ptr &h, ifc_match_func callback) { usb_ifc_info info; libusb_device_descriptor ddesc; @@ -120,26 +138,22 @@ probe(usb_handle *h, ifc_match_func call return (-1); } -static usb_handle * +static std::unique_ptr enumerate(ifc_match_func callback) { static libusb_context *ctx = NULL; - usb_handle *h; + std::unique_ptr h; libusb_device **ppdev; ssize_t ndev; ssize_t x; - h = reinterpret_cast(malloc(sizeof(*h))); - if (h == NULL) - return (h); - if (ctx == NULL) libusb_init(&ctx); ndev = libusb_get_device_list(ctx, &ppdev); for (x = 0; x < ndev; x++) { - memset(h, 0, sizeof(*h)); + h.reset(new usb_handle); h->dev = ppdev[x]; @@ -149,13 +163,13 @@ enumerate(ifc_match_func callback) return (h); } } - free(h); + h.reset(); libusb_free_device_list(ppdev, 1); - return (NULL); + return (nullptr); } -int -usb_write(usb_handle * h, const void *_data, int len) +ssize_t +LibusbUsbTransport::Write(const void *_data, size_t len) { int actlen; @@ -165,8 +179,8 @@ usb_write(usb_handle * h, const void *_d return (actlen); } -int -usb_read(usb_handle * h, void *_data, int len) +ssize_t +LibusbUsbTransport::Read(void *_data, size_t len) { int actlen; @@ -176,25 +190,19 @@ usb_read(usb_handle * h, void *_data, in return (actlen); } -int -usb_close(usb_handle * h) +int +LibusbUsbTransport::Close() { libusb_close(h->handle); h->handle = NULL; libusb_unref_device(h->dev); - free(h); + h.reset(); return (0); } -usb_handle * +Transport * usb_open(ifc_match_func callback) { - return (enumerate(callback)); -} - -int -usb_wait_for_disconnect(usb_handle * h) -{ - /* TODO: Punt for now */ - return 0; + std::unique_ptr h = enumerate(callback); + return (h ? new LibusbUsbTransport(std::move(h)) : nullptr); } Copied: head/devel/android-tools-fastboot-devel/files/util_freebsd.cpp (from r411449, head/devel/android-tools-fastboot/files/util_freebsd.cpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/android-tools-fastboot-devel/files/util_freebsd.cpp Sun Mar 20 14:57:56 2016 (r411450, copy of r411449, head/devel/android-tools-fastboot/files/util_freebsd.cpp) @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 Hans Petter Selasky. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "fastboot.h" + +#include +#include + +void +get_my_path(char *path) +{ + getcwd(path, PATH_MAX - 1); +}