]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
resource: Do not require size to stay valid after close
[libsigrok.git] / src / libsigrok-internal.h
index 275deac4ad07c22ef7a99048149e0f34d0e1efd3..391671648b262e38f410386db0ad995c161cf486 100644 (file)
@@ -209,6 +209,10 @@ struct sr_context {
 #ifdef HAVE_LIBUSB_1_0
        libusb_context *libusb_ctx;
 #endif
+       sr_resource_open_callback resource_open_cb;
+       sr_resource_close_callback resource_close_cb;
+       sr_resource_read_callback resource_read_cb;
+       void *resource_cb_data;
 };
 
 /** Input module metadata keys. */
@@ -589,10 +593,6 @@ struct drv_context {
        GSList *instances;
 };
 
-/*--- input/input.c ---------------------------------------------------------*/
-
-SR_PRIV int64_t sr_file_get_size(FILE *file);
-
 /*--- log.c -----------------------------------------------------------------*/
 
 #if defined(G_OS_WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
@@ -765,6 +765,22 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
                std_dev_clear_callback clear_private);
 SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi);
 
+/*--- resource.c ------------------------------------------------------------*/
+
+SR_PRIV int64_t sr_file_get_size(FILE *file);
+
+SR_PRIV int sr_resource_open(struct sr_context *ctx,
+               struct sr_resource *res, int type, const char *name)
+               G_GNUC_WARN_UNUSED_RESULT;
+SR_PRIV int sr_resource_close(struct sr_context *ctx,
+               struct sr_resource *res);
+SR_PRIV ssize_t sr_resource_read(struct sr_context *ctx,
+               const struct sr_resource *res, void *buf, size_t count)
+               G_GNUC_WARN_UNUSED_RESULT;
+SR_PRIV void *sr_resource_load(struct sr_context *ctx, int type,
+               const char *name, size_t *size, size_t max_size)
+               G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
 /*--- strutil.c -------------------------------------------------------------*/
 
 SR_PRIV int sr_atol(const char *str, long *ret);
@@ -843,10 +859,10 @@ SR_PRIV int serial_timeout(struct sr_serial_dev_inst *port, int num_bytes);
 
 #ifdef HAVE_LIBUSB_1_0
 SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
-SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
-                                  const char *filename);
-SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
-                                 const char *filename);
+SR_PRIV int ezusb_install_firmware(struct sr_context *ctx, libusb_device_handle *hdl,
+                                  const char *name);
+SR_PRIV int ezusb_upload_firmware(struct sr_context *ctx, libusb_device *dev,
+                                 int configuration, const char *name);
 #endif
 
 /*--- hardware/usb.c --------------------------------------------------------*/