/* Note to proofreaders argv is a char*[] lua strings are const char* gtk takes argv and modifies it to remove gtk specific parts so we need to copy (strdup) parameters from lua but because gtk might do crazy stuff, we keep a copy of our original argv to be able to free() it */ static int load_from_lua(lua_State *L) { if(darktable.lua_state.state) { luaL_error(L, "Attempt to load darktable multiple time."); } int argc = lua_gettop(L); char **argv = calloc(argc + 1, sizeof(char *)); char **argv_copy = malloc((argc + 1) * sizeof(char *)); argv[0] = strdup("lua"); argv_copy[0] = argv[0]; for(int i = 1; i < argc; i++) { argv[i] = strdup(luaL_checkstring(L, i + 1)); argv_copy[i] = argv[i]; } lua_pop(L, lua_gettop(L)); argv[argc] = NULL; argv_copy[argc] = NULL; gtk_init(&argc, &argv); if(dt_init(argc, argv, FALSE, TRUE, L)) { luaL_error(L,"Starting darktable failed."); } for(int i = 0; i < argc; i++) { free(argv_copy[i]); } free(argv_copy); free(argv); dt_lua_push_darktable_lib(L); return 1; }
int main(int argc, char *arg[]) { int result = 1; // only used to force-init opencl, so we want these options: char *m_arg[] = { "-d", "opencl", "--library", ":memory:"}; const int m_argc = sizeof(m_arg) / sizeof(m_arg[0]); char **argv = malloc(argc * sizeof(arg[0]) + sizeof(m_arg)); if(!argv) goto end; for(int i = 0; i < argc; i++) argv[i] = arg[i]; for(int i = 0; i < m_argc; i++) argv[argc + i] = m_arg[i]; argc += m_argc; if(dt_init(argc, argv, FALSE, FALSE, NULL)) goto end; dt_cleanup(); free(argv); result = 0; end: #ifdef _WIN32 printf("\npress any key to exit\n"); FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); getch(); #endif exit(result); }
int main(int argc, char *arg[]) { // only used to force-init opencl, so we want these options: const int m_argc = 5; char *m_arg[] = { "darktable-cltest", "-d", "opencl", "--library", ":memory:" }; if(dt_init(m_argc, m_arg, 0, NULL)) exit(1); exit(0); }
void bif_date_init () { bif_define_typed ("dayname", bif_dayname, &bt_varchar); bif_define_typed ("monthname", bif_monthname, &bt_varchar); bif_define_typed ("dayofmonth", bif_day, &bt_integer); bif_define_typed ("dayofweek", bif_dayofweek, &bt_integer); bif_define_typed ("dayofyear", bif_dayofyear, &bt_integer); bif_define_typed ("quarter", bif_quarter, &bt_integer); bif_define_typed ("week", bif_week, &bt_integer); bif_define_typed ("month", bif_month, &bt_integer); bif_define_typed ("year", bif_year, &bt_integer); bif_define_typed ("hour", bif_hour, &bt_integer); bif_define_typed ("minute", bif_minute, &bt_integer); bif_define_typed ("second", bif_second, &bt_integer); bif_define_typed ("timezone", bif_timezone, &bt_integer); bif_define_typed ("rdf_now_impl", bif_timestamp, &bt_timestamp); bif_define_typed ("rdf_year_impl", bif_year, &bt_integer); bif_define_typed ("rdf_month_impl", bif_month, &bt_integer); bif_define_typed ("rdf_day_impl", bif_day, &bt_integer); bif_define_typed ("rdf_hours_impl", bif_hour, &bt_integer); bif_define_typed ("rdf_minutes_impl", bif_minute, &bt_integer); bif_define_typed ("nasa_tjd_number", bif_nasa_tjd_number, &bt_integer); bif_define_typed ("nasa_tjd_fraction", bif_nasa_tjd_fraction, &bt_double); bif_define_typed ("merge_nasa_tjd_to_datetime", bif_merge_nasa_tjd_to_datetime, &bt_datetime); bif_define_typed ("now", bif_timestamp, &bt_timestamp); /* This is standard name */ bif_define_typed ("getdate", bif_timestamp, &bt_datetime); /* This is standard name? */ bif_define_typed ("curdate", bif_curdate, &bt_date); /* This is standard fun. */ bif_define_typed ("curtime", bif_curtime, &bt_time); /* This is standard fun. */ bif_define_typed ("curdatetime", bif_curdatetime, &bt_timestamp); /* This is our own. */ bif_define_typed ("datestring", bif_date_string, &bt_varchar); bif_define_typed ("datestring_GMT", bif_date_string_GMT, &bt_varchar); bif_define_typed ("stringdate", bif_string_timestamp, &bt_datetime); bif_define_typed ("d", bif_string_date, &bt_date); /* Two aliases for ODBC */ bif_define_typed ("ts", bif_string_timestamp, &bt_timestamp); /* brace literals */ bif_define_typed ("stringtime", bif_string_time, &bt_time); /* New one. */ bif_define_typed ("t", bif_string_time, &bt_time); /* An alias for ODBC */ bif_define_typed ("get_timestamp", bif_timestamp, &bt_timestamp); bif_define_typed ("dateadd", bif_date_add, &bt_timestamp); bif_define_typed ("datediff", bif_date_diff, &bt_integer); bif_define_typed ("timestampadd", bif_timestampadd, &bt_timestamp); bif_define_typed ("timestampdiff", bif_timestampdiff, &bt_integer); bif_define_typed ("dt_set_tz", bif_dt_set_tz, &bt_timestamp); bif_define_typed ("__extract", bif_extract, &bt_integer); dt_init (); }
int main(int argc, char **argv) { devicetree_t dt; dt_slice_t s; dt.error = error; if (argc != 2) return -1; if (loadfile(argv[1], &s)) return -1; if (dt_init(&dt, s.data, s.size)) return -1; printf("magic %x\n", dt.hdr.magic); printf("size %d\n", dt.hdr.size); printf("off_struct %d (%d)\n", dt.hdr.off_struct, dt.hdr.sz_struct); printf("off_strings %d (%d)\n", dt.hdr.off_strings, dt.hdr.sz_strings); printf("version %d (min %d)\n", dt.hdr.version, dt.hdr.version_compat); dt_walk(&dt, node_cb, prop_cb, NULL); return 0; }
int main(int argc, char *arg[]) { bindtextdomain (GETTEXT_PACKAGE, DARKTABLE_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &arg); // parse command line arguments char *image_filename = NULL; char *xmp_filename = NULL; char *output_filename = NULL; int file_counter = 0; int width = 0, height = 0, bpp = 0; gboolean verbose = FALSE, high_quality = TRUE; for(int k=1; k<argc; k++) { if(arg[k][0] == '-') { if(!strcmp(arg[k], "--help")) { usage(arg[0]); exit(1); } else if(!strcmp(arg[k], "--version")) { printf("this is darktable-cli\ncopyright (c) 2012-2013 johannes hanika, tobias ellinghaus\n"); exit(1); } else if(!strcmp(arg[k], "--width")) { k++; width = MAX(atoi(arg[k]), 0); } else if(!strcmp(arg[k], "--height")) { k++; height = MAX(atoi(arg[k]), 0); } else if(!strcmp(arg[k], "--bpp")) { k++; bpp = MAX(atoi(arg[k]), 0); fprintf(stderr, "%s %d\n", _("TODO: sorry, due to api restrictions we currently cannot set the bpp to"), bpp); } else if(!strcmp(arg[k], "--hq")) { k++; gchar *str = g_ascii_strup(arg[k], -1); if(!g_strcmp0(str, "0") || !g_strcmp0(str, "FALSE")) high_quality = FALSE; else if(!g_strcmp0(str, "1") || !g_strcmp0(str, "TRUE")) high_quality = TRUE; else { fprintf(stderr, "%s: %s\n", _("Unknown option for --hq"), arg[k]); usage(arg[0]); exit(1); } g_free(str); } else if(!strcmp(arg[k], "-v") || !strcmp(arg[k], "--verbose")) { verbose = TRUE; } } else { if(file_counter == 0) image_filename = arg[k]; else if(file_counter == 1) xmp_filename = arg[k]; else if(file_counter == 2) output_filename = arg[k]; file_counter++; } } if(file_counter < 2 || file_counter > 3) { usage(arg[0]); exit(1); } else if(file_counter == 2) { // no xmp file given output_filename = xmp_filename; xmp_filename = NULL; } // the output file already exists, so there will be a sequence number added if(g_file_test(output_filename, G_FILE_TEST_EXISTS)) { fprintf(stderr, "%s\n", _("output file already exists, it will get renamed")); } char *m_arg[] = {"darktable-cli", "--library", ":memory:", NULL}; // init dt without gui: if(dt_init(3, m_arg, 0)) exit(1); dt_film_t film; int id = 0; int filmid = 0; gchar *directory = g_path_get_dirname(image_filename); filmid = dt_film_new(&film, directory); id = dt_image_import(filmid, image_filename, TRUE); if(!id) { fprintf(stderr, _("error: can't open file %s"), image_filename); fprintf(stderr, "\n"); exit(1); } g_free(directory); // attach xmp, if requested: if(xmp_filename) { const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, id); dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg); dt_exif_xmp_read(image, xmp_filename, 1); // don't write new xmp: dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_RELAXED); dt_image_cache_read_release(darktable.image_cache, image); } // print the history stack if(verbose) { gchar *history = dt_history_get_items_as_string(id); if(history) printf("%s\n", history); else printf("[%s]\n", _("empty history stack")); } // try to find out the export format from the output_filename char *ext = output_filename + strlen(output_filename); while(ext > output_filename && *ext != '.') ext--; *ext = '\0'; ext++; if(!strcmp(ext, "jpg")) ext = "jpeg"; // init the export data structures int size = 0, dat_size = 0; dt_imageio_module_format_t *format; dt_imageio_module_storage_t *storage; dt_imageio_module_data_t *sdata, *fdata; storage = dt_imageio_get_storage_by_name("disk"); // only exporting to disk makes sense if(storage == NULL) { fprintf(stderr, "%s\n", _("cannot find disk storage module. please check your installation, something seems to be broken.")); exit(1); } sdata = storage->get_params(storage, &size); if(sdata == NULL) { fprintf(stderr, "%s\n", _("failed to get parameters from storage module, aborting export ...")); exit(1); } // and now for the really ugly hacks. don't tell your children about this one or they won't sleep at night any longer ... g_strlcpy((char*)sdata, output_filename, DT_MAX_PATH_LEN); // all is good now, the last line didn't happen. format = dt_imageio_get_format_by_name(ext); if(format == NULL) { fprintf(stderr, _("unknown extension '.%s'"), ext); fprintf(stderr, "\n"); exit(1); } fdata = format->get_params(format, &dat_size); if(fdata == NULL) { fprintf(stderr, "%s\n", _("failed to get parameters from format module, aborting export ...")); exit(1); } uint32_t w,h,fw,fh,sw,sh; fw=fh=sw=sh=0; storage->dimension(storage, &sw, &sh); format->dimension(format, &fw, &fh); if( sw==0 || fw==0) w=sw>fw?sw:fw; else w=sw<fw?sw:fw; if( sh==0 || fh==0) h=sh>fh?sh:fh; else h=sh<fh?sh:fh; fdata->max_width = width; fdata->max_height = height; fdata->max_width = (w!=0 && fdata->max_width >w)?w:fdata->max_width; fdata->max_height = (h!=0 && fdata->max_height >h)?h:fdata->max_height; fdata->style[0] = '\0'; //TODO: add a callback to set the bpp without going through the config storage->store(storage,sdata, id, format, fdata, 1, 1, high_quality); // cleanup time if(storage->finalize_store) storage->finalize_store(storage, sdata); storage->free_params(storage, sdata); format->free_params(format, fdata); dt_cleanup(); }
int main(int argc, char *arg[]) { bindtextdomain(GETTEXT_PACKAGE, DARKTABLE_LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); gtk_init_check(&argc, &arg); // parse command line arguments dt_mipmap_size_t max_mip = DT_MIPMAP_2; int k; for(k = 1; k < argc; k++) { if(!strcmp(arg[k], "-h") || !strcmp(arg[k], "--help")) { usage(arg[0]); exit(EXIT_FAILURE); } else if(!strcmp(arg[k], "--version")) { printf("this is darktable-generate-cache\ncopyright (c) 2014 johannes hanika; 2015 LebedevRI\n"); exit(EXIT_FAILURE); } else if(!strcmp(arg[k], "-m") || !strcmp(arg[k], "--max-mip")) { k++; max_mip = (dt_mipmap_size_t)MIN(MAX(atoi(arg[k]), 0), 7); } else if(!strcmp(arg[k], "--core")) { // everything from here on should be passed to the core k++; break; } } int m_argc = 0; char *m_arg[3 + argc - k]; m_arg[m_argc++] = "darktable-generate-cache"; m_arg[m_argc++] = "--conf"; m_arg[m_argc++] = "write_sidecar_files=FALSE"; for(; k < argc; k++) m_arg[m_argc++] = arg[k]; m_arg[m_argc] = NULL; // init dt without gui: if(dt_init(m_argc, m_arg, 0, NULL)) exit(EXIT_FAILURE); if(!dt_conf_get_bool("cache_disk_backend")) { fprintf(stderr, _("Warning: disk backend for mipmap cache is disabled (cache_disk_backend)\nIf you want " "to pre-generate thumbnails and for darktable to use them, you need to enable disk backend " "for mipmap cache\nno thumbnails to be generated, done.")); dt_cleanup(); exit(EXIT_FAILURE); } fprintf(stderr, _("creating complete lighttable thumbnail cache\n")); if(generate_thumbnail_cache(max_mip)) { exit(EXIT_FAILURE); } dt_cleanup(); }
int main (int argc, char *argv[]) { if(dt_init(argc, argv, 1)) exit(1); dt_gui_gtk_run(darktable.gui); exit(0); }
/* * Run "--device" action */ static int do_device_info(void) { dt_init(); dt_info_print(); return 0; }
int main(int argc, char *arg[]) { bindtextdomain(GETTEXT_PACKAGE, DARKTABLE_LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); if(!gtk_parse_args(&argc, &arg)) exit(1); // parse command line arguments char *input_filename = NULL; char *xmp_filename = NULL; char *output_filename = NULL; int file_counter = 0; int width = 0, height = 0, bpp = 0; gboolean verbose = FALSE, high_quality = TRUE, upscale = FALSE; int k; for(k = 1; k < argc; k++) { if(arg[k][0] == '-') { if(!strcmp(arg[k], "--help")) { usage(arg[0]); exit(1); } else if(!strcmp(arg[k], "--version")) { printf("this is darktable-cli %s\ncopyright (c) 2012-2016 johannes hanika, tobias ellinghaus\n", darktable_package_version); exit(1); } else if(!strcmp(arg[k], "--width") && argc > k + 1) { k++; width = MAX(atoi(arg[k]), 0); } else if(!strcmp(arg[k], "--height") && argc > k + 1) { k++; height = MAX(atoi(arg[k]), 0); } else if(!strcmp(arg[k], "--bpp") && argc > k + 1) { k++; bpp = MAX(atoi(arg[k]), 0); fprintf(stderr, "%s %d\n", _("TODO: sorry, due to API restrictions we currently cannot set the BPP to"), bpp); } else if(!strcmp(arg[k], "--hq") && argc > k + 1) { k++; gchar *str = g_ascii_strup(arg[k], -1); if(!g_strcmp0(str, "0") || !g_strcmp0(str, "FALSE")) high_quality = FALSE; else if(!g_strcmp0(str, "1") || !g_strcmp0(str, "TRUE")) high_quality = TRUE; else { fprintf(stderr, "%s: %s\n", _("unknown option for --hq"), arg[k]); usage(arg[0]); exit(1); } g_free(str); } else if(!strcmp(arg[k], "--upscale") && argc > k + 1) { k++; gchar *str = g_ascii_strup(arg[k], -1); if(!g_strcmp0(str, "0") || !g_strcmp0(str, "FALSE")) upscale = FALSE; else if(!g_strcmp0(str, "1") || !g_strcmp0(str, "TRUE")) upscale= TRUE; else { fprintf(stderr, "%s: %s\n", _("unknown option for --upscale"), arg[k]); usage(arg[0]); exit(1); } g_free(str); } else if(!strcmp(arg[k], "-v") || !strcmp(arg[k], "--verbose")) { verbose = TRUE; } else if(!strcmp(arg[k], "--core")) { // everything from here on should be passed to the core k++; break; } } else { if(file_counter == 0) input_filename = arg[k]; else if(file_counter == 1) xmp_filename = arg[k]; else if(file_counter == 2) output_filename = arg[k]; file_counter++; } } int m_argc = 0; char **m_arg = malloc((5 + argc - k + 1) * sizeof(char *)); m_arg[m_argc++] = "darktable-cli"; m_arg[m_argc++] = "--library"; m_arg[m_argc++] = ":memory:"; m_arg[m_argc++] = "--conf"; m_arg[m_argc++] = "write_sidecar_files=FALSE"; for(; k < argc; k++) m_arg[m_argc++] = arg[k]; m_arg[m_argc] = NULL; if(file_counter < 2 || file_counter > 3) { usage(arg[0]); free(m_arg); exit(1); } else if(file_counter == 2) { // no xmp file given output_filename = xmp_filename; xmp_filename = NULL; } if(g_file_test(output_filename, G_FILE_TEST_IS_DIR)) { fprintf(stderr, _("error: output file is a directory. please specify file name")); fprintf(stderr, "\n"); free(m_arg); exit(1); } // the output file already exists, so there will be a sequence number added if(g_file_test(output_filename, G_FILE_TEST_EXISTS)) { fprintf(stderr, "%s\n", _("output file already exists, it will get renamed")); } // init dt without gui: if(dt_init(m_argc, m_arg, 0, NULL)) { free(m_arg); exit(1); } GList *id_list = NULL; if(g_file_test(input_filename, G_FILE_TEST_IS_DIR)) { int filmid = dt_film_import(input_filename); if(!filmid) { fprintf(stderr, _("error: can't open folder %s"), input_filename); fprintf(stderr, "\n"); free(m_arg); exit(1); } id_list = dt_film_get_image_ids(filmid); } else { dt_film_t film; int id = 0; int filmid = 0; gchar *directory = g_path_get_dirname(input_filename); filmid = dt_film_new(&film, directory); id = dt_image_import(filmid, input_filename, TRUE); if(!id) { fprintf(stderr, _("error: can't open file %s"), input_filename); fprintf(stderr, "\n"); free(m_arg); exit(1); } g_free(directory); id_list = g_list_append(id_list, GINT_TO_POINTER(id)); } int total = g_list_length(id_list); if(total == 0) { fprintf(stderr, _("no images to export, aborting\n")); free(m_arg); exit(1); } // attach xmp, if requested: if(xmp_filename) { for(GList *iter = id_list; iter; iter = g_list_next(iter)) { int id = GPOINTER_TO_INT(iter->data); dt_image_t *image = dt_image_cache_get(darktable.image_cache, id, 'w'); dt_exif_xmp_read(image, xmp_filename, 1); // don't write new xmp: dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_RELAXED); } } // print the history stack. only look at the first image and assume all got the same processing applied if(verbose) { int id = GPOINTER_TO_INT(id_list->data); gchar *history = dt_history_get_items_as_string(id); if(history) printf("%s\n", history); else printf("[%s]\n", _("empty history stack")); } // try to find out the export format from the output_filename char *ext = output_filename + strlen(output_filename); while(ext > output_filename && *ext != '.') ext--; *ext = '\0'; ext++; if(!strcmp(ext, "jpg")) ext = "jpeg"; if(!strcmp(ext, "tif")) ext = "tiff"; // init the export data structures dt_imageio_module_format_t *format; dt_imageio_module_storage_t *storage; dt_imageio_module_data_t *sdata, *fdata; storage = dt_imageio_get_storage_by_name("disk"); // only exporting to disk makes sense if(storage == NULL) { fprintf( stderr, "%s\n", _("cannot find disk storage module. please check your installation, something seems to be broken.")); free(m_arg); exit(1); } sdata = storage->get_params(storage); if(sdata == NULL) { fprintf(stderr, "%s\n", _("failed to get parameters from storage module, aborting export ...")); free(m_arg); exit(1); } // and now for the really ugly hacks. don't tell your children about this one or they won't sleep at night // any longer ... g_strlcpy((char *)sdata, output_filename, DT_MAX_PATH_FOR_PARAMS); // all is good now, the last line didn't happen. format = dt_imageio_get_format_by_name(ext); if(format == NULL) { fprintf(stderr, _("unknown extension '.%s'"), ext); fprintf(stderr, "\n"); free(m_arg); exit(1); } fdata = format->get_params(format); if(fdata == NULL) { fprintf(stderr, "%s\n", _("failed to get parameters from format module, aborting export ...")); free(m_arg); exit(1); } uint32_t w, h, fw, fh, sw, sh; fw = fh = sw = sh = 0; storage->dimension(storage, sdata, &sw, &sh); format->dimension(format, fdata, &fw, &fh); if(sw == 0 || fw == 0) w = sw > fw ? sw : fw; else w = sw < fw ? sw : fw; if(sh == 0 || fh == 0) h = sh > fh ? sh : fh; else h = sh < fh ? sh : fh; fdata->max_width = width; fdata->max_height = height; fdata->max_width = (w != 0 && fdata->max_width > w) ? w : fdata->max_width; fdata->max_height = (h != 0 && fdata->max_height > h) ? h : fdata->max_height; fdata->style[0] = '\0'; fdata->style_append = 0; if(storage->initialize_store) { storage->initialize_store(storage, sdata, &format, &fdata, &id_list, high_quality, upscale); format->set_params(format, fdata, format->params_size(format)); storage->set_params(storage, sdata, storage->params_size(storage)); } // TODO: add a callback to set the bpp without going through the config int num = 1; for(GList *iter = id_list; iter; iter = g_list_next(iter), num++) { int id = GPOINTER_TO_INT(iter->data); storage->store(storage, sdata, id, format, fdata, num, total, high_quality, upscale); } // cleanup time if(storage->finalize_store) storage->finalize_store(storage, sdata); storage->free_params(storage, sdata); format->free_params(format, fdata); g_list_free(id_list); dt_cleanup(); free(m_arg); }
int main(int argc, char *argv[]) { #ifdef _WIN32 // on Windows we have a hard time showing stuff printed to stdout/stderr to the user. // because of that we write it to a log file. char datetime[20]; dt_gettime(datetime, sizeof(datetime)); // make sure to not redirect output when the output is already being redirected, either to a file or a pipe. int out_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); int err_type = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); gboolean redirect_output = ((out_type != FILE_TYPE_DISK && out_type != FILE_TYPE_PIPE) && (err_type != FILE_TYPE_DISK && err_type != FILE_TYPE_PIPE)); for(int k = 1; k < argc; k++) { // For simple arguments do not redirect stdout if(!strcmp(argv[k], "--help") || !strcmp(argv[k], "-h") || !strcmp(argv[k], "/?") || !strcmp(argv[k], "--version")) { redirect_output = FALSE; break; } } if(redirect_output) { // something like C:\Users\username\AppData\Local\Microsoft\Windows\Temporary Internet Files\darktable\darktable-log.txt char *logdir = g_build_filename(g_get_user_cache_dir(), "darktable", NULL); char *logfile = g_build_filename(logdir, "darktable-log.txt", NULL); g_mkdir_with_parents(logdir, 0700); g_freopen(logfile, "a", stdout); dup2(fileno(stdout), fileno(stderr)); // We don't need the console window anymore, free it // This ensures that only darktable's main window will be visible FreeConsole(); g_free(logdir); g_free(logfile); // don't buffer stdout/stderr. we have basically two options: unbuffered or line buffered. // unbuffered keeps the order in which things are printed but concurrent threads printing can lead to intermangled output. ugly. // line buffered should keep lines together but in my tests the order of things no longer matches. ugly and potentially confusing. // thus we are doing the thing that is just ugly (in rare cases) but at least not confusing. setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); printf("========================================\n"); printf("version: %s\n", darktable_package_string); printf("start: %s\n", datetime); printf("\n"); } #endif if(dt_init(argc, argv, TRUE, TRUE, NULL)) exit(1); dt_gui_gtk_run(darktable.gui); #ifdef _WIN32 if(redirect_output) { dt_gettime(datetime, sizeof(datetime)); printf("\n"); printf("end: %s\n", datetime); printf("========================================\n"); printf("\n"); } #endif exit(0); }
int main(int argc, char **argv) { FILE *in = fopen (argv[1], "r"); if(in == NULL){ printf ("in = null\n"); return -1; } // int ileslow = (argc<3) ? atoi(argv[2]):50; int ileslow=50; int licznik_slow = 0; int k=0; char* buff2; FILE *out= fopen(argv [2], "w"); if(out == NULL){ printf ("out = Null\n"); return -1; } char znak; char buff[1024]; int it; for (it = 0; it<=1024;it++) buff[it] = '\0'; struct dt *s = dt_init(1024); int i,j = 0; znak = getc (in); while (znak != EOF){ buff[i]= znak; znak = getc (in); j++; i++; if (buff[i-1]== ' '){ if(!(buff2 = malloc((i+1)*sizeof( char)))) { printf("FATAL ERROR\n"); return -1; } strncpy (buff2 , buff, i); dt_add (s, buff2); free(buff2); buff2 = NULL; for (j=i;j>=0;j--) buff[j] = '\0'; i=0; } } printf("haalo "); printf("%d\n\n", s->n); srand(time(NULL)); int m= rand()%s->n; printf("%d\n",m); while(licznik_slow<ileslow) { fprintf(out,"%s", s->t[m]); licznik_slow++; m++; if(m>s->n) m=rand()%s->n; } dt_print( s, stdout ); return 0; }