Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Mar 2016 14:57:56 +0000 (UTC)
From:      Jan Beich <jbeich@FreeBSD.org>
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
Message-ID:  <201603201457.u2KEvumB052986@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <string.h>
 #include <libusb.h>
 
+#include <memory>
+
 #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<usb_handle> 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<usb_handle> h;
+
+	DISALLOW_COPY_AND_ASSIGN(LibusbUsbTransport);
+};
+
 static int 
-probe(usb_handle *h, ifc_match_func callback)
+probe(std::unique_ptr<usb_handle> &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<usb_handle>
 enumerate(ifc_match_func callback)
 {
 	static libusb_context *ctx = NULL;
-	usb_handle *h;
+	std::unique_ptr<usb_handle> h;
 	libusb_device **ppdev;
 	ssize_t ndev;
 	ssize_t x;
 
-	h = reinterpret_cast<usb_handle*>(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<usb_handle> 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 <unistd.h>
+#include <limits.h>
+
+void 
+get_my_path(char *path)
+{
+	getcwd(path, PATH_MAX - 1);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603201457.u2KEvumB052986>