#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <Ecore.h>
#include <Ecore_Con.h>
#include <Ecore_Getopt.h>
static int retval = EXIT_SUCCESS;
{
if (!echo)
{
else if (do_ssl_upgrade)
{
const char upgrade_msg[] = "\nSend \"Upgrade: SSL\" followed by newline (\\n) to do it.\n";
}
}
}
{
}
{
const char upgrade_ssl[] = "Upgrade: SSL\n";
printf("INFO: client data %p: %s\n"
"INFO: - size: %d\n"
"-- BEGIN DATA --\n",
puts("-- END DATA --");
if (do_ssl_upgrade && ((
size_t)ev->
size == strlen(upgrade_ssl)) &&
(memcmp(ev->
data, upgrade_ssl, ev->
size) == 0))
{
{
}
else
}
if (echo)
{
}
}
{
}
{
}
{
}
static const char *types_strs[] = {
"tcp",
"udp",
"ssl",
"tcp+ssl",
"mcast",
"local-user",
"local-system",
NULL
};
"ecore_con_server_example",
NULL,
"1",
"(C) 2016 Enlightenment Project; 2010 Mike Blumenkrantz",
"BSD 2-Clause",
"Example of ecore_con_server_add() usage.\n",
{
"Try to use $LISTEN_FDS from systemd, if not do a regular serve"),
"If set will limit number of clients to accept"),
"Immediately reject excess clients (over limit)"),
"Behave as 'echo' server, send back to client all the data receive"),
}
};
int
main(int argc, char **argv)
{
Ecore_Con_Type type;
char *name = NULL;
char *type_choice = NULL;
int clients_limit = -1;
int port = -1;
};
int args;
if (args < 0)
{
fputs("ERROR: Could not parse command line options.\n", stderr);
retval = EXIT_FAILURE;
goto end;
}
if (quit_option) goto end;
if (args < 0)
{
fputs("ERROR: Could not parse positional arguments.\n", stderr);
retval = EXIT_FAILURE;
goto end;
}
if (!type_choice) type_choice = "tcp";
if (strcmp(type_choice, "tcp") == 0)
type = ECORE_CON_REMOTE_TCP;
else if (strcmp(type_choice, "udp") == 0)
type = ECORE_CON_REMOTE_UDP;
else if (strcmp(type_choice, "ssl") == 0)
type = ECORE_CON_REMOTE_TCP | ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT;
else if (strcmp(type_choice, "tcp+ssl") == 0)
{
type = ECORE_CON_REMOTE_TCP;
}
else if (strcmp(type_choice, "local-user") == 0)
type = ECORE_CON_LOCAL_USER;
else if (strcmp(type_choice, "local-system") == 0)
type = ECORE_CON_LOCAL_SYSTEM;
else if (strcmp(type_choice, "mcast") == 0)
type = ECORE_CON_REMOTE_MCAST;
else
{
fprintf(stderr, "ERROR: unsupported --type/-t '%s'\n", type_choice);
retval = EXIT_FAILURE;
goto end;
}
if (socket_activated) type |= ECORE_CON_SOCKET_ACTIVATE;
if (!svr) goto end;
if ((strcmp(type_choice, "ssl") == 0)
#if 1
|| (strcmp(type_choice, "tcp+ssl") == 0)
#endif
)
{
{
fprintf(stderr, "ERROR: could not add cert: server.pem\n");
goto no_mainloop;
}
{
fprintf(stderr, "ERROR: could not add privkey: server.pem\n");
goto no_mainloop;
}
}
no_mainloop:
svr = NULL;
end:
return retval;
}