wip - reworking hcl server/client code
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f9ee45cf41
commit
59dfe8cbb7
395
bin/main-c.c
395
bin/main-c.c
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hcl-c.h"
|
#include "hcl-c.h"
|
||||||
|
#include "hcl-x.h"
|
||||||
#include "hcl-opt.h"
|
#include "hcl-opt.h"
|
||||||
#include "hcl-utl.h"
|
#include "hcl-utl.h"
|
||||||
#include "hcl-xutl.h"
|
#include "hcl-xutl.h"
|
||||||
@ -53,6 +54,7 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ struct client_xtn_t
|
|||||||
int logfd;
|
int logfd;
|
||||||
hcl_bitmask_t logmask;
|
hcl_bitmask_t logmask;
|
||||||
int logfd_istty;
|
int logfd_istty;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
hcl_bch_t buf[4096];
|
hcl_bch_t buf[4096];
|
||||||
@ -138,7 +140,6 @@ static int write_log (hcl_client_t* client, int fd, const hcl_bch_t* ptr, hcl_oo
|
|||||||
{
|
{
|
||||||
client_xtn_t* xtn;
|
client_xtn_t* xtn;
|
||||||
|
|
||||||
|
|
||||||
xtn = hcl_client_getxtn(client);
|
xtn = hcl_client_getxtn(client);
|
||||||
|
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
@ -178,7 +179,7 @@ static int write_log (hcl_client_t* client, int fd, const hcl_bch_t* ptr, hcl_oo
|
|||||||
xtn->logbuf.len += len;
|
xtn->logbuf.len += len;
|
||||||
ptr += len;
|
ptr += len;
|
||||||
len -= len;
|
len -= len;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,16 +244,16 @@ static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_
|
|||||||
#else
|
#else
|
||||||
tmp = localtime(&now);
|
tmp = localtime(&now);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||||
#else
|
#else
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||||
#endif
|
#endif
|
||||||
if (tslen == 0)
|
if (tslen == 0)
|
||||||
{
|
{
|
||||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||||
tslen = 25;
|
tslen = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_log (client, logfd, ts, tslen);
|
write_log (client, logfd, ts, tslen);
|
||||||
@ -275,9 +276,9 @@ static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_
|
|||||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||||
if (n == 0 || n == -2)
|
if (n == 0 || n == -2)
|
||||||
{
|
{
|
||||||
/* n = 0:
|
/* n = 0:
|
||||||
* converted all successfully
|
* converted all successfully
|
||||||
* n == -2:
|
* n == -2:
|
||||||
* buffer not sufficient. not all got converted yet.
|
* buffer not sufficient. not all got converted yet.
|
||||||
* write what have been converted this round. */
|
* write what have been converted this round. */
|
||||||
|
|
||||||
@ -343,7 +344,7 @@ static void set_signal (int sig, signal_handler_t handler)
|
|||||||
|
|
||||||
static void set_signal_to_ignore (int sig)
|
static void set_signal_to_ignore (int sig)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
memset (&sa, 0, sizeof(sa));
|
memset (&sa, 0, sizeof(sa));
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
@ -355,7 +356,7 @@ static void set_signal_to_ignore (int sig)
|
|||||||
|
|
||||||
static void set_signal_to_default (int sig)
|
static void set_signal_to_default (int sig)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
memset (&sa, 0, sizeof(sa));
|
memset (&sa, 0, sizeof(sa));
|
||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
@ -377,12 +378,12 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
|
|||||||
xtn = (client_xtn_t*)hcl_client_getxtn(client);
|
xtn = (client_xtn_t*)hcl_client_getxtn(client);
|
||||||
|
|
||||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||||
if (cm)
|
if (cm)
|
||||||
{
|
{
|
||||||
/* i duplicate this string for open() below as open() doesn't
|
/* i duplicate this string for open() below as open() doesn't
|
||||||
* accept a length-bounded string */
|
* accept a length-bounded string */
|
||||||
xstr = strdup(str);
|
xstr = strdup(str);
|
||||||
if (!xstr)
|
if (!xstr)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
||||||
return -1;
|
return -1;
|
||||||
@ -453,119 +454,6 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_reply (hcl_client_t* client, hcl_client_reply_type_t type, const hcl_ooch_t* dptr, hcl_oow_t dlen)
|
|
||||||
{
|
|
||||||
client_xtn_t* client_xtn;
|
|
||||||
client_xtn = hcl_client_getxtn(client);
|
|
||||||
|
|
||||||
if (client_xtn->reply_count > 0)
|
|
||||||
{
|
|
||||||
hcl_client_seterrbfmt (client, HCL_EFLOOD, "\n<<WARNING>> redundant reply received\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dptr)
|
|
||||||
{
|
|
||||||
/* short-form response - no end_reply will be called */
|
|
||||||
if (type == HCL_CLIENT_REPLY_TYPE_ERROR)
|
|
||||||
{
|
|
||||||
#if defined(HCL_OOCH_IS_UCH)
|
|
||||||
hcl_bch_t bcs[256];
|
|
||||||
hcl_oow_t bcslen;
|
|
||||||
|
|
||||||
/* NOTE: the error may get truncated without looping */
|
|
||||||
bcslen = HCL_COUNTOF(bcs);
|
|
||||||
hcl_conv_uchars_to_bchars_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client));
|
|
||||||
printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs);
|
|
||||||
#else
|
|
||||||
printf ("\nERROR - [%.*s]\n", (int)dlen, dptr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if defined(HCL_OOCH_IS_UCH)
|
|
||||||
hcl_oow_t drem = dlen;
|
|
||||||
while (drem > 0)
|
|
||||||
{
|
|
||||||
hcl_bch_t bcs[256];
|
|
||||||
hcl_oow_t ucslen, bcslen;
|
|
||||||
|
|
||||||
ucslen = drem;
|
|
||||||
bcslen = HCL_COUNTOF(bcs);
|
|
||||||
hcl_conv_uchars_to_bchars_with_cmgr(dptr, &ucslen, bcs, &bcslen, hcl_client_getcmgr(client));
|
|
||||||
client_xtn->data_length += bcslen;
|
|
||||||
if (write_all(0, bcs, bcslen) <= -1)
|
|
||||||
{
|
|
||||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
drem -= ucslen;
|
|
||||||
dptr += ucslen;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
client_xtn->data_length += dlen;
|
|
||||||
if (write_all(0, dptr, dlen) <= -1)
|
|
||||||
{
|
|
||||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length);
|
|
||||||
|
|
||||||
/*fflush (stdout);*/
|
|
||||||
client_xtn->reply_count++;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* long-form response */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int end_reply (hcl_client_t* client, hcl_client_end_reply_state_t state)
|
|
||||||
{
|
|
||||||
client_xtn_t* client_xtn;
|
|
||||||
client_xtn = hcl_client_getxtn(client);
|
|
||||||
|
|
||||||
if (state == HCL_CLIENT_END_REPLY_STATE_REVOKED)
|
|
||||||
{
|
|
||||||
/* nothing to do here */
|
|
||||||
printf ("\n<<WARNING>> REPLY(%lu bytes) received so far has been revoked\n", (unsigned long int)client_xtn->data_length);
|
|
||||||
client_xtn->data_length = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client_xtn->reply_count++;
|
|
||||||
/*fflush (stdout);*/
|
|
||||||
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int feed_attr (hcl_client_t* client, const hcl_oocs_t* key, const hcl_oocs_t* val)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int feed_data (hcl_client_t* client, const void* ptr, hcl_oow_t len)
|
|
||||||
{
|
|
||||||
client_xtn_t* client_xtn;
|
|
||||||
|
|
||||||
client_xtn = hcl_client_getxtn(client);
|
|
||||||
client_xtn->data_length += len;
|
|
||||||
|
|
||||||
if (write_all(0, ptr, len) <= -1)
|
|
||||||
{
|
|
||||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
static int send_iov (int sck, struct iovec* iov, int count)
|
static int send_iov (int sck, struct iovec* iov, int count)
|
||||||
@ -582,7 +470,7 @@ static int send_iov (int sck, struct iovec* iov, int count)
|
|||||||
msg.msg_iovlen = count - index;
|
msg.msg_iovlen = count - index;
|
||||||
nwritten = sendmsg(sck, &msg, 0);
|
nwritten = sendmsg(sck, &msg, 0);
|
||||||
/*nwritten = writev(proto->worker->sck, (const struct iovec*)&iov[index], count - index);*/
|
/*nwritten = writev(proto->worker->sck, (const struct iovec*)&iov[index], count - index);*/
|
||||||
if (nwritten <= -1)
|
if (nwritten <= -1)
|
||||||
{
|
{
|
||||||
/* error occurred inside the worker thread shouldn't affect the error information
|
/* error occurred inside the worker thread shouldn't affect the error information
|
||||||
* in the server object. so here, i just log a message */
|
* in the server object. so here, i just log a message */
|
||||||
@ -602,48 +490,104 @@ static int send_iov (int sck, struct iovec* iov, int count)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_script_line (int sck, const char* line, size_t len)
|
/* ========================================================================= */
|
||||||
|
|
||||||
|
enum hcl_xproto_rcv_state_t
|
||||||
{
|
{
|
||||||
struct iovec iov[3];
|
HCL_XPROTO_RCV_HEADER,
|
||||||
int count;
|
HCL_XPROTO_RCV_PAYLOAD,
|
||||||
|
};
|
||||||
|
typedef enum hcl_xproto_rcv_state_t hcl_xproto_rcv_state_t;
|
||||||
|
|
||||||
count = 0;
|
|
||||||
iov[count].iov_base = ".SCRIPT ";
|
|
||||||
iov[count++].iov_len = 8;
|
|
||||||
iov[count].iov_base = (char*)line;
|
|
||||||
iov[count++].iov_len = len;
|
|
||||||
iov[count].iov_base = "\n";
|
|
||||||
iov[count++].iov_len = 1;
|
|
||||||
|
|
||||||
return send_iov(sck, iov, count);
|
struct hcl_xproto_t
|
||||||
}
|
|
||||||
|
|
||||||
static int send_begin_line (int sck)
|
|
||||||
{
|
{
|
||||||
struct iovec iov[2];
|
hcl_t* hcl;
|
||||||
int count;
|
|
||||||
|
|
||||||
count = 0;
|
struct
|
||||||
iov[count].iov_base = ".BEGIN";
|
{
|
||||||
iov[count++].iov_len = 6;
|
hcl_xproto_rcv_state_t state;
|
||||||
iov[count].iov_base = "\n";
|
hcl_oow_t len_needed;
|
||||||
iov[count++].iov_len = 1;
|
unsigned int eof: 1;
|
||||||
|
unsigned int polled: 1;
|
||||||
|
|
||||||
return send_iov(sck, iov, count);
|
hcl_oow_t len;
|
||||||
}
|
hcl_uint8_t buf[4096];
|
||||||
|
|
||||||
static int send_end_line (int sck)
|
hcl_xpkt_hdr_t hdr;
|
||||||
|
} rcv;
|
||||||
|
};
|
||||||
|
typedef struct hcl_xproto_t hcl_xproto_t;
|
||||||
|
|
||||||
|
static int receive_raw_bytes (hcl_xproto_t* proto, int sck, hcl_ntime_t* idle_tmout)
|
||||||
{
|
{
|
||||||
struct iovec iov[2];
|
hcl_t* hcl = proto->hcl;
|
||||||
int count;
|
struct pollfd pfd;
|
||||||
|
int tmout, actual_tmout;
|
||||||
|
ssize_t x;
|
||||||
|
int n;
|
||||||
|
|
||||||
count = 0;
|
HCL_ASSERT (hcl, proto->rcv.len < proto->rcv.len_needed);
|
||||||
iov[count].iov_base = ".END";
|
|
||||||
iov[count++].iov_len = 4;
|
|
||||||
iov[count].iov_base = "\n";
|
|
||||||
iov[count++].iov_len = 1;
|
|
||||||
|
|
||||||
return send_iov(sck, iov, count);
|
if (HCL_UNLIKELY(proto->rcv.eof))
|
||||||
|
{
|
||||||
|
hcl_seterrbfmt (hcl, HCL_EGENERIC, "connection closed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HCL_LIKELY(!proto->rcv.polled))
|
||||||
|
{
|
||||||
|
tmout = idle_tmout? HCL_SECNSEC_TO_MSEC(idle_tmout->sec, idle_tmout->nsec): -1;
|
||||||
|
actual_tmout = (tmout <= 0)? 10000: tmout;
|
||||||
|
|
||||||
|
pfd.fd = sck;
|
||||||
|
pfd.events = POLLIN | POLLERR;
|
||||||
|
pfd.revents = 0;
|
||||||
|
n = poll(&pfd, 1, actual_tmout);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
if (errno == EINTR) return 0;
|
||||||
|
hcl_seterrwithsyserr (hcl, 0, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (n == 0)
|
||||||
|
{
|
||||||
|
/* timed out - no activity on the pfd */
|
||||||
|
if (tmout > 0)
|
||||||
|
{
|
||||||
|
/* timeout explicity set. no activity for that duration. considered idle */
|
||||||
|
hcl_seterrbfmt (hcl, HCL_EGENERIC, "no activity on the socket %d", sck);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* didn't read yet */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pfd.revents & POLLERR)
|
||||||
|
{
|
||||||
|
hcl_seterrbfmt (hcl, HCL_EGENERIC, "error condition detected on socket %d", sck);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
proto->rcv.polled = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
x = recv(sck, &proto->rcv.buf[proto->rcv.len], HCL_COUNTOF(proto->rcv.buf) - proto->rcv.len, 0);
|
||||||
|
if (x <= -1)
|
||||||
|
{
|
||||||
|
if (errno == EINTR) return 0; /* didn't read read */
|
||||||
|
|
||||||
|
proto->rcv.polled = 0;
|
||||||
|
hcl_seterrwithsyserr (hcl, 0, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
proto->rcv.polled = 0;
|
||||||
|
if (x == 0) proto->rcv.eof = 1;
|
||||||
|
|
||||||
|
proto->rcv.len += x;
|
||||||
|
return 1; /* read some data */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_request (hcl_client_t* client, const char* ipaddr, const char* script, int reuse_addr, int shut_wr_after_req)
|
static int handle_request (hcl_client_t* client, const char* ipaddr, const char* script, int reuse_addr, int shut_wr_after_req)
|
||||||
@ -658,20 +602,23 @@ static int handle_request (hcl_client_t* client, const char* ipaddr, const char*
|
|||||||
hcl_bch_t buf[256];
|
hcl_bch_t buf[256];
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
const char* scptr;
|
const char* scptr;
|
||||||
|
const char* sccur;
|
||||||
|
|
||||||
|
hcl_xproto_t proto;
|
||||||
|
|
||||||
client_xtn_t* client_xtn;
|
client_xtn_t* client_xtn;
|
||||||
|
|
||||||
client_xtn = hcl_client_getxtn(client);
|
client_xtn = hcl_client_getxtn(client);
|
||||||
|
|
||||||
sckfam = hcl_bchars_to_sckaddr(ipaddr, strlen(ipaddr), &sckaddr, &scklen);
|
sckfam = hcl_bchars_to_sckaddr(ipaddr, strlen(ipaddr), &sckaddr, &scklen);
|
||||||
if (sckfam <= -1)
|
if (sckfam <= -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "cannot convert ip address - %s\n", ipaddr);
|
fprintf (stderr, "cannot convert ip address - %s\n", ipaddr);
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
sck = socket (sckfam, SOCK_STREAM, 0);
|
sck = socket (sckfam, SOCK_STREAM, 0);
|
||||||
if (sck <= -1)
|
if (sck <= -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "cannot create a socket for %s - %s\n", ipaddr, strerror(errno));
|
fprintf (stderr, "cannot create a socket for %s - %s\n", ipaddr, strerror(errno));
|
||||||
goto oops;
|
goto oops;
|
||||||
@ -705,68 +652,78 @@ static int handle_request (hcl_client_t* client, const char* ipaddr, const char*
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_begin_line(sck) <= -1) goto oops;
|
|
||||||
|
|
||||||
scptr = script;
|
|
||||||
|
/* TODO: create hcl_xproto_open... */
|
||||||
|
memset (&proto, 0, HCL_SIZEOF(proto));
|
||||||
|
proto.hcl = hcl_openstdwithmmgr(hcl_client_getmmgr(client), 0, HCL_NULL); // TODO:
|
||||||
|
proto.rcv.state = HCL_XPROTO_RCV_HEADER;
|
||||||
|
proto.rcv.len_needed = HCL_SIZEOF(proto.rcv.hdr);
|
||||||
|
proto.rcv.eof = 0;
|
||||||
|
proto.rcv.polled = 0;
|
||||||
|
|
||||||
|
scptr = sccur = script;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
const char* nl;
|
struct pollfd pfd;
|
||||||
nl = strchr(scptr, '\n');
|
|
||||||
if (send_script_line(sck, scptr, (nl? (nl - scptr): strlen(scptr))) <= -1) goto oops;
|
pfd.fd = sck;
|
||||||
if (!nl) break;
|
pfd.events = POLLIN | POLLERR;
|
||||||
scptr = nl + 1;
|
if (*sccur != '\0') pfd.events |= POLLOUT;
|
||||||
|
pfd.revents = 0;
|
||||||
|
|
||||||
|
n = poll(&pfd, 1, 1000);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "poll error on %d - %s\n", sck, strerror(n));
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
/* TODO: proper timeout handling */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pfd.revents & POLLERR)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "error condition detected on %d\n", sck);
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pfd.revents & POLLOUT)
|
||||||
|
{
|
||||||
|
hcl_xpkt_hdr_t hdr;
|
||||||
|
struct iovec iov[2];
|
||||||
|
|
||||||
|
while (*sccur != '\0' && sccur - scptr < 255) sccur++;
|
||||||
|
|
||||||
|
hdr.type = HCL_XPKT_CODEIN;
|
||||||
|
hdr.id = 1; /* TODO: */
|
||||||
|
hdr.len = sccur - scptr;
|
||||||
|
|
||||||
|
iov[0].iov_base = &hdr;
|
||||||
|
iov[0].iov_len = HCL_SIZEOF(hdr);
|
||||||
|
iov[1].iov_base = scptr;
|
||||||
|
iov[1].iov_len = sccur - scptr;
|
||||||
|
|
||||||
|
send_iov (sck, iov, 2); /* TODO: error check */
|
||||||
|
|
||||||
|
scptr = sccur;
|
||||||
|
|
||||||
|
if (*sccur == '\0' && shut_wr_after_req) shutdown (sck, SHUT_WR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pfd.revents & POLLIN)
|
||||||
|
{
|
||||||
|
printf ("receiving...\n");
|
||||||
|
if (receive_raw_bytes(&proto, sck, HCL_NULL) <= -1) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_end_line(sck) <= -1) goto oops;
|
|
||||||
|
|
||||||
if (shut_wr_after_req) shutdown (sck, SHUT_WR);
|
|
||||||
|
|
||||||
client_xtn->data_length = 0;
|
client_xtn->data_length = 0;
|
||||||
client_xtn->reply_count = 0;
|
client_xtn->reply_count = 0;
|
||||||
|
|
||||||
/* TODO: implement timeout? */
|
|
||||||
avail = 0;
|
|
||||||
while (client_xtn->reply_count == 0)
|
|
||||||
{
|
|
||||||
n = recv(sck, &buf[avail], HCL_SIZEOF(buf) - avail, 0);
|
|
||||||
if (n <= -1)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Unable to read from %d - %s\n", sck, strerror(n));
|
|
||||||
goto oops;
|
|
||||||
}
|
|
||||||
if (n == 0)
|
|
||||||
{
|
|
||||||
if (hcl_client_getstate(client) != HCL_CLIENT_STATE_START)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Sudden end of reply\n");
|
|
||||||
goto oops;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
avail += n;;
|
|
||||||
x = hcl_client_feed(client, buf, avail, &used);
|
|
||||||
if (x <= -1)
|
|
||||||
{
|
|
||||||
#if defined(HCL_OOCH_IS_UCH)
|
|
||||||
hcl_errnum_t errnum = hcl_client_geterrnum(client);
|
|
||||||
const hcl_ooch_t* errmsg = hcl_client_geterrmsg(client);
|
|
||||||
hcl_bch_t errbuf[2048];
|
|
||||||
hcl_oow_t ucslen, bcslen;
|
|
||||||
|
|
||||||
bcslen = HCL_COUNTOF(errbuf);
|
|
||||||
hcl_conv_ucstr_to_bcstr_with_cmgr (errmsg, &ucslen, errbuf, &bcslen, hcl_client_getcmgr(client));
|
|
||||||
fprintf (stderr, "Client error [%d] - %s\n", (int)errnum, errbuf);
|
|
||||||
#else
|
|
||||||
fprintf (stderr, "Client error [%d] - %s\n", (int)hcl_client_geterrnum(client), hcl_client_geterrmsg(client));
|
|
||||||
#endif
|
|
||||||
goto oops;
|
|
||||||
}
|
|
||||||
|
|
||||||
avail -= used;
|
|
||||||
if (avail > 0) memmove (&buf[0], &buf[used], avail);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: we can check if the buffer has all been consumed. if not, there is trailing garbage.. */
|
/* TODO: we can check if the buffer has all been consumed. if not, there is trailing garbage.. */
|
||||||
|
|
||||||
/*shutdown (sck, (shut_wr_after_req? SHUT_RD: SHUT_RDWR));*/
|
/*shutdown (sck, (shut_wr_after_req? SHUT_RD: SHUT_RDWR));*/
|
||||||
@ -861,10 +818,6 @@ int main (int argc, char* argv[])
|
|||||||
|
|
||||||
memset (&client_prim, 0, HCL_SIZEOF(client_prim));
|
memset (&client_prim, 0, HCL_SIZEOF(client_prim));
|
||||||
client_prim.log_write = log_write;
|
client_prim.log_write = log_write;
|
||||||
client_prim.start_reply = start_reply;
|
|
||||||
client_prim.feed_attr = feed_attr;
|
|
||||||
client_prim.feed_data = feed_data;
|
|
||||||
client_prim.end_reply = end_reply;
|
|
||||||
|
|
||||||
client = hcl_client_open(&sys_mmgr, HCL_SIZEOF(client_xtn_t), &client_prim, HCL_NULL);
|
client = hcl_client_open(&sys_mmgr, HCL_SIZEOF(client_xtn_t), &client_prim, HCL_NULL);
|
||||||
if (!client)
|
if (!client)
|
||||||
|
20
bin/main-j.c
20
bin/main-j.c
@ -15,7 +15,7 @@ struct json_xtn_t
|
|||||||
int logfd;
|
int logfd;
|
||||||
hcl_bitmask_t logmask;
|
hcl_bitmask_t logmask;
|
||||||
int logfd_istty;
|
int logfd_istty;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
hcl_bch_t buf[4096];
|
hcl_bch_t buf[4096];
|
||||||
@ -127,7 +127,7 @@ static int write_log (hcl_json_t* json, int fd, const hcl_bch_t* ptr, hcl_oow_t
|
|||||||
xtn->logbuf.len += len;
|
xtn->logbuf.len += len;
|
||||||
ptr += len;
|
ptr += len;
|
||||||
len -= len;
|
len -= len;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* m
|
|||||||
json_xtn_t* xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
json_xtn_t* xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||||
hcl_bch_t buf[256];
|
hcl_bch_t buf[256];
|
||||||
hcl_oow_t ucslen, bcslen;
|
hcl_oow_t ucslen, bcslen;
|
||||||
|
|
||||||
hcl_oow_t msgidx;
|
hcl_oow_t msgidx;
|
||||||
int n, logfd;
|
int n, logfd;
|
||||||
|
|
||||||
@ -193,12 +193,12 @@ static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* m
|
|||||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||||
#else
|
#else
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||||
#endif
|
#endif
|
||||||
if (tslen == 0)
|
if (tslen == 0)
|
||||||
{
|
{
|
||||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||||
tslen = 25;
|
tslen = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_log (json, logfd, ts, tslen);
|
write_log (json, logfd, ts, tslen);
|
||||||
@ -221,9 +221,9 @@ static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* m
|
|||||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||||
if (n == 0 || n == -2)
|
if (n == 0 || n == -2)
|
||||||
{
|
{
|
||||||
/* n = 0:
|
/* n = 0:
|
||||||
* converted all successfully
|
* converted all successfully
|
||||||
* n == -2:
|
* n == -2:
|
||||||
* buffer not sufficient. not all got converted yet.
|
* buffer not sufficient. not all got converted yet.
|
||||||
* write what have been converted this round. */
|
* write what have been converted this round. */
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ int main (int argc, char* argv[])
|
|||||||
/*p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }";*/
|
/*p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }";*/
|
||||||
|
|
||||||
if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1)
|
if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1)
|
||||||
{
|
{
|
||||||
hcl_json_logbfmt (json, HCL_LOG_FATAL | HCL_LOG_APP, "ERROR: unable to process - %js\n", hcl_json_geterrmsg(json));
|
hcl_json_logbfmt (json, HCL_LOG_FATAL | HCL_LOG_APP, "ERROR: unable to process - %js\n", hcl_json_geterrmsg(json));
|
||||||
}
|
}
|
||||||
else if (json_xtn->depth != 0)
|
else if (json_xtn->depth != 0)
|
||||||
|
30
bin/main-s.c
30
bin/main-s.c
@ -24,7 +24,7 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hcl-s.h"
|
#include "hcl-x.h"
|
||||||
#include "hcl-opt.h"
|
#include "hcl-opt.h"
|
||||||
#include "hcl-utl.h"
|
#include "hcl-utl.h"
|
||||||
#include "hcl-xutl.h"
|
#include "hcl-xutl.h"
|
||||||
@ -59,7 +59,7 @@ struct server_xtn_t
|
|||||||
int logfd;
|
int logfd;
|
||||||
hcl_bitmask_t logmask;
|
hcl_bitmask_t logmask;
|
||||||
int logfd_istty;
|
int logfd_istty;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
hcl_bch_t buf[4096];
|
hcl_bch_t buf[4096];
|
||||||
@ -169,7 +169,7 @@ static int write_log (hcl_server_t* server, int fd, const hcl_bch_t* ptr, hcl_oo
|
|||||||
xtn->logbuf.len += len;
|
xtn->logbuf.len += len;
|
||||||
ptr += len;
|
ptr += len;
|
||||||
len -= len;
|
len -= len;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,12 +235,12 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask,
|
|||||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||||
#else
|
#else
|
||||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||||
#endif
|
#endif
|
||||||
if (tslen == 0)
|
if (tslen == 0)
|
||||||
{
|
{
|
||||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||||
tslen = 25;
|
tslen = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_log (server, logfd, ts, tslen);
|
write_log (server, logfd, ts, tslen);
|
||||||
@ -270,9 +270,9 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask,
|
|||||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||||
if (n == 0 || n == -2)
|
if (n == 0 || n == -2)
|
||||||
{
|
{
|
||||||
/* n = 0:
|
/* n = 0:
|
||||||
* converted all successfully
|
* converted all successfully
|
||||||
* n == -2:
|
* n == -2:
|
||||||
* buffer not sufficient. not all got converted yet.
|
* buffer not sufficient. not all got converted yet.
|
||||||
* write what have been converted this round. */
|
* write what have been converted this round. */
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ static void set_signal (int sig, signal_handler_t handler)
|
|||||||
|
|
||||||
static void set_signal_to_ignore (int sig)
|
static void set_signal_to_ignore (int sig)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
memset (&sa, 0, sizeof(sa));
|
memset (&sa, 0, sizeof(sa));
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
@ -350,7 +350,7 @@ static void set_signal_to_ignore (int sig)
|
|||||||
|
|
||||||
static void set_signal_to_default (int sig)
|
static void set_signal_to_default (int sig)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
memset (&sa, 0, sizeof(sa));
|
memset (&sa, 0, sizeof(sa));
|
||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
@ -372,12 +372,12 @@ static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
|
|||||||
xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||||
|
|
||||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||||
if (cm)
|
if (cm)
|
||||||
{
|
{
|
||||||
/* i duplicate this string for open() below as open() doesn't
|
/* i duplicate this string for open() below as open() doesn't
|
||||||
* accept a length-bounded string */
|
* accept a length-bounded string */
|
||||||
xstr = strdup(str);
|
xstr = strdup(str);
|
||||||
if (!xstr)
|
if (!xstr)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
||||||
return -1;
|
return -1;
|
||||||
@ -497,7 +497,7 @@ static int handle_incpath (hcl_server_t* server, const char* str)
|
|||||||
|
|
||||||
#define MIN_WORKER_STACK_SIZE 512000ul
|
#define MIN_WORKER_STACK_SIZE 512000ul
|
||||||
#define MIN_ACTOR_HEAP_SIZE 512000ul
|
#define MIN_ACTOR_HEAP_SIZE 512000ul
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
hcl_bci_t c;
|
hcl_bci_t c;
|
||||||
|
@ -106,12 +106,13 @@ endif
|
|||||||
|
|
||||||
if ENABLE_HCLX
|
if ENABLE_HCLX
|
||||||
pkglib_LTLIBRARIES += libhclx.la
|
pkglib_LTLIBRARIES += libhclx.la
|
||||||
pkginclude_HEADERS += hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
pkginclude_HEADERS += hcl-c.h hcl-s.h hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||||
libhclx_la_SOURCES = \
|
libhclx_la_SOURCES = \
|
||||||
tmr.c hcl-tmr.h \
|
tmr.c hcl-tmr.h \
|
||||||
xutl.c xutl-sa.h hcl-xutl.h \
|
xutl.c xutl-sa.h hcl-xutl.h \
|
||||||
json.c hcl-json.h \
|
json.c hcl-json.h \
|
||||||
hcl-s.c hcl-s2.c hcl-s.h \
|
hcl-s.c hcl-s.h \
|
||||||
|
hcl-x.c hcl-x.h \
|
||||||
hcl-c.c hcl-c.h
|
hcl-c.c hcl-c.h
|
||||||
libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
||||||
libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||||
|
@ -97,7 +97,7 @@ host_triplet = @host@
|
|||||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-str.la \
|
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-str.la \
|
||||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-sys.la
|
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-sys.la
|
||||||
@ENABLE_HCLX_TRUE@am__append_7 = libhclx.la
|
@ENABLE_HCLX_TRUE@am__append_7 = libhclx.la
|
||||||
@ENABLE_HCLX_TRUE@am__append_8 = hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
@ENABLE_HCLX_TRUE@am__append_8 = hcl-c.h hcl-s.h hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||||
subdir = lib
|
subdir = lib
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||||
@ -171,11 +171,11 @@ libhcl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
@ENABLE_HCLX_TRUE@libhclx_la_DEPENDENCIES = libhcl.la \
|
@ENABLE_HCLX_TRUE@libhclx_la_DEPENDENCIES = libhcl.la \
|
||||||
@ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_5)
|
@ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_5)
|
||||||
am__libhclx_la_SOURCES_DIST = tmr.c hcl-tmr.h xutl.c xutl-sa.h \
|
am__libhclx_la_SOURCES_DIST = tmr.c hcl-tmr.h xutl.c xutl-sa.h \
|
||||||
hcl-xutl.h json.c hcl-json.h hcl-s.c hcl-s2.c hcl-s.h hcl-c.c \
|
hcl-xutl.h json.c hcl-json.h hcl-s.c hcl-s.h hcl-x.c hcl-x.h \
|
||||||
hcl-c.h
|
hcl-c.c hcl-c.h
|
||||||
@ENABLE_HCLX_TRUE@am_libhclx_la_OBJECTS = libhclx_la-tmr.lo \
|
@ENABLE_HCLX_TRUE@am_libhclx_la_OBJECTS = libhclx_la-tmr.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-xutl.lo libhclx_la-json.lo \
|
@ENABLE_HCLX_TRUE@ libhclx_la-xutl.lo libhclx_la-json.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-hcl-s.lo libhclx_la-hcl-s2.lo \
|
@ENABLE_HCLX_TRUE@ libhclx_la-hcl-s.lo libhclx_la-hcl-x.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-hcl-c.lo
|
@ENABLE_HCLX_TRUE@ libhclx_la-hcl-c.lo
|
||||||
libhclx_la_OBJECTS = $(am_libhclx_la_OBJECTS)
|
libhclx_la_OBJECTS = $(am_libhclx_la_OBJECTS)
|
||||||
libhclx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
libhclx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
@ -213,7 +213,7 @@ am__depfiles_remade = ./$(DEPDIR)/libhcl_la-bigint.Plo \
|
|||||||
./$(DEPDIR)/libhcl_la-utl.Plo ./$(DEPDIR)/libhcl_la-xchg.Plo \
|
./$(DEPDIR)/libhcl_la-utl.Plo ./$(DEPDIR)/libhcl_la-xchg.Plo \
|
||||||
./$(DEPDIR)/libhcl_la-xma.Plo ./$(DEPDIR)/libhclx_la-hcl-c.Plo \
|
./$(DEPDIR)/libhcl_la-xma.Plo ./$(DEPDIR)/libhclx_la-hcl-c.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-hcl-s.Plo \
|
./$(DEPDIR)/libhclx_la-hcl-s.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-hcl-s2.Plo \
|
./$(DEPDIR)/libhclx_la-hcl-x.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-json.Plo ./$(DEPDIR)/libhclx_la-tmr.Plo \
|
./$(DEPDIR)/libhclx_la-json.Plo ./$(DEPDIR)/libhclx_la-tmr.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-xutl.Plo
|
./$(DEPDIR)/libhclx_la-xutl.Plo
|
||||||
am__mv = mv -f
|
am__mv = mv -f
|
||||||
@ -244,7 +244,7 @@ am__can_run_installinfo = \
|
|||||||
esac
|
esac
|
||||||
am__pkginclude_HEADERS_DIST = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h \
|
am__pkginclude_HEADERS_DIST = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h \
|
||||||
hcl-opt.h hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-xma.h \
|
hcl-opt.h hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-xma.h \
|
||||||
hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
hcl-c.h hcl-s.h hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||||
HEADERS = $(pkginclude_HEADERS)
|
HEADERS = $(pkginclude_HEADERS)
|
||||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
||||||
hcl-cfg.h.in
|
hcl-cfg.h.in
|
||||||
@ -479,7 +479,8 @@ libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_6)
|
|||||||
@ENABLE_HCLX_TRUE@ tmr.c hcl-tmr.h \
|
@ENABLE_HCLX_TRUE@ tmr.c hcl-tmr.h \
|
||||||
@ENABLE_HCLX_TRUE@ xutl.c xutl-sa.h hcl-xutl.h \
|
@ENABLE_HCLX_TRUE@ xutl.c xutl-sa.h hcl-xutl.h \
|
||||||
@ENABLE_HCLX_TRUE@ json.c hcl-json.h \
|
@ENABLE_HCLX_TRUE@ json.c hcl-json.h \
|
||||||
@ENABLE_HCLX_TRUE@ hcl-s.c hcl-s2.c hcl-s.h \
|
@ENABLE_HCLX_TRUE@ hcl-s.c hcl-s.h \
|
||||||
|
@ENABLE_HCLX_TRUE@ hcl-x.c hcl-x.h \
|
||||||
@ENABLE_HCLX_TRUE@ hcl-c.c hcl-c.h
|
@ENABLE_HCLX_TRUE@ hcl-c.c hcl-c.h
|
||||||
|
|
||||||
@ENABLE_HCLX_TRUE@libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
@ENABLE_HCLX_TRUE@libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
||||||
@ -612,7 +613,7 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xma.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xma.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-c.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-c.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-s.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-s.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-s2.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-hcl-x.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-json.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-json.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-tmr.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-tmr.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-xutl.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-xutl.Plo@am__quote@ # am--include-marker
|
||||||
@ -871,12 +872,12 @@ libhclx_la-hcl-s.lo: hcl-s.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-hcl-s.lo `test -f 'hcl-s.c' || echo '$(srcdir)/'`hcl-s.c
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-hcl-s.lo `test -f 'hcl-s.c' || echo '$(srcdir)/'`hcl-s.c
|
||||||
|
|
||||||
libhclx_la-hcl-s2.lo: hcl-s2.c
|
libhclx_la-hcl-x.lo: hcl-x.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-hcl-s2.lo -MD -MP -MF $(DEPDIR)/libhclx_la-hcl-s2.Tpo -c -o libhclx_la-hcl-s2.lo `test -f 'hcl-s2.c' || echo '$(srcdir)/'`hcl-s2.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-hcl-x.lo -MD -MP -MF $(DEPDIR)/libhclx_la-hcl-x.Tpo -c -o libhclx_la-hcl-x.lo `test -f 'hcl-x.c' || echo '$(srcdir)/'`hcl-x.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-hcl-s2.Tpo $(DEPDIR)/libhclx_la-hcl-s2.Plo
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-hcl-x.Tpo $(DEPDIR)/libhclx_la-hcl-x.Plo
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hcl-s2.c' object='libhclx_la-hcl-s2.lo' libtool=yes @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hcl-x.c' object='libhclx_la-hcl-x.lo' libtool=yes @AMDEPBACKSLASH@
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-hcl-s2.lo `test -f 'hcl-s2.c' || echo '$(srcdir)/'`hcl-s2.c
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-hcl-x.lo `test -f 'hcl-x.c' || echo '$(srcdir)/'`hcl-x.c
|
||||||
|
|
||||||
libhclx_la-hcl-c.lo: hcl-c.c
|
libhclx_la-hcl-c.lo: hcl-c.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-hcl-c.lo -MD -MP -MF $(DEPDIR)/libhclx_la-hcl-c.Tpo -c -o libhclx_la-hcl-c.lo `test -f 'hcl-c.c' || echo '$(srcdir)/'`hcl-c.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-hcl-c.lo -MD -MP -MF $(DEPDIR)/libhclx_la-hcl-c.Tpo -c -o libhclx_la-hcl-c.lo `test -f 'hcl-c.c' || echo '$(srcdir)/'`hcl-c.c
|
||||||
@ -1069,7 +1070,7 @@ distclean: distclean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-c.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-c.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s2.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-x.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-xutl.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-xutl.Plo
|
||||||
@ -1149,7 +1150,7 @@ maintainer-clean: maintainer-clean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-c.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-c.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-hcl-s2.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-hcl-x.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-xutl.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-xutl.Plo
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
|
|
||||||
#include "hcl-c.h"
|
#include "hcl-c.h"
|
||||||
#include "hcl-prv.h"
|
#include "hcl-prv.h"
|
||||||
@ -1044,3 +1045,5 @@ int hcl_client_feed (hcl_client_t* client, const void* ptr, hcl_oow_t len, hcl_o
|
|||||||
*xlen = total;
|
*xlen = total;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
|
|
||||||
#ifndef _HCL_C_H_
|
#ifndef _HCL_C_H_
|
||||||
#define _HCL_C_H_
|
#define _HCL_C_H_
|
||||||
@ -265,3 +266,6 @@ HCL_EXPORT void hcl_client_freemem (
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -150,7 +150,7 @@ HCL_EXPORT int hcl_is_bch_type (hcl_bch_t c, hcl_bch_prop_t type);
|
|||||||
# if __has_builtin(__builtin_tolower)
|
# if __has_builtin(__builtin_tolower)
|
||||||
# define hcl_to_bch_lower __builtin_tolower
|
# define hcl_to_bch_lower __builtin_tolower
|
||||||
# endif
|
# endif
|
||||||
#elif (__GNUC__ >= 4)
|
#elif (__GNUC__ >= 4)
|
||||||
# define hcl_is_bch_upper __builtin_isupper
|
# define hcl_is_bch_upper __builtin_isupper
|
||||||
# define hcl_is_bch_lower __builtin_islower
|
# define hcl_is_bch_lower __builtin_islower
|
||||||
# define hcl_is_bch_alpha __builtin_isalpha
|
# define hcl_is_bch_alpha __builtin_isalpha
|
||||||
|
11
lib/hcl-s.c
11
lib/hcl-s.c
@ -21,6 +21,7 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
|
|
||||||
#include "hcl-s.h"
|
#include "hcl-s.h"
|
||||||
#include "hcl-prv.h"
|
#include "hcl-prv.h"
|
||||||
@ -515,8 +516,8 @@ start_over:
|
|||||||
|
|
||||||
#if defined(HCL_OOCH_IS_UCH)
|
#if defined(HCL_OOCH_IS_UCH)
|
||||||
bcslen = bb->len;
|
bcslen = bb->len;
|
||||||
ucslen = HCL_COUNTOF(arg->buf);
|
ucslen = HCL_COUNTOF(arg->buf.c);
|
||||||
y = hcl_convbtooochars(hcl, bb->buf, &bcslen, arg->buf, &ucslen);
|
y = hcl_convbtooochars(hcl, bb->buf, &bcslen, arg->buf.c, &ucslen);
|
||||||
if (y <= -1 && ucslen <= 0)
|
if (y <= -1 && ucslen <= 0)
|
||||||
{
|
{
|
||||||
if (y == -3 && x != 0) goto start_over; /* incomplete sequence and not EOF yet */
|
if (y == -3 && x != 0) goto start_over; /* incomplete sequence and not EOF yet */
|
||||||
@ -525,9 +526,9 @@ start_over:
|
|||||||
/* if ucslen is greater than 0, i see that some characters have been
|
/* if ucslen is greater than 0, i see that some characters have been
|
||||||
* converted properly */
|
* converted properly */
|
||||||
#else
|
#else
|
||||||
bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf);
|
bcslen = (bb->len < HCL_COUNTOF(arg->buf.b))? bb->len: HCL_COUNTOF(arg->buf.b);
|
||||||
ucslen = bcslen;
|
ucslen = bcslen;
|
||||||
hcl_copy_bchars (arg->buf, bb->buf, bcslen);
|
hcl_copy_bchars (arg->buf.b, bb->buf, bcslen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
remlen = bb->len - bcslen;
|
remlen = bb->len - bcslen;
|
||||||
@ -2555,3 +2556,5 @@ void hcl_server_freemem (hcl_server_t* server, void* ptr)
|
|||||||
{
|
{
|
||||||
HCL_MMGR_FREE (server->_mmgr, ptr);
|
HCL_MMGR_FREE (server->_mmgr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
#ifndef _HCL_S_H_
|
#ifndef _HCL_S_H_
|
||||||
#define _HCL_S_H_
|
#define _HCL_S_H_
|
||||||
|
|
||||||
@ -219,3 +220,7 @@ HCL_EXPORT int hcl_server_proto_handle_request (
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
401
lib/hcl-x.h
Normal file
401
lib/hcl-x.h
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HCL_X_T_
|
||||||
|
#define _HCL_X_T_
|
||||||
|
|
||||||
|
/*#include <hcl-cmn.h>*/
|
||||||
|
#include <hcl.h>
|
||||||
|
|
||||||
|
enum hcl_xpkt_type_t
|
||||||
|
{
|
||||||
|
HCL_XPKT_CODEIN,
|
||||||
|
HCL_XPKT_CODEOUT, /* return value is passed over this? */
|
||||||
|
HCL_XPKT_STDIN,
|
||||||
|
HCL_XPKT_STDOUT,
|
||||||
|
|
||||||
|
HCL_XPKT_LIST_WORKERS,
|
||||||
|
HCL_XPKT_KILL_WORKER
|
||||||
|
};
|
||||||
|
typedef enum hcl_xpkt_type_t hcl_xpkt_type_t;
|
||||||
|
|
||||||
|
struct hcl_xpkt_hdr_t
|
||||||
|
{
|
||||||
|
hcl_uint8_t type;
|
||||||
|
hcl_uint8_t id;
|
||||||
|
hcl_uint8_t len;
|
||||||
|
};
|
||||||
|
typedef struct hcl_xpkt_hdr_t hcl_xpkt_hdr_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
typedef struct hcl_server_proto_t hcl_server_proto_t;
|
||||||
|
typedef struct hcl_server_worker_t hcl_server_worker_t;
|
||||||
|
typedef struct hcl_server_t hcl_server_t;
|
||||||
|
|
||||||
|
enum hcl_server_option_t
|
||||||
|
{
|
||||||
|
HCL_SERVER_TRAIT,
|
||||||
|
HCL_SERVER_LOG_MASK,
|
||||||
|
HCL_SERVER_WORKER_MAX_COUNT,
|
||||||
|
HCL_SERVER_WORKER_STACK_SIZE,
|
||||||
|
HCL_SERVER_WORKER_IDLE_TIMEOUT,
|
||||||
|
HCL_SERVER_ACTOR_HEAP_SIZE,
|
||||||
|
HCL_SERVER_ACTOR_MAX_RUNTIME,
|
||||||
|
HCL_SERVER_SCRIPT_INCLUDE_PATH,
|
||||||
|
HCL_SERVER_MODULE_INCTX
|
||||||
|
};
|
||||||
|
typedef enum hcl_server_option_t hcl_server_option_t;
|
||||||
|
|
||||||
|
enum hcl_server_trait_t
|
||||||
|
{
|
||||||
|
#if defined(HCL_BUILD_DEBUG)
|
||||||
|
HCL_SERVER_TRAIT_DEBUG_GC = (1 << 0),
|
||||||
|
HCL_SERVER_TRAIT_DEBUG_BIGINT = (1 << 1)
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
typedef enum hcl_server_trait_t hcl_server_trait_t;
|
||||||
|
|
||||||
|
#define HCL_SERVER_WID_INVALID ((hcl_oow_t)-1)
|
||||||
|
#define HCL_SERVER_WID_MAX (HCL_SERVER_WID_INVALID - 1)
|
||||||
|
|
||||||
|
typedef void (*hcl_server_log_write_t) (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_oow_t wid,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_ooch_t* msg,
|
||||||
|
hcl_oow_t len
|
||||||
|
);
|
||||||
|
|
||||||
|
struct hcl_server_prim_t
|
||||||
|
{
|
||||||
|
hcl_server_log_write_t log_write;
|
||||||
|
};
|
||||||
|
typedef struct hcl_server_prim_t hcl_server_prim_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct hcl_client_t hcl_client_t;
|
||||||
|
|
||||||
|
enum hcl_client_option_t
|
||||||
|
{
|
||||||
|
HCL_CLIENT_TRAIT,
|
||||||
|
HCL_CLIENT_LOG_MASK,
|
||||||
|
};
|
||||||
|
typedef enum hcl_client_option_t hcl_client_option_t;
|
||||||
|
|
||||||
|
enum hcl_client_trait_t
|
||||||
|
{
|
||||||
|
/* no trait defined at this moment. XXXX is just a placeholder */
|
||||||
|
HCL_CLIENT_XXXX = (1 << 0)
|
||||||
|
};
|
||||||
|
typedef enum hcl_client_trait_t hcl_client_trait_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*hcl_client_log_write_t) (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_ooch_t* msg,
|
||||||
|
hcl_oow_t len
|
||||||
|
);
|
||||||
|
|
||||||
|
struct hcl_client_prim_t
|
||||||
|
{
|
||||||
|
hcl_client_log_write_t log_write;
|
||||||
|
};
|
||||||
|
typedef struct hcl_client_prim_t hcl_client_prim_t;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_server_t* hcl_server_open (
|
||||||
|
hcl_mmgr_t* mmgr,
|
||||||
|
hcl_oow_t xtnsize,
|
||||||
|
hcl_server_prim_t* prim,
|
||||||
|
hcl_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_close (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_start (
|
||||||
|
hcl_server_t* server,
|
||||||
|
const hcl_bch_t* addrs
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_stop (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_setoption (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_server_option_t id,
|
||||||
|
const void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_getoption (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_server_option_t id,
|
||||||
|
void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_server_getxtn (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_mmgr_t* hcl_server_getmmgr (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_cmgr_t* hcl_server_getcmgr (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_setcmgr (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_cmgr_t* cmgr
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_errnum_t hcl_server_geterrnum (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT const hcl_ooch_t* hcl_server_geterrstr (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT const hcl_ooch_t* hcl_server_geterrmsg (
|
||||||
|
hcl_server_t* server
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_seterrnum (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_errnum_t errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_seterrbfmt (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_errnum_t errnum,
|
||||||
|
const hcl_bch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_seterrufmt (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_errnum_t errnum,
|
||||||
|
const hcl_uch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_logbfmt (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_bch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_logufmt (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_uch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_server_allocmem (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_server_callocmem (
|
||||||
|
hcl_server_t* server,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_server_reallocmem (
|
||||||
|
hcl_server_t* server,
|
||||||
|
void* ptr,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_server_freemem (
|
||||||
|
hcl_server_t* server,
|
||||||
|
void* ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_proto_feed_reply (
|
||||||
|
hcl_server_proto_t* proto,
|
||||||
|
const hcl_ooch_t* ptr,
|
||||||
|
hcl_oow_t len,
|
||||||
|
int escape
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_proto_feed_reply_bytes (
|
||||||
|
hcl_server_proto_t* proto,
|
||||||
|
const hcl_bch_t* ptr,
|
||||||
|
hcl_oow_t len
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_server_proto_handle_incoming (
|
||||||
|
hcl_server_proto_t* proto
|
||||||
|
);
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_client_t* hcl_client_open (
|
||||||
|
hcl_mmgr_t* mmgr,
|
||||||
|
hcl_oow_t xtnsize,
|
||||||
|
hcl_client_prim_t* prim,
|
||||||
|
hcl_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_close (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_reset (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_client_feed (
|
||||||
|
hcl_client_t* client,
|
||||||
|
const void* ptr,
|
||||||
|
hcl_oow_t len,
|
||||||
|
hcl_oow_t* xlen
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_client_setoption (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_client_option_t id,
|
||||||
|
const void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_client_getoption (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_client_option_t id,
|
||||||
|
void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_client_getxtn (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_mmgr_t* hcl_client_getmmgr (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_cmgr_t* hcl_client_getcmgr (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_setcmgr (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_cmgr_t* cmgr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT hcl_errnum_t hcl_client_geterrnum (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT const hcl_ooch_t* hcl_client_geterrstr (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT const hcl_ooch_t* hcl_client_geterrmsg (
|
||||||
|
hcl_client_t* client
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_seterrnum (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_errnum_t errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_seterrbfmt (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_errnum_t errnum,
|
||||||
|
const hcl_bch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_seterrufmt (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_errnum_t errnum,
|
||||||
|
const hcl_uch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_logbfmt (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_bch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_logufmt (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_bitmask_t mask,
|
||||||
|
const hcl_uch_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_client_allocmem (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_client_callocmem (
|
||||||
|
hcl_client_t* client,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void* hcl_client_reallocmem (
|
||||||
|
hcl_client_t* client,
|
||||||
|
void* ptr,
|
||||||
|
hcl_oow_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_client_freemem (
|
||||||
|
hcl_client_t* client,
|
||||||
|
void* ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1666,8 +1666,8 @@ struct hcl_t
|
|||||||
hcl_oop_process_t nil_process; /* instance of Process */
|
hcl_oop_process_t nil_process; /* instance of Process */
|
||||||
|
|
||||||
/* =============================================================
|
/* =============================================================
|
||||||
* KERNEL CLASSES
|
* KERNEL CLASSES
|
||||||
* Be sure to Keep these kernel class pointers registered in the
|
* Be sure to Keep these kernel class pointers registered in the
|
||||||
* kernel_classes table in gc.c
|
* kernel_classes table in gc.c
|
||||||
* ============================================================= */
|
* ============================================================= */
|
||||||
hcl_oop_class_t c_apex; /* Apex */
|
hcl_oop_class_t c_apex; /* Apex */
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define POLLNVAL 0x020 /* Invalid polling request. */
|
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||||
|
|
||||||
/* Data structure describing a polling request. */
|
/* Data structure describing a polling request. */
|
||||||
struct pollfd
|
struct pollfd
|
||||||
{
|
{
|
||||||
int fd; /* File descriptor to poll. */
|
int fd; /* File descriptor to poll. */
|
||||||
short int events; /* Types of events poller cares about. */
|
short int events; /* Types of events poller cares about. */
|
||||||
|
@ -38,13 +38,13 @@ hcl_oow_t hcl_uc_to_utf16 (hcl_uch_t uc, hcl_bch_t* utf16, hcl_oow_t size)
|
|||||||
{
|
{
|
||||||
hcl_uint16_t* u16 = (hcl_uint16_t*)utf16;
|
hcl_uint16_t* u16 = (hcl_uint16_t*)utf16;
|
||||||
|
|
||||||
if (uc <= 0xFFFF)
|
if (uc <= 0xFFFF)
|
||||||
{
|
{
|
||||||
u16[0] = (hcl_uint16_t)uc;
|
u16[0] = (hcl_uint16_t)uc;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
#if (HCL_SIZEOF_UCH_T > 2)
|
#if (HCL_SIZEOF_UCH_T > 2)
|
||||||
else if (uc <= 0x10FFFF)
|
else if (uc <= 0x10FFFF)
|
||||||
{
|
{
|
||||||
u16[0] = HIGH_SURROGATE_START | (((uc >> 16) & 0x1F) - 1) | (uc >> 10);
|
u16[0] = HIGH_SURROGATE_START | (((uc >> 16) & 0x1F) - 1) | (uc >> 10);
|
||||||
u16[1] = LOW_SURROGATE_START | (uc & 0x3FF);
|
u16[1] = LOW_SURROGATE_START | (uc & 0x3FF);
|
||||||
@ -61,7 +61,7 @@ hcl_oow_t hcl_utf16_to_uc (const hcl_bch_t* utf16, hcl_oow_t size, hcl_uch_t* uc
|
|||||||
|
|
||||||
if (size < 2) return 0; /* incomplete sequence */
|
if (size < 2) return 0; /* incomplete sequence */
|
||||||
|
|
||||||
if (u16[0] < HIGH_SURROGATE_START || u16[0] > LOW_SURROGATE_END)
|
if (u16[0] < HIGH_SURROGATE_START || u16[0] > LOW_SURROGATE_END)
|
||||||
{
|
{
|
||||||
/* BMP - U+0000 - U+D7FF, U+E000 - U+FFFF */
|
/* BMP - U+0000 - U+D7FF, U+E000 - U+FFFF */
|
||||||
*uc = u16[0];
|
*uc = u16[0];
|
||||||
|
@ -69,7 +69,7 @@ int hcl_marshalcode (hcl_t* hcl, const hcl_code_t* code, hcl_xchg_writer_t wrtr,
|
|||||||
hcl_uint8_t b;
|
hcl_uint8_t b;
|
||||||
hcl_oow_t w;
|
hcl_oow_t w;
|
||||||
hcl_xchg_hdr_t h;
|
hcl_xchg_hdr_t h;
|
||||||
|
|
||||||
lfbase = (hcl->option.trait & HCL_TRAIT_INTERACTIVE)? hcl->c->fnblk.info[hcl->c->fnblk.depth].lfbase: 0;
|
lfbase = (hcl->option.trait & HCL_TRAIT_INTERACTIVE)? hcl->c->fnblk.info[hcl->c->fnblk.depth].lfbase: 0;
|
||||||
|
|
||||||
/* start with a header */
|
/* start with a header */
|
||||||
@ -368,7 +368,7 @@ int hcl_unmarshalcode (hcl_t* hcl, hcl_code_t* code, hcl_xchg_reader_t rdr, void
|
|||||||
}
|
}
|
||||||
nbytes = hcl_leoowtoh(w);
|
nbytes = hcl_leoowtoh(w);
|
||||||
|
|
||||||
ns = hcl_makestring(hcl, HCL_NULL, nchars, 0);
|
ns = hcl_makestring(hcl, HCL_NULL, nchars, 0);
|
||||||
if (HCL_UNLIKELY(!ns)) goto oops;
|
if (HCL_UNLIKELY(!ns)) goto oops;
|
||||||
|
|
||||||
ucspos = 0;
|
ucspos = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user