Fixing formatting with astyle in tests/*
This commit is contained in:
@@ -332,7 +332,9 @@ static void *tcp_proxy(void *arg)
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
if (tcp_can_send(con_skt, 100))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(100);
|
||||
}
|
||||
@@ -452,7 +454,9 @@ static void show_msg(int not_main_window, int style,
|
||||
GtkWidget *dialog;
|
||||
|
||||
if (not_main_window)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
dialog = gtk_message_dialog_new(GTK_WINDOW(NULL),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@@ -465,8 +469,10 @@ static void show_msg(int not_main_window, int style,
|
||||
gtk_widget_destroy(dialog);
|
||||
|
||||
if (not_main_window)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write message to status bar
|
||||
@@ -475,13 +481,17 @@ static void show_msg(int not_main_window, int style,
|
||||
static void show_status(int not_main_thread, char *msg)
|
||||
{
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_statusbar_push(GTK_STATUSBAR(g_statusbar), CONTEXT_ID, msg);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear status bar
|
||||
@@ -490,13 +500,17 @@ static void show_status(int not_main_thread, char *msg)
|
||||
static void clear_status(int not_main_thread)
|
||||
{
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_statusbar_remove_all(GTK_STATUSBAR(g_statusbar), CONTEXT_ID);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable 'Start Listening' button
|
||||
@@ -505,13 +519,17 @@ static void clear_status(int not_main_thread)
|
||||
static void enable_btn_start(int not_main_thread)
|
||||
{
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(g_btn_start), TRUE);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable 'Start Listening' button
|
||||
@@ -520,13 +538,17 @@ static void enable_btn_start(int not_main_thread)
|
||||
static void disable_btn_start(int not_main_thread)
|
||||
{
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(g_btn_start), FALSE);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return local port setting
|
||||
@@ -569,13 +591,17 @@ static void show_loc_port_stats(int not_main_thread, int count)
|
||||
sprintf(buf, "%d", count);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(g_tbx_loc_stats), buf);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update remote port stat counter
|
||||
@@ -588,13 +614,17 @@ static void show_rem_port_stats(int not_main_thread, int count)
|
||||
sprintf(buf, "%d", count);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(g_tbx_rem_stats), buf);
|
||||
|
||||
if (not_main_thread)
|
||||
{
|
||||
gdk_threads_leave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User clicked on window close button
|
||||
|
||||
@@ -30,7 +30,9 @@ int tcp_socket_create(void)
|
||||
|
||||
/* in win32 a socket is an unsigned int, in linux, it's an int */
|
||||
if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
@@ -157,7 +159,9 @@ int tcp_last_error_would_block()
|
||||
void tcp_close(int skt)
|
||||
{
|
||||
if (skt <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
closesocket(skt);
|
||||
@@ -180,7 +184,9 @@ int tcp_socket(void)
|
||||
|
||||
/* in win32 a socket is an unsigned int, in linux, it's an int */
|
||||
if ((rv = (int) socket(PF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
@@ -295,8 +301,10 @@ int tcp_socket_ok(int skt)
|
||||
if (getsockopt(skt, SOL_SOCKET, SO_ERROR, (char *) (&opt), &opt_len) == 0)
|
||||
{
|
||||
if (opt == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -323,15 +331,21 @@ int tcp_select(int sck1, int sck2)
|
||||
FD_ZERO(&rfds);
|
||||
|
||||
if (sck1 > 0)
|
||||
{
|
||||
FD_SET(((unsigned int) sck1), &rfds);
|
||||
}
|
||||
|
||||
if (sck2 > 0)
|
||||
{
|
||||
FD_SET(((unsigned int) sck2), &rfds);
|
||||
}
|
||||
|
||||
max = sck1;
|
||||
|
||||
if (sck2 > max)
|
||||
{
|
||||
max = sck2;
|
||||
}
|
||||
|
||||
rv = select(max + 1, &rfds, 0, 0, &time);
|
||||
|
||||
@@ -340,11 +354,15 @@ int tcp_select(int sck1, int sck2)
|
||||
rv = 0;
|
||||
|
||||
if (FD_ISSET(((unsigned int) sck1), &rfds))
|
||||
{
|
||||
rv = rv | 1;
|
||||
}
|
||||
|
||||
if (FD_ISSET(((unsigned int)sck2), &rfds))
|
||||
{
|
||||
rv = rv | 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = 0;
|
||||
|
||||
@@ -43,10 +43,13 @@ void hexdump(int address, char *buf, int len)
|
||||
unsigned char c;
|
||||
|
||||
char cvt[] = {'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
if ((buf == NULL) || (len <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addr = (address < 0) ? 0 : address;
|
||||
blocks = len / 16;
|
||||
@@ -85,17 +88,23 @@ void hexdump(int address, char *buf, int len)
|
||||
outbuf[index2++] = ' ';
|
||||
|
||||
if ((c >= 0x20) && (c <= 0x7e))
|
||||
{
|
||||
outbuf[index3++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
outbuf[index3++] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
outbuf[index3] = 0;
|
||||
puts(outbuf);
|
||||
}
|
||||
|
||||
if (!residual)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
outbuf[7] = cvt[(addr >> 0) & 0x0000000f];
|
||||
outbuf[6] = cvt[(addr >> 4) & 0x0000000f];
|
||||
@@ -120,10 +129,14 @@ void hexdump(int address, char *buf, int len)
|
||||
outbuf[index2++] = ' ';
|
||||
|
||||
if ((c >= 0x20) && (c <= 0x7e))
|
||||
{
|
||||
outbuf[index3++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
outbuf[index3++] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
outbuf[index3] = 0;
|
||||
puts(outbuf);
|
||||
|
||||
Reference in New Issue
Block a user