Added partial sample program to accept requests over a socket
This commit is contained in:
parent
a2d8206c58
commit
d51ad1cd6a
@ -79,7 +79,7 @@ endif
|
||||
|
||||
|
||||
bin_PROGRAMS = hcl
|
||||
hcl_SOURCES = main.c
|
||||
hcl_SOURCES = main.c main2.c
|
||||
hcl_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
hcl_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
hcl_LDADD = $(LIBADD_LIB_COMMON) -lhcl #-ldyncall_s
|
||||
|
@ -163,7 +163,7 @@ libhcl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libhcl_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_hcl_OBJECTS = hcl-main.$(OBJEXT)
|
||||
am_hcl_OBJECTS = hcl-main.$(OBJEXT) hcl-main2.$(OBJEXT)
|
||||
hcl_OBJECTS = $(am_hcl_OBJECTS)
|
||||
hcl_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
@ -434,7 +434,7 @@ libhcl_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_3)
|
||||
libhcl_la_DEPENDENCIES = $(am__append_4)
|
||||
hcl_SOURCES = main.c
|
||||
hcl_SOURCES = main.c main2.c
|
||||
hcl_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
hcl_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
hcl_LDADD = $(LIBADD_LIB_COMMON) -lhcl #-ldyncall_s
|
||||
@ -587,6 +587,7 @@ distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-main2.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-bigint.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-comp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-debug.Plo@am__quote@
|
||||
@ -786,6 +787,20 @@ hcl-main.obj: main.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
|
||||
hcl-main2.o: main2.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-main2.o -MD -MP -MF $(DEPDIR)/hcl-main2.Tpo -c -o hcl-main2.o `test -f 'main2.c' || echo '$(srcdir)/'`main2.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-main2.Tpo $(DEPDIR)/hcl-main2.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main2.c' object='hcl-main2.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-main2.o `test -f 'main2.c' || echo '$(srcdir)/'`main2.c
|
||||
|
||||
hcl-main2.obj: main2.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-main2.obj -MD -MP -MF $(DEPDIR)/hcl-main2.Tpo -c -o hcl-main2.obj `if test -f 'main2.c'; then $(CYGPATH_W) 'main2.c'; else $(CYGPATH_W) '$(srcdir)/main2.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-main2.Tpo $(DEPDIR)/hcl-main2.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main2.c' object='hcl-main2.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-main2.obj `if test -f 'main2.c'; then $(CYGPATH_W) 'main2.c'; else $(CYGPATH_W) '$(srcdir)/main2.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
|
@ -2246,7 +2246,6 @@ hcl_oop_t hcl_executefromip (hcl_t* hcl, hcl_oow_t initial_ip)
|
||||
int n, log_default_type_mask;
|
||||
|
||||
HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX); /* asserted by the compiler */
|
||||
HCL_ASSERT (hcl, initial_ip < hcl->code.bc.len);
|
||||
if (initial_ip >= hcl->code.bc.len)
|
||||
{
|
||||
hcl_seterrnum (hcl, HCL_EINVAL);
|
||||
|
@ -345,6 +345,9 @@ typedef struct hcl_bcs_t hcl_bcs_t;
|
||||
# define HCL_SIZEOF_OOCH_T HCL_SIZEOF_BCH_T
|
||||
#endif
|
||||
|
||||
/* the maximum number of bch charaters to represent a single uch character */
|
||||
#define HCL_BCSIZE_MAX 6
|
||||
|
||||
/* =========================================================================
|
||||
* TIME-RELATED TYPES
|
||||
* =========================================================================*/
|
||||
|
13
lib/hcl.c
13
lib/hcl.c
@ -286,11 +286,22 @@ void hcl_fini (hcl_t* hcl)
|
||||
}
|
||||
}
|
||||
|
||||
void hcl_reset (hcl_t* hcl)
|
||||
void hcl_reset (hcl_t* hcl/*, int flags*/)
|
||||
{
|
||||
hcl_oop_t v;
|
||||
hcl_oow_t i;
|
||||
|
||||
#if 0
|
||||
if (flags & HCL_RESET_LXC)
|
||||
{
|
||||
hcl->c->nungots = 0;
|
||||
|
||||
hcl->c->inarg.line = 1;
|
||||
hcl->c->inarg.colm = 1;
|
||||
/* reset on curinp???? hwo to reset the input stream? or crate a separate function? */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* delete all literals shown in the literal frame from the system dictionary
|
||||
* excluding special kernel symbols. */
|
||||
for (i = 0; i < hcl->code.lit.len; i++)
|
||||
|
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);
|
||||
}
|
||||
|
2190
lib/main2.c
Normal file
2190
lib/main2.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,8 +26,6 @@
|
||||
|
||||
#include "hcl-prv.h"
|
||||
|
||||
#define HCL_BCLEN_MAX 6
|
||||
|
||||
/* some naming conventions
|
||||
* bchars, uchars -> pointer and length
|
||||
* bcstr, ucstr -> null-terminated string pointer
|
||||
@ -577,7 +575,7 @@ static HCL_INLINE int ucsn_to_bcsn_with_cmgr (
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_bch_t bcsbuf[HCL_BCLEN_MAX];
|
||||
hcl_bch_t bcsbuf[HCL_BCSIZE_MAX];
|
||||
hcl_oow_t mlen = 0;
|
||||
|
||||
while (p < end)
|
||||
@ -659,7 +657,7 @@ static int ucs_to_bcs_with_cmgr (
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_bch_t bcsbuf[HCL_BCLEN_MAX];
|
||||
hcl_bch_t bcsbuf[HCL_BCSIZE_MAX];
|
||||
hcl_oow_t mlen = 0;
|
||||
|
||||
while (*p != '\0')
|
||||
|
Loading…
x
Reference in New Issue
Block a user