First steps towards removing glib dependencies

- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-10-05 00:29:09 -07:00
parent 3e0ecb5ff6
commit 4b12f28ca4
29 changed files with 382 additions and 159 deletions

View file

@ -120,7 +120,7 @@ ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(
QTCXXFLAGS += -fPIE QTCXXFLAGS += -fPIE
endif 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)) ifneq (,$(filter $(UNAME),linux kfreebsd gnu))
LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0)
GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
@ -135,13 +135,13 @@ LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
LIBXML2 = $(shell $(XML2CONFIG) --libs) LIBXML2 = $(shell $(XML2CONFIG) --libs)
LIBXSLT = $(shell $(XSLCONFIG) --libs) LIBXSLT = $(shell $(XSLCONFIG) --libs)
XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) #GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk+-2.0) #GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk+-2.0)
XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) XSLCFLAGS = $(shell $(XSLCONFIG) --cflags)
OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null)
LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null)
LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) #LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4)
LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) #LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4)
LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null) LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null)
ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null))

2
deco.c
View file

@ -249,7 +249,7 @@ double restore_deco_state(char *data)
return tissue_tolerance; 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; unsigned int depth;
double pressure_delta; double pressure_delta;

10
dive.c
View file

@ -2,7 +2,9 @@
/* maintains the internal dive list structure */ /* maintains the internal dive list structure */
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#endif
#include "dive.h" #include "dive.h"
@ -481,7 +483,7 @@ static void sanitize_cylinder_info(struct dive *dive)
} }
/* some events should never be thrown away */ /* 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")) if (!strcmp(event->name, "gaschange"))
return FALSE; 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 * merges almost exact duplicates - something that happens easily
* with overlapping dive downloads. * 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)) if (likely_same_dive(a, b))
return merge_dives(a, b, 0, prefer_downloaded); 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); 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 *res = alloc_dive();
struct dive *dl = NULL; struct dive *dl = NULL;
@ -1877,7 +1879,7 @@ struct dive *find_dive_including(timestamp_t when)
return NULL; 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; return when - offset <= dive->when && dive->when + dive->duration.seconds <= when + offset;
} }

56
dive.h
View file

@ -5,9 +5,14 @@
#include <stdint.h> #include <stdint.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <sys/param.h>
#if 0
#include <glib.h> #include <glib.h>
#include <glib/gstdio.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 <libxml/tree.h>
#include <libxslt/transform.h> #include <libxslt/transform.h>
@ -18,8 +23,16 @@ extern "C" {
#else #else
#if __STDC_VERSION__ >= 199901L #if __STDC_VERSION__ >= 199901L
#include <stdbool.h> #include <stdbool.h>
#define TRUE true
#define FALSE false
#else #else
typedef int bool; typedef int bool;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#endif #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 * We don't actually use these all yet, so maybe they'll change, but
* I made a number of types as guidelines. * I made a number of types as guidelines.
*/ */
typedef gint64 timestamp_t; typedef int64_t timestamp_t;
typedef struct { typedef struct {
int seconds; int seconds;
@ -257,7 +270,7 @@ static inline int get_he(const struct gasmix *mix)
return mix->he.permille; 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))); 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 ndl;
duration_t stoptime; duration_t stoptime;
depth_t stopdepth; depth_t stopdepth;
gboolean in_deco; bool in_deco;
int cns; int cns;
int po2; int po2;
}; };
@ -296,7 +309,7 @@ struct event {
struct event *next; struct event *next;
duration_t time; duration_t time;
int type, flags, value; int type, flags, value;
gboolean deleted; bool deleted;
char name[]; char name[];
}; };
@ -355,7 +368,7 @@ struct dive {
dive_trip_t *divetrip; dive_trip_t *divetrip;
struct dive *next, **pprev; struct dive *next, **pprev;
int selected; int selected;
gboolean downloaded; bool downloaded;
timestamp_t when; timestamp_t when;
char *location; char *location;
char *notes; 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; int mbar = dive->surface_pressure.mbar;
if (!mbar && non_null) if (!mbar && non_null)
@ -576,16 +589,17 @@ static inline struct dive *get_dive_by_diveid(uint32_t diveid, uint32_t deviceid
return NULL; return NULL;
} }
extern struct dive *find_dive_including(timestamp_t when); 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); 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) */ /* 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 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_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_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error);
extern void parse_xml_exit(void); 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); 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 update_dive(struct dive *new_dive);
extern void save_dives(const char *filename); 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 void save_dive(FILE *f, struct dive *dive);
extern xsltStylesheetPtr get_stylesheet(const char *name); 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 void sort_table(struct dive_table *table);
extern struct dive *fixup_dive(struct dive *dive); extern struct dive *fixup_dive(struct dive *dive);
extern unsigned int dc_airtemp(struct divecomputer *dc); 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 *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, gboolean 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 nr);
extern void copy_samples(struct dive *s, struct dive *d); 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 */ /* 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_cylinder_description(cylinder_type_t *);
extern void add_weightsystem_description(weightsystem_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 void clear_events(void);
extern int add_new_dive(struct dive *dive); extern int add_new_dive(struct dive *dive);
extern gboolean edit_trip(dive_trip_t *trip); extern bool edit_trip(dive_trip_t *trip);
extern int edit_dive_info(struct dive *dive, gboolean newdive); extern int edit_dive_info(struct dive *dive, bool newdive);
extern int edit_multi_dive_info(struct dive *single_dive); extern int edit_multi_dive_info(struct dive *single_dive);
extern void dive_list_update_dives(void); extern void dive_list_update_dives(void);
extern void flush_divelist(struct dive *dive); extern void flush_divelist(struct dive *dive);
extern void set_dc_nickname(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 *); extern int total_weight(struct dive *);
#define DIVE_ERROR_PARSE 1 #define DIVE_ERROR_PARSE 1
@ -687,17 +701,17 @@ typedef enum {
extern const char *existing_filename; extern const char *existing_filename;
extern const char *subsurface_gettext_domainpath(char *); extern const char *subsurface_gettext_domainpath(char *);
extern gboolean subsurface_os_feature_available(os_feature_t); extern bool subsurface_os_feature_available(os_feature_t);
extern gboolean subsurface_launch_for_uri(const char *); extern bool subsurface_launch_for_uri(const char *);
extern void subsurface_command_line_init(gint *, gchar ***); extern void subsurface_command_line_init(int *, char ***);
extern void subsurface_command_line_exit(gint *, gchar ***); extern void subsurface_command_line_exit(int *, char ***);
#define FRACTION(n,x) ((unsigned)(n)/(x)),((unsigned)(n)%(x)) #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 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 clear_deco(double surface_pressure);
extern void dump_tissues(void); 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 set_gf(short gflow, short gfhigh);
extern void cache_deco_state(double, char **datap); extern void cache_deco_state(double, char **datap);
extern double restore_deco_state(char *data); extern double restore_deco_state(char *data);
@ -708,7 +722,7 @@ struct divedatapoint {
int o2; int o2;
int he; int he;
int po2; int po2;
gboolean entered; bool entered;
struct divedatapoint *next; struct divedatapoint *next;
}; };

View file

@ -38,7 +38,11 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#endif
#include <assert.h> #include <assert.h>
#include <zip.h> #include <zip.h>
#include <libxslt/transform.h> #include <libxslt/transform.h>
@ -71,7 +75,7 @@ void dump_selection(void)
} }
#endif #endif
void set_autogroup(gboolean value) void set_autogroup(bool value)
{ {
/* if we keep the UI paradigm, this needs to toggle /* if we keep the UI paradigm, this needs to toggle
* the checkbox on the autogroup menu item */ * the checkbox on the autogroup menu item */
@ -456,7 +460,7 @@ double init_decompression(struct dive *dive)
int i, divenr = -1; int i, divenr = -1;
unsigned int surface_time; unsigned int surface_time;
timestamp_t when, lasttime = 0; timestamp_t when, lasttime = 0;
gboolean deco_init = FALSE; bool deco_init = FALSE;
double tissue_tolerance, surface_pressure; double tissue_tolerance, surface_pressure;
if (!dive) 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) static void get_string(char **str, const char *s)
{ {
int len; int len;
@ -563,6 +568,7 @@ void get_suit(struct dive *dive, char **str)
{ {
get_string(str, dive->suit); get_string(str, dive->suit);
} }
#endif
#define MAX_DATE_STRING 256 #define MAX_DATE_STRING 256
/* caller needs to free the string */ /* caller needs to free the string */
@ -606,13 +612,24 @@ char *get_trip_date_string(timestamp_t when, int nr)
if (buffer) { if (buffer) {
struct tm tm; struct tm tm;
utc_mkdate(when, &tm); utc_mkdate(when, &tm);
snprintf(buffer, MAX_DATE_STRING, if (nr != 1) {
/*++GETTEXT 60 char buffer monthname, year, nr dives */ snprintf(buffer, MAX_DATE_STRING,
ngettext("%1$s %2$d (%3$d dive)", #if 0
"%1$s %2$d (%3$d dives)", nr), /*++GETTEXT 60 char buffer monthname, year, nr dives */
monthname(tm.tm_mon), ngettext("%1$s %2$d (%3$d dive)",
tm.tm_year + 1900, "%1$s %2$d (%3$d dives)", nr),
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; return buffer;
} }

View file

@ -12,8 +12,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#define N_(arg) arg
#endif
#include "dive.h" #include "dive.h"
#include "display.h" #include "display.h"
#if USE_GTK_UI #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 *found_match = NULL;
static GtkTreeIter match_iter; static GtkTreeIter match_iter;
static gboolean match_desc(GtkTreeModel *model, GtkTreePath *path, static bool match_desc(GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer data) GtkTreeIter *iter, gpointer data)
{ {
int match; int match;
@ -492,7 +496,7 @@ void add_weightsystem_description(weightsystem_t *weightsystem)
#endif /* USE_GTK_UI */ #endif /* USE_GTK_UI */
gboolean cylinder_nodata(cylinder_t *cyl) bool cylinder_nodata(cylinder_t *cyl)
{ {
return !cyl->type.size.mliter && return !cyl->type.size.mliter &&
!cyl->type.workingpressure.mbar && !cyl->type.workingpressure.mbar &&
@ -503,13 +507,13 @@ gboolean cylinder_nodata(cylinder_t *cyl)
!cyl->end.mbar; !cyl->end.mbar;
} }
static gboolean cylinder_nosamples(cylinder_t *cyl) static bool cylinder_nosamples(cylinder_t *cyl)
{ {
return !cyl->sample_start.mbar && return !cyl->sample_start.mbar &&
!cyl->sample_end.mbar; !cyl->sample_end.mbar;
} }
gboolean cylinder_none(void *_data) bool cylinder_none(void *_data)
{ {
cylinder_t *cyl = _data; cylinder_t *cyl = _data;
return cylinder_nodata(cyl) && cylinder_nosamples(cyl); 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 /* descriptions are equal if they are both NULL or both non-NULL
and the same text */ 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) || return ((! desc1 && ! desc2) ||
(desc1 && desc2 && strcmp(desc1, desc2) == 0)); (desc1 && desc2 && strcmp(desc1, desc2) == 0));
} }
gboolean weightsystem_none(void *_data) bool weightsystem_none(void *_data)
{ {
weightsystem_t *ws = _data; weightsystem_t *ws = _data;
return !ws->weight.grams && !ws->description; return !ws->weight.grams && !ws->description;
} }
gboolean no_weightsystems(weightsystem_t *ws) bool no_weightsystems(weightsystem_t *ws)
{ {
int i; int i;
@ -539,13 +543,13 @@ gboolean no_weightsystems(weightsystem_t *ws)
return TRUE; 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 && return ws1->weight.grams == ws2->weight.grams &&
description_equal(ws1->description, ws2->description); 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; int i;
@ -601,7 +605,7 @@ static void *ws_ptr(struct dive *dive, int idx)
static void show_equipment(struct dive *dive, int max, static void show_equipment(struct dive *dive, int max,
struct equipment_list *equipment_list, struct equipment_list *equipment_list,
void*(*ptr_function)(struct dive*, int), void*(*ptr_function)(struct dive*, int),
gboolean(*none_function)(void *), bool(*none_function)(void *),
void(*set_one_function)(void*, GtkListStore*, GtkTreeIter *)) void(*set_one_function)(void*, GtkListStore*, GtkTreeIter *))
{ {
int i, used; int i, used;
@ -861,8 +865,8 @@ struct tank_info_t tank_info[100] = {
{ "HP130", .cuft = 130, .psi = 3442 }, { "HP130", .cuft = 130, .psi = 3442 },
/* Common European steel cylinders */ /* Common European steel cylinders */
{ "3L 232 bar", .ml = 3000, .bar = 232 }, { "3L 232 bar", .ml = 3000, .bar = 232 },
{ "3L 300 bar", .ml = 3000, .bar = 300 }, { "3L 300 bar", .ml = 3000, .bar = 300 },
{ "10L 300 bar", .ml = 10000, .bar = 300 }, { "10L 300 bar", .ml = 10000, .bar = 300 },
{ "12L 200 bar", .ml = 12000, .bar = 200 }, { "12L 200 bar", .ml = 12000, .bar = 200 },
{ "12L 232 bar", .ml = 12000, .bar = 232 }, { "12L 232 bar", .ml = 12000, .bar = 232 },

9
file.c
View file

@ -4,7 +4,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#define N_(arg) arg
#endif
#include <zip.h> #include <zip.h>
#include "dive.h" #include "dive.h"
@ -24,7 +29,7 @@ int readfile(const char *filename, struct memblock *mem)
mem->buffer = NULL; mem->buffer = NULL;
mem->size = 0; mem->size = 0;
fd = g_open(filename, O_RDONLY | O_BINARY, 0); fd = open(filename, O_RDONLY | O_BINARY, 0);
if (fd < 0) if (fd < 0)
return fd; return fd;
ret = fstat(fd, &st); 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; struct sample *sample;
errno = 0; errno = 0;
val = g_ascii_strtod(p,&end); val = strtod(p,&end); // FIXME == localization issue
if (end == p) if (end == p)
break; break;
if (errno) if (errno)

2
file.h
View file

@ -6,7 +6,9 @@ struct memblock {
size_t size; size_t size;
}; };
#if 0
extern int try_to_open_cochran(const char *filename, struct memblock *mem, GError **error); extern int try_to_open_cochran(const char *filename, struct memblock *mem, GError **error);
#endif
extern int readfile(const char *filename, struct memblock *mem); extern int readfile(const char *filename, struct memblock *mem);
#endif #endif

30
info.c
View file

@ -2,7 +2,7 @@
* *
* UI toolkit independent logic used for the info frame * 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 print_gps_coordinates(char *buffer, int len, int lat, int lon);
* void save_equipment_data(struct dive *dive); * void save_equipment_data(struct dive *dive);
* void update_equipment_data(struct dive *dive, struct dive *master); * void update_equipment_data(struct dive *dive, struct dive *master);
@ -10,7 +10,7 @@
* const char *get_window_title(struct dive *dive); * const char *get_window_title(struct dive *dive);
* char *evaluate_string_change(const char *newstring, char **textp, const char *master); * char *evaluate_string_change(const char *newstring, char **textp, const char *master);
* int text_changed(const char *old, const char *new); * 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); * int divename(char *buf, size_t size, struct dive *dive, char *trailer);
*/ */
#include <stdio.h> #include <stdio.h>
@ -19,12 +19,19 @@
#include <time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#include <sys/time.h> #include <sys/time.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#define N_(arg) arg
#endif
#include "dive.h" #include "dive.h"
#include "display.h" #include "display.h"
#include "divelist.h" #include "divelist.h"
#if USE_GTK_UI
/* old is NULL or a valid string, new is a valid string /* old is NULL or a valid string, new is a valid string
* NOTE: NULL and "" need to be treated as "unchanged" */ * NOTE: NULL and "" need to be treated as "unchanged" */
int text_changed(const char *old, const char *new) 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 */ /* 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; const char *text = gps_text;
char *endptr; char *endptr;
gboolean south = FALSE; bool south = FALSE;
gboolean west = FALSE; bool west = FALSE;
double parselat, parselong; double parselat, parselong;
gunichar degrees = UCS4_DEGREE; gunichar degrees = UCS4_DEGREE;
gunichar c; gunichar c;
@ -270,7 +277,7 @@ gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitud
return TRUE; 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; double latitude, longitude;
int latudeg, longudeg; int latudeg, longudeg;
@ -295,13 +302,15 @@ gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_tex
dive->longitude.udeg = longudeg; dive->longitude.udeg = longudeg;
return TRUE; return TRUE;
} }
#endif
/* take latitude and longitude in udeg and print them in a human readable /* take latitude and longitude in udeg and print them in a human readable
* form, without losing precision */ * form, without losing precision */
void print_gps_coordinates(char *buffer, int len, int lat, int lon) void print_gps_coordinates(char *buffer, int len, int lat, int lon)
{ {
unsigned int latdeg, londeg; unsigned int latdeg, londeg;
#if 0
double latmin, lonmin; double latmin, lonmin;
#endif
char *lath, *lonh, dbuf_lat[32], dbuf_lon[32]; char *lath, *lonh, dbuf_lat[32], dbuf_lon[32];
if (!lat && !lon) { if (!lat && !lon) {
@ -314,11 +323,18 @@ void print_gps_coordinates(char *buffer, int len, int lat, int lon)
lon = abs(lon); lon = abs(lon);
latdeg = lat / 1000000; latdeg = lat / 1000000;
londeg = lon / 1000000; londeg = lon / 1000000;
#if 0
latmin = (lat % 1000000) * 60.0 / 1000000.0; latmin = (lat % 1000000) * 60.0 / 1000000.0;
lonmin = (lon % 1000000) * 60.0 / 1000000.0; lonmin = (lon % 1000000) * 60.0 / 1000000.0;
*dbuf_lat = *dbuf_lon = 0; *dbuf_lat = *dbuf_lon = 0;
g_ascii_formatd(dbuf_lat, sizeof(dbuf_lat), "%8.5f", latmin); g_ascii_formatd(dbuf_lat, sizeof(dbuf_lat), "%8.5f", latmin);
g_ascii_formatd(dbuf_lon, sizeof(dbuf_lon), "%8.5f", lonmin); 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) { if (!*dbuf_lat || !*dbuf_lon) {
*buffer = 0; *buffer = 0;
return; return;

4
info.h
View file

@ -10,7 +10,7 @@
extern "C" { extern "C" {
#endif #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 print_gps_coordinates(char *buffer, int len, int lat, int lon);
extern void save_equipment_data(struct dive *dive); extern void save_equipment_data(struct dive *dive);
extern void update_equipment_data(struct dive *dive, struct dive *master); 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 const char *get_window_title(struct dive *dive);
extern char *evaluate_string_change(const char *newstring, char **textp, const char *master); 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 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); extern int divename(char *buf, size_t size, struct dive *dive, char *trailer);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1,7 +1,13 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <inttypes.h> #include <inttypes.h>
#include <string.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#define N_(arg) arg
#endif
#include "dive.h" #include "dive.h"
#include "device.h" #include "device.h"
@ -26,7 +32,7 @@ const char *progress_bar_text = "";
double progress_bar_fraction = 0.0; double progress_bar_fraction = 0.0;
static int stoptime, stopdepth, ndl, po2, cns; 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 #if USE_GTK_UI
static GError *error(const char *fmt, ...) static GError *error(const char *fmt, ...)

View file

@ -24,7 +24,7 @@ typedef struct device_data_t {
dc_device_t *device; dc_device_t *device;
dc_context_t *context; dc_context_t *context;
int preexisting; int preexisting;
gboolean force_download; bool force_download;
} device_data_t; } device_data_t;
const char *do_libdivecomputer_import(device_data_t *data); const char *do_libdivecomputer_import(device_data_t *data);

12
macos.c
View file

@ -169,8 +169,8 @@ const char *system_default_filename(void)
char *buffer; char *buffer;
int len; int len;
home = g_get_home_dir(); home = getenv("HOME");
user = g_get_user_name(); user = getenv("LOGNAME");
len = strlen(home) + strlen(user) + 45; len = strlen(home) + strlen(user) + 45;
buffer = malloc(len); buffer = malloc(len);
snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user); 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 */ #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 */ /* 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 */ /* 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; 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); CFURLRef urlref = CFURLCreateWithBytes(NULL, uri, strlen(uri), kCFStringEncodingMacRoman, NULL);
OSStatus status = LSOpenCFURLRef(urlref, NULL); OSStatus status = LSOpenCFURLRef(urlref, NULL);

View file

@ -18,6 +18,7 @@ int main(int argc, char **argv)
{ {
int i; int i;
bool no_filenames = true; bool no_filenames = true;
#if 0
const char *path; const char *path;
/* set up l18n - the search directory needs to change /* set up l18n - the search directory needs to change
@ -28,7 +29,7 @@ int main(int argc, char **argv)
bindtextdomain("subsurface", path); bindtextdomain("subsurface", path);
bind_textdomain_codeset("subsurface", "utf-8"); bind_textdomain_codeset("subsurface", "utf-8");
textdomain("subsurface"); textdomain("subsurface");
#endif
setup_system_prefs(); setup_system_prefs();
prefs = default_prefs; prefs = default_prefs;

View file

@ -11,7 +11,12 @@
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxslt/transform.h> #include <libxslt/transform.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#define N_(arg) arg
#endif
#include<sqlite3.h> #include<sqlite3.h>
#include "dive.h" #include "dive.h"
@ -129,7 +134,7 @@ struct {
const char *nickname, *serial_nr, *firmware; const char *nickname, *serial_nr, *firmware;
} dc; } dc;
} cur_settings; } cur_settings;
static gboolean in_settings = FALSE; static bool in_settings = FALSE;
static struct tm cur_tm; static struct tm cur_tm;
static int cur_cylinder_index, cur_ws_index; static int cur_cylinder_index, cur_ws_index;
static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco; static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco;
@ -235,13 +240,101 @@ enum number_type {
FLOAT 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) static enum number_type parse_float(char *buffer, double *res, char **endp)
{ {
double val; double val;
static gboolean first_time = TRUE; static bool first_time = TRUE;
errno = 0; errno = 0;
val = g_ascii_strtod(buffer, endp); val = ascii_strtod(buffer, endp);
if (errno || *endp == buffer) if (errno || *endp == buffer)
return NEITHER; return NEITHER;
if (**endp == ',') { if (**endp == ',') {
@ -255,7 +348,7 @@ static enum number_type parse_float(char *buffer, double *res, char **endp)
} }
/* Try again */ /* Try again */
**endp = '.'; **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: case FLOAT:
/* Turn fractions into percent unless explicit.. */ /* Turn fractions into percent unless explicit.. */
if (val <= 1.0) { if (val <= 1.0) {
while (g_ascii_isspace(*end)) while (isspace(*end))
end++; end++;
if (*end != '%') if (*end != '%')
val *= 100; val *= 100;
@ -487,10 +580,10 @@ static void utf8_string(char *buffer, void *_res)
{ {
int size; int size;
char *res; char *res;
while (g_ascii_isspace(*buffer)) while (isspace(*buffer))
buffer++; buffer++;
size = strlen(buffer); size = strlen(buffer);
while (size && g_ascii_isspace(buffer[size-1])) while (size && isspace(buffer[size-1]))
size--; size--;
if (!size) if (!size)
return; return;
@ -521,7 +614,7 @@ static void get_rating(char *buffer, void *_i)
static void double_to_permil(char *buffer, void *_i) static void double_to_permil(char *buffer, void *_i)
{ {
int *i = _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) 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; int sign = 1, decimals = 6, value = 0;
degrees_t ret; degrees_t ret;
while (g_ascii_isspace(*buf)) while (isspace(*buf))
buf++; buf++;
switch (*buf) { switch (*buf) {
case '-': 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 * to make a dive valid, but if it has no location, no date and no
* samples I'm pretty sure it's useless. * samples I'm pretty sure it's useless.
*/ */
static gboolean is_dive(void) static bool is_dive(void)
{ {
return (cur_dive && return (cur_dive &&
(cur_dive->location || cur_dive->when || cur_dive->dc.samples)); (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; return NULL;
memcpy(filename, path, len); memcpy(filename, path, len);
filename[len] = G_DIR_SEPARATOR; #ifdef WIN32
filename[len] = '\\';
#else
filename[len] = '/';
#endif
memcpy(filename + len + 1, name, namelen+1); memcpy(filename + len + 1, name, namelen+1);
ret = NULL; ret = NULL;

View file

@ -5,9 +5,14 @@
* (c) Dirk Hohndel 2013 * (c) Dirk Hohndel 2013
*/ */
#include <libintl.h> #include <libintl.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#endif
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include <string.h>
#include "dive.h" #include "dive.h"
#include "divelist.h" #include "divelist.h"
#include "planner.h" #include "planner.h"
@ -47,7 +52,7 @@ void dump_plan(struct diveplan *diveplan)
} }
#endif #endif
void set_last_stop(gboolean last_stop_6m) void set_last_stop(bool last_stop_6m)
{ {
if (last_stop_6m == TRUE) if (last_stop_6m == TRUE)
decostoplevels[1] = 6000; 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 /* simple helper function to compare two permille values with
* (rounded) percent granularity */ * (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; 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 */ /* 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); struct divedatapoint *pdp, *dp = get_nth_dp(diveplan, idx);
if (idx > 0) { if (idx > 0) {
@ -803,7 +808,7 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
if (!text) if (!text)
return 0; return 0;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
if (!*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 */ /* We don't want any extra crud */
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
if (*text) if (*text)
return 0; return 0;
@ -843,19 +848,19 @@ int validate_time(const char *text, int *sec_p, int *rel_p)
if (!text) if (!text)
return 0; return 0;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
rel = 1; rel = 1;
if (*text == '+') { if (*text == '+') {
rel = 1; rel = 1;
text++; text++;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
} else if (*text == '@') { } else if (*text == '@') {
rel = 0; rel = 0;
text++; text++;
while (g_ascii_isspace(*text)) while (isspace(*text))
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? */ /* Maybe we should accept 'min' at the end? */
if (g_ascii_isspace(*text)) if (isspace(*text))
text++; text++;
if (*text) if (*text)
return 0; return 0;
@ -913,7 +918,7 @@ int validate_depth(const char *text, int *mm_p)
if (depth < 0) if (depth < 0)
return 0; return 0;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
imperial = get_units()->length == FEET; imperial = get_units()->length == FEET;
@ -924,7 +929,7 @@ int validate_depth(const char *text, int *mm_p)
imperial = 1; imperial = 1;
text += 2; text += 2;
} }
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
if (*text) if (*text)
return 0; return 0;
@ -952,10 +957,10 @@ int validate_po2(const char *text, int *mbar_po2)
if (po2 < 0) if (po2 < 0)
return 0; return 0;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
if (*text) if (*text)
return 0; return 0;
@ -975,7 +980,7 @@ int validate_volume(const char *text, int *sac)
if (volume < 0) if (volume < 0)
return 0; return 0;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
imperial = get_units()->volume == CUFT; imperial = get_units()->volume == CUFT;
@ -986,11 +991,11 @@ int validate_volume(const char *text, int *sac)
imperial = 1; imperial = 1;
text += 4; text += 4;
} }
while (g_ascii_isspace(*text) || *text == '/') while (isspace(*text) || *text == '/')
text++; text++;
if (!strncasecmp(text, _("min"), 3)) if (!strncasecmp(text, _("min"), 3))
text += 3; text += 3;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
if (*text) if (*text)
return 0; return 0;

View file

@ -14,9 +14,9 @@ extern int validate_po2(const char *text, int *mbar_po2);
extern int validate_volume(const char *text, int *sac); extern int validate_volume(const char *text, int *sac);
extern timestamp_t current_time_notz(void); extern timestamp_t current_time_notz(void);
extern void show_planned_dive(char **error_string_p); 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 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 diveplan diveplan;
extern struct dive *planned_dive; extern struct dive *planned_dive;

View file

@ -2,8 +2,14 @@
/* creates all the necessary data for drawing the dive profile /* creates all the necessary data for drawing the dive profile
* uses cairo to draw it * uses cairo to draw it
*/ */
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#define N_(arg) arg
#endif
#include <limits.h> #include <limits.h>
#include <string.h>
#include "dive.h" #include "dive.h"
#include "display.h" #include "display.h"
@ -931,7 +937,7 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer
int i, cylinderindex; int i, cylinderindex;
pr_track_t *track_pr[MAX_CYLINDERS] = {NULL, }; pr_track_t *track_pr[MAX_CYLINDERS] = {NULL, };
pr_track_t *current; pr_track_t *current;
gboolean missing_pr = FALSE; bool missing_pr = FALSE;
cylinderindex = -1; cylinderindex = -1;
current = NULL; 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, 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; int pressurevalue, mod, ead, end, eadd;
const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit; const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit;

View file

@ -1,7 +1,9 @@
/* qt-gui.cpp */ /* qt-gui.cpp */
/* Qt UI implementation */ /* Qt UI implementation */
#include <libintl.h> #include <libintl.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -64,7 +66,10 @@ Translator::Translator(QObject *parent):
QString Translator::translate(const char *context, const char *sourceText, QString Translator::translate(const char *context, const char *sourceText,
const char *disambiguation) const const char *disambiguation) const
{ {
return sourceText;
#if 0
return gettext(sourceText); return gettext(sourceText);
#endif
} }
static QApplication *application = NULL; static QApplication *application = NULL;
@ -141,7 +146,7 @@ void exit_ui(void)
free((void *)default_dive_computer_device); 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) if (!force && existing_filename)
return; return;

View file

@ -8,7 +8,6 @@
#include <QDateTime> #include <QDateTime>
#include "dive.h" #include "dive.h"
#include "ui_diveplanner.h"
class QListView; class QListView;
class QStringListModel; class QStringListModel;
@ -202,6 +201,8 @@ private:
int dpMaxTime; // this is the time of the dive calculated by the deco. int dpMaxTime; // this is the time of the dive calculated by the deco.
}; };
#include "ui_diveplanner.h"
class DivePlannerWidget : public QWidget { class DivePlannerWidget : public QWidget {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -696,8 +696,12 @@ void MainTab::on_notes_textChanged()
void MainTab::on_coordinates_textChanged(const QString& text) void MainTab::on_coordinates_textChanged(const QString& text)
{ {
QByteArray textByteArray = text.toLocal8Bit(); QByteArray textByteArray = text.toLocal8Bit();
gboolean gpsChanged = FALSE; bool gpsChanged = FALSE;
EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data())); // EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data()));
// FIXME
// FIXME
// FIXME
// FIXME
if (gpsChanged) { if (gpsChanged) {
markChangedWidget(ui.coordinates); markChangedWidget(ui.coordinates);
} else { } else {

View file

@ -20,7 +20,6 @@
#include "divelistview.h" #include "divelistview.h"
#include "starwidget.h" #include "starwidget.h"
#include "glib.h"
#include "../dive.h" #include "../dive.h"
#include "../divelist.h" #include "../divelist.h"
#include "../pref.h" #include "../pref.h"
@ -36,8 +35,6 @@
#include "about.h" #include "about.h"
#include "printdialog.h" #include "printdialog.h"
#include "glib/gi18n.h"
static MainWindow* instance = 0; static MainWindow* instance = 0;
MainWindow* mainWindow() MainWindow* mainWindow()

View file

@ -13,7 +13,7 @@
#include "../divelist.h" #include "../divelist.h"
struct dive_table gps_location_table; struct dive_table gps_location_table;
static gboolean merge_locations_into_dives(void); static bool merge_locations_into_dives(void);
SubsurfaceWebServices* SubsurfaceWebServices::instance() SubsurfaceWebServices* SubsurfaceWebServices::instance()
{ {
@ -177,7 +177,7 @@ unsigned int SubsurfaceWebServices::download_dialog_parse_response(const QByteAr
return status; return status;
} }
static gboolean is_automatic_fix(struct dive *gpsfix) static bool is_automatic_fix(struct dive *gpsfix)
{ {
if (gpsfix && gpsfix->location && if (gpsfix && gpsfix->location &&
(!strcmp(gpsfix->location, "automatic fix") || (!strcmp(gpsfix->location, "automatic fix") ||
@ -188,7 +188,7 @@ static gboolean is_automatic_fix(struct dive *gpsfix)
#define SAME_GROUP 6 * 3600 // six hours #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; int i, nr = 0, changed = 0;
struct dive *gpsfix, *last_named_fix = NULL, *dive; struct dive *gpsfix, *last_named_fix = NULL, *dive;

View file

@ -125,12 +125,12 @@ static void show_utf8(FILE *f, const char *text, const char *pre, const char *po
if (!text) if (!text)
return; return;
while (g_ascii_isspace(*text)) while (isspace(*text))
text++; text++;
len = strlen(text); len = strlen(text);
if (!len) if (!len)
return; return;
while (len && g_ascii_isspace(text[len-1])) while (len && isspace(text[len-1]))
len--; len--;
/* FIXME! Quoting! */ /* FIXME! Quoting! */
fputs(pre, f); fputs(pre, f);
@ -549,13 +549,13 @@ void save_dives(const char *filename)
save_dives_logic(filename, FALSE); 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; int i;
struct dive *dive; struct dive *dive;
dive_trip_t *trip; dive_trip_t *trip;
FILE *f = g_fopen(filename, "w"); FILE *f = fopen(filename, "w");
if (!f) if (!f)
return; return;

View file

@ -6,7 +6,13 @@
* void process_all_dives(struct dive *dive, struct dive **prev_dive); * void process_all_dives(struct dive *dive, struct dive **prev_dive);
* void get_selected_dives_text(char *buffer, int size); * void get_selected_dives_text(char *buffer, int size);
*/ */
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#define N_(arg) arg
#endif
#include <string.h>
#include <ctype.h> #include <ctype.h>
#include "dive.h" #include "dive.h"

View file

@ -1,7 +1,12 @@
#include "subsurfacestartup.h" #include "subsurfacestartup.h"
#include <stdbool.h> #include <stdbool.h>
#include <string.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else /* stupid */
#define _(arg) arg
#define N_(arg) arg
#endif
struct preferences prefs; struct preferences prefs;
struct preferences default_prefs = { struct preferences default_prefs = {
.units = SI_UNITS, .units = SI_UNITS,

1
time.c
View file

@ -1,4 +1,3 @@
#include <glib/gi18n.h>
#include <string.h> #include <string.h>
#include "dive.h" #include "dive.h"

View file

@ -13,11 +13,17 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#define N_(arg) arg
#endif
#include "libdivecomputer.h" #include "libdivecomputer.h"
#include "uemis.h" #include "uemis.h"
@ -55,7 +61,7 @@ static int mbuf_size = 0;
struct argument_block { struct argument_block {
const char *mountpath; const char *mountpath;
progressbar_t *progress; progressbar_t *progress;
gboolean force_download; bool force_download;
}; };
#endif #endif
@ -98,7 +104,7 @@ static void uemis_ts(char *buffer, void *_when)
/* float minutes */ /* float minutes */
static void uemis_duration(char *buffer, duration_t *duration) 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 */ /* 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) static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid)
{ {
weight->weight.grams = uemis_get_weight_unit(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")); weight->description = strdup(_("unknown"));
} }
@ -172,18 +178,36 @@ static long bytes_available(int file)
static int number_of_file(char *path) static int number_of_file(char *path)
{ {
int count = 0; int count = 0;
GDir *dir = g_dir_open(path, 0, NULL); DIR * dirp;
while (g_dir_read_name(dir)) struct dirent * entry;
count++;
g_dir_close(dir); 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; 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. /* 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 * Test for the maximum number of ANS files (I believe this is always
* 4000 but in case there are differences depending on firmware, this * 4000 but in case there are differences depending on firmware, this
* code is easy enough */ * code is easy enough */
static gboolean uemis_init(const char *path) static bool uemis_init(const char *path)
{ {
char *ans_path; char *ans_path;
int i; int i;
@ -191,8 +215,8 @@ static gboolean uemis_init(const char *path)
if (!path) if (!path)
return FALSE; return FALSE;
/* let's check if this is indeed a Uemis DC */ /* let's check if this is indeed a Uemis DC */
reqtxt_path = g_build_filename(path, "/req.txt", NULL); reqtxt_path = build_filename(path,"req.txt");
reqtxt_file = g_open(reqtxt_path, O_RDONLY, 0666); reqtxt_file = open(reqtxt_path, O_RDONLY, 0666);
if (!reqtxt_file) { if (!reqtxt_file) {
#if UEMIS_DEBUG & 1 #if UEMIS_DEBUG & 1
fprintf(debugfile, ":EE req.txt can't be opened\n"); 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 /* 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 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); number_of_files = number_of_file(ans_path);
g_free(ans_path); free(ans_path);
/* initialize the array in which we collect the answers */ /* initialize the array in which we collect the answers */
for (i = 0; i < NUM_PARAM_BUFS; i++) for (i = 0; i < NUM_PARAM_BUFS; i++)
param_buff[i] = ""; param_buff[i] = "";
@ -274,7 +298,7 @@ static char *next_segment(char *buf, int *offset, int size)
{ {
int i = *offset; int i = *offset;
int seg_size; int seg_size;
gboolean done = FALSE; bool done = FALSE;
char *segment; char *segment;
while (!done) { 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? */ /* are there more ANS files we can check? */
static gboolean next_file(int max) static bool next_file(int max)
{ {
if (filenr >= max) if (filenr >= max)
return FALSE; return FALSE;
@ -380,7 +404,7 @@ static void uemis_increased_timeout(int *timeout)
} }
/* send a request to the dive computer and collect the answer */ /* 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 n_param_out, char **error_text)
{ {
int i = 0, file_length; 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 fl[13];
char tmp[101]; char tmp[101];
char *what = _("data"); char *what = _("data");
gboolean searching = TRUE; bool searching = TRUE;
gboolean assembling_mbuf = FALSE; bool assembling_mbuf = FALSE;
gboolean ismulti = FALSE; bool ismulti = FALSE;
gboolean found_answer = FALSE; bool found_answer = FALSE;
gboolean more_files = TRUE; bool more_files = TRUE;
gboolean answer_in_mbuf = FALSE; bool answer_in_mbuf = FALSE;
char *ans_path; char *ans_path;
int ans_file; int ans_file;
int timeout = UEMIS_LONG_TIMEOUT; 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); snprintf(sb, BUFLEN, "n%04d12345678", filenr);
str_append_with_delim(sb, request); str_append_with_delim(sb, request);
for (i = 0; i < n_param_in; i++) 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; return FALSE;
progress_bar_fraction = filenr / 4000.0; progress_bar_fraction = filenr / 4000.0;
snprintf(fl, 13, "ANS%d.TXT", filenr - 1); snprintf(fl, 13, "ANS%d.TXT", filenr - 1);
ans_path = g_build_filename(path, "ANS", fl, NULL); ans_path = build_filename(build_filename(path, "ANS"), fl);
ans_file = g_open(ans_path, O_RDONLY, 0666); ans_file = open(ans_path, O_RDONLY, 0666);
read(ans_file, tmp, 100); read(ans_file, tmp, 100);
close(ans_file); close(ans_file);
#if UEMIS_DEBUG & 8 #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; pbuf[3] = 0;
fprintf(debugfile, "::t %s \"%s...\"\n", ans_path, pbuf); fprintf(debugfile, "::t %s \"%s...\"\n", ans_path, pbuf);
#endif #endif
g_free(ans_path); free(ans_path);
if (tmp[0] == '1') { if (tmp[0] == '1') {
searching = FALSE; searching = FALSE;
if (tmp[1] == 'm') { 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; more_files = FALSE;
assembling_mbuf = 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); trigger_response(reqtxt_file, "n", filenr, file_length);
} }
} else { } else {
@ -478,15 +502,15 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
assembling_mbuf = FALSE; assembling_mbuf = FALSE;
searching = 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); trigger_response(reqtxt_file, "r", filenr, file_length);
uemis_increased_timeout(&timeout); uemis_increased_timeout(&timeout);
} }
if (ismulti && more_files && tmp[0] == '1') { if (ismulti && more_files && tmp[0] == '1') {
int size; int size;
snprintf(fl, 13, "ANS%d.TXT", assembling_mbuf ? filenr - 2 : filenr - 1); snprintf(fl, 13, "ANS%d.TXT", assembling_mbuf ? filenr - 2 : filenr - 1);
ans_path = g_build_filename(path, "ANS", fl, NULL); ans_path = build_filename(build_filename(path, "ANS"), fl);
ans_file = g_open(ans_path, O_RDONLY, 0666); ans_file = open(ans_path, O_RDONLY, 0666);
size = bytes_available(ans_file); size = bytes_available(ans_file);
if (size > 3) { if (size > 3) {
char *buf = malloc(size - 2); 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) { if (!ismulti) {
snprintf(fl, 13, "ANS%d.TXT", filenr - 1); snprintf(fl, 13, "ANS%d.TXT", filenr - 1);
ans_path = g_build_filename(path, "ANS", fl, NULL); ans_path = build_filename(build_filename(path, "ANS"), fl);
ans_file = g_open(ans_path, O_RDONLY, 0666); ans_file = open(ans_path, O_RDONLY, 0666);
size = bytes_available(ans_file); size = bytes_available(ans_file);
if (size > 3) { if (size > 3) {
buf = malloc(size - 2); buf = malloc(size - 2);
@ -575,9 +599,9 @@ static void parse_divespot(char *buf)
"%s%s", len ? ", " : "", val); "%s%s", len ? ", " : "", val);
} else if (!strcmp(type, "float")) { } else if (!strcmp(type, "float")) {
if (!strcmp(tag, "longitude")) if (!strcmp(tag, "longitude"))
longitude = g_ascii_strtod(val, NULL); longitude = ascii_strtod(val, NULL);
else if (!strcmp(tag, "latitude")) else if (!strcmp(tag, "latitude"))
latitude = g_ascii_strtod(val, NULL); latitude = ascii_strtod(val, NULL);
} }
} while (tag && *tag); } while (tag && *tag);
uemis_set_divelocation(divespot, locationstring, latitude, longitude); 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 * 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 * 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. */ * 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 *buf = strdup(inbuf);
char *tp, *bp, *tag, *type, *val; char *tp, *bp, *tag, *type, *val;
gboolean done = FALSE; bool done = FALSE;
int inbuflen = strlen(inbuf); int inbuflen = strlen(inbuf);
char *endptr = buf + inbuflen; char *endptr = buf + inbuflen;
gboolean log = FALSE; bool log = FALSE;
char *sections[10]; char *sections[10];
int s, nr_sections = 0; int s, nr_sections = 0;
struct dive *dive = NULL; struct dive *dive = NULL;
@ -767,7 +791,7 @@ char *do_uemis_import(const char *mountpath, short force_download)
char *deviceid = NULL; char *deviceid = NULL;
char *result = NULL; char *result = NULL;
char *endptr; char *endptr;
gboolean success, keep_number = FALSE, once = TRUE; bool success, keep_number = FALSE, once = TRUE;
if (dive_table.nr == 0) if (dive_table.nr == 0)
keep_number = TRUE; 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 /* 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 * as we set this function up in every loop while uemis_download is waiting for
* the download to finish */ * the download to finish */
static gboolean timeout_func(gpointer _data) static bool timeout_func(gpointer _data)
{ {
GtkDialog *dialog = _data; GtkDialog *dialog = _data;
if (!import_thread_cancelled) if (!import_thread_cancelled)
@ -907,7 +931,7 @@ static gboolean timeout_func(gpointer _data)
} }
GError *uemis_download(const char *mountpath, progressbar_t *progress, GError *uemis_download(const char *mountpath, progressbar_t *progress,
GtkDialog *dialog, gboolean force_download) GtkDialog *dialog, bool force_download)
{ {
pthread_t pthread; pthread_t pthread;
void *retval; void *retval;

View file

@ -12,7 +12,12 @@
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#if 0
#include <glib/gi18n.h> #include <glib/gi18n.h>
#else
#define _(arg) arg
#define N_(arg) arg
#endif
#define __USE_XOPEN #define __USE_XOPEN
#include <time.h> #include <time.h>
#include <math.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) void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude)
{ {
struct uemis_helper *hp = uemis_helper; struct uemis_helper *hp = uemis_helper;
#if 0 /* seems overkill */
if (!g_utf8_validate(text, -1, NULL)) if (!g_utf8_validate(text, -1, NULL))
return; return;
#endif
while (hp) { while (hp) {
if (hp->divespot == divespot && hp->location) { if (hp->divespot == divespot && hp->location) {
*hp->location = strdup(text); *hp->location = strdup(text);