mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 23:44:20 +01:00
Small fixes.
This commit is contained in:
parent
3069cc0d2f
commit
d508ffc81b
|
@ -46,7 +46,7 @@ void print_list_items()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < list_index_count; i++)
|
for (int i = 0; i < list_index_count; i++)
|
||||||
{
|
{
|
||||||
PRINT_LINE("%i. %s", i, list[i].name);
|
PRINT_LINE("%i. [%s]", i, list[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct exp_data* get_from_list(int index)
|
struct exp_data* get_from_list(int index)
|
||||||
|
|
25
src/main.c
25
src/main.c
|
@ -8,18 +8,25 @@
|
||||||
|
|
||||||
int checkarg(int argc, char* argv[]);
|
int checkarg(int argc, char* argv[]);
|
||||||
int handleoptions();
|
int handleoptions();
|
||||||
static void sig_handler();
|
void app_cleanup();
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
signal(SIGINT, app_cleanup);
|
||||||
list_add("Socket server", "sock:server", start_server);
|
list_add("Socket server", "sock:server", start_server);
|
||||||
list_add("Socket client", "sock:client", clientstart);
|
list_add("Socket client", "sock:client", clientstart);
|
||||||
|
int result;
|
||||||
|
|
||||||
printf(" _____ \n / ____| \n | | _____ ___ __ \n | | / _ \\ \\/ / '_ \\ \n | |___| __/> <| |_) |\n \\_____\\___/_/\\_\\ .__/ \n | | \n |_| \n");
|
printf(" _____ \n / ____| \n | | _____ ___ __ \n | | / _ \\ \\/ / '_ \\ \n | |___| __/> <| |_) |\n \\_____\\___/_/\\_\\ .__/ \n | | \n |_| \n");
|
||||||
signal(SIGINT, sig_handler);
|
|
||||||
int argresult = checkarg(argc, argv);
|
// Check for argruments and if we can use them.
|
||||||
if (argresult == 0) // If checkarg returns 0 that means it succesfully handled the argruments.
|
result = checkarg(argc, argv);
|
||||||
return argresult;
|
if (result == 0)
|
||||||
return handleoptions(); // If the app does not get args we will display a small options menu.
|
return result;
|
||||||
|
// If the app does not get args we will display a small options menu.
|
||||||
|
result = handleoptions();
|
||||||
|
app_cleanup();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
int checkarg(int argc, char* argv[])
|
int checkarg(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
@ -56,13 +63,13 @@ int handleoptions()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_LINE("Option: %s choosen", data->name);
|
PRINT_LINE("Option: [%s] chosen", data->name);
|
||||||
|
|
||||||
return data->func_ptr != NULL ? data->func_ptr(NULL) : -1;
|
return data->func_ptr != NULL ? data->func_ptr(NULL) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the signal to exit the app!
|
// Clean and exit the app.
|
||||||
static void sig_handler()
|
void app_cleanup()
|
||||||
{
|
{
|
||||||
clear_list(); // Clear the exp list.
|
clear_list(); // Clear the exp list.
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "sockets.h"
|
#include "sockets.h"
|
||||||
|
|
||||||
|
|
||||||
|
void print_help();
|
||||||
|
|
||||||
int clientstart()
|
int clientstart()
|
||||||
{
|
{
|
||||||
int client_sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
int client_sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
@ -48,7 +50,18 @@ int clientstart()
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char c = getchar();
|
char c = getchar();
|
||||||
if (c == 'q')
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'q':
|
||||||
return 0;
|
return 0;
|
||||||
|
case 'h':
|
||||||
|
print_help();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void print_help()
|
||||||
|
{
|
||||||
|
PRINT_LINE("Usage:");
|
||||||
|
PRINT_LINE("send <string>");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user