subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

device-private.h (2910B)


      1 /*
      2  * libdivecomputer
      3  *
      4  * Copyright (C) 2008 Jef Driesen
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2.1 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General Public
     17  * License along with this library; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     19  * MA 02110-1301 USA
     20  */
     21 
     22 #ifndef DEVICE_PRIVATE_H
     23 #define DEVICE_PRIVATE_H
     24 
     25 #include <limits.h>
     26 
     27 #include <libdivecomputer/context.h>
     28 #include <libdivecomputer/device.h>
     29 
     30 #include "common-private.h"
     31 
     32 #ifdef __cplusplus
     33 extern "C" {
     34 #endif /* __cplusplus */
     35 
     36 #define EVENT_PROGRESS_INITIALIZER {0, UINT_MAX}
     37 
     38 struct dc_device_t;
     39 struct dc_device_vtable_t;
     40 
     41 typedef struct dc_device_vtable_t dc_device_vtable_t;
     42 
     43 struct dc_device_t {
     44 	const dc_device_vtable_t *vtable;
     45 	// Library context.
     46 	dc_context_t *context;
     47 	// Event notifications.
     48 	unsigned int event_mask;
     49 	dc_event_callback_t event_callback;
     50 	void *event_userdata;
     51 	// Cancellation support.
     52 	dc_cancel_callback_t cancel_callback;
     53 	void *cancel_userdata;
     54 	// Cached events for the parsers.
     55 	dc_event_devinfo_t devinfo;
     56 	dc_event_clock_t clock;
     57 };
     58 
     59 struct dc_device_vtable_t {
     60 	size_t size;
     61 
     62 	dc_family_t type;
     63 
     64 	dc_status_t (*set_fingerprint) (dc_device_t *device, const unsigned char data[], unsigned int size);
     65 
     66 	dc_status_t (*read) (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size);
     67 
     68 	dc_status_t (*write) (dc_device_t *device, unsigned int address, const unsigned char data[], unsigned int size);
     69 
     70 	dc_status_t (*dump) (dc_device_t *device, dc_buffer_t *buffer);
     71 
     72 	dc_status_t (*foreach) (dc_device_t *device, dc_dive_callback_t callback, void *userdata);
     73 
     74 	dc_status_t (*timesync) (dc_device_t *device, const dc_datetime_t *datetime);
     75 
     76 	dc_status_t (*close) (dc_device_t *device);
     77 };
     78 
     79 int
     80 dc_device_isinstance (dc_device_t *device, const dc_device_vtable_t *vtable);
     81 
     82 dc_device_t *
     83 dc_device_allocate (dc_context_t *context, const dc_device_vtable_t *vtable);
     84 
     85 void
     86 dc_device_deallocate (dc_device_t *device);
     87 
     88 void
     89 device_event_emit (dc_device_t *device, dc_event_type_t event, const void *data);
     90 
     91 void
     92 device_set_hw_id (dc_device_t *device, unsigned int hw_id);
     93 
     94 int
     95 device_is_cancelled (dc_device_t *device);
     96 
     97 dc_status_t
     98 device_dump_read (dc_device_t *device, unsigned int address, unsigned char data[], unsigned int size, unsigned int blocksize);
     99 
    100 #ifdef __cplusplus
    101 }
    102 #endif /* __cplusplus */
    103 #endif /* DEVICE_PRIVATE_H */