54#include <glib/gstdio.h>
63#if defined __APPLE__ || defined _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE || defined _BSD_SOURCE \
64 || defined _SVID_SOURCE || defined _POSIX_SOURCE || defined __DragonFly__ || defined __FreeBSD__ \
65 || defined __NetBSD__ || defined __OpenBSD__
79#include <glib/gi18n.h>
88#include <librsvg/rsvg.h>
91#include <librsvg/rsvg-cairo.h>
172 const gchar *s = string, *
p = string;
198 gchar *result =
NULL;
261 const size_t len =
strlen(path);
272 if(len > 1 && path[1] !=
'/')
274 while(path[off] !=
'\0' && path[off] !=
'/')
318 register const gchar *s = src;
319 while(s - src <
n && *s)
329 dest[s - src] =
'\0';
340 dest[s - src] =
'\0';
359 if(result)
return FALSE;
366 const gboolean
size_ok = stats.st_size > 0;
434 if((*c < 0x20) || (*c >= 0x7f)) *c =
'?';
444 const int a = Y % 19;
445 const int b = Y / 100;
446 const int c = Y % 100;
449 const int f = (b + 8) / 25;
450 const int g = (b -
f + 1) / 3;
451 const int h = (19*a + b -
d -
g + 15) % 30;
454 const int L = (32 + 2*e + 2*
i - h -
k) % 7;
455 const int m = (a + 11*h + 22*
L) / 451;
456 *month = (h +
L - 7*
m + 114) / 31;
457 *
day = ((h +
L - 7*
m + 114) % 31) + 1;
469 if((
lt.tm_mon == 9 &&
lt.tm_mday == 31) || (
lt.tm_mon == 10 &&
lt.tm_mday == 1))
568#define OSD_COORDINATES_CHR_N "N"
569#define OSD_COORDINATES_CHR_S "S"
570#define OSD_COORDINATES_CHR_E "E"
571#define OSD_COORDINATES_CHR_W "W"
586 latitude =
fabsf(latitude);
604 longitude =
fabsf(longitude);
621 elevation =
fabsf(elevation);
641 else if(list[3] ==
NULL)
644 if(dir ==
'S' || dir ==
'W')
res *= -1.0;
693 const double num =
r_1;
718 const gchar *input =
_input;
728 input +=
strlen(
"file://");
774 if(first >=
'A' && first <=
'Z' && filename[1] ==
':')
779 else if(first ==
'\\' && filename[1] ==
'\\')
807 int last =
strlen(dirname) - 1;
809 dirname[last] =
'\0';
842 if(text[0] ==
needle) count ++;
869 const gchar c = next[0];
926 const size_t end =
ftell(fd);
929 char *content = (
char *)
malloc(
sizeof(
char) * end);
932 const size_t count =
fread(content,
sizeof(
char), end, fd);
961 char buffer[64 * 1024];
988 #if LIBRSVG_CHECK_VERSION(2,52,0)
998#define VIEWPORT_SIZE 32767
1020 #if LIBRSVG_CHECK_VERSION(2,52,0)
static void error(char *msg)
static const float const float const float min
void dt_loc_get_datadir(char *datadir, size_t bufsize)
gchar * dt_loc_get_home_dir(const gchar *user)
const dt_collection_sort_t items[]
static gchar * g_realpath(const char *path)
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
double dt_screen_ppd(void)
static cairo_surface_t * dt_cairo_image_surface_create_for_data(unsigned char *data, cairo_format_t format, int width, int height, int stride)
static const dt_aligned_pixel_simd_t sign
static const dt_aligned_pixel_simd_t value
static const char *const day[7]
gboolean dt_util_gps_elevation_to_number(const double r_1, const double r_2, char sign, double *result)
guint dt_util_string_count_char(const char *text, const char needle)
gchar * dt_util_str_replace(const gchar *string, const gchar *pattern, const gchar *substitute)
gchar * dt_util_longitude_str(float longitude)
gchar * dt_str_replace(const char *string, const char *search, const char *replace)
gboolean dt_has_same_path_basename(const char *filename1, const char *filename2)
Test whether two paths are byte-identical before their normal extensions.
void dt_util_str_to_loc_numbers_format(char *data)
#define OSD_COORDINATES_CHR_N
gchar * dt_cleanup_separators(gchar *string)
gchar * dt_util_elevation_str(float elevation)
gboolean dt_util_dir_exist(const char *dir)
dt_logo_season_t dt_util_get_logo_season(void)
RsvgDimensionData dt_get_svg_dimension(RsvgHandle *svg)
char * dt_read_file(const char *const filename, size_t *filesize)
static const char * OSD_ELEVATION_BSL
#define OSD_COORDINATES_CHR_S
cairo_surface_t * dt_util_get_logo_text(const float size)
static void easter(int Y, int *month, int *day)
GDateTime * dt_util_get_file_datetime(const char *const path)
GList * dt_util_str_to_glist(const gchar *separator, const gchar *text)
gboolean dt_util_test_image_file(const char *filename)
#define OSD_COORDINATES_CHR_W
int dt_util_streams_equal(FILE *first, FILE *second)
Compare the remaining bytes of two borrowed binary streams.
void dt_copy_file(const char *const sourcefile, const char *dst)
void dt_copy_resource_file(const char *src, const char *dst)
guint dt_util_str_occurence(const gchar *haystack, const gchar *needle)
double dt_util_gps_string_to_number(const gchar *input)
gchar * dt_util_path_get_dirname(const gchar *filename)
gboolean dt_util_is_dir_empty(const char *dirname)
#define OSD_COORDINATES_CHR_E
gchar * dt_util_normalize_path(const gchar *_input)
size_t dt_utf8_strlcpy(char *dest, const char *src, size_t n)
size_t safe_strlen(const char *str)
check if the string is empty or NULL before calling strlen()
char * dt_util_format_exposure(const float exposuretime)
gboolean dt_util_test_writable_dir(const char *path)
gboolean dt_util_gps_rationale_to_number(const double r0_1, const double r0_2, const double r1_1, const double r1_2, const double r2_1, const double r2_2, char sign, double *result)
gchar * dt_util_fix_path(const gchar *path)
const char * dt_util_path_get_extension(const char *path)
Locate a normal filename extension in a path basename.
gchar * dt_util_foo_to_utf8(const char *string)
gchar * dt_util_latitude_str(float latitude)
gchar * dt_util_remove_whitespace(const gchar *path)
void dt_render_svg(RsvgHandle *svg, cairo_t *cr, double width, double height, double offset_x, double offset_y)
static const char * OSD_ELEVATION_ASL
gchar * dt_util_glist_to_str(const gchar *separator, GList *items)
char * dt_copy_filename_extension(const char *filename1, const char *filename2)
Replace filename1's normal extension with filename2's normal extension.
static cairo_surface_t * _util_get_svg_img(gchar *logo, const float size)
gchar * dt_util_dstrcat(gchar *str, const gchar *format,...)
GList * dt_util_glist_uniq(GList *items)
cairo_surface_t * dt_util_get_logo(const float size)
@ DT_LOGO_SEASON_HALLOWEEN