Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
ansel/main.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2011 johannes hanika.
4 Copyright (C) 2012 Richard Wonka.
5 Copyright (C) 2014 Jérémy Rosen.
6 Copyright (C) 2014, 2016-2018 Tobias Ellinghaus.
7 Copyright (C) 2018 Peter Budai.
8 Copyright (C) 2019 Michael Baumgaertner.
9 Copyright (C) 2019 parafin.
10 Copyright (C) 2019-2020 Pascal Obry.
11 Copyright (C) 2022 Aurélien PIERRE.
12 Copyright (C) 2022 Martin Bařinka.
13 Copyright (C) 2022 Philippe Weyland.
14 Copyright (C) 2025 Guillaume Stutin.
15
16 darktable is free software: you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 darktable is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with darktable. If not, see <http://www.gnu.org/licenses/>.
28*/
29#include "darktable.h"
30#include "gui/application.h"
31#include <stdlib.h>
32
33#ifdef __APPLE__
34#include "osx/osx.h"
35#endif
36
37#ifdef _WIN32
38#include "win/main_wrapper.h"
39#include "common/datetime.h"
40#endif
41
42int main(int argc, char *argv[])
43{
44#ifdef __APPLE__
46#endif
47#ifdef _WIN32
48 // Opening any native shell dialog (GtkFileChooserNative -> IFileDialog) loads every
49 // installed shell extension into our process; extensions shipping Intel's OpenMP
50 // runtime (libiomp5md.dll) then collide with our libomp and the Intel runtime aborts
51 // the app with OMP error #15. We never run their OpenMP code and they never run ours,
52 // so the duplicate-runtime detection is a false positive here: silence it, as the
53 // runtime's own message advises.
54 g_setenv("KMP_DUPLICATE_LIB_OK", "TRUE", TRUE);
55
56 // ansel.exe is linked as a GUI-subsystem binary, so it has no console of its own and
57 // anything printed to stdout/stderr would go nowhere. We write it to a log file
58 // instead -- unless the caller already arranged somewhere for it to go.
59 char datetime[DT_DATETIME_EXIF_LENGTH];
61
62 // make sure to not redirect output when the output is already being redirected, either to a file or a pipe.
67
68 for(int k = 1; k < argc; k++)
69 {
70 // For simple arguments do not redirect stdout
71 if(!strcmp(argv[k], "--help") || !strcmp(argv[k], "-h") || !strcmp(argv[k], "/?") || !strcmp(argv[k], "--version")
72 || !strcmp(argv[k], "-d") || !strcmp(argv[k], "--debug"))
73 {
75 break;
76 }
77 }
78
80 {
81 // something like C:\Users\username\AppData\Local\Microsoft\Windows\Temporary Internet Files\ansel\ansel-log.txt
83 char *logfile = g_build_filename(logdir, "ansel-log.txt", NULL);
84
86
87 /* If this fails, freopen() has already closed stdout and fileno() answers -1; handing
88 * that to dup2() reaches the CRT's invalid-parameter handler, which ends the process
89 * before the first window is ever drawn. A log file we could not open is not worth
90 * dying for, so stop redirecting and carry on. */
92
94 {
96
97 // don't buffer stdout/stderr. we have basically two options: unbuffered or line buffered.
98 // unbuffered keeps the order in which things are printed but concurrent threads printing can lead to intermangled output. ugly.
99 // line buffered should keep lines together but in my tests the order of things no longer matches. ugly and potentially confusing.
100 // thus we are doing the thing that is just ugly (in rare cases) but at least not confusing.
103
104 printf("========================================\n");
105 printf("version: %s\n", darktable_package_string);
106 printf("start: %s\n", datetime);
107 printf("\n");
108 }
109
112 }
113
114 // make sure GTK client side decoration is disabled, otherwise windows resizing issues can be observed
115 g_setenv("GTK_CSD", "0", TRUE);
116#endif
117
118 if(dt_init(argc, argv, TRUE, TRUE)) exit(1);
120
121#ifdef _WIN32
123 {
124 printf("\n");
125 printf("end: %s\n", datetime);
126 printf("========================================\n");
127 printf("\n");
128 }
129#endif
130
131 exit(0);
132}
133
134// clang-format off
135// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
136// vim: shiftwidth=2 expandtab tabstop=2 cindent
137// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
138// clang-format on
void dt_gui_gtk_run(dt_gui_gtk_t *gui)
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
const char darktable_package_string[]
int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load_data)
Definition darktable.c:885
struct dt_gui_gtk_t * dt_gui_get_global(void)
Definition darktable.c:523
void dt_datetime_now_to_exif(char *exif)
Definition datetime.c:225
#define DT_DATETIME_EXIF_LENGTH
Definition datetime.h:39
float *const restrict const size_t k
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
void dt_osx_prepare_environment()
Definition osx.mm:213
int main()
Definition prova.c:47