- return aoview_log_serial;
-}
-
-static void
-aoview_log_open_failed(char *name)
-{
- char *utf8_file;
- utf8_file = g_filename_to_utf8(name, -1, NULL, NULL, NULL);
- if (!utf8_file)
- utf8_file = name;
- gtk_message_dialog_format_secondary_text(log_fail_dialog,
- "\"%s\"", utf8_file);
- if (utf8_file != name)
- g_free(utf8_file);
- gtk_dialog_run(GTK_DIALOG(log_fail_dialog));
- gtk_widget_hide(GTK_WIDGET(log_fail_dialog));
- aoview_log_failed = 1;
-}
-
-static void
-aoview_log_start(void)
-{
- if (!aoview_log_file) {
- char base[50];
- struct tm tm;
- time_t now;
- char *full;
- int r;
-
- now = time(NULL);
- (void) localtime_r(&now, &tm);
- aoview_mkdir(aoview_log_dir);
- for (;;) {
- sprintf(base, "%04d-%02d-%02d-serial-%03d-flight-%03d.log",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- aoview_log_serial,
- aoview_log_sequence);
- full = aoview_fullname(aoview_log_dir, base);
- r = access(full, F_OK);
- if (r < 0) {
- aoview_log_file = fopen(full, "w");
- if (!aoview_log_file)
- aoview_log_open_failed(full);
- else
- setlinebuf(aoview_log_file);
- free(full);
- break;
- }
- free (full);
- aoview_log_sequence++;
- }
- }