From ed9a719c8e0899d70ce3db48520e940c299cc192 Mon Sep 17 00:00:00 2001 From: Mariusz Woloszyn Date: Mon, 11 Mar 2002 18:13:08 +0000 Subject: [PATCH] * libgphoto2_port/gphoto2-port.[ch]: added gp_port_check_event() git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4262 67ed7778-7388-44ab-90cf-0a291f65f57c --- libgphoto2_port/ChangeLog | 10 ++++++ .../libgphoto2_port/gphoto2-port.c | 35 +++++++++++++++++++ .../libgphoto2_port/gphoto2-port.h | 1 + 3 files changed, 46 insertions(+) diff --git a/libgphoto2_port/ChangeLog b/libgphoto2_port/ChangeLog index 73505e070..eac07c4b7 100644 --- a/libgphoto2_port/ChangeLog +++ b/libgphoto2_port/ChangeLog @@ -1,3 +1,13 @@ +2002-03-11 Mariusz Woloszyn + * libgphoto2_port/gphoto2-port-library.h: added + check_event to GPPortOperationsl + * libgphoto2_port/gphoto2-port.h: added eventep to + GPPortSettingsUSB + * usb/libusb.c: added gp_port_usb_check_event(), + changed gp_port_usb_find_bulk to gp_port_usb_find_ep(), + added setting of eventsep to gp_port_usb_find_device_lib() + * libgphoto2_port/gphoto2-port.[ch]: added gp_port_check_event() + 2002-02-23 Dan Fandrich * libgphoto2_port/gphoto2-port-info-list.c: Fixed error test for diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port.c b/libgphoto2_port/libgphoto2_port/gphoto2-port.c index e3088ca93..ae056e0a4 100644 --- a/libgphoto2_port/libgphoto2_port/gphoto2-port.c +++ b/libgphoto2_port/libgphoto2_port/gphoto2-port.c @@ -414,6 +414,41 @@ gp_port_read (GPPort *port, char *data, int size) return (retval); } +/** + * gp_port_check_event: + * @port: a #GPPort + * @data: a pointer to an allocated buffer + * @size: the number of bytes that should be read + * + * Reads a specified number of bytes from the event ep the supplied buffer. + * + * Return value: a gphoto2 error code + **/ +int +gp_port_check_event (GPPort *port, char *data, int size) +{ + int retval; + + gp_log (GP_LOG_DEBUG, "gphoto2-port", "Reading %i=0x%x bytes from event ep...", + size, size); + + CHECK_NULL (port); + CHECK_INIT (port); + + /* Check if we read as many bytes as expected */ + CHECK_SUPP (port, _("check_event"), port->pc->ops->check_event); + retval = port->pc->ops->check_event (port, data, size); + CHECK_RESULT (retval); + if (retval != size) + gp_log (GP_LOG_DEBUG, "gphoto2-port", "Could only read %i " + "out of %i byte(s)", retval, size); + + gp_log_data ("gphoto2-port", data, retval); + + return (retval); +} + + /** * gp_port_set_timeout: * @port: a #GPPort diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port.h b/libgphoto2_port/libgphoto2_port/gphoto2-port.h index 08fc81114..9633009f2 100644 --- a/libgphoto2_port/libgphoto2_port/gphoto2-port.h +++ b/libgphoto2_port/libgphoto2_port/gphoto2-port.h @@ -99,6 +99,7 @@ int gp_port_close (GPPort *port); int gp_port_write (GPPort *port, const char *data, int size); int gp_port_read (GPPort *port, char *data, int size); +int gp_port_check_event (GPPort *port, char *data, int size); int gp_port_get_timeout (GPPort *port, int *timeout); int gp_port_set_timeout (GPPort *port, int timeout);