diff options
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 44 |
1 files changed, 36 insertions, 8 deletions
@@ -26,7 +26,7 @@ static inline int same_string(const char *a, const char *b) { - return !strcmp(a ? : "", b ? : ""); + return !strcmp(a ?: "", b ?: ""); } #include <libxml/tree.h> @@ -107,6 +107,12 @@ static inline int interpolate(int a, int b, int part, int whole) return rint(x / whole); } +static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit) { + depth_t depth; + depth.mm = po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000; + return depth; +} + struct sample { duration_t time; depth_t depth; @@ -364,6 +370,7 @@ struct dive_table { extern struct dive_table dive_table; extern int selected_dive; +extern unsigned int dc_number; #define current_dive (get_dive(selected_dive)) #define current_dc (get_dive_dc(current_dive, dc_number)) @@ -408,6 +415,8 @@ static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr) return dc; } +extern void make_first_dc(void); + /* * Iterate over each dive, with the first parameter being the index * iterator variable, and the second one being the dive one. @@ -429,7 +438,7 @@ static inline struct dive *get_dive_by_uemis_diveid(uint32_t diveid, uint32_t de int i; struct dive *dive; - for_each_dive(i, dive) { + for_each_dive (i, dive) { struct divecomputer *dc = &dive->dc; do { if (dc->diveid == diveid && dc->deviceid == deviceid) @@ -439,17 +448,17 @@ static inline struct dive *get_dive_by_uemis_diveid(uint32_t diveid, uint32_t de return NULL; } -static inline struct dive *get_dive_by_diveid(int id) +static inline struct dive *get_dive_by_uniq_id(int id) { int i; struct dive *dive = NULL; - for_each_dive(i, dive) { + for_each_dive (i, dive) { if (dive->id == id) break; } #ifdef DEBUG - if(dive == NULL){ + if (dive == NULL) { fprintf(stderr, "Invalid id %x passed to get_dive_by_diveid, try to fix the code\n", id); exit(1); } @@ -457,6 +466,24 @@ static inline struct dive *get_dive_by_diveid(int id) return dive; } +static inline int get_idx_by_uniq_id(int id) +{ + int i; + struct dive *dive = NULL; + + for_each_dive (i, dive) { + if (dive->id == id) + break; + } +#ifdef DEBUG + if (dive == NULL) { + fprintf(stderr, "Invalid id %x passed to get_dive_by_diveid, try to fix the code\n", id); + exit(1); + } +#endif + return i; +} + #ifdef __cplusplus extern "C" { #endif @@ -490,7 +517,7 @@ extern int export_dives_xslt(const char *filename, const bool selected, const ch struct git_oid; struct git_repository; -#define dummy_git_repository ((git_repository *) 3ul) /* Random bogus pointer, not NULL */ +#define dummy_git_repository ((git_repository *)3ul) /* Random bogus pointer, not NULL */ extern struct git_repository *is_git_repository(const char *filename, const char **branchp); extern int git_save_dives(struct git_repository *, const char *, bool select_only); extern int git_load_dives(struct git_repository *, const char *); @@ -536,7 +563,7 @@ extern unsigned int dc_airtemp(struct divecomputer *dc); extern unsigned int dc_watertemp(struct divecomputer *dc); extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded); extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded); -extern void renumber_dives(int nr); +extern void renumber_dives(int start_nr, bool selected_only); extern void copy_events(struct dive *s, struct dive *d); extern void copy_cylinders(struct dive *s, struct dive *d); extern void copy_samples(struct dive *s, struct dive *d); @@ -544,6 +571,7 @@ extern void copy_samples(struct dive *s, struct dive *d); extern void fill_default_cylinder(cylinder_t *cyl); extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx); extern void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name); +extern void remove_event(struct event *event); extern void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *mean, int *duration); extern int get_cylinder_index(struct dive *dive, struct event *ev); extern int nr_cylinders(struct dive *dive); @@ -674,7 +702,7 @@ extern double strtod_flags(const char *str, const char **ptr, unsigned int flags #define ascii_strtod(str, ptr) strtod_flags(str, ptr, STRTOD_ASCII) extern void set_save_userid_local(short value); -extern void set_userid(char* user_id); +extern void set_userid(char *user_id); #ifdef __cplusplus } |