summaryrefslogtreecommitdiff
path: root/libgphoto2_port/libgphoto2_port
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2010-03-13 11:26:56 +0000
committerMarcus Meissner <marcus@jet.franken.de>2010-03-13 11:26:56 +0000
commit966b176c62a686572c55aba6975aebdaab1c9e77 (patch)
tree118e46850b7dd2a6ae3563d84c6a2e66f971589f /libgphoto2_port/libgphoto2_port
parentb4a0fa7cfa4856cbd12a0a8aeb6fbd6100e4d35a (diff)
downloadlibgphoto2-966b176c62a686572c55aba6975aebdaab1c9e77.tar.gz
- added usb disk direct driver.
- make gp_log_add_func/remove_func use non-format string - remove gp_log_simple_add_func/remove_func again git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@12752 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/libgphoto2_port')
-rw-r--r--libgphoto2_port/libgphoto2_port/gphoto2-port-log.c119
-rw-r--r--libgphoto2_port/libgphoto2_port/gphoto2-port.c34
-rw-r--r--libgphoto2_port/libgphoto2_port/libgphoto2_port.ver3
3 files changed, 52 insertions, 104 deletions
diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
index 843c96d4c..26572469e 100644
--- a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
+++ b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
@@ -58,19 +58,10 @@ typedef struct {
GPLogFunc func; /**< Internal function pointer to call */
void *data; /**< Private data supplied by caller */
} LogFunc;
-typedef struct {
- unsigned int id; /**< Internal id */
- GPLogLevel level; /**< Internal loglevel */
- GPLogSimpleFunc func; /**< Internal function pointer to call */
- void *data; /**< Private data supplied by caller */
-} LogSimpleFunc;
static LogFunc *log_funcs = NULL;
static unsigned int log_funcs_count = 0;
-static LogSimpleFunc *log_simple_funcs = NULL;
-static unsigned int log_simple_funcs_count = 0;
-
/**
* \brief Add a function to get logging information
*
@@ -133,67 +124,6 @@ gp_log_remove_func (int id)
}
/**
- * \brief Add a function to get logging information
- *
- * \param level the maximum level of logging it will get, up to and including the passed value
- * \param func a #GPLogSimpleFunc
- * \param data data
- *
- * Adds a log function that will be called for each log message that is flagged
- * with a log level that appears in given log level. This function returns
- * an id that you can use for removing the log function again (using
- * #gp_log_remove_func).
- *
- * \return an id or a gphoto2 error code
- **/
-int
-gp_log_simple_add_func (GPLogLevel level, GPLogSimpleFunc func, void *data)
-{
- LogSimpleFunc *new_log_funcs;
-
- if (!func)
- return (GP_ERROR_BAD_PARAMETERS);
-
- if (!log_simple_funcs)
- new_log_funcs = malloc (sizeof (LogSimpleFunc));
- else
- new_log_funcs = realloc (log_simple_funcs, sizeof (LogSimpleFunc) *
- (log_simple_funcs_count + 1));
- if (!new_log_funcs)
- return (GP_ERROR_NO_MEMORY);
-
- log_simple_funcs = new_log_funcs;
- log_simple_funcs_count++;
-
- log_simple_funcs[log_simple_funcs_count - 1].id = log_simple_funcs_count;
- log_simple_funcs[log_simple_funcs_count - 1].level = level;
- log_simple_funcs[log_simple_funcs_count - 1].func = func;
- log_simple_funcs[log_simple_funcs_count - 1].data = data;
-
- return (log_simple_funcs_count);
-}
-
-/**
- * \brief Remove a logging receiving function
- * \param id an id (return value of #gp_log_add_func)
- *
- * Removes the log function with given id.
- *
- * \return a gphoto2 error code
- **/
-int
-gp_log_simple_remove_func (int id)
-{
- if (id < 1 || id > log_simple_funcs_count)
- return (GP_ERROR_BAD_PARAMETERS);
-
- memmove (log_simple_funcs + id - 1, log_simple_funcs + id, log_simple_funcs_count - id);
- log_simple_funcs_count--;
-
- return (GP_OK);
-}
-
-/**
* Width of offset field in characters. Note that HEXDUMP_COMPLETE_LINE
* needs to be changed when this value is changed.
*/
@@ -334,48 +264,33 @@ gp_logv (GPLogLevel level, const char *domain, const char *format,
#ifdef HAVE_VA_COPY
va_list xargs;
#endif
+ int strsize = 1000;
+ char *str;
+ int n;
- for (i = 0; i < log_funcs_count; i++) {
- if (log_funcs[i].level >= level) {
-#ifdef HAVE_VA_COPY
- va_copy (xargs, args);
- log_funcs[i].func (level, domain, format, xargs,
- log_funcs[i].data);
-#else
- log_funcs[i].func (level, domain, format, args,
- log_funcs[i].data);
-#endif
- }
- }
+ if (!log_funcs_count)
+ return;
- if (log_simple_funcs_count) {
+ str = malloc(strsize);
+ if (!str) return;
#ifdef HAVE_VA_COPY
- va_list xargs;
+ va_copy (xargs, args);
#endif
- int strsize = 1000;
- char *str = malloc(strsize);
- int n;
-
+ n = vsnprintf (str, strsize, format, xargs);
+ if (n+1>strsize) {
+ free (str);
+ str = malloc(n+1);
if (!str) return;
+ strsize = n+1;
#ifdef HAVE_VA_COPY
va_copy (xargs, args);
#endif
n = vsnprintf (str, strsize, format, xargs);
- if (n+1>strsize) {
- free (str);
- str = malloc(n+1);
- if (!str) return;
- strsize = n+1;
-#ifdef HAVE_VA_COPY
- va_copy (xargs, args);
-#endif
- n = vsnprintf (str, strsize, format, xargs);
- }
- for (i = 0; i < log_simple_funcs_count; i++)
- if (log_simple_funcs[i].level >= level)
- log_simple_funcs[i].func (level, domain, str, log_simple_funcs[i].data);
- free (str);
}
+ for (i = 0; i < log_funcs_count; i++)
+ if (log_funcs[i].level >= level)
+ log_funcs[i].func (level, domain, str, log_funcs[i].data);
+ free (str);
}
/**
diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port.c b/libgphoto2_port/libgphoto2_port/gphoto2-port.c
index 62818fb9c..ee85a00f1 100644
--- a/libgphoto2_port/libgphoto2_port/gphoto2-port.c
+++ b/libgphoto2_port/libgphoto2_port/gphoto2-port.c
@@ -208,6 +208,11 @@ gp_port_set_info (GPPort *port, GPPortInfo info)
port->settings.usb.altsetting = -1;
gp_port_set_timeout (port, 5000);
break;
+ case GP_PORT_USB_DISK_DIRECT:
+ snprintf(port->settings.usbdiskdirect.path,
+ sizeof(port->settings.usbdiskdirect.path), "%s",
+ strchr(info->path, ':') + 1);
+ break;
default:
/* Nothing in here */
break;
@@ -1064,6 +1069,35 @@ gp_port_usb_msg_class_read (GPPort *port, int request, int value, int index,
return (retval);
}
+/**
+ * \brief Seek on a port (for usb disk direct ports)
+ *
+ * \param port a #GPPort
+ * \param offset offset to seek to
+ * \param whence the underlying lseek call whence parameter
+ *
+ * Seeks to a specific offset on the usb disk
+ *
+ * \return a gphoto2 error code
+ **/
+int
+gp_port_seek (GPPort *port, int offset, int whence)
+{
+ int retval;
+
+ gp_log (GP_LOG_DEBUG, "gphoto2-port", "Seeking to: %d whence: %d",
+ offset, whence);
+
+ CHECK_NULL (port);
+ CHECK_INIT (port);
+
+ CHECK_SUPP (port, "seek", port->pc->ops->seek);
+ retval = port->pc->ops->seek (port, offset, whence);
+
+ gp_log (GP_LOG_DEBUG, "gphoto2-port", "Seek result: %d", retval);
+
+ return retval;
+}
/**
* \brief Set verbose port error message
diff --git a/libgphoto2_port/libgphoto2_port/libgphoto2_port.ver b/libgphoto2_port/libgphoto2_port/libgphoto2_port.ver
index 3e1a90f5d..6684883d3 100644
--- a/libgphoto2_port/libgphoto2_port/libgphoto2_port.ver
+++ b/libgphoto2_port/libgphoto2_port/libgphoto2_port.ver
@@ -4,8 +4,6 @@ LIBGPHOTO2_5_0 {
gp_log_add_func;
gp_log_data;
gp_log_remove_func;
- gp_log_simple_add_func;
- gp_log_simple_remove_func;
gp_logv;
gp_port_check_int;
gp_port_check_int_fast;
@@ -34,6 +32,7 @@ LIBGPHOTO2_5_0 {
gp_port_open;
gp_port_read;
gp_port_result_as_string;
+ gp_port_seek;
gp_port_send_break;
gp_port_set_error;
gp_port_set_info;