2013-09-29 00:21:18 +04:00
|
|
|
/* include/v/vere.h
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
2018-03-05 18:33:53 +03:00
|
|
|
|
|
|
|
#include "h2o.h"
|
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
/** Quasi-tunable parameters.
|
|
|
|
**/
|
|
|
|
/* First kernel this executable can boot.
|
|
|
|
*/
|
2014-01-07 00:37:42 +04:00
|
|
|
# define FirstKernel 164
|
|
|
|
# define DefaultKernel 164
|
2014-03-14 21:47:17 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
#define RECK
|
|
|
|
|
|
|
|
/** Data types.
|
|
|
|
**/
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_hhed: http header.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_hhed {
|
|
|
|
struct _u3_hhed* nex_u;
|
2018-03-14 08:35:36 +03:00
|
|
|
c3_w nam_w;
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_c* nam_c;
|
2018-03-14 08:35:36 +03:00
|
|
|
c3_w val_w;
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_c* val_c;
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_hhed;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_hbod: http body block. Also used for responses.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_hbod {
|
|
|
|
struct _u3_hbod* nex_u;
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w len_w;
|
|
|
|
c3_y hun_y[0];
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_hbod;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2018-05-04 22:41:21 +03:00
|
|
|
/* u3_rsat: http request state.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
u3_rsat_init = 0, // initialized
|
|
|
|
u3_rsat_plan = 1, // planned
|
|
|
|
u3_rsat_ripe = 2 // responded
|
|
|
|
} u3_rsat;
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_hreq: incoming http request.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_hreq {
|
2018-03-05 18:33:53 +03:00
|
|
|
h2o_req_t* rec_u; // h2o request
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w seq_l; // sequence within connection
|
2018-05-04 22:41:21 +03:00
|
|
|
u3_rsat sat_e; // request state
|
2018-07-17 19:55:16 +03:00
|
|
|
uv_timer_t* tim_u; // timeout
|
2018-03-05 18:33:53 +03:00
|
|
|
struct _u3_hcon* hon_u; // connection backlink
|
|
|
|
struct _u3_hreq* nex_u; // next in connection's list
|
2018-07-06 01:09:07 +03:00
|
|
|
struct _u3_hreq* pre_u; // next in connection's list
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_hreq;
|
|
|
|
|
|
|
|
/* u3_hcon: incoming http connection.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_hcon {
|
2018-03-05 18:33:53 +03:00
|
|
|
uv_tcp_t wax_u; // client stream handler
|
|
|
|
h2o_conn_t* con_u; // h2o connection
|
|
|
|
h2o_socket_t* sok_u; // h2o connection socket
|
|
|
|
c3_w ipf_w; // client ipv4
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w coq_l; // connection number
|
|
|
|
c3_w seq_l; // next request number
|
2018-03-05 18:33:53 +03:00
|
|
|
struct _u3_http* htp_u; // server backlink
|
|
|
|
struct _u3_hreq* req_u; // request list
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_hcon* nex_u; // next in server's list
|
2018-07-06 01:09:07 +03:00
|
|
|
struct _u3_hcon* pre_u; // next in server's list
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_hcon;
|
|
|
|
|
|
|
|
/* u3_http: http server.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_http {
|
2018-03-05 18:33:53 +03:00
|
|
|
uv_tcp_t wax_u; // server stream handler
|
2018-06-12 08:36:45 +03:00
|
|
|
void* h2o_u; // libh2o configuration
|
2018-06-12 20:55:57 +03:00
|
|
|
struct _u3_prox* rox_u; // maybe proxied
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w sev_l; // server number
|
|
|
|
c3_w coq_l; // next connection number
|
2018-06-12 08:36:45 +03:00
|
|
|
c3_s por_s; // running port
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o sec; // logically secure
|
2016-02-11 22:44:28 +03:00
|
|
|
c3_o lop; // loopback-only
|
2018-06-29 07:36:55 +03:00
|
|
|
c3_o liv; // c3n == shutdown
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_hcon* hon_u; // connection list
|
|
|
|
struct _u3_http* nex_u; // next in list
|
|
|
|
} u3_http;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2018-07-03 20:54:03 +03:00
|
|
|
/* u3_form: http config from %eyre
|
|
|
|
*/
|
|
|
|
typedef struct _u3_form {
|
|
|
|
c3_o pro; // proxy
|
|
|
|
c3_o log; // keep access log
|
|
|
|
c3_o red; // redirect to HTTPS
|
|
|
|
uv_buf_t key_u; // PEM RSA private key
|
|
|
|
uv_buf_t cer_u; // PEM certificate chain
|
|
|
|
} u3_form;
|
|
|
|
|
2018-06-13 02:08:10 +03:00
|
|
|
/* u3_hfig: general http configuration
|
|
|
|
*/
|
|
|
|
typedef struct _u3_hfig {
|
2018-07-03 20:54:03 +03:00
|
|
|
u3_form* for_u; // config from %eyre
|
2018-06-29 07:36:55 +03:00
|
|
|
struct _u3_warc* cli_u; // rev proxy clients
|
2018-06-15 01:58:45 +03:00
|
|
|
struct _u3_pcon* con_u; // cli_u connections
|
2018-06-13 02:08:10 +03:00
|
|
|
} u3_hfig;
|
|
|
|
|
2018-06-12 20:55:57 +03:00
|
|
|
/* u3_proxy_type: proxy connection downstream type
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
u3_ptyp_prox = 0, // connected to us
|
|
|
|
u3_ptyp_ward = 1 // we connected back to
|
|
|
|
} u3_proxy_type;
|
|
|
|
|
|
|
|
/* u3_pcon: established proxy connection
|
|
|
|
*/
|
|
|
|
typedef struct _u3_pcon {
|
|
|
|
uv_tcp_t don_u; // downstream handle
|
|
|
|
uv_tcp_t* upt_u; // upstream handle
|
|
|
|
uv_buf_t buf_u; // pending buffer
|
|
|
|
c3_o sec; // yes == https
|
|
|
|
u3_proxy_type typ_e; // tagged
|
|
|
|
union { // union
|
|
|
|
struct _u3_warc* cli_u; // typ_e == ward
|
|
|
|
struct _u3_prox* lis_u; // typ_e == prox
|
|
|
|
} src_u; // connection source
|
2018-06-15 01:58:45 +03:00
|
|
|
struct _u3_pcon* nex_u; // next in list
|
|
|
|
struct _u3_pcon* pre_u; // previous in list
|
2018-06-12 20:55:57 +03:00
|
|
|
} u3_pcon;
|
|
|
|
|
|
|
|
/* u3_warc: server connecting back to u3_ward as client
|
|
|
|
*/
|
|
|
|
typedef struct _u3_warc {
|
2018-06-15 01:58:45 +03:00
|
|
|
c3_w ipf_w; // ward ip
|
|
|
|
c3_s por_s; // ward port
|
|
|
|
c3_o sec; // secure connection
|
|
|
|
u3_atom sip; // ward ship
|
|
|
|
c3_c* hot_c; // ward hostname
|
2018-07-11 05:51:43 +03:00
|
|
|
uv_buf_t non_u; // nonce
|
2018-06-12 20:55:57 +03:00
|
|
|
struct _u3_http* htp_u; // local server backlink
|
2018-06-15 01:58:45 +03:00
|
|
|
struct _u3_warc* nex_u; // next in list
|
|
|
|
struct _u3_warc* pre_u; // previous in list
|
2018-06-12 20:55:57 +03:00
|
|
|
} u3_warc;
|
|
|
|
|
2018-07-15 02:01:52 +03:00
|
|
|
/* u3_wcon: candidate u3_ward upstream connection
|
|
|
|
*/
|
|
|
|
typedef struct _u3_wcon {
|
|
|
|
uv_tcp_t upt_u; // connection handle
|
|
|
|
struct _u3_ward* rev_u; // connecting to ward
|
|
|
|
struct _u3_wcon* nex_u; // next in list
|
|
|
|
} u3_wcon;
|
|
|
|
|
2018-06-12 20:55:57 +03:00
|
|
|
/* u3_ward: reverse, reverse TCP proxy (ship-specific listener)
|
|
|
|
*/
|
|
|
|
typedef struct _u3_ward {
|
|
|
|
uv_tcp_t tcp_u; // listener handle
|
|
|
|
uv_timer_t tim_u; // expiration timer
|
|
|
|
u3_atom sip; // reverse proxy for ship
|
|
|
|
c3_s por_s; // listening on port
|
2018-07-11 05:51:43 +03:00
|
|
|
uv_buf_t non_u; // nonce
|
2018-07-15 02:01:52 +03:00
|
|
|
struct _u3_wcon* won_u; // candidate upstream connections
|
2018-06-12 20:55:57 +03:00
|
|
|
struct _u3_pcon* con_u; // initiating connection
|
2018-06-15 01:58:45 +03:00
|
|
|
struct _u3_ward* nex_u; // next in list
|
|
|
|
struct _u3_ward* pre_u; // previous in list
|
2018-06-12 20:55:57 +03:00
|
|
|
} u3_ward;
|
|
|
|
|
|
|
|
/* u3_prox: reverse TCP proxy server
|
|
|
|
*/
|
|
|
|
typedef struct _u3_prox {
|
|
|
|
uv_tcp_t sev_u; // server handle
|
|
|
|
c3_s por_s; // listening on port
|
|
|
|
c3_o sec; // yes == https
|
|
|
|
struct _u3_http* htp_u; // local server backlink
|
|
|
|
struct _u3_pcon* con_u; // active connection list
|
|
|
|
struct _u3_ward* rev_u; // active reverse listeners
|
|
|
|
} u3_prox;
|
|
|
|
|
2018-03-14 18:32:48 +03:00
|
|
|
/* u3_csat: client connection state.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
u3_csat_init = 0, // initialized
|
|
|
|
u3_csat_addr = 1, // address resolution begun
|
|
|
|
u3_csat_quit = 2, // cancellation requested
|
|
|
|
u3_csat_ripe = 3 // passed to libh2o
|
|
|
|
} u3_csat;
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cres: response to http client.
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_cres {
|
2014-02-27 04:37:47 +04:00
|
|
|
c3_w sas_w; // status code
|
2018-03-13 05:13:36 +03:00
|
|
|
u3_noun hed; // headers
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_hbod* bod_u; // exit of body queue
|
|
|
|
u3_hbod* dob_u; // entry of body queue
|
|
|
|
} u3_cres;
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_creq: outgoing http request.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_creq { // client request
|
2014-02-27 04:37:47 +04:00
|
|
|
c3_l num_l; // request number
|
2018-03-13 20:49:18 +03:00
|
|
|
h2o_http1client_t* cli_u; // h2o client
|
2018-03-14 18:32:48 +03:00
|
|
|
u3_csat sat_e; // connection state
|
2018-03-13 04:01:34 +03:00
|
|
|
c3_o sec; // yes == https
|
|
|
|
c3_w ipf_w; // IP
|
|
|
|
c3_c* ipf_c; // IP (string)
|
2014-03-03 02:31:03 +04:00
|
|
|
c3_c* hot_c; // host
|
|
|
|
c3_s por_s; // port
|
2018-03-13 04:01:34 +03:00
|
|
|
c3_c* por_c; // port (string)
|
|
|
|
c3_m met_m; // method
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_c* url_c; // url
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_hhed* hed_u; // headers
|
|
|
|
u3_hbod* bod_u; // body
|
|
|
|
u3_hbod* rub_u; // exit of send queue
|
|
|
|
u3_hbod* bur_u; // entry of send queue
|
2018-03-13 04:01:34 +03:00
|
|
|
h2o_iovec_t* vec_u; // send-buffer array
|
|
|
|
u3_cres* res_u; // nascent response
|
|
|
|
struct _u3_creq* nex_u; // next in list
|
|
|
|
struct _u3_creq* pre_u; // previous in list
|
|
|
|
} u3_creq;
|
2014-09-10 20:06:30 +04:00
|
|
|
|
|
|
|
/* u3_chot: foreign host (not yet used).
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_chot {
|
2014-02-27 04:37:47 +04:00
|
|
|
c3_w ipf_w; // ip address (or 0)
|
2014-03-03 02:31:03 +04:00
|
|
|
c3_c* hot_c; // hostname (no port) (or 0)
|
2018-03-13 04:01:34 +03:00
|
|
|
void* ins_u; // insecure connection (or 0)
|
|
|
|
void* sec_u; // secure connection (or 0)
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_chot;
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp: http client.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_cttp {
|
2018-03-13 04:01:34 +03:00
|
|
|
u3_creq* ceq_u; // request list
|
2018-03-14 20:49:15 +03:00
|
|
|
h2o_http1client_ctx_t* //
|
|
|
|
ctx_u; // h2o client ctx
|
|
|
|
void* tls_u; // client SSL_CTX*
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_cttp;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2018-06-08 05:56:01 +03:00
|
|
|
/* u3_pact: ames packet, coming or going.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2018-06-08 05:56:01 +03:00
|
|
|
typedef struct _u3_pact {
|
|
|
|
uv_udp_send_t snd_u; // udp send request
|
|
|
|
c3_w pip_w; // target IPv4 address
|
|
|
|
c3_s por_s; // target port
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w len_w; // length in bytes
|
2018-06-08 05:56:01 +03:00
|
|
|
c3_y* hun_y; // packet buffer
|
|
|
|
c3_y imp_y; // galaxy number (optional)
|
|
|
|
c3_c* dns_c; // galaxy fqdn (optional)
|
|
|
|
} u3_pact;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames: ames networking.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_ames { // packet network state
|
2015-02-23 03:11:46 +03:00
|
|
|
union {
|
|
|
|
uv_udp_t wax_u;
|
|
|
|
uv_handle_t had_u;
|
|
|
|
};
|
|
|
|
uv_timer_t tim_u; // network timer
|
|
|
|
c3_o alm; // alarm on
|
|
|
|
c3_w law_w; // last wakeup, unix time
|
|
|
|
c3_s por_s; // public IPv4 port
|
|
|
|
c3_w imp_w[256]; // imperial IPs
|
2016-10-25 17:51:10 +03:00
|
|
|
time_t imp_t[256]; // imperial IP timestamps
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_ames;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_save: checkpoint control.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_save {
|
2013-10-14 22:23:55 +04:00
|
|
|
uv_timer_t tim_u; // checkpoint timer
|
|
|
|
uv_signal_t sil_u; // child signal
|
2014-04-08 20:25:49 +04:00
|
|
|
c3_d ent_d; // event number
|
2013-10-14 22:23:55 +04:00
|
|
|
c3_w pid_w; // pid of checkpoint process
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_save;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ubuf: unix tty i/o buffer.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_ubuf {
|
|
|
|
struct _u3_ubuf* nex_u;
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w len_w;
|
|
|
|
c3_y hun_y[0]; // bytes to send
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_ubuf;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_utat: unix terminal state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
struct {
|
|
|
|
c3_l col_l; // columns
|
|
|
|
c3_l row_l; // rows
|
|
|
|
} siz;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
c3_w* lin_w; // current line (utf32)
|
|
|
|
c3_w len_w; // length of current line
|
|
|
|
c3_w cus_w; // cursor position
|
|
|
|
} mir;
|
|
|
|
|
|
|
|
struct { // escape code control
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o ape; // escape received
|
|
|
|
c3_o bra; // bracket or O received
|
2013-09-29 00:21:18 +04:00
|
|
|
} esc;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
c3_y syb_y[5]; // utf8 code buffer
|
|
|
|
c3_w len_w; // present length
|
|
|
|
c3_w wid_w; // total width
|
|
|
|
} fut;
|
2015-12-13 06:53:02 +03:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uv_thread_t* sit_u; // spinner thread
|
|
|
|
c3_o diz_o; // spinner activated
|
|
|
|
c3_d eve_d; // spinner start tick (unix μs)
|
2016-02-21 01:35:06 +03:00
|
|
|
c3_d end_d; // spinner end tick (unix μs)
|
2015-12-13 06:53:02 +03:00
|
|
|
c3_c* why_c; // spinner event wire (root only)
|
|
|
|
} sun;
|
|
|
|
|
|
|
|
uv_mutex_t mex_u; // mutex for non-daemon term state
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_utat;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_uled: event log header.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
c3_l mag_l; // mug of log format, 'a', 'b'...
|
|
|
|
c3_w kno_w; // kernel number validated with
|
|
|
|
c3_l sal_l; // salt for passcode
|
|
|
|
c3_l key_l; // mug of crypto key, or 0
|
|
|
|
c3_l sev_l; // host process identity
|
|
|
|
c3_l tno_l; // terminal count in host
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_uled;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_olar: event log trailer, old version.
|
2014-03-11 03:13:19 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
c3_w syn_w; // must equal mug of address
|
|
|
|
c3_w ent_w; // event sequence number
|
|
|
|
c3_w len_w; // word length of this event
|
|
|
|
c3_w mug_w; // mug of entry
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_olar;
|
2014-03-11 03:13:19 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ular: event log trailer.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
c3_w syn_w; // must equal mug of address
|
2014-04-08 20:25:49 +04:00
|
|
|
c3_d ent_d; // event sequence number
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w len_w; // word length of this event
|
2014-03-11 03:13:19 +04:00
|
|
|
c3_w mug_w; // mug of entry
|
|
|
|
c3_w tem_w; // raft term of event
|
|
|
|
c3_w typ_w; // type of event, %ra|%ov
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_ular;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ulog: unix event log.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
c3_i fid_i; // file descriptor
|
2014-01-27 22:48:55 +04:00
|
|
|
c3_d len_d; // length in words
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_ulog;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-06-06 02:35:41 +03:00
|
|
|
struct _u3_umon;
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_udir;
|
|
|
|
struct _u3_ufil;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-06-09 23:55:07 +03:00
|
|
|
/* u3_unod: file or directory.
|
|
|
|
*/
|
2015-06-05 05:47:27 +03:00
|
|
|
typedef struct _u3_unod {
|
|
|
|
uv_fs_event_t was_u; // stat watcher
|
|
|
|
c3_o dir; // c3y if dir, c3n if file
|
|
|
|
c3_o dry; // ie, unmodified
|
|
|
|
c3_c* pax_c; // absolute path
|
2015-06-09 01:51:11 +03:00
|
|
|
struct _u3_udir* par_u; // parent
|
2015-06-06 02:35:41 +03:00
|
|
|
struct _u3_unod* nex_u; // internal list
|
2015-06-05 05:47:27 +03:00
|
|
|
} u3_unod;
|
|
|
|
|
2015-06-09 23:55:07 +03:00
|
|
|
/* u3_ufil: synchronized file.
|
|
|
|
*/
|
2015-06-05 05:47:27 +03:00
|
|
|
typedef struct _u3_ufil {
|
|
|
|
uv_fs_event_t was_u; // stat watcher
|
|
|
|
c3_o dir; // c3y if dir, c3n if file
|
|
|
|
c3_o dry; // ie, unmodified
|
|
|
|
c3_c* pax_c; // absolute path
|
2015-06-09 01:51:11 +03:00
|
|
|
struct _u3_udir* par_u; // parent
|
2015-06-05 05:47:27 +03:00
|
|
|
struct _u3_unod* nex_u; // internal list
|
2015-06-09 01:51:11 +03:00
|
|
|
c3_w mug_w; // mug of last %into
|
|
|
|
c3_w gum_w; // mug of last %ergo
|
2015-06-05 05:47:27 +03:00
|
|
|
} u3_ufil;
|
|
|
|
|
2015-06-09 23:55:07 +03:00
|
|
|
/* u3_ufil: synchronized directory.
|
|
|
|
*/
|
2015-06-05 05:47:27 +03:00
|
|
|
typedef struct _u3_udir {
|
|
|
|
uv_fs_event_t was_u; // stat watcher
|
|
|
|
c3_o dir; // c3y if dir, c3n if file
|
|
|
|
c3_o dry; // ie, unmodified
|
|
|
|
c3_c* pax_c; // absolute path
|
2015-06-09 01:51:11 +03:00
|
|
|
struct _u3_udir* par_u; // parent
|
2015-06-05 05:47:27 +03:00
|
|
|
struct _u3_unod* nex_u; // internal list
|
2015-06-06 02:35:41 +03:00
|
|
|
u3_unod* kid_u; // subnodes
|
2015-06-05 05:47:27 +03:00
|
|
|
} u3_udir;
|
|
|
|
|
2015-06-09 23:55:07 +03:00
|
|
|
/* u3_ufil: synchronized mount point.
|
|
|
|
*/
|
2015-06-05 05:47:27 +03:00
|
|
|
typedef struct _u3_umon {
|
2015-06-18 02:44:00 +03:00
|
|
|
u3_udir dir_u; // root directory, must be first
|
2015-06-09 01:51:11 +03:00
|
|
|
c3_c* nam_c; // mount point name
|
2015-06-12 06:52:42 +03:00
|
|
|
struct _u3_umon* nex_u; // internal list
|
2015-06-05 05:47:27 +03:00
|
|
|
} u3_umon;
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_usig: receive signals.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_usig {
|
2013-09-29 00:21:18 +04:00
|
|
|
uv_signal_t sil_u;
|
|
|
|
c3_i num_i;
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_usig* nex_u;
|
|
|
|
} u3_usig;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix: clay support system, also
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_unix {
|
2015-06-12 06:52:42 +03:00
|
|
|
uv_check_t syn_u; // fs sync check
|
|
|
|
uv_timer_t tim_u; // timer
|
|
|
|
u3_umon* mon_u; // mount points
|
|
|
|
u3_usig* sig_u; // signal list
|
|
|
|
c3_o alm; // timer set
|
|
|
|
c3_o dyr; // ready to update
|
2014-06-01 07:26:18 +04:00
|
|
|
#ifdef SYNCLOG
|
|
|
|
c3_w lot_w; // sync-slot
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_sylo {
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o unx; // from unix
|
2014-06-01 07:26:18 +04:00
|
|
|
c3_m wer_m; // mote saying where
|
|
|
|
c3_m wot_m; // mote saying what
|
|
|
|
c3_c* pax_c; // path
|
|
|
|
} sylo[1024];
|
|
|
|
#endif
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_unix;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u3_behn: just a timer for ever
|
2014-10-15 06:25:23 +04:00
|
|
|
*/
|
2015-06-24 22:50:30 +03:00
|
|
|
typedef struct _u3_behn {
|
|
|
|
uv_timer_t tim_u; // behn timer
|
2014-10-15 06:25:23 +04:00
|
|
|
c3_w run_w; // run of consecutive alarms
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o alm; // alarm
|
2015-06-24 22:50:30 +03:00
|
|
|
} u3_behn;
|
2014-10-15 06:25:23 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
/* u2_utfo: unix terminfo strings.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
struct {
|
|
|
|
const c3_y* kcuu1_y; // key_up
|
2014-03-14 21:47:17 +04:00
|
|
|
const c3_y* kcud1_y; // key_down
|
2013-09-29 00:21:18 +04:00
|
|
|
const c3_y* kcub1_y; // key_back
|
|
|
|
const c3_y* kcuf1_y; // key_forward
|
|
|
|
c3_w max_w; // maximum input sequence length
|
|
|
|
} inn;
|
|
|
|
struct {
|
|
|
|
const c3_y* clear_y; // clear_screen
|
2014-03-14 21:47:17 +04:00
|
|
|
const c3_y* el_y; // clr_bol clear to beginning
|
2013-09-29 00:21:18 +04:00
|
|
|
// const c3_y* el1_y; // clr_eol clear to end
|
|
|
|
const c3_y* ed_y; // clear to end of screen
|
|
|
|
const c3_y* bel_y; // bel sound bell
|
|
|
|
const c3_y* cub1_y; // parm_left
|
|
|
|
const c3_y* cuf1_y; // parm_right
|
|
|
|
const c3_y* cuu1_y; // parm_up
|
|
|
|
const c3_y* cud1_y; // parm_down
|
|
|
|
// const c3_y* cub_y; // parm_left_cursor #num
|
2014-03-14 21:47:17 +04:00
|
|
|
// const c3_y* cuf_y; // parm_right_cursor #num
|
2013-09-29 00:21:18 +04:00
|
|
|
} out;
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_utfo;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
#if 0
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_uwen: unix alarm.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_uwen {
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_y* pax_y; // printed path
|
|
|
|
c3_d wen_d[2]; // timer expire
|
|
|
|
};
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_utim: unix timer control.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_utim {
|
2014-05-26 06:08:07 +04:00
|
|
|
uv_timer_t wat_u; // timer control
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_uwen* wen_u; // timers in ascending order
|
2013-09-29 00:21:18 +04:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_utty: unix tty.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_utty {
|
2014-05-26 06:08:07 +04:00
|
|
|
union {
|
|
|
|
uv_pipe_t pop_u;
|
|
|
|
uv_tcp_t wax_u;
|
|
|
|
};
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_utty* nex_u; // next in host list
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_i fid_i; // file descriptor
|
|
|
|
c3_w tid_l; // terminal identity number
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_utfo ufo_u; // terminfo strings
|
2014-05-28 01:56:14 +04:00
|
|
|
c3_i cug_i; // blocking fcntl flags
|
|
|
|
c3_i nob_i; // nonblocking fcntl flags
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_utat tat_u; // control state
|
2014-05-28 01:56:14 +04:00
|
|
|
struct termios bak_u; // cooked terminal state
|
|
|
|
struct termios raw_u; // raw terminal state
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_utty;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_utel: unix telnet listener.
|
2014-06-08 03:05:53 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_utel {
|
|
|
|
struct _u3_utty uty_t; // pseudo-tty
|
2014-06-08 03:05:53 +04:00
|
|
|
c3_s por_s; // file descriptor
|
|
|
|
void* tel_u; // telnet context
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_utel;
|
2014-06-08 03:05:53 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_raty: raft server type.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
typedef enum {
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_raty_none,
|
|
|
|
u3_raty_foll,
|
|
|
|
u3_raty_cand,
|
|
|
|
u3_raty_lead
|
|
|
|
} u3_raty;
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_raft: raft state.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2014-03-12 23:25:45 +04:00
|
|
|
uv_tcp_t wax_u; // TCP listener
|
|
|
|
uv_timer_t tim_u; // election/heartbeat timer
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ulog lug_u; // event log
|
2014-04-08 20:25:49 +04:00
|
|
|
c3_d ent_d; // last log index
|
2014-03-12 23:25:45 +04:00
|
|
|
c3_w lat_w; // last log term
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_raty typ_e; // server type
|
|
|
|
struct _u3_rnam* nam_u; // list of peers
|
|
|
|
struct _u3_rcon* run_u; // unknown connections
|
2014-03-12 23:25:45 +04:00
|
|
|
c3_w pop_w; // population count
|
|
|
|
c3_w vot_w; // votes in this election
|
|
|
|
c3_c* str_c; // our name
|
|
|
|
// persistent state
|
|
|
|
c3_w tem_w; // current term
|
|
|
|
c3_c* vog_c; // who we voted for this term
|
|
|
|
// end persistent state
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_raft;
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_rreq: raft request.
|
2014-03-05 05:43:40 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_rreq {
|
|
|
|
struct _u3_rmsg* msg_u;
|
|
|
|
struct _u3_rreq* nex_u;
|
|
|
|
struct _u3_rcon* ron_u;
|
|
|
|
} u3_rreq;
|
2014-03-05 05:43:40 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_rbuf: raft input buffer.
|
2014-03-05 05:43:40 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_rbuf {
|
2014-03-05 05:43:40 +04:00
|
|
|
c3_w len_w;
|
|
|
|
c3_w cap_w;
|
|
|
|
c3_y buf_y[0];
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_rbuf;
|
2014-03-05 05:43:40 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_rcon: raft connection.
|
2014-02-27 03:46:34 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_rcon {
|
2014-03-12 23:25:45 +04:00
|
|
|
uv_tcp_t wax_u; // TCP handle
|
2014-09-10 20:06:30 +04:00
|
|
|
struct _u3_rnam* nam_u; // peer we're connected to
|
|
|
|
u3_rbuf* red_u; // read buffer
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o red; // u3_yes on new data
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_rbuf* wri_u; // write buffer
|
|
|
|
u3_raft* raf_u; // back-reference to server
|
|
|
|
u3_rreq* out_u; // exit of request queue
|
|
|
|
u3_rreq* tou_u; // entry of request queue
|
|
|
|
struct _u3_rcon* nex_u; // pointer to next con
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o liv; // are we live?
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_rcon;
|
|
|
|
|
|
|
|
/* u3_rnam: raft peer name.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_rnam {
|
2014-03-12 23:25:45 +04:00
|
|
|
c3_c* str_c; // our name
|
|
|
|
c3_c* nam_c; // hostname
|
|
|
|
c3_c* por_c; // port
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_rcon* ron_u; // connection
|
|
|
|
struct _u3_rnam* nex_u; // pointer to next peer
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o vog; // did they vote for us?
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_rnam;
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_opts: command line configuration.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_opts {
|
2017-10-27 00:40:06 +03:00
|
|
|
c3_c* arv_c; // -A, initial sync from
|
2017-12-14 02:13:44 +03:00
|
|
|
c3_c* dns_c; // -H, ames bootstrap domain
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_c* gen_c; // -G, czar generator
|
|
|
|
c3_c* imp_c; // -I, czar name
|
|
|
|
c3_c* nam_c; // -n, unix hostname
|
2017-10-27 00:40:06 +03:00
|
|
|
c3_c* pil_c; // -B, bootstrap from
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_c* raf_c; // -r, raft flotilla
|
|
|
|
c3_c* tic_c; // -t, ticket value
|
2017-10-30 13:18:53 +03:00
|
|
|
c3_c* url_c; // -u, pill url
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_c* who_c; // -w, begin with ticket
|
|
|
|
c3_o abo; // -a
|
|
|
|
c3_o bat; // -b, batch create
|
2014-12-01 03:06:08 +03:00
|
|
|
c3_o dem; // -d, daemon
|
|
|
|
c3_o dry; // -D, dry compute
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o fak; // -F, fake carrier
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_o fog; // -X, skip last event
|
|
|
|
c3_o gab; // -g, run with garbage collector
|
2017-10-30 13:17:14 +03:00
|
|
|
c3_o git; // -s, pill url from arvo git hash
|
2017-10-27 00:40:06 +03:00
|
|
|
c3_o mem; // -M, memory madness
|
2017-10-31 03:41:48 +03:00
|
|
|
c3_o net; // -N, remote networking in -F mode
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_o nuu; // -c, new pier
|
2014-12-01 03:06:08 +03:00
|
|
|
c3_o pro; // -P, profile
|
2015-05-20 03:04:08 +03:00
|
|
|
c3_o qui; // -q, quiet
|
2015-10-31 15:17:04 +03:00
|
|
|
c3_o rep; // -R, report build info
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_o tex; // -x, exit after loading
|
2017-10-27 00:40:06 +03:00
|
|
|
c3_o veb; // -v, verbose (inverse of -q)
|
|
|
|
c3_o vno; // -V, replay without reboots
|
2017-10-27 19:19:39 +03:00
|
|
|
c3_s por_s; // -p, ames port
|
|
|
|
c3_s rop_s; // -l, raft port
|
|
|
|
c3_w fuz_w; // -f, fuzz testing
|
|
|
|
c3_w kno_w; // -k, kernel version
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_opts;
|
|
|
|
|
|
|
|
/* u3_host: entire host.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
typedef struct _u3_host {
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_w kno_w; // current executing stage
|
2015-06-06 02:35:41 +03:00
|
|
|
c3_c* dir_c; // pier path (no trailing /)
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_d now_d; // event tick
|
|
|
|
uv_loop_t* lup_u; // libuv event loop
|
2018-06-13 02:08:10 +03:00
|
|
|
u3_hfig fig_u; // http configuration
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http* htp_u; // http servers
|
|
|
|
u3_cttp ctp_u; // http clients
|
|
|
|
u3_utel tel_u; // telnet listener
|
|
|
|
u3_utty* uty_u; // linked terminal list
|
|
|
|
u3_ames sam_u; // packet interface
|
|
|
|
u3_save sav_u; // autosave
|
|
|
|
u3_opts ops_u; // commandline options
|
|
|
|
u3_unix unx_u; // sync and clay
|
2015-06-24 22:50:30 +03:00
|
|
|
u3_behn teh_u; // behn timer
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o liv; // if u3_no, shut down
|
2014-05-13 02:42:43 +04:00
|
|
|
c3_i xit_i; // exit code for shutdown
|
2018-03-14 20:53:22 +03:00
|
|
|
void* tls_u; // server SSL_CTX*
|
2014-09-10 20:06:30 +04:00
|
|
|
} u3_host; // host == computer == process
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
# define u3L u3_Host.lup_u // global event loop
|
2014-09-11 04:01:32 +04:00
|
|
|
# define u3Z (&(u3_Raft))
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Global variables.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
c3_global u3_host u3_Host;
|
|
|
|
c3_global u3_raft u3_Raft;
|
|
|
|
c3_global c3_c* u3_Local;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Functions.
|
|
|
|
**/
|
|
|
|
/* Urbit time: 128 bits, leap-free.
|
|
|
|
**
|
|
|
|
** High 64 bits: 0x8000.000c.cea3.5380 + Unix time at leap 25 (Jul 2012)
|
|
|
|
** Low 64 bits: 1/2^64 of a second.
|
|
|
|
**
|
|
|
|
** Seconds per Gregorian 400-block: 12.622.780.800
|
|
|
|
** 400-blocks from 0 to 0AD: 730.692.561
|
|
|
|
** Years from 0 to 0AD: 292.277.024.400
|
|
|
|
** Seconds from 0 to 0AD: 9.223.372.029.693.628.800
|
|
|
|
** Seconds between 0A and Unix epoch: 62.167.219.200
|
|
|
|
** Seconds before Unix epoch: 9.223.372.091.860.848.000
|
|
|
|
** The same, in C hex notation: 0x8000000cce9e0d80ULL
|
|
|
|
**
|
|
|
|
** New leap seconds after July 2012 (leap second 25) are ignored. The
|
|
|
|
** platform OS will not ignore them, of course, so they must be detected
|
|
|
|
** and counteracted. Perhaps this phenomenon will soon find an endpoint.
|
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_sec_in(): urbit seconds from unix time.
|
2013-09-29 00:21:18 +04:00
|
|
|
**
|
|
|
|
** Adjust (externally) for future leap secs!
|
|
|
|
*/
|
|
|
|
c3_d
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_sec_in(c3_w unx_w);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_sec_out(): unix time from urbit seconds.
|
2013-09-29 00:21:18 +04:00
|
|
|
**
|
|
|
|
** Adjust (externally) for future leap secs!
|
|
|
|
*/
|
|
|
|
c3_w
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_sec_out(c3_d urs_d);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_fsc_in(): urbit fracto-seconds from unix microseconds.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
c3_d
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_fsc_in(c3_w usc_w);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_fsc_out: unix microseconds from urbit fracto-seconds.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
c3_w
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_fsc_out(c3_d ufc_d);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_in_tv(): urbit time from struct timeval.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_atom
|
|
|
|
u3_time_in_tv(struct timeval* tim_tv);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_out_tv(): struct timeval from urbit time.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_out_tv(struct timeval* tim_tv, u3_noun now);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_in_ts(): urbit time from struct timespec.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_atom
|
|
|
|
u3_time_in_ts(struct timespec* tim_ts);
|
2014-11-05 03:29:08 +03:00
|
|
|
#if defined(U3_OS_linux)
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_t_in_ts(): urbit time from time_t.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_atom
|
|
|
|
u3_time_t_in_ts(time_t tim);
|
2013-09-29 00:21:18 +04:00
|
|
|
#endif
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_out_ts(): struct timespec from urbit time.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_out_ts(struct timespec* tim_ts, u3_noun now);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_time_gap_ms(): (wen - now) in ms.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
c3_d
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_time_gap_ms(u3_noun now, u3_noun wen);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Filesystem (new api).
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_walk_load(): load file or bail.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
|
|
|
u3_walk_load(c3_c* pas_c);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_walk_safe(): load file or 0.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
|
|
|
u3_walk_safe(c3_c* pas_c);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_walk_save(): save file or bail.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2018-02-24 08:52:35 +03:00
|
|
|
u3_walk_save(c3_c* pas_c, u3_noun tim, u3_atom pad, c3_c* bas_c, u3_noun pax);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sync_reck(): traverse filesystem for changes -> lamb
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_sync_reck(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_walk(): traverse `dir_c` to produce an arch, updating `old`.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_walk(const c3_c* dir_c, u3_noun old);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_path(): C unix path in computer for file or directory.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
c3_c*
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_path(c3_o fyl, u3_noun pax);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Filesystem (old api).
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_file(): load internal file as atom from local or system.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_weak
|
|
|
|
u3_ve_file(c3_c* ext_c, u3_noun tah);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_frep(): load [.~ %rep myp {now} tah].
|
2013-09-29 00:21:18 +04:00
|
|
|
**
|
|
|
|
** File is either ~ or [nbytes mdate atom].
|
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
|
|
|
u3_ve_frep(u3_noun myp, u3_noun tah);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_date(): date internal file.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
c3_d
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ve_date(c3_c* ext_c, u3_noun tah);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_save(): save internal file as atom.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
c3_o
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ve_save(c3_c* ext_c, u3_noun tah, u3_noun dat);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_zeus(): prayer to internal file path. Return unit.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
|
|
|
u3_ve_zeus(u3_noun hap);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Output.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ve_tank(): print a tank at `tab`.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ve_tank(c3_l tab_l, u3_noun tac);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_reck_kick(): handle effect.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_reck_kick(u3_noun ovo);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/** Main loop, new style.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_loop(): enter main event loop.
|
2014-01-16 05:41:30 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_loop(void);
|
2014-01-16 05:41:30 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_lead(): actions on promotion to leader.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_lo_lead(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_exit(): shut down io across pier.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_exit(void);
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_show(): print typeless noun.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_show(c3_c* cap_c, u3_noun nun);
|
|
|
|
#define u3ls(cap_c, nun) u3_lo_show(cap_c, nun)
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_bail(): clean up all event state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_lo_bail(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_tank(): dump single tank.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_tank(c3_l tab_l, u3_noun tac);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_punt(): dump tank list.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_punt(c3_l tab_l, u3_noun tac);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_sway(): print trace.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_sway(c3_l tab_l, u3_noun tax);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_grab(): garbage-collect the world, plus roots; end with u3_none
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_grab(c3_c* cap_c, u3_noun som, ...);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_open(): begin callback processing.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_lo_open(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_lo_shut(): end callback processing.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_lo_shut(c3_o);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/** Terminal, new style.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_get_blew(): return window size [columns rows].
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun
|
|
|
|
u3_term_get_blew(c3_l tid_l);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_ef_boil(): initial effects for restored server.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_ef_boil();
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-05-19 21:38:23 +03:00
|
|
|
/* u3_term_ef_ticket(): initial effects for new ticket.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c);
|
|
|
|
|
2015-05-19 21:56:44 +03:00
|
|
|
/* u3_term_ef_verb(): initial effects for verbose events.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_term_ef_verb(void);
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_ef_winc(): window change.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_ef_winc(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_ef_ctlc(): send ^C.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_ef_ctlc(void);
|
2014-03-14 21:47:17 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_ef_bake(): initial effects for new server.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_ef_bake(u3_noun fav);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-10-15 20:47:52 +03:00
|
|
|
/* u3_term_ef_blit(): send %blit effect to terminal.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_ef_blit(c3_l tid_l,
|
|
|
|
u3_noun blt);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_init(): initialize terminal I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_init(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_talk(): start terminal listener.
|
2014-05-26 06:08:07 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_talk(void);
|
2014-05-26 06:08:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_exit(): terminate terminal I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_exit(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_poll(): update terminal IO state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_poll(void);
|
2014-03-14 21:47:17 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_hija(): hijack console for cooked print.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
FILE*
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_hija(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_term_io_loja(): release console from cooked print.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_term_io_loja(int x);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/* uL, uH: wrap hijack/lojack around fprintf.
|
|
|
|
**
|
|
|
|
** uL(fprintf(uH, ...));
|
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
# define uH u3_term_io_hija()
|
|
|
|
# define uL(x) u3_term_io_loja(x)
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/** Ames, packet networking.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_ef_bake(): create ames duct.
|
2014-07-10 01:42:08 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_ef_bake(void);
|
2014-07-10 01:42:08 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_ef_send(): send packet to network.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_ef_send(u3_noun lan,
|
|
|
|
u3_noun pac);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_io_init(): initialize ames I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_io_init(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_io_talk(): bring up listener.
|
2014-01-17 12:12:05 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_io_talk(void);
|
2014-01-17 12:12:05 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_io_exit(): terminate ames I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_io_exit(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_ames_io_poll(): update ames IO state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_ames_io_poll(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Autosave.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_save_ef_chld(): report SIGCHLD.
|
2013-10-04 00:38:37 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_save_ef_chld(void);
|
2013-10-04 00:38:37 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_save_io_init(): initialize autosave.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_save_io_init(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_save_io_exit(): terminate autosave.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_save_io_exit(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_save_io_poll(): update autosave state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_save_io_poll(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/** Storage, new school.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_ef_hold():
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_ef_hold();
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_ef_move():
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_ef_move();
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-06-09 23:55:07 +03:00
|
|
|
/* u3_unix_initial_into(): intialize filesystem from urb/zod
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_unix_ef_initial_into();
|
|
|
|
|
2015-06-09 20:27:22 +03:00
|
|
|
/* u3_unix_ef_look(): update filesystem from unix
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2015-06-18 22:56:11 +03:00
|
|
|
u3_unix_ef_look(u3_noun all);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-06-05 05:47:27 +03:00
|
|
|
/* u3_unix_ef_ergo(): update filesystem from urbit
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2015-06-09 20:27:22 +03:00
|
|
|
u3_unix_ef_ergo(u3_noun mon, u3_noun can);
|
|
|
|
|
|
|
|
/* u3_unix_ef_ogre(): delete mount point
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_unix_ef_ogre(u3_noun mon);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2015-10-15 20:47:52 +03:00
|
|
|
/* u3_unix_ef_hill(): enumerate mount points
|
2015-06-17 22:06:40 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_unix_ef_hill(u3_noun hil);
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_io_init(): initialize storage.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_io_init(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_io_talk(): start listening for fs events.
|
2014-01-17 12:12:05 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_io_talk(void);
|
2014-01-17 12:12:05 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_io_exit(): terminate storage.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_io_exit(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_unix_io_poll(): update storage state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_unix_io_poll(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/** behn, just a timer.
|
2014-10-15 06:25:23 +04:00
|
|
|
**/
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u2_behn_io_init(): initialize behn timer.
|
2014-10-15 06:25:23 +04:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u2_behn_io_init(void);
|
2014-10-15 06:25:23 +04:00
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u2_behn_io_exit(): terminate timer.
|
2014-10-15 06:25:23 +04:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u2_behn_io_exit(void);
|
2014-10-15 06:25:23 +04:00
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u2_behn_io_poll(): update behn IO state.
|
2014-10-15 06:25:23 +04:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u2_behn_io_poll(void);
|
2014-10-15 06:25:23 +04:00
|
|
|
|
|
|
|
|
2014-02-27 04:37:47 +04:00
|
|
|
/** HTTP server.
|
2013-09-29 00:21:18 +04:00
|
|
|
**/
|
2018-06-12 08:39:24 +03:00
|
|
|
/* u3_http_ef_form: send %from effect to http.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_http_ef_form(u3_noun fig);
|
|
|
|
|
2018-06-06 20:20:35 +03:00
|
|
|
/* u3_http_ef_that: send %that effect to http.
|
|
|
|
*/
|
|
|
|
void
|
2018-07-11 06:33:40 +03:00
|
|
|
u3_http_ef_that(u3_noun tat);
|
2018-06-06 20:20:35 +03:00
|
|
|
|
2018-10-02 00:16:44 +03:00
|
|
|
/* u3_http_ef_http_response: send %http-response to http.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_http_ef_http_response(c3_l sev_l,
|
|
|
|
c3_l coq_l,
|
|
|
|
c3_l seq_l,
|
|
|
|
u3_noun rep);
|
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_ef_thou(): send %thou effect to http.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_ef_thou(c3_l sev_l,
|
2014-03-20 02:40:40 +04:00
|
|
|
c3_l coq_l,
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_l seq_l,
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_noun rep);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp_ef_thus(): send %thus effect to cttp.
|
2013-10-27 07:55:53 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_cttp_ef_thus(c3_l num_l,
|
|
|
|
u3_noun req);
|
2013-10-27 07:55:53 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_ef_bake(): create new http server.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_ef_bake(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_io_init(): initialize http I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_io_init(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_io_talk(): start http listener.
|
2014-01-17 12:12:05 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_io_talk(void);
|
2014-01-17 12:12:05 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_io_exit(): terminate http I/O.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_io_exit(void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_http_io_poll(): update http IO state.
|
2013-09-29 00:21:18 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_http_io_poll(void);
|
2014-02-26 00:18:07 +04:00
|
|
|
|
|
|
|
/** Raft log syncing.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_raft_readopt(): parse command line options.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_rnam*
|
|
|
|
u3_raft_readopt(const c3_c* arg_c, c3_c* our_c, c3_s oup_s);
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_raft_init(): start Raft process.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_raft_init(void);
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_raft_work(): poke, kick, and push pending events.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_raft_work(void);
|
|
|
|
|
2014-02-26 00:18:07 +04:00
|
|
|
|
|
|
|
/** Disk persistence.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_boot(): restore or create pier from disk.
|
2014-02-26 00:18:07 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_sist_boot(void);
|
2014-02-26 00:18:07 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_pack(): write a log entry to disk.
|
2014-02-26 00:18:07 +04:00
|
|
|
**
|
|
|
|
** XX Synchronous.
|
|
|
|
**
|
|
|
|
** typ_w is a mote describing the entry type: %ov for Arvo
|
|
|
|
** logs, %ra for Raft events.
|
|
|
|
**
|
|
|
|
** Returns the entry's sequence number.
|
|
|
|
*/
|
2014-04-10 00:31:00 +04:00
|
|
|
c3_d
|
2014-09-11 04:01:32 +04:00
|
|
|
u3_sist_pack(c3_w tem_w,
|
2014-03-11 03:13:19 +04:00
|
|
|
c3_w typ_w,
|
|
|
|
c3_w* bob_w,
|
|
|
|
c3_w len_w);
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_put(): moronic key-value store put.
|
2014-03-08 06:56:15 +04:00
|
|
|
**
|
2014-09-10 20:06:30 +04:00
|
|
|
** u3_sist_put will do its best to associate the passed key with
|
2014-03-08 06:56:15 +04:00
|
|
|
** the passed value in a way that will persist across process
|
|
|
|
** restarts. It will probably do so by writing a file named for
|
|
|
|
** the key with contents identical to the value. To rely on it
|
|
|
|
** for anything heavy-duty would be a mistake.
|
|
|
|
**
|
|
|
|
** Why would we even have something like this? Because sometimes
|
|
|
|
** we need to maintain files completely independently of the
|
|
|
|
** noun state.
|
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i);
|
2014-03-08 06:56:15 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_nil(): moronic key-value store rm.
|
2014-03-08 06:56:15 +04:00
|
|
|
**
|
|
|
|
** Does its best to expunge all records on the given key. Has
|
|
|
|
** no effect if the key doesn't exist.
|
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_sist_nil(const c3_c* key_c);
|
2014-03-08 06:56:15 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_has(): moronic key-value store existence check.
|
2014-03-08 06:56:15 +04:00
|
|
|
**
|
|
|
|
** Returns the byte length of the value previously stored via
|
2014-09-10 20:06:30 +04:00
|
|
|
** u3_sist_put, or -1 if it couldn't find one.
|
2014-03-08 06:56:15 +04:00
|
|
|
*/
|
|
|
|
ssize_t
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_sist_has(const c3_c* key_c);
|
2014-03-08 06:56:15 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_sist_get(): moronic key-value store get.
|
2014-03-08 06:56:15 +04:00
|
|
|
**
|
2014-09-10 20:06:30 +04:00
|
|
|
** u3_sist_get is the mirror of u3_sist_put. It writes to val_y,
|
2014-03-08 06:56:15 +04:00
|
|
|
** which had better be at least as big as the return value from
|
2014-09-10 20:06:30 +04:00
|
|
|
** u3_sist_has, the value that you previously put.
|
2014-03-08 06:56:15 +04:00
|
|
|
**
|
2014-09-10 20:06:30 +04:00
|
|
|
** Needless to say, u3_sist_get crashes if it can't find your
|
2014-03-08 06:56:15 +04:00
|
|
|
** value.
|
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_sist_get(const c3_c* key_c, c3_y* val_y);
|
2014-03-08 06:56:15 +04:00
|
|
|
|
2015-03-19 01:48:29 +03:00
|
|
|
/* u3_sist_rand(): fill 8 words (32 bytes) with high-quality entropy.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3_sist_rand(c3_w* rad_w);
|
|
|
|
|
2014-11-05 03:41:26 +03:00
|
|
|
/** New timer system.
|
|
|
|
**/
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u3_behn_io_init(): initialize time timer.
|
2014-11-05 03:41:26 +03:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u3_behn_io_init(void);
|
2014-11-05 03:41:26 +03:00
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u3_behn_io_exit(): terminate timer.
|
2014-11-05 03:41:26 +03:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u3_behn_io_exit(void);
|
2014-11-05 03:41:26 +03:00
|
|
|
|
2015-06-24 22:50:30 +03:00
|
|
|
/* u3_behn_io_poll(): update behn IO state.
|
2014-11-05 03:41:26 +03:00
|
|
|
*/
|
|
|
|
void
|
2015-06-24 22:50:30 +03:00
|
|
|
u3_behn_io_poll(void);
|
2014-11-05 03:41:26 +03:00
|
|
|
|
2014-02-27 04:37:47 +04:00
|
|
|
|
|
|
|
/** HTTP client.
|
|
|
|
**/
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp_ef_thus(): send %thus effect to cttp.
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_cttp_ef_thus(c3_l num_l,
|
|
|
|
u3_noun req);
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp_io_init(): initialize cttp I/O.
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_cttp_io_init(void);
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp_io_exit(): terminate cttp I/O.
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
2014-03-14 21:47:17 +04:00
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_cttp_io_exit(void);
|
2014-02-27 04:37:47 +04:00
|
|
|
|
2014-09-10 20:06:30 +04:00
|
|
|
/* u3_cttp_io_poll(): update cttp IO state.
|
2014-02-27 04:37:47 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-09-10 20:06:30 +04:00
|
|
|
u3_cttp_io_poll(void);
|