Ejemplo n.º 1
0
// xxx copied from ../gtk/main.c
void
vfprintf_stderr(const char *fmt, va_list ap)
{
#ifdef _WIN32
    create_console();
#endif
    vfprintf(stderr, fmt, ap);
}
Ejemplo n.º 2
0
// xxx copied from ../gtk/main.c
static void
wireshark_cmdarg_err_cont(const char *fmt, va_list ap)
{
#ifdef _WIN32
    create_console();
#endif
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
}
Ejemplo n.º 3
0
bool LLAppViewerWin32::initWindow()
{
    // pop up debug console if necessary
    if (gUseConsole && gSavedSettings.getBOOL("ShowConsoleWindow"))
    {
        create_console();
    }

    return LLAppViewer::initWindow();
}
Ejemplo n.º 4
0
// xxx copied from ../gtk/main.c
static void
show_version(void)
{
#ifdef _WIN32
    create_console();
#endif

    printf(PACKAGE " " VERSION "%s\n"
           "\n"
           "%s"
           "\n"
           "%s"
           "\n"
           "%s",
           wireshark_svnversion, get_copyright_info(), comp_info_str->str,
           runtime_info_str->str);

#ifdef _WIN32
//    destroy_console();
#endif
}
Ejemplo n.º 5
0
INT WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    int rv;
    int index = 1;
    wfInfo * wfi;
    WSADATA wsa_data;
    WNDCLASSEX wnd_cls;

    if (WSAStartup(0x101, &wsa_data) != 0)
    {
        return 1;
    }
    g_done_event = CreateEvent(0, 1, 0, 0);
#if defined(WITH_DEBUG) || defined(_DEBUG)
    create_console();
#endif
    if (!freerdp_global_init())
    {
        printf("Error initializing freerdp\n");
        return 1;
    }
    freerdp_chanman_init();
    g_default_cursor = LoadCursor(NULL, IDC_ARROW);

    wnd_cls.cbSize        = sizeof(WNDCLASSEX);
    wnd_cls.style         = CS_HREDRAW | CS_VREDRAW;
    wnd_cls.lpfnWndProc   = wf_event_proc;
    wnd_cls.cbClsExtra    = 0;
    wnd_cls.cbWndExtra    = 0;
    wnd_cls.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wnd_cls.hCursor       = g_default_cursor;
    wnd_cls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wnd_cls.lpszMenuName  = NULL;
    wnd_cls.lpszClassName = g_wnd_class_name;
    wnd_cls.hInstance     = hInstance;
    wnd_cls.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    RegisterClassEx(&wnd_cls);

    g_hInstance = hInstance;

    if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
        printf("error creating keyboard handler thread");

    while (1)
    {
        wfi = (wfInfo *) malloc(sizeof(wfInfo));
        memset(wfi, 0, sizeof(wfInfo));
        wfi->settings = (rdpSet *) malloc(sizeof(rdpSet));
        wfi->chan_man = freerdp_chanman_new();

        wfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
        memset(wfi->clrconv, 0, sizeof(CLRCONV));
        wfi->clrconv->alpha = 1;
        wfi->clrconv->palette = NULL;

        rv = process_params(wfi, __argc, __argv, &index);
        if (rv)
        {
            freerdp_chanman_free(wfi->chan_man);
            free(wfi->settings);
            free(wfi);
            break;
        }
        if (CreateThread(NULL, 0, thread_func, wfi, 0, NULL) != 0)
        {
            g_thread_count++;
        }
    }

    if (g_thread_count > 0)
        WaitForSingleObject(g_done_event, INFINITE);
    else
        MessageBox(GetConsoleWindow(),
                   L"Failed to start wfreerdp.\n\nPlease check the debug output.",
                   L"FreeRDP Error", MB_ICONSTOP);

    freerdp_chanman_uninit();
    freerdp_global_finish();
    WSACleanup();
    return 0;
}
Ejemplo n.º 6
0
static int
process_params(wfInfo * wfi, int argc, char ** argv, int * pindex)
{
    rdpSet * settings;
    char * p;
    int i;
    char show_console = 1;

    /* Early scanning of options for stdout/console handling */
    for(i = 1; i < argc; i++)
        if (strcmp("--no-console", argv[i]) == 0)
        {
            show_console = 0;
        }
        else if (strcmp("--debug-log", argv[i]) == 0)
        {
            freopen("freerdp.log", "w", stdout);
            show_console = 0;
        }
    if (show_console && !GetConsoleWindow())
    {
        create_console();
        printf("(this console window can be redirected to freerdp.log with --debug-log\n"
               "or hidden with --no-debug)\n");
    }

    set_default_params(wfi);
    settings = wfi->settings;

    DEBUG("process_params\n");
    if (argc < *pindex + 1)
    {
        if (*pindex == 1)
            printf("no parameters specified\n");
        return 1;
    }
    while (*pindex < argc)
    {
        if (strcmp("-a", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing server depth\n");
                return 1;
            }
            settings->server_depth = atoi(argv[*pindex]);
        }
        else if (strcmp("-u", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing username\n");
                return 1;
            }
            strncpy(settings->username, argv[*pindex], sizeof(settings->username) - 1);
            settings->username[sizeof(settings->username) - 1] = 0;
        }
        else if (strcmp("-p", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing password\n");
                return 1;
            }
            strncpy(settings->password, argv[*pindex], sizeof(settings->password) - 1);
            settings->password[sizeof(settings->password) - 1] = 0;
            settings->autologin = 1;
        }
        else if (strcmp("-d", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing domain\n");
                return 1;
            }
            strncpy(settings->domain, argv[*pindex], sizeof(settings->domain) - 1);
            settings->domain[sizeof(settings->domain) - 1] = 0;
        }
        else if (strcmp("-s", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing shell\n");
                return 1;
            }
            strncpy(settings->shell, argv[*pindex], sizeof(settings->shell) - 1);
            settings->shell[sizeof(settings->shell) - 1] = 0;
        }
        else if (strcmp("-c", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing directory\n");
                return 1;
            }
            strncpy(settings->directory, argv[*pindex], sizeof(settings->directory) - 1);
            settings->directory[sizeof(settings->directory) - 1] = 0;
        }
        else if (strcmp("-g", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing width\n");
                return 1;
            }
            settings->width = strtol(argv[*pindex], &p, 10);
            if (*p == 'x')
            {
                settings->height = strtol(p + 1, &p, 10);
            }
            if (*p == '%')
            {
                wfi->percentscreen = settings->width;
            }
        }
        else if (strcmp("-t", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing port number\n");
                return 1;
            }
            settings->tcp_port_rdp = atoi(argv[*pindex]);
        }
        else if (strcmp("-T", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing window title\n");
                return 1;
            }
            strncpy(wfi->window_title, argv[*pindex], sizeof(wfi->window_title) - 1);
            wfi->window_title[sizeof(wfi->window_title) - 1] = 0;
        }
        else if (strcmp("-n", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing hostname\n");
                return 1;
            }
            strncpy(settings->hostname, argv[*pindex], sizeof(settings->hostname) - 1);
            settings->hostname[sizeof(settings->hostname) - 1] = 0;
        }
        else if (strcmp("-o", argv[*pindex]) == 0)
        {
            settings->console_audio = 1;
        }
        else if (strcmp("-0", argv[*pindex]) == 0)
        {
            settings->console_session = 1;
        }
        else if (strcmp("-z", argv[*pindex]) == 0)
        {
            settings->bulk_compression = 1;
        }
        else if (strcmp("--rfx", argv[*pindex]) == 0)
        {
            settings->rfx_flags = 1;
            settings->ui_decode_flags = 1;
            settings->use_frame_ack = 0;
            settings->server_depth = 32;
            settings->performanceflags = PERF_FLAG_NONE;
        }
        else if (strcmp("--gdi", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing GDI rendering\n");
                return 1;
            }
            if (strncmp("sw", argv[*pindex], 1) == 0) /* Software */
            {
                settings->software_gdi = 1;
            }
            else if (strncmp("hw", argv[*pindex], 1) == 0) /* Hardware */
            {
                settings->software_gdi = 0;
            }
            else
            {
                printf("unknown GDI rendering\n");
                return 1;
            }
        }
        else if (strcmp("--no-osb", argv[*pindex]) == 0)
        {
            settings->off_screen_bitmaps = 0;
        }
        else if (strcmp("-f", argv[*pindex]) == 0)
        {
            wfi->fullscreen = wfi->fs_toggle = 1;
            DEBUG("full screen option\n");
        }
        else if (strcmp("-x", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing performance flag\n");
                return 1;
            }
            if (strncmp("m", argv[*pindex], 1) == 0) /* modem */
            {
                settings->performanceflags = PERF_DISABLE_WALLPAPER |
                                             PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS |
                                             PERF_DISABLE_THEMING;
            }
            else if (strncmp("b", argv[*pindex], 1) == 0) /* broadband */
            {
                settings->performanceflags = PERF_DISABLE_WALLPAPER;
            }
            else if (strncmp("l", argv[*pindex], 1) == 0) /* lan */
            {
                settings->performanceflags = PERF_FLAG_NONE;
            }
            else
            {
                settings->performanceflags = strtol(argv[*pindex], 0, 16);
            }
        }
#ifndef DISABLE_TLS
        else if (strcmp("--no-rdp", argv[*pindex]) == 0)
        {
            settings->rdp_security = 0;
        }
        else if (strcmp("--no-tls", argv[*pindex]) == 0)
        {
            settings->tls_security = 0;
        }
        else if (strcmp("--no-nla", argv[*pindex]) == 0)
        {
            settings->nla_security = 0;
        }
        else if (strcmp("--sec", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing protocol security\n");
                return 1;
            }
            if (strncmp("rdp", argv[*pindex], 1) == 0) /* Standard RDP */
            {
                settings->rdp_security = 1;
                settings->tls_security = 0;
                settings->nla_security = 0;
            }
            else if (strncmp("tls", argv[*pindex], 1) == 0) /* TLS */
            {
                settings->rdp_security = 0;
                settings->tls_security = 1;
                settings->nla_security = 0;
            }
            else if (strncmp("nla", argv[*pindex], 1) == 0) /* NLA */
            {
                settings->rdp_security = 0;
                settings->tls_security = 0;
                settings->nla_security = 1;
            }
            else
            {
                printf("unknown protocol security\n");
                return 1;
            }
        }
#endif
        else if (strcmp("--plugin", argv[*pindex]) == 0)
        {
            *pindex = *pindex + 1;
            if (*pindex == argc)
            {
                printf("missing plugin name\n");
                return 1;
            }
            /* TODO: Handle --data ... -- */
            freerdp_chanman_load_plugin(wfi->chan_man, settings, argv[*pindex], NULL);
        }
        else if ((strcmp("-h", argv[*pindex]) == 0) || strcmp("--help", argv[*pindex]) == 0)
        {
            out_args();
            return 1;
        }
        else if (strcmp("--version", argv[*pindex]) == 0)
        {
            printf("This is FreeRDP version %s\n", PACKAGE_VERSION);
            return 1;
        }
        else if (argv[*pindex][0] != '-')
        {
            settings->server[sizeof(settings->server) - 1] = 0;
            if (argv[*pindex][0] == '[' && (p = strchr(argv[*pindex], ']'))
                    && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
            {
                /* Either "[...]" or "[...]:..." with at most one : after the brackets */
                strncpy(settings->server, argv[*pindex] + 1, sizeof(settings->server) - 1);
                if ((p = strchr(settings->server, ']')))
                {
                    *p = 0;
                    if (p[1] == ':')
                        settings->tcp_port_rdp = atoi(p + 2);
                }
            }
            else
            {
                /* Port number is cut off and used if exactly one : in the string */
                strncpy(settings->server, argv[*pindex], sizeof(settings->server) - 1);
                if ((p = strchr(settings->server, ':')) && !strchr(p + 1, ':'))
                {
                    *p = 0;
                    settings->tcp_port_rdp = atoi(p + 1);
                }
            }
            /* server is the last argument for the current session. arguments
               followed will be parsed for the next session. */
            *pindex = *pindex + 1;
            return 0;
        }
        else if ((strcmp("--no-console", argv[*pindex]) == 0) ||
                 (strcmp("--debug-log", argv[*pindex]) == 0))
        {
            /* Skip options that already has been processed */
        }
        else
        {
            printf("invalid option: %s\n", argv[*pindex]);
            return 1;
        }
        *pindex = *pindex + 1;
    }
    printf("missing server name\n");
    return 1;
}
Ejemplo n.º 7
0
// xxx copied from ../gtk/main.c
static void
print_usage(gboolean print_ver) {
    FILE *output;

#ifdef _WIN32
    create_console();
#endif

    if (print_ver) {
        output = stdout;
        fprintf(output, "Wireshark " VERSION "%s\n"
                "Interactively dump and analyze network traffic.\n"
                "See http://www.wireshark.org for more information.\n"
                "\n"
                "%s",
                wireshark_svnversion, get_copyright_info());
    } else {
        output = stderr;
    }
    fprintf(output, "\n");
    fprintf(output, "Usage: wireshark [options] ... [ <infile> ]\n");
    fprintf(output, "\n");

#ifdef HAVE_LIBPCAP
    fprintf(output, "Capture interface:\n");
    fprintf(output, "  -i <interface>           name or idx of interface (def: first non-loopback)\n");
    fprintf(output, "  -f <capture filter>      packet filter in libpcap filter syntax\n");
    fprintf(output, "  -s <snaplen>             packet snapshot length (def: 65535)\n");
    fprintf(output, "  -p                       don't capture in promiscuous mode\n");
    fprintf(output, "  -k                       start capturing immediately (def: do nothing)\n");
    fprintf(output, "  -Q                       quit Wireshark after capturing\n");
    fprintf(output, "  -S                       update packet display when new packets are captured\n");
    fprintf(output, "  -l                       turn on automatic scrolling while -S is in use\n");
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
    fprintf(output, "  -B <buffer size>         size of kernel buffer (def: 1MB)\n");
#endif
    fprintf(output, "  -y <link type>           link layer type (def: first appropriate)\n");
    fprintf(output, "  -D                       print list of interfaces and exit\n");
    fprintf(output, "  -L                       print list of link-layer types of iface and exit\n");
    fprintf(output, "\n");
    fprintf(output, "Capture stop conditions:\n");
    fprintf(output, "  -c <packet count>        stop after n packets (def: infinite)\n");
    fprintf(output, "  -a <autostop cond.> ...  duration:NUM - stop after NUM seconds\n");
    fprintf(output, "                           filesize:NUM - stop this file after NUM KB\n");
    fprintf(output, "                              files:NUM - stop after NUM files\n");
    /*fprintf(output, "\n");*/
    fprintf(output, "Capture output:\n");
    fprintf(output, "  -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
    fprintf(output, "                           filesize:NUM - switch to next file after NUM KB\n");
    fprintf(output, "                              files:NUM - ringbuffer: replace after NUM files\n");
#endif  /* HAVE_LIBPCAP */

    /*fprintf(output, "\n");*/
    fprintf(output, "Input file:\n");
    fprintf(output, "  -r <infile>              set the filename to read from (no pipes or stdin!)\n");

    fprintf(output, "\n");
    fprintf(output, "Processing:\n");
    fprintf(output, "  -R <read filter>         packet filter in Wireshark display filter syntax\n");
    fprintf(output, "  -n                       disable all name resolutions (def: all enabled)\n");
    fprintf(output, "  -N <name resolve flags>  enable specific name resolution(s): \"mntC\"\n");

    fprintf(output, "\n");
    fprintf(output, "User interface:\n");
    fprintf(output, "  -C <config profile>      start with specified configuration profile\n");
    fprintf(output, "  -g <packet number>       go to specified packet number after \"-r\"\n");
    fprintf(output, "  -J <jump filter>         jump to the first packet matching the (display)\n");
    fprintf(output, "                           filter\n");
    fprintf(output, "  -j                       search backwards for a matching packet after \"-J\"\n");
    fprintf(output, "  -m <font>                set the font name used for most text\n");
    fprintf(output, "  -t ad|a|r|d|dd|e         output format of time stamps (def: r: rel. to first)\n");
    fprintf(output, "  -u s|hms                 output format of seconds (def: s: seconds)\n");
    fprintf(output, "  -X <key>:<value>         eXtension options, see man page for details\n");
    fprintf(output, "  -z <statistics>          show various statistics, see man page for details\n");

    fprintf(output, "\n");
    fprintf(output, "Output:\n");
    fprintf(output, "  -w <outfile|->           set the output filename (or '-' for stdout)\n");

    fprintf(output, "\n");
    fprintf(output, "Miscellaneous:\n");
    fprintf(output, "  -h                       display this help and exit\n");
    fprintf(output, "  -v                       display version info and exit\n");
    fprintf(output, "  -P <key>:<path>          persconf:path - personal configuration files\n");
    fprintf(output, "                           persdata:path - personal data files\n");
    fprintf(output, "  -o <name>:<value> ...    override preference or recent setting\n");
    fprintf(output, "  -K <keytab>              keytab file to use for kerberos decryption\n");
#ifndef _WIN32
    fprintf(output, "  --display=DISPLAY        X display to use\n");
#endif

#ifdef _WIN32
//    destroy_console();
#endif
}
Ejemplo n.º 8
0
// XXX Copied from ui/gtk/main.c. This should be moved to a common location.
static e_prefs *
read_configuration_files(char **gdp_path, char **dp_path)
{
  int                  gpf_open_errno, gpf_read_errno;
  int                  cf_open_errno, df_open_errno;
  int                  gdp_open_errno, gdp_read_errno;
  int                  dp_open_errno, dp_read_errno;
  char                *gpf_path, *pf_path;
  char                *cf_path, *df_path;
  int                  pf_open_errno, pf_read_errno;
  e_prefs             *prefs_p;

  /* Read the preference files. */
  prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
                     &pf_open_errno, &pf_read_errno, &pf_path);

  if (gpf_path != NULL) {
    if (gpf_open_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open global preferences file\n\"%s\": %s.", gpf_path,
        g_strerror(gpf_open_errno));
    }
    if (gpf_read_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "I/O error reading global preferences file\n\"%s\": %s.", gpf_path,
        g_strerror(gpf_read_errno));
    }
  }
  if (pf_path != NULL) {
    if (pf_open_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open your preferences file\n\"%s\": %s.", pf_path,
        g_strerror(pf_open_errno));
    }
    if (pf_read_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "I/O error reading your preferences file\n\"%s\": %s.", pf_path,
        g_strerror(pf_read_errno));
    }
    g_free(pf_path);
    pf_path = NULL;
  }

#ifdef _WIN32
  /* if the user wants a console to be always there, well, we should open one for him */
  if (prefs_p->gui_console_open == console_open_always) {
    create_console();
  }
#endif

  /* Read the capture filter file. */
  read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno);
  if (cf_path != NULL) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open your capture filter file\n\"%s\": %s.", cf_path,
        g_strerror(cf_open_errno));
      g_free(cf_path);
  }

  /* Read the display filter file. */
  read_filter_list(DFILTER_LIST, &df_path, &df_open_errno);
  if (df_path != NULL) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open your display filter file\n\"%s\": %s.", df_path,
        g_strerror(df_open_errno));
      g_free(df_path);
  }

  /* Read the disabled protocols file. */
  read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
                            dp_path, &dp_open_errno, &dp_read_errno);
  if (*gdp_path != NULL) {
    if (gdp_open_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open global disabled protocols file\n\"%s\": %s.",
        *gdp_path, g_strerror(gdp_open_errno));
    }
    if (gdp_read_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "I/O error reading global disabled protocols file\n\"%s\": %s.",
        *gdp_path, g_strerror(gdp_read_errno));
    }
    g_free(*gdp_path);
    *gdp_path = NULL;
  }
  if (*dp_path != NULL) {
    if (dp_open_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "Could not open your disabled protocols file\n\"%s\": %s.", *dp_path,
        g_strerror(dp_open_errno));
    }
    if (dp_read_errno != 0) {
      simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
        "I/O error reading your disabled protocols file\n\"%s\": %s.", *dp_path,
        g_strerror(dp_read_errno));
    }
    g_free(*dp_path);
    *dp_path = NULL;
  }

  return prefs_p;
}
Ejemplo n.º 9
0
static void
console_log_handler(const char *log_domain, GLogLevelFlags log_level,
                    const char *message, gpointer user_data _U_)
{
    time_t curr;
    struct tm *today;
    const char *level;


    /* ignore log message, if log_level isn't interesting based
       upon the console log preferences.
       If the preferences haven't been loaded loaded yet, display the
       message anyway.

       The default console_log_level preference value is such that only
         ERROR, CRITICAL and WARNING level messages are processed;
         MESSAGE, INFO and DEBUG level messages are ignored.  */
    if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
        prefs.console_log_level != 0) {
        return;
    }

#ifdef _WIN32
    if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
        /* the user wants a console or the application will terminate immediately */
        create_console();
    }
    if (get_has_console()) {
        /* For some unknown reason, the above doesn't appear to actually cause
           anything to be sent to the standard output, so we'll just splat the
           message out directly, just to make sure it gets out. */
#endif
        switch(log_level & G_LOG_LEVEL_MASK) {
            case G_LOG_LEVEL_ERROR:
                level = "Err ";
                break;
            case G_LOG_LEVEL_CRITICAL:
                level = "Crit";
                break;
            case G_LOG_LEVEL_WARNING:
                level = "Warn";
                break;
            case G_LOG_LEVEL_MESSAGE:
                level = "Msg ";
                break;
            case G_LOG_LEVEL_INFO:
                level = "Info";
                break;
            case G_LOG_LEVEL_DEBUG:
                level = "Dbg ";
                break;
            default:
                fprintf(stderr, "unknown log_level %d\n", log_level);
                level = NULL;
                g_assert_not_reached();
        }

        /* create a "timestamp" */
        time(&curr);
        today = localtime(&curr);
        guint64 microseconds = create_timestamp();
        if (today != NULL) {
                fprintf(stderr, "%02d:%02d:%02d.%03" G_GUINT64_FORMAT " %8s %s %s\n",
                        today->tm_hour, today->tm_min, today->tm_sec,
                        microseconds % 1000000 / 1000,
                        log_domain != NULL ? log_domain : "",
                        level, message);
        } else {
                fprintf(stderr, "Time not representable %8s %s %s\n",
                        log_domain != NULL ? log_domain : "",
                        level, message);
        }
#ifdef _WIN32
        if(log_level & G_LOG_LEVEL_ERROR) {
            /* wait for a key press before the following error handler will terminate the program
               this way the user at least can read the error message */
            printf("\n\nPress any key to exit\n");
            _getch();
        }
    } else {
        /* XXX - on UN*X, should we just use g_log_default_handler()?
           We want the error messages to go to the standard output;
           on macOS, that will cause them to show up in various
           per-user logs accessible through Console (details depend
           on whether you're running 10.0 through 10.4 or running
           10.5 and later), and, on other UN*X desktop environments,
           if they don't show up in some form of console log, that's
           a deficiency in that desktop environment.  (Too bad
           Windows doesn't set the standard output and error for
           GUI apps to something that shows up in such a log.) */
        g_log_default_handler(log_domain, log_level, message, user_data);
    }
#endif
}