Added partial sample program to accept requests over a socket
This commit is contained in:
32
lib/main.c
32
lib/main.c
@ -519,14 +519,14 @@ static int write_all (int fd, const char* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_ooi_t wr;
|
||||
|
||||
wr = write (1, ptr, len);
|
||||
wr = write(fd, ptr, len);
|
||||
|
||||
if (wr <= -1)
|
||||
{
|
||||
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN == EWOULDBLOCK)
|
||||
if (errno == EAGAIN) continue;
|
||||
#else
|
||||
# if defined(EAGAIN)
|
||||
#if defined(EAGAIN)
|
||||
if (errno == EAGAIN) continue;
|
||||
#elif defined(EWOULDBLOCK)
|
||||
if (errno == EWOULDBLOCK) continue;
|
||||
@ -549,12 +549,6 @@ static int write_all (int fd, const char* ptr, hcl_oow_t len)
|
||||
|
||||
static void log_write (hcl_t* hcl, int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
# error NOT IMPLEMENTED
|
||||
|
||||
#elif defined(macintosh)
|
||||
# error NOT IMPLEMENTED
|
||||
#else
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen, msgidx;
|
||||
int n;
|
||||
@ -664,8 +658,6 @@ static void log_write (hcl_t* hcl, int mask, const hcl_ooch_t* msg, hcl_oow_t le
|
||||
{
|
||||
if (mask & (HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN)) write_all (logfd, "\x1B[0m", 4);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1330,7 +1322,7 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
static int handle_dbgopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
{
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
const hcl_bch_t* cm, * flt;
|
||||
hcl_oow_t len;
|
||||
unsigned int trait, dbgopt = 0;
|
||||
@ -1567,7 +1559,7 @@ static void print_synerr (hcl_t* hcl)
|
||||
|
||||
#define MIN_MEMSIZE 512000ul
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
static int main_tty (int argc, char* argv[])
|
||||
{
|
||||
hcl_t* hcl;
|
||||
xtn_t* xtn;
|
||||
@ -1895,3 +1887,19 @@ oops:
|
||||
hcl_close (hcl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main_server (int argc, char* argv[]);
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
const char* slash;
|
||||
const char* prog;
|
||||
|
||||
prog = argv[0];
|
||||
slash = strrchr(prog, '/');
|
||||
if (slash) prog = slash + 1;
|
||||
|
||||
if (strcmp(prog, "hcld") == 0) return main_server (argc, argv);
|
||||
|
||||
return main_tty (argc, argv);
|
||||
}
|
||||
|
Reference in New Issue
Block a user