From e42642e6af2b81d5eadca0a70aed91af3ee2d8cd Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 13 Apr 2009 19:14:41 +0000 Subject: [PATCH] added new file -> programmatic handler defines and types git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@11974 67ed7778-7388-44ab-90cf-0a291f65f57c --- gphoto2/gphoto2-file.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gphoto2/gphoto2-file.h b/gphoto2/gphoto2-file.h index 4ee887fbd..51beb82fb 100644 --- a/gphoto2/gphoto2-file.h +++ b/gphoto2/gphoto2-file.h @@ -27,6 +27,7 @@ #define __GPHOTO2_FILE_H__ #include +#include #ifdef __cplusplus extern "C" { @@ -81,9 +82,19 @@ typedef enum { */ typedef enum { GP_FILE_ACCESSTYPE_MEMORY, /**< File is in system memory. */ - GP_FILE_ACCESSTYPE_FD /**< File is associated with a UNIX filedescriptor. */ + GP_FILE_ACCESSTYPE_FD, /**< File is associated with a UNIX filedescriptor. */ + GP_FILE_ACCESSTYPE_HANDLER /**< File is associated with a programmatic handler. */ } CameraFileAccessType; +/* FIXME: api might be unstable. function return gphoto results codes. */ +typedef struct _CameraFileHandler { + int (*size) (void*priv, uint64_t *size); /* only for read? */ + int (*read) (void*priv, unsigned char *data, uint64_t *len); + int (*write) (void*priv, unsigned char *data, uint64_t *len); + /* FIXME: should we have both read/write methods? */ + /* FIXME: how to finish method, due to LRU it might be longlived. */ +} CameraFileHandler; + /*! \struct CameraFile * \brief File structure. * @@ -94,6 +105,7 @@ typedef struct _CameraFile CameraFile; int gp_file_new (CameraFile **file); int gp_file_new_from_fd (CameraFile **file, int fd); +int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv); int gp_file_ref (CameraFile *file); int gp_file_unref (CameraFile *file); int gp_file_free (CameraFile *file);