diff options
-rw-r--r-- | Configure.mk | 10 | ||||
-rw-r--r-- | deco.c | 2 | ||||
-rw-r--r-- | dive.c | 10 | ||||
-rw-r--r-- | dive.h | 56 | ||||
-rw-r--r-- | divelist.c | 35 | ||||
-rw-r--r-- | equipment.c | 30 | ||||
-rw-r--r-- | file.c | 9 | ||||
-rw-r--r-- | file.h | 2 | ||||
-rw-r--r-- | info.c | 30 | ||||
-rw-r--r-- | info.h | 4 | ||||
-rw-r--r-- | libdivecomputer.c | 8 | ||||
-rw-r--r-- | libdivecomputer.h | 2 | ||||
-rw-r--r-- | macos.c | 12 | ||||
-rw-r--r-- | main.cpp | 3 | ||||
-rw-r--r-- | parse-xml.c | 119 | ||||
-rw-r--r-- | planner.c | 37 | ||||
-rw-r--r-- | planner.h | 4 | ||||
-rw-r--r-- | profile.c | 10 | ||||
-rw-r--r-- | qt-gui.cpp | 7 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 3 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 8 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 3 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 6 | ||||
-rw-r--r-- | save-xml.c | 8 | ||||
-rw-r--r-- | statistics.c | 6 | ||||
-rw-r--r-- | subsurfacestartup.c | 7 | ||||
-rw-r--r-- | time.c | 1 | ||||
-rw-r--r-- | uemis-downloader.c | 102 | ||||
-rw-r--r-- | uemis.c | 7 |
29 files changed, 382 insertions, 159 deletions
diff --git a/Configure.mk b/Configure.mk index 4039db454..eddd7c847 100644 --- a/Configure.mk +++ b/Configure.mk @@ -120,7 +120,7 @@ ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $( QTCXXFLAGS += -fPIE endif -LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) +# LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) @@ -135,13 +135,13 @@ LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) LIBXML2 = $(shell $(XML2CONFIG) --libs) LIBXSLT = $(shell $(XSLCONFIG) --libs) XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) -GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) -GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk+-2.0) +#GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) +#GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk+-2.0) XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) -LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) -LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) +#LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) +#LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null) ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) @@ -249,7 +249,7 @@ double restore_deco_state(char *data) return tissue_tolerance; } -unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth) +unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth) { unsigned int depth; double pressure_delta; @@ -2,7 +2,9 @@ /* maintains the internal dive list structure */ #include <string.h> #include <stdio.h> +#if 0 #include <glib/gi18n.h> +#endif #include "dive.h" @@ -481,7 +483,7 @@ static void sanitize_cylinder_info(struct dive *dive) } /* some events should never be thrown away */ -static gboolean is_potentially_redundant(struct event *event) +static bool is_potentially_redundant(struct event *event) { if (!strcmp(event->name, "gaschange")) return FALSE; @@ -1585,7 +1587,7 @@ static int likely_same_dive(struct dive *a, struct dive *b) * merges almost exact duplicates - something that happens easily * with overlapping dive downloads. */ -struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downloaded) +struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded) { if (likely_same_dive(a, b)) return merge_dives(a, b, 0, prefer_downloaded); @@ -1810,7 +1812,7 @@ static void join_dive_computers(struct divecomputer *res, struct divecomputer *a remove_redundant_dc(res, prefer_downloaded); } -struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean prefer_downloaded) +struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded) { struct dive *res = alloc_dive(); struct dive *dl = NULL; @@ -1877,7 +1879,7 @@ struct dive *find_dive_including(timestamp_t when) return NULL; } -gboolean dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset) +bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset) { return when - offset <= dive->when && dive->when + dive->duration.seconds <= when + offset; } @@ -5,9 +5,14 @@ #include <stdint.h> #include <time.h> #include <math.h> +#include <sys/param.h> +#if 0 #include <glib.h> #include <glib/gstdio.h> +#else /* this is stupid - this doesn't deal with translations anymore */ +#define _(arg) arg +#endif #include <libxml/tree.h> #include <libxslt/transform.h> @@ -18,8 +23,16 @@ extern "C" { #else #if __STDC_VERSION__ >= 199901L #include <stdbool.h> +#define TRUE true +#define FALSE false #else typedef int bool; +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif #endif #endif @@ -99,7 +112,7 @@ extern int dive_mask; * We don't actually use these all yet, so maybe they'll change, but * I made a number of types as guidelines. */ -typedef gint64 timestamp_t; +typedef int64_t timestamp_t; typedef struct { int seconds; @@ -257,7 +270,7 @@ static inline int get_he(const struct gasmix *mix) return mix->he.permille; } -static inline gboolean is_air(int o2, int he) +static inline bool is_air(int o2, int he) { return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1))); } @@ -279,7 +292,7 @@ struct sample { duration_t ndl; duration_t stoptime; depth_t stopdepth; - gboolean in_deco; + bool in_deco; int cns; int po2; }; @@ -296,7 +309,7 @@ struct event { struct event *next; duration_t time; int type, flags, value; - gboolean deleted; + bool deleted; char name[]; }; @@ -355,7 +368,7 @@ struct dive { dive_trip_t *divetrip; struct dive *next, **pprev; int selected; - gboolean downloaded; + bool downloaded; timestamp_t when; char *location; char *notes; @@ -394,7 +407,7 @@ static inline void copy_gps_location(struct dive *from, struct dive *to) } } -static inline int get_surface_pressure_in_mbar(const struct dive *dive, gboolean non_null) +static inline int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null) { int mbar = dive->surface_pressure.mbar; if (!mbar && non_null) @@ -576,16 +589,17 @@ static inline struct dive *get_dive_by_diveid(uint32_t diveid, uint32_t deviceid return NULL; } extern struct dive *find_dive_including(timestamp_t when); -extern gboolean dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset); +extern bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset); struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset); /* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */ extern int match_one_dc(struct divecomputer *a, struct divecomputer *b); +extern double ascii_strtod(char *, char **); extern void parse_xml_init(void); extern void parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error); extern void parse_xml_exit(void); -extern void set_filename(const char *filename, gboolean force); +extern void set_filename(const char *filename, bool force); extern int parse_dm4_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error); @@ -606,7 +620,7 @@ extern void show_yearly_stats(void); extern void update_dive(struct dive *new_dive); extern void save_dives(const char *filename); -extern void save_dives_logic(const char *filename, gboolean select_only); +extern void save_dives_logic(const char *filename, bool select_only); extern void save_dive(FILE *f, struct dive *dive); extern xsltStylesheetPtr get_stylesheet(const char *name); @@ -625,8 +639,8 @@ extern void finish_sample(struct divecomputer *dc); extern void sort_table(struct dive_table *table); extern struct dive *fixup_dive(struct dive *dive); extern unsigned int dc_airtemp(struct divecomputer *dc); -extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean prefer_downloaded); -extern struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downloaded); +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 copy_samples(struct dive *s, struct dive *d); @@ -635,7 +649,7 @@ extern void add_event(struct divecomputer *dc, int time, int type, int flags, in /* UI related protopypes */ -extern void report_error(GError* error); +// extern void report_error(GError* error); extern void add_cylinder_description(cylinder_type_t *); extern void add_weightsystem_description(weightsystem_t *); @@ -647,14 +661,14 @@ extern int evn_foreach(void (*callback)(const char *, int *, void *), void *data extern void clear_events(void); extern int add_new_dive(struct dive *dive); -extern gboolean edit_trip(dive_trip_t *trip); -extern int edit_dive_info(struct dive *dive, gboolean newdive); +extern bool edit_trip(dive_trip_t *trip); +extern int edit_dive_info(struct dive *dive, bool newdive); extern int edit_multi_dive_info(struct dive *single_dive); extern void dive_list_update_dives(void); extern void flush_divelist(struct dive *dive); extern void set_dc_nickname(struct dive *dive); -extern void set_autogroup(gboolean value); +extern void set_autogroup(bool value); extern int total_weight(struct dive *); #define DIVE_ERROR_PARSE 1 @@ -687,17 +701,17 @@ typedef enum { extern const char *existing_filename; extern const char *subsurface_gettext_domainpath(char *); -extern gboolean subsurface_os_feature_available(os_feature_t); -extern gboolean subsurface_launch_for_uri(const char *); -extern void subsurface_command_line_init(gint *, gchar ***); -extern void subsurface_command_line_exit(gint *, gchar ***); +extern bool subsurface_os_feature_available(os_feature_t); +extern bool subsurface_launch_for_uri(const char *); +extern void subsurface_command_line_init(int *, char ***); +extern void subsurface_command_line_exit(int *, char ***); #define FRACTION(n,x) ((unsigned)(n)/(x)),((unsigned)(n)%(x)) extern double add_segment(double pressure, const struct gasmix *gasmix, int period_in_seconds, int setpoint, const struct dive *dive); extern void clear_deco(double surface_pressure); extern void dump_tissues(void); -extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth); +extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth); extern void set_gf(short gflow, short gfhigh); extern void cache_deco_state(double, char **datap); extern double restore_deco_state(char *data); @@ -708,7 +722,7 @@ struct divedatapoint { int o2; int he; int po2; - gboolean entered; + bool entered; struct divedatapoint *next; }; diff --git a/divelist.c b/divelist.c index d5ee9b71a..5bc175170 100644 --- a/divelist.c +++ b/divelist.c @@ -38,7 +38,11 @@ #include <string.h> #include <time.h> #include <math.h> +#if 0 #include <glib/gi18n.h> +#else /* stupid */ +#define _(arg) arg +#endif #include <assert.h> #include <zip.h> #include <libxslt/transform.h> @@ -71,7 +75,7 @@ void dump_selection(void) } #endif -void set_autogroup(gboolean value) +void set_autogroup(bool value) { /* if we keep the UI paradigm, this needs to toggle * the checkbox on the autogroup menu item */ @@ -456,7 +460,7 @@ double init_decompression(struct dive *dive) int i, divenr = -1; unsigned int surface_time; timestamp_t when, lasttime = 0; - gboolean deco_init = FALSE; + bool deco_init = FALSE; double tissue_tolerance, surface_pressure; if (!dive) @@ -534,6 +538,7 @@ void update_cylinder_related_info(struct dive *dive) } } +#if USE_GTK_UI static void get_string(char **str, const char *s) { int len; @@ -563,6 +568,7 @@ void get_suit(struct dive *dive, char **str) { get_string(str, dive->suit); } +#endif #define MAX_DATE_STRING 256 /* caller needs to free the string */ @@ -606,13 +612,24 @@ char *get_trip_date_string(timestamp_t when, int nr) if (buffer) { struct tm tm; utc_mkdate(when, &tm); - snprintf(buffer, MAX_DATE_STRING, - /*++GETTEXT 60 char buffer monthname, year, nr dives */ - ngettext("%1$s %2$d (%3$d dive)", - "%1$s %2$d (%3$d dives)", nr), - monthname(tm.tm_mon), - tm.tm_year + 1900, - nr); + if (nr != 1) { + snprintf(buffer, MAX_DATE_STRING, +#if 0 + /*++GETTEXT 60 char buffer monthname, year, nr dives */ + ngettext("%1$s %2$d (%3$d dive)", + "%1$s %2$d (%3$d dives)", nr), +#else + _("%1$s %2$d (%3$d dives)"), +#endif + monthname(tm.tm_mon), + tm.tm_year + 1900, + nr); + } else { + snprintf(buffer, MAX_DATE_STRING, + _("%1$s %2$d (1 dive)"), + monthname(tm.tm_mon), + tm.tm_year + 1900); + } } return buffer; } diff --git a/equipment.c b/equipment.c index 2e41bf209..4880b49fc 100644 --- a/equipment.c +++ b/equipment.c @@ -12,8 +12,12 @@ #include <stdlib.h> #include <stdarg.h> #include <time.h> +#if 0 #include <glib/gi18n.h> - +#else /* stupid */ +#define _(arg) arg +#define N_(arg) arg +#endif #include "dive.h" #include "display.h" #if USE_GTK_UI @@ -186,7 +190,7 @@ static void set_weight_weight_spinbutton(struct ws_widget *ws_widget, int grams) static GtkTreeIter *found_match = NULL; static GtkTreeIter match_iter; -static gboolean match_desc(GtkTreeModel *model, GtkTreePath *path, +static bool match_desc(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { int match; @@ -492,7 +496,7 @@ void add_weightsystem_description(weightsystem_t *weightsystem) #endif /* USE_GTK_UI */ -gboolean cylinder_nodata(cylinder_t *cyl) +bool cylinder_nodata(cylinder_t *cyl) { return !cyl->type.size.mliter && !cyl->type.workingpressure.mbar && @@ -503,13 +507,13 @@ gboolean cylinder_nodata(cylinder_t *cyl) !cyl->end.mbar; } -static gboolean cylinder_nosamples(cylinder_t *cyl) +static bool cylinder_nosamples(cylinder_t *cyl) { return !cyl->sample_start.mbar && !cyl->sample_end.mbar; } -gboolean cylinder_none(void *_data) +bool cylinder_none(void *_data) { cylinder_t *cyl = _data; return cylinder_nodata(cyl) && cylinder_nosamples(cyl); @@ -517,19 +521,19 @@ gboolean cylinder_none(void *_data) /* descriptions are equal if they are both NULL or both non-NULL and the same text */ -static gboolean description_equal(const char *desc1, const char *desc2) +static bool description_equal(const char *desc1, const char *desc2) { return ((! desc1 && ! desc2) || (desc1 && desc2 && strcmp(desc1, desc2) == 0)); } -gboolean weightsystem_none(void *_data) +bool weightsystem_none(void *_data) { weightsystem_t *ws = _data; return !ws->weight.grams && !ws->description; } -gboolean no_weightsystems(weightsystem_t *ws) +bool no_weightsystems(weightsystem_t *ws) { int i; @@ -539,13 +543,13 @@ gboolean no_weightsystems(weightsystem_t *ws) return TRUE; } -static gboolean one_weightsystem_equal(weightsystem_t *ws1, weightsystem_t *ws2) +static bool one_weightsystem_equal(weightsystem_t *ws1, weightsystem_t *ws2) { return ws1->weight.grams == ws2->weight.grams && description_equal(ws1->description, ws2->description); } -gboolean weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2) +bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2) { int i; @@ -601,7 +605,7 @@ static void *ws_ptr(struct dive *dive, int idx) static void show_equipment(struct dive *dive, int max, struct equipment_list *equipment_list, void*(*ptr_function)(struct dive*, int), - gboolean(*none_function)(void *), + bool(*none_function)(void *), void(*set_one_function)(void*, GtkListStore*, GtkTreeIter *)) { int i, used; @@ -861,8 +865,8 @@ struct tank_info_t tank_info[100] = { { "HP130", .cuft = 130, .psi = 3442 }, /* Common European steel cylinders */ - { "3L 232 bar", .ml = 3000, .bar = 232 }, - { "3L 300 bar", .ml = 3000, .bar = 300 }, + { "3L 232 bar", .ml = 3000, .bar = 232 }, + { "3L 300 bar", .ml = 3000, .bar = 300 }, { "10L 300 bar", .ml = 10000, .bar = 300 }, { "12L 200 bar", .ml = 12000, .bar = 200 }, { "12L 232 bar", .ml = 12000, .bar = 232 }, @@ -4,7 +4,12 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#if 0 #include <glib/gi18n.h> +#else /* stupid */ +#define _(arg) arg +#define N_(arg) arg +#endif #include <zip.h> #include "dive.h" @@ -24,7 +29,7 @@ int readfile(const char *filename, struct memblock *mem) mem->buffer = NULL; mem->size = 0; - fd = g_open(filename, O_RDONLY | O_BINARY, 0); + fd = open(filename, O_RDONLY | O_BINARY, 0); if (fd < 0) return fd; ret = fstat(fd, &st); @@ -232,7 +237,7 @@ static int try_to_open_csv(const char *filename, struct memblock *mem, enum csv_ struct sample *sample; errno = 0; - val = g_ascii_strtod(p,&end); + val = strtod(p,&end); // FIXME == localization issue if (end == p) break; if (errno) @@ -6,7 +6,9 @@ struct memblock { size_t size; }; +#if 0 extern int try_to_open_cochran(const char *filename, struct memblock *mem, GError **error); +#endif extern int readfile(const char *filename, struct memblock *mem); #endif @@ -2,7 +2,7 @@ * * UI toolkit independent logic used for the info frame * - * gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text); + * bool gps_changed(struct dive *dive, struct dive *master, const char *gps_text); * void print_gps_coordinates(char *buffer, int len, int lat, int lon); * void save_equipment_data(struct dive *dive); * void update_equipment_data(struct dive *dive, struct dive *master); @@ -10,7 +10,7 @@ * const char *get_window_title(struct dive *dive); * char *evaluate_string_change(const char *newstring, char **textp, const char *master); * int text_changed(const char *old, const char *new); - * gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude); + * bool parse_gps_text(const char *gps_text, double *latitude, double *longitude); * int divename(char *buf, size_t size, struct dive *dive, char *trailer); */ #include <stdio.h> @@ -19,12 +19,19 @@ #include <time.h> #include <ctype.h> #include <sys/time.h> +#if 0 #include <glib/gi18n.h> +#else /* stupid */ +#define _(arg) arg +#define N_(arg) arg +#endif #include "dive.h" #include "display.h" #include "divelist.h" +#if USE_GTK_UI + /* old is NULL or a valid string, new is a valid string * NOTE: NULL and "" need to be treated as "unchanged" */ int text_changed(const char *old, const char *new) @@ -177,12 +184,12 @@ static int string_advance_cardinal(const char *text, const char *look) } /* this has to be done with UTF8 as people might want to enter the degree symbol */ -gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude) +bool parse_gps_text(const char *gps_text, double *latitude, double *longitude) { const char *text = gps_text; char *endptr; - gboolean south = FALSE; - gboolean west = FALSE; + bool south = FALSE; + bool west = FALSE; double parselat, parselong; gunichar degrees = UCS4_DEGREE; gunichar c; @@ -270,7 +277,7 @@ gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitud return TRUE; } -gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text) +bool gps_changed(struct dive *dive, struct dive *master, const char *gps_text) { double latitude, longitude; int latudeg, longudeg; @@ -295,13 +302,15 @@ gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_tex dive->longitude.udeg = longudeg; return TRUE; } - +#endif /* take latitude and longitude in udeg and print them in a human readable * form, without losing precision */ void print_gps_coordinates(char *buffer, int len, int lat, int lon) { unsigned int latdeg, londeg; +#if 0 double latmin, lonmin; +#endif char *lath, *lonh, dbuf_lat[32], dbuf_lon[32]; if (!lat && !lon) { @@ -314,11 +323,18 @@ void print_gps_coordinates(char *buffer, int len, int lat, int lon) lon = abs(lon); latdeg = lat / 1000000; londeg = lon / 1000000; +#if 0 latmin = (lat % 1000000) * 60.0 / 1000000.0; lonmin = (lon % 1000000) * 60.0 / 1000000.0; *dbuf_lat = *dbuf_lon = 0; g_ascii_formatd(dbuf_lat, sizeof(dbuf_lat), "%8.5f", latmin); g_ascii_formatd(dbuf_lon, sizeof(dbuf_lon), "%8.5f", lonmin); +#else + int ilatmin = (lat % 1000000) * 60; + int ilonmin = (lon % 1000000) * 60; + snprintf(dbuf_lat, sizeof(dbuf_lat), "%2d.%05d", ilatmin / 1000000, (ilatmin % 1000000) / 10); + snprintf(dbuf_lon, sizeof(dbuf_lon), "%2d.%05d", ilonmin / 1000000, (ilonmin % 1000000) / 10); +#endif if (!*dbuf_lat || !*dbuf_lon) { *buffer = 0; return; @@ -10,7 +10,7 @@ extern "C" { #endif -extern gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text); +extern bool gps_changed(struct dive *dive, struct dive *master, const char *gps_text); extern void print_gps_coordinates(char *buffer, int len, int lat, int lon); extern void save_equipment_data(struct dive *dive); extern void update_equipment_data(struct dive *dive, struct dive *master); @@ -18,7 +18,7 @@ extern void update_time_depth(struct dive *dive, struct dive *edited); extern const char *get_window_title(struct dive *dive); extern char *evaluate_string_change(const char *newstring, char **textp, const char *master); extern int text_changed(const char *old, const char * /*new is a c++ keyword*/); -extern gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude); +extern bool parse_gps_text(const char *gps_text, double *latitude, double *longitude); extern int divename(char *buf, size_t size, struct dive *dive, char *trailer); #ifdef __cplusplus diff --git a/libdivecomputer.c b/libdivecomputer.c index 01c356873..96ade89ef 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -1,7 +1,13 @@ #include <stdio.h> #include <unistd.h> #include <inttypes.h> +#include <string.h> +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#define N_(arg) arg +#endif #include "dive.h" #include "device.h" @@ -26,7 +32,7 @@ const char *progress_bar_text = ""; double progress_bar_fraction = 0.0; static int stoptime, stopdepth, ndl, po2, cns; -static gboolean in_deco, first_temp_is_air; +static bool in_deco, first_temp_is_air; #if USE_GTK_UI static GError *error(const char *fmt, ...) diff --git a/libdivecomputer.h b/libdivecomputer.h index 4bb0239e9..4165811ec 100644 --- a/libdivecomputer.h +++ b/libdivecomputer.h @@ -24,7 +24,7 @@ typedef struct device_data_t { dc_device_t *device; dc_context_t *context; int preexisting; - gboolean force_download; + bool force_download; } device_data_t; const char *do_libdivecomputer_import(device_data_t *data); @@ -169,8 +169,8 @@ const char *system_default_filename(void) char *buffer; int len; - home = g_get_home_dir(); - user = g_get_user_name(); + home = getenv("HOME"); + user = getenv("LOGNAME"); len = strlen(home) + strlen(user) + 45; buffer = malloc(len); snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user); @@ -242,22 +242,22 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, } #endif /* UES_GTK_UI */ -void subsurface_command_line_init(gint *argc, gchar ***argv) +void subsurface_command_line_init(int *argc, char ***argv) { /* this is a no-op */ } -void subsurface_command_line_exit(gint *argc, gchar ***argv) +void subsurface_command_line_exit(int *argc, char ***argv) { /* this is a no-op */ } -gboolean subsurface_os_feature_available(os_feature_t f) +int subsurface_os_feature_available(os_feature_t f) { return TRUE; } -gboolean subsurface_launch_for_uri(const char* uri) +int subsurface_launch_for_uri(const char* uri) { CFURLRef urlref = CFURLCreateWithBytes(NULL, uri, strlen(uri), kCFStringEncodingMacRoman, NULL); OSStatus status = LSOpenCFURLRef(urlref, NULL); @@ -18,6 +18,7 @@ int main(int argc, char **argv) { int i; bool no_filenames = true; +#if 0 const char *path; /* set up l18n - the search directory needs to change @@ -28,7 +29,7 @@ int main(int argc, char **argv) bindtextdomain("subsurface", path); bind_textdomain_codeset("subsurface", "utf-8"); textdomain("subsurface"); - +#endif setup_system_prefs(); prefs = default_prefs; diff --git a/parse-xml.c b/parse-xml.c index 66246570f..0ed3d11bd 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -11,7 +11,12 @@ #include <libxml/parserInternals.h> #include <libxml/tree.h> #include <libxslt/transform.h> +#if 0 #include <glib/gi18n.h> +#else /* stupid */ +#define _(arg) arg +#define N_(arg) arg +#endif #include<sqlite3.h> #include "dive.h" @@ -129,7 +134,7 @@ struct { const char *nickname, *serial_nr, *firmware; } dc; } cur_settings; -static gboolean in_settings = FALSE; +static bool in_settings = FALSE; static struct tm cur_tm; static int cur_cylinder_index, cur_ws_index; static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco; @@ -235,13 +240,101 @@ enum number_type { FLOAT }; +double ascii_strtod(char *str, char **ptr) +{ + char *p; + + if (ptr == (char **)0) + return atof (str); + + p = str; + + while (isspace (*p)) + ++p; + + if (*p == '+' || *p == '-') + ++p; + + /* INF or INFINITY. */ + if ((p[0] == 'i' || p[0] == 'I') + && (p[1] == 'n' || p[1] == 'N') + && (p[2] == 'f' || p[2] == 'F')) + { + if ((p[3] == 'i' || p[3] == 'I') + && (p[4] == 'n' || p[4] == 'N') + && (p[5] == 'i' || p[5] == 'I') + && (p[6] == 't' || p[6] == 'T') + && (p[7] == 'y' || p[7] == 'Y')) + { + *ptr = p + 7; + return atof (str); + } + else + { + *ptr = p + 3; + return atof (str); + } + } + + /* NAN or NAN(foo). */ + if ((p[0] == 'n' || p[0] == 'N') + && (p[1] == 'a' || p[1] == 'A') + && (p[2] == 'n' || p[2] == 'N')) + { + p += 3; + if (*p == '(') + { + ++p; + while (*p != '\0' && *p != ')') + ++p; + if (*p == ')') + ++p; + } + *ptr = p; + return atof (str); + } + + /* digits, with 0 or 1 periods in it. */ + if (isdigit (*p) || *p == '.') + { + int got_dot = 0; + while (isdigit (*p) || (!got_dot && *p == '.')) + { + if (*p == '.') + got_dot = 1; + ++p; + } + + /* Exponent. */ + if (*p == 'e' || *p == 'E') + { + int i; + i = 1; + if (p[i] == '+' || p[i] == '-') + ++i; + if (isdigit (p[i])) + { + while (isdigit (p[i])) + ++i; + *ptr = p + i; + return atof (str); + } + } + *ptr = p; + return atof (str); + } + /* Didn't find any digits. Doesn't look like a number. */ + *ptr = str; + return 0.0; +} + static enum number_type parse_float(char *buffer, double *res, char **endp) { double val; - static gboolean first_time = TRUE; + static bool first_time = TRUE; errno = 0; - val = g_ascii_strtod(buffer, endp); + val = ascii_strtod(buffer, endp); if (errno || *endp == buffer) return NEITHER; if (**endp == ',') { @@ -255,7 +348,7 @@ static enum number_type parse_float(char *buffer, double *res, char **endp) } /* Try again */ **endp = '.'; - val = g_ascii_strtod(buffer, endp); + val = ascii_strtod(buffer, endp); } } @@ -436,7 +529,7 @@ static void percent(char *buffer, void *_fraction) case FLOAT: /* Turn fractions into percent unless explicit.. */ if (val <= 1.0) { - while (g_ascii_isspace(*end)) + while (isspace(*end)) end++; if (*end != '%') val *= 100; @@ -487,10 +580,10 @@ static void utf8_string(char *buffer, void *_res) { int size; char *res; - while (g_ascii_isspace(*buffer)) + while (isspace(*buffer)) buffer++; size = strlen(buffer); - while (size && g_ascii_isspace(buffer[size-1])) + while (size && isspace(buffer[size-1])) size--; if (!size) return; @@ -521,7 +614,7 @@ static void get_rating(char *buffer, void *_i) static void double_to_permil(char *buffer, void *_i) { int *i = _i; - *i = g_ascii_strtod(buffer, NULL) * 1000.0 + 0.5; + *i = ascii_strtod(buffer, NULL) * 1000.0 + 0.5; } static void hex_value(char *buffer, void *_i) @@ -976,7 +1069,7 @@ static degrees_t parse_degrees(char *buf, char **end) int sign = 1, decimals = 6, value = 0; degrees_t ret; - while (g_ascii_isspace(*buf)) + while (isspace(*buf)) buf++; switch (*buf) { case '-': @@ -1181,7 +1274,7 @@ static void try_to_fill_trip(dive_trip_t **dive_trip_p, const char *name, char * * to make a dive valid, but if it has no location, no date and no * samples I'm pretty sure it's useless. */ -static gboolean is_dive(void) +static bool is_dive(void) { return (cur_dive && (cur_dive->location || cur_dive->when || cur_dive->dc.samples)); @@ -1863,7 +1956,11 @@ static xsltStylesheetPtr try_get_stylesheet(const char *path, int len, const cha return NULL; memcpy(filename, path, len); - filename[len] = G_DIR_SEPARATOR; +#ifdef WIN32 + filename[len] = '\\'; +#else + filename[len] = '/'; +#endif memcpy(filename + len + 1, name, namelen+1); ret = NULL; @@ -5,9 +5,14 @@ * (c) Dirk Hohndel 2013 */ #include <libintl.h> +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#endif #include <unistd.h> #include <ctype.h> +#include <string.h> #include "dive.h" #include "divelist.h" #include "planner.h" @@ -47,7 +52,7 @@ void dump_plan(struct diveplan *diveplan) } #endif -void set_last_stop(gboolean last_stop_6m) +void set_last_stop(bool last_stop_6m) { if (last_stop_6m == TRUE) decostoplevels[1] = 6000; @@ -69,7 +74,7 @@ void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he) /* simple helper function to compare two permille values with * (rounded) percent granularity */ -static inline gboolean match_percent(int a, int b) +static inline bool match_percent(int a, int b) { return (a + 5) / 10 == (b + 5) / 10; } @@ -337,7 +342,7 @@ struct divedatapoint *get_nth_dp(struct diveplan *diveplan, int idx) } /* return -1 to warn about potentially very long calculation */ -int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel) +int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, bool is_rel) { struct divedatapoint *pdp, *dp = get_nth_dp(diveplan, idx); if (idx > 0) { @@ -803,7 +808,7 @@ int validate_gas(const char *text, int *o2_p, int *he_p) if (!text) return 0; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; if (!*text) @@ -820,7 +825,7 @@ int validate_gas(const char *text, int *o2_p, int *he_p) } /* We don't want any extra crud */ - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; if (*text) return 0; @@ -843,19 +848,19 @@ int validate_time(const char *text, int *sec_p, int *rel_p) if (!text) return 0; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; rel = 1; if (*text == '+') { rel = 1; text++; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; } else if (*text == '@') { rel = 0; text++; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; } @@ -892,7 +897,7 @@ int validate_time(const char *text, int *sec_p, int *rel_p) } /* Maybe we should accept 'min' at the end? */ - if (g_ascii_isspace(*text)) + if (isspace(*text)) text++; if (*text) return 0; @@ -913,7 +918,7 @@ int validate_depth(const char *text, int *mm_p) if (depth < 0) return 0; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; imperial = get_units()->length == FEET; @@ -924,7 +929,7 @@ int validate_depth(const char *text, int *mm_p) imperial = 1; text += 2; } - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; if (*text) return 0; @@ -952,10 +957,10 @@ int validate_po2(const char *text, int *mbar_po2) if (po2 < 0) return 0; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; if (*text) return 0; @@ -975,7 +980,7 @@ int validate_volume(const char *text, int *sac) if (volume < 0) return 0; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; imperial = get_units()->volume == CUFT; @@ -986,11 +991,11 @@ int validate_volume(const char *text, int *sac) imperial = 1; text += 4; } - while (g_ascii_isspace(*text) || *text == '/') + while (isspace(*text) || *text == '/') text++; if (!strncasecmp(text, _("min"), 3)) text += 3; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; if (*text) return 0; @@ -14,9 +14,9 @@ extern int validate_po2(const char *text, int *mbar_po2); extern int validate_volume(const char *text, int *sac); extern timestamp_t current_time_notz(void); extern void show_planned_dive(char **error_string_p); -extern int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel); +extern int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, bool is_rel); extern void add_po2_to_nth_dp(struct diveplan *diveplan, int idx, int po2); -extern void set_last_stop(gboolean last_stop_6m); +extern void set_last_stop(bool last_stop_6m); extern struct diveplan diveplan; extern struct dive *planned_dive; @@ -2,8 +2,14 @@ /* creates all the necessary data for drawing the dive profile * uses cairo to draw it */ +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#define N_(arg) arg +#endif #include <limits.h> +#include <string.h> #include "dive.h" #include "display.h" @@ -931,7 +937,7 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer int i, cylinderindex; pr_track_t *track_pr[MAX_CYLINDERS] = {NULL, }; pr_track_t *current; - gboolean missing_pr = FALSE; + bool missing_pr = FALSE; cylinderindex = -1; current = NULL; @@ -1210,7 +1216,7 @@ struct divecomputer *select_dc(struct divecomputer *main) } static void plot_string(struct plot_data *entry, char *buf, int bufsize, - int depth, int pressure, int temp, gboolean has_ndl) + int depth, int pressure, int temp, bool has_ndl) { int pressurevalue, mod, ead, end, eadd; const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit; diff --git a/qt-gui.cpp b/qt-gui.cpp index 701a88b9e..8f1c85d70 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -1,7 +1,9 @@ /* qt-gui.cpp */ /* Qt UI implementation */ #include <libintl.h> +#if 0 #include <glib/gi18n.h> +#endif #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -64,7 +66,10 @@ Translator::Translator(QObject *parent): QString Translator::translate(const char *context, const char *sourceText, const char *disambiguation) const { + return sourceText; +#if 0 return gettext(sourceText); +#endif } static QApplication *application = NULL; @@ -141,7 +146,7 @@ void exit_ui(void) free((void *)default_dive_computer_device); } -void set_filename(const char *filename, gboolean force) +void set_filename(const char *filename, bool force) { if (!force && existing_filename) return; diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index ee81c6996..acb36e63e 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -8,7 +8,6 @@ #include <QDateTime> #include "dive.h" -#include "ui_diveplanner.h" class QListView; class QStringListModel; @@ -202,6 +201,8 @@ private: int dpMaxTime; // this is the time of the dive calculated by the deco. }; +#include "ui_diveplanner.h" + class DivePlannerWidget : public QWidget { Q_OBJECT public: diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 2498a0d97..b19638b69 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -696,8 +696,12 @@ void MainTab::on_notes_textChanged() void MainTab::on_coordinates_textChanged(const QString& text) { QByteArray textByteArray = text.toLocal8Bit(); - gboolean gpsChanged = FALSE; - EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data())); + bool gpsChanged = FALSE; + // EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data())); + // FIXME + // FIXME + // FIXME + // FIXME if (gpsChanged) { markChangedWidget(ui.coordinates); } else { diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 84b1bc50b..bd2d9d0fb 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -20,7 +20,6 @@ #include "divelistview.h" #include "starwidget.h" -#include "glib.h" #include "../dive.h" #include "../divelist.h" #include "../pref.h" @@ -36,8 +35,6 @@ #include "about.h" #include "printdialog.h" -#include "glib/gi18n.h" - static MainWindow* instance = 0; MainWindow* mainWindow() diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index f0d33e53f..cd6273087 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -13,7 +13,7 @@ #include "../divelist.h" struct dive_table gps_location_table; -static gboolean merge_locations_into_dives(void); +static bool merge_locations_into_dives(void); SubsurfaceWebServices* SubsurfaceWebServices::instance() { @@ -177,7 +177,7 @@ unsigned int SubsurfaceWebServices::download_dialog_parse_response(const QByteAr return status; } -static gboolean is_automatic_fix(struct dive *gpsfix) +static bool is_automatic_fix(struct dive *gpsfix) { if (gpsfix && gpsfix->location && (!strcmp(gpsfix->location, "automatic fix") || @@ -188,7 +188,7 @@ static gboolean is_automatic_fix(struct dive *gpsfix) #define SAME_GROUP 6 * 3600 // six hours -static gboolean merge_locations_into_dives(void) +static bool merge_locations_into_dives(void) { int i, nr = 0, changed = 0; struct dive *gpsfix, *last_named_fix = NULL, *dive; diff --git a/save-xml.c b/save-xml.c index 454da8484..6d95cb4f7 100644 --- a/save-xml.c +++ b/save-xml.c @@ -125,12 +125,12 @@ static void show_utf8(FILE *f, const char *text, const char *pre, const char *po if (!text) return; - while (g_ascii_isspace(*text)) + while (isspace(*text)) text++; len = strlen(text); if (!len) return; - while (len && g_ascii_isspace(text[len-1])) + while (len && isspace(text[len-1])) len--; /* FIXME! Quoting! */ fputs(pre, f); @@ -549,13 +549,13 @@ void save_dives(const char *filename) save_dives_logic(filename, FALSE); } -void save_dives_logic(const char *filename, const gboolean select_only) +void save_dives_logic(const char *filename, const bool select_only) { int i; struct dive *dive; dive_trip_t *trip; - FILE *f = g_fopen(filename, "w"); + FILE *f = fopen(filename, "w"); if (!f) return; diff --git a/statistics.c b/statistics.c index 83675cf22..1eb6669df 100644 --- a/statistics.c +++ b/statistics.c @@ -6,7 +6,13 @@ * void process_all_dives(struct dive *dive, struct dive **prev_dive); * void get_selected_dives_text(char *buffer, int size); */ +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#define N_(arg) arg +#endif +#include <string.h> #include <ctype.h> #include "dive.h" diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 741606ee4..eb3d5fc73 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -1,7 +1,12 @@ #include "subsurfacestartup.h" #include <stdbool.h> +#include <string.h> +#if 0 #include <glib/gi18n.h> - +#else /* stupid */ +#define _(arg) arg +#define N_(arg) arg +#endif struct preferences prefs; struct preferences default_prefs = { .units = SI_UNITS, @@ -1,4 +1,3 @@ -#include <glib/gi18n.h> #include <string.h> #include "dive.h" diff --git a/uemis-downloader.c b/uemis-downloader.c index 9864cfe66..647b57d8a 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -13,11 +13,17 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <dirent.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <string.h> +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#define N_(arg) arg +#endif #include "libdivecomputer.h" #include "uemis.h" @@ -55,7 +61,7 @@ static int mbuf_size = 0; struct argument_block { const char *mountpath; progressbar_t *progress; - gboolean force_download; + bool force_download; }; #endif @@ -98,7 +104,7 @@ static void uemis_ts(char *buffer, void *_when) /* float minutes */ static void uemis_duration(char *buffer, duration_t *duration) { - duration->seconds = g_ascii_strtod(buffer, NULL) * 60 + 0.5; + duration->seconds = ascii_strtod(buffer, NULL) * 60 + 0.5; } /* int cm */ @@ -135,7 +141,7 @@ static void uemis_add_string(char *buffer, char **text) static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid) { weight->weight.grams = uemis_get_weight_unit(diveid) ? - lbs_to_grams(g_ascii_strtod(buffer, NULL)) : g_ascii_strtod(buffer, NULL) * 1000; + lbs_to_grams(ascii_strtod(buffer, NULL)) : ascii_strtod(buffer, NULL) * 1000; weight->description = strdup(_("unknown")); } @@ -172,18 +178,36 @@ static long bytes_available(int file) static int number_of_file(char *path) { int count = 0; - GDir *dir = g_dir_open(path, 0, NULL); - while (g_dir_read_name(dir)) - count++; - g_dir_close(dir); + DIR * dirp; + struct dirent * entry; + + dirp = opendir(path); + while ((entry = readdir(dirp)) != NULL) { + if (entry->d_type == DT_REG) { /* If the entry is a regular file */ + count++; + } + } + closedir(dirp); return count; } +static char *build_filename(const char *path, const char *name) +{ + int len = strlen(path) + strlen(name) + 1; + char *buf = malloc(len); +#if WIN32 + snprintf(buf, len, "%s\%s", path, name); +#else + snprintf(buf, len, "%s/%s", path, name); +#endif + return buf; +} + /* Check if there's a req.txt file and get the starting filenr from it. * Test for the maximum number of ANS files (I believe this is always * 4000 but in case there are differences depending on firmware, this * code is easy enough */ -static gboolean uemis_init(const char *path) +static bool uemis_init(const char *path) { char *ans_path; int i; @@ -191,8 +215,8 @@ static gboolean uemis_init(const char *path) if (!path) return FALSE; /* let's check if this is indeed a Uemis DC */ - reqtxt_path = g_build_filename(path, "/req.txt", NULL); - reqtxt_file = g_open(reqtxt_path, O_RDONLY, 0666); + reqtxt_path = build_filename(path,"req.txt"); + reqtxt_file = open(reqtxt_path, O_RDONLY, 0666); if (!reqtxt_file) { #if UEMIS_DEBUG & 1 fprintf(debugfile, ":EE req.txt can't be opened\n"); @@ -218,9 +242,9 @@ static gboolean uemis_init(const char *path) /* It would be nice if we could simply go back to the first set of * ANS files. But with a FAT filesystem that isn't possible */ - ans_path = g_build_filename(path, "ANS", NULL); + ans_path = build_filename(path, "ANS"); number_of_files = number_of_file(ans_path); - g_free(ans_path); + free(ans_path); /* initialize the array in which we collect the answers */ for (i = 0; i < NUM_PARAM_BUFS; i++) param_buff[i] = ""; @@ -274,7 +298,7 @@ static char *next_segment(char *buf, int *offset, int size) { int i = *offset; int seg_size; - gboolean done = FALSE; + bool done = FALSE; char *segment; while (!done) { @@ -319,7 +343,7 @@ static void buffer_add(char **buffer, int *buffer_size, char *buf) } /* are there more ANS files we can check? */ -static gboolean next_file(int max) +static bool next_file(int max) { if (filenr >= max) return FALSE; @@ -380,7 +404,7 @@ static void uemis_increased_timeout(int *timeout) } /* send a request to the dive computer and collect the answer */ -static gboolean uemis_get_answer(const char *path, char *request, int n_param_in, +static bool uemis_get_answer(const char *path, char *request, int n_param_in, int n_param_out, char **error_text) { int i = 0, file_length; @@ -388,17 +412,17 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in char fl[13]; char tmp[101]; char *what = _("data"); - gboolean searching = TRUE; - gboolean assembling_mbuf = FALSE; - gboolean ismulti = FALSE; - gboolean found_answer = FALSE; - gboolean more_files = TRUE; - gboolean answer_in_mbuf = FALSE; + bool searching = TRUE; + bool assembling_mbuf = FALSE; + bool ismulti = FALSE; + bool found_answer = FALSE; + bool more_files = TRUE; + bool answer_in_mbuf = FALSE; char *ans_path; int ans_file; int timeout = UEMIS_LONG_TIMEOUT; - reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666); + reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666); snprintf(sb, BUFLEN, "n%04d12345678", filenr); str_append_with_delim(sb, request); for (i = 0; i < n_param_in; i++) @@ -438,8 +462,8 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in return FALSE; progress_bar_fraction = filenr / 4000.0; snprintf(fl, 13, "ANS%d.TXT", filenr - 1); - ans_path = g_build_filename(path, "ANS", fl, NULL); - ans_file = g_open(ans_path, O_RDONLY, 0666); + ans_path = build_filename(build_filename(path, "ANS"), fl); + ans_file = open(ans_path, O_RDONLY, 0666); read(ans_file, tmp, 100); close(ans_file); #if UEMIS_DEBUG & 8 @@ -453,7 +477,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in pbuf[3] = 0; fprintf(debugfile, "::t %s \"%s...\"\n", ans_path, pbuf); #endif - g_free(ans_path); + free(ans_path); if (tmp[0] == '1') { searching = FALSE; if (tmp[1] == 'm') { @@ -468,7 +492,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in more_files = FALSE; assembling_mbuf = FALSE; } - reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666); + reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666); trigger_response(reqtxt_file, "n", filenr, file_length); } } else { @@ -478,15 +502,15 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in assembling_mbuf = FALSE; searching = FALSE; } - reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666); + reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666); trigger_response(reqtxt_file, "r", filenr, file_length); uemis_increased_timeout(&timeout); } if (ismulti && more_files && tmp[0] == '1') { int size; snprintf(fl, 13, "ANS%d.TXT", assembling_mbuf ? filenr - 2 : filenr - 1); - ans_path = g_build_filename(path, "ANS", fl, NULL); - ans_file = g_open(ans_path, O_RDONLY, 0666); + ans_path = build_filename(build_filename(path, "ANS"), fl); + ans_file = open(ans_path, O_RDONLY, 0666); size = bytes_available(ans_file); if (size > 3) { char *buf = malloc(size - 2); @@ -509,8 +533,8 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in if (!ismulti) { snprintf(fl, 13, "ANS%d.TXT", filenr - 1); - ans_path = g_build_filename(path, "ANS", fl, NULL); - ans_file = g_open(ans_path, O_RDONLY, 0666); + ans_path = build_filename(build_filename(path, "ANS"), fl); + ans_file = open(ans_path, O_RDONLY, 0666); size = bytes_available(ans_file); if (size > 3) { buf = malloc(size - 2); @@ -575,9 +599,9 @@ static void parse_divespot(char *buf) "%s%s", len ? ", " : "", val); } else if (!strcmp(type, "float")) { if (!strcmp(tag, "longitude")) - longitude = g_ascii_strtod(val, NULL); + longitude = ascii_strtod(val, NULL); else if (!strcmp(tag, "latitude")) - latitude = g_ascii_strtod(val, NULL); + latitude = ascii_strtod(val, NULL); } } while (tag && *tag); uemis_set_divelocation(divespot, locationstring, latitude, longitude); @@ -637,14 +661,14 @@ static void parse_tag(struct dive *dive, char *tag, char *val) * index into yet another data store that we read out later. In order to * correctly populate the location and gps data from that we need to remember * the adresses of those fields for every dive that references the divespot. */ -static void process_raw_buffer(uint32_t deviceid, char *inbuf, char **max_divenr, gboolean keep_number, int *for_dive) +static void process_raw_buffer(uint32_t deviceid, char *inbuf, char **max_divenr, bool keep_number, int *for_dive) { char *buf = strdup(inbuf); char *tp, *bp, *tag, *type, *val; - gboolean done = FALSE; + bool done = FALSE; int inbuflen = strlen(inbuf); char *endptr = buf + inbuflen; - gboolean log = FALSE; + bool log = FALSE; char *sections[10]; int s, nr_sections = 0; struct dive *dive = NULL; @@ -767,7 +791,7 @@ char *do_uemis_import(const char *mountpath, short force_download) char *deviceid = NULL; char *result = NULL; char *endptr; - gboolean success, keep_number = FALSE, once = TRUE; + bool success, keep_number = FALSE, once = TRUE; if (dive_table.nr == 0) keep_number = TRUE; @@ -898,7 +922,7 @@ static void *pthread_wrapper(void *_data) /* this simply ends the dialog without a response and asks not to be fired again * as we set this function up in every loop while uemis_download is waiting for * the download to finish */ -static gboolean timeout_func(gpointer _data) +static bool timeout_func(gpointer _data) { GtkDialog *dialog = _data; if (!import_thread_cancelled) @@ -907,7 +931,7 @@ static gboolean timeout_func(gpointer _data) } GError *uemis_download(const char *mountpath, progressbar_t *progress, - GtkDialog *dialog, gboolean force_download) + GtkDialog *dialog, bool force_download) { pthread_t pthread; void *retval; @@ -12,7 +12,12 @@ #include <string.h> #include <stdint.h> #include <stdlib.h> +#if 0 #include <glib/gi18n.h> +#else +#define _(arg) arg +#define N_(arg) arg +#endif #define __USE_XOPEN #include <time.h> #include <math.h> @@ -166,8 +171,10 @@ void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_ void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude) { struct uemis_helper *hp = uemis_helper; +#if 0 /* seems overkill */ if (!g_utf8_validate(text, -1, NULL)) return; +#endif while (hp) { if (hp->divespot == divespot && hp->location) { *hp->location = strdup(text); |