コード例 #1
0
ファイル: json_output.c プロジェクト: rubenk/burp
int json_send_warn(struct asfd *asfd, const char *msg)
{
	if(json_start(asfd)
	  || yajl_gen_str_pair_w("warning", msg)
	  || json_end(asfd)) return -1;
	return 0;
}
コード例 #2
0
ファイル: json_output.c プロジェクト: rubenk/burp
int json_cntr_to_file(struct asfd *asfd, struct cntr *cntr)
{
	int ret=-1;
	if(json_start(asfd)
	  || do_counters(cntr))
		goto end;
	ret=0;
end:
	if(json_end(asfd)) return -1;
	return ret;
}
コード例 #3
0
ファイル: json_output.c プロジェクト: rubenk/burp
int json_send(struct asfd *asfd, struct cstat *clist, struct cstat *cstat,
	struct bu *bu, const char *logfile, const char *browse,
	int use_cache)
{
	int ret=-1;
	struct cstat *c;

	if(json_start(asfd)
	  || json_clients())
		goto end;

	if(cstat && bu)
	{
		if(json_send_client_backup(asfd, cstat, bu, NULL,
			logfile, browse, use_cache)) goto end;
	}
	else if(cstat)
	{
		if(json_send_client_backup_list(asfd, cstat, use_cache))
			goto end;
	}
	else for(c=clist; c; c=c->next)
	{
		if(!c->permitted) continue;
		if(json_send_client_backup(asfd, c,
			bu_find_current(c->bu),
			bu_find_working_or_finishing(c->bu),
			NULL, NULL, use_cache))
				goto end;
	}

	ret=0;
end:
	if(json_clients_end()
	  || json_end(asfd)) return -1;
	return ret;
}
コード例 #4
0
static void phantom_debug_window_loop()
{
    static char buf[DEBBS+1];
    int step = 0;

    int show = 's';

    t_current_set_name("Debug Win");
    // Which thread will receive typein for this window
    phantom_debug_window->owner = get_current_tid();

    int wx = 600;

#if CONF_NEW_CTTY
	if( t_new_ctty( get_current_tid() ) )
		panic("console t_new_ctty");
#else
    // Need separate ctty
    t_set_ctty( get_current_tid(), wtty_init( WTTY_SMALL_BUF ) );
#endif
    // TODO HACK! Need ioctl to check num of bytes?
    wtty_t *tty;
    t_get_ctty( get_current_tid(), &tty );


    while(1)
    {
        if(tty && !wtty_is_empty(tty))
        {
            char c = wtty_getc( tty );
            switch(c)
            {
            case '?':
            case'h':
                printf(
                       "Commands:\n"
                       "---------\n"
                       "w\t- show windows list\n"
                       "t\t- show threads list\n"
                       "s\t- show stats\n"
                       "p\t- show profiler\n"
                       "d\t- dump threads to JSON\n"
                      );
                break;
            case 'p': // profiler
            case 't':
                //w_set_title( phantom_debug_window,  "Threads" );
                //show = c;
                //break;

            case 'w':
                //w_set_title( phantom_debug_window,  "Windows" );
                //show = c;
                //break;

            case 's':
                //w_set_title( phantom_debug_window,  "Stats" );
                show = c;
                break;

            case 'd':
                {
                    json_output jo = { 0 };

                    json_start( &jo );
                    json_dump_threads( &jo );
                    json_stop( &jo );

                }
                break;
            }
        }


        {
            static char old_show = 0;
            if( old_show != show )
            {
                old_show = show;
                switch(show)
                {
                case 't':
                    w_set_title( phantom_debug_window,  "Threads" );
                    break;

                case 'w':
                    w_set_title( phantom_debug_window,  "Windows" );
                    break;

                case 's':
                    w_set_title( phantom_debug_window,  "Stats" );
                    break;

                case 'p':
                    w_set_title( phantom_debug_window,  "Profiler" );
                    break;
                }
            }
        }


        //hal_sleep_msec(1000);
        hal_sleep_msec(100);
#if 1
#if 1
        w_clear( phantom_debug_window );
        ttyd = DEBWIN_YS-20;
        ttxd = 0;
#endif
        //put_progress();

        void *bp = buf;
        int len = DEBBS;
        int rc;

        time_t sec = uptime();
        int min = sec/60; sec %= 60;
        int hr = min/60; min %= 60;
        int days = hr/24; hr %= 24;

        struct tm mt = *current_time;

        rc = snprintf(bp, len, " View: \x1b[32mt\x1b[37mhreads \x1b[32ms\x1b[37mtats \x1b[32mw\x1b[37mindows \x1b[32mp\x1b[37mrofile       \x1b[32m?\x1b[37m - help\n \x1b[32mStep %d, uptime %dd, %02d:%02d:%02d\x1b[37m, %d events\n Time %04d/%02d/%02d %02d:%02d:%02d GMT, CPU 0 %2d%% idle\n",
                      step++, days, hr, min, (int)sec,
                      ev_get_n_events_in_q(),
                      mt.tm_year + 1900, mt.tm_mon, mt.tm_mday,
                      mt.tm_hour, mt.tm_min, mt.tm_sec, 100-percpu_cpu_load[0]
                     );
        bp += rc;
        len -= rc;

        switch(show)
        {
        case 't':
        default:
            phantom_dump_threads_buf(bp,len);
            break;

        case 'w':
            phantom_dump_windows_buf(bp,len);
            break;

        case 's':
            phantom_dump_stats_buf(bp,len);
            break;

        case 'p':
            phantom_dump_profiler_buf(bp,len);
            break;
        }

        phantom_debug_window_puts(buf);

        if(wx == 600) wx = 620; else wx = 600;
        //w_move( phantom_debug_window, wx, 50 );
#endif
        put_progress();
        w_update( phantom_debug_window );

    }
}