/*******************************************/ /* _mhttpont.pkg : _on by http :-) */ /* by Marc Barilley */ /* inspired by work done by Sylvain Huet */ /* supports switch beetween _on / HTTPsend */ /*******************************************/ /* */ var HTTP_NO_SERVER = (-2);; var HTTP_ABNORMAL_TERMINATION = (-1);; var HTTP_SERVER_CLOSED = 0;; var HTTP_CONNECTING = 1;; var HTTP_CONNECTED = 2;; var HTTP_FIRST_CONNECTION = 4;; /* client */ struct Http_Chn_Client_SysCommand_Upload_Struct = [ Http_Chn_Client_SysCommand_Upload_Struct_pack : P, Http_Chn_Client_SysCommand_Upload_Struct_sign : S, Http_Chn_Client_SysCommand_Upload_Struct_size : I, Http_Chn_Client_SysCommand_Upload_Struct_ptr : I, Http_Chn_Client_SysCommand_Upload_Struct_curget : S ] mkHttp_Chn_Client_SysCommand_Upload_Struct;; typedef Http_Chn_Client_SysCommand_Types = Http_Chn_Client_SysCommand_Upload Http_Chn_Client_SysCommand_Upload_Struct |Http_Chn_Client_SysCommand_CloseClient ;; typedef Http_Chn_Client_Command = Http_Chn_Client_UserCommand S |Http_Chn_Client_SysCommand Http_Chn_Client_SysCommand_Types ;; struct Http_Chn_Client_Struct = [ Http_Chn_Client_rurl : S, Http_Chn_Client_rchannelIP : S, Http_Chn_Client_rchannelport : I, Http_Chn_Client_script : S, Http_Chn_Client_uchannel : Chn, Http_Chn_Client_ticket : I, Http_Chn_Client_bufHTTPin : S, Http_Chn_Client_fis : I, Http_Chn_Client_bufHTTPout : [Http_Chn_Client_Command r1], Http_Chn_Client_lastmsg : Http_Chn_Client_Command, Http_Chn_Client_urlhttp : S, Http_Chn_Client_nummsg : I, Http_Chn_Client_curget : S, Http_Chn_Client_INET : INET, Http_Chn_Client_lifeINET : INET, Http_Chn_Client_state : I ] mkHttp_Chn_Client_Struct;; /* server */ struct Http_Server_Client_Node = [ Http_Server_Client_Node_attachedServer : Http_Chn_Server_Struct, Http_Server_Client_Node_globHTTPcon : HTTPcon, Http_Server_Client_Node_timeOutTimer : Timer, Http_Server_Client_Node_bufout : S, Http_Server_Client_Node_ticket : I, Http_Server_Client_Node_fis : S, Http_Server_Client_Node_num : I, Http_Server_Client_Node_uchannel : Chn, Http_Server_Client_Node_lasttime : I ] mkHttp_Server_Client_Node;; struct Http_Chn_Server_Struct = [ Http_Chn_Server_server : HTTPserver, Http_Chn_Server_port : I, Http_Chn_Server_script : S, Http_Chn_Server_env : Env, Http_Chn_Server_clienttickets : I, Http_Chn_Server_clients : [Http_Server_Client_Node r1], Http_Chn_Server_timeout : I ] mkHttp_Chn_Server_Struct;; typedef Http_Chn = Http_Chn_Server Http_Server_Client_Node |Http_Chn_Client Http_Chn_Client_Struct ;; /* */ var h8="00000000";; var h4="0000";; var HTTP_ON_maxsize = 4096;; fun itoh8(i)= let itoh i -> s in strcat substr h8 0 8-strlen s s;; fun itoh4(i)= let itoh i -> s in strcat substr h4 0 4-strlen s s;; proto add_http_c = fun [Http_Chn_Client_Struct [Http_Chn_Client_Command r1] S] [Http_Chn_Client_Command r1];; proto flush_http_c = fun [Http_Chn_Client_Struct] Http_Chn_Client_Struct;; proto add_http_s = fun [Http_Server_Client_Node S S] Http_Server_Client_Node;; proto flush_http_s = fun [Http_Server_Client_Node] Http_Server_Client_Node;; var http_header="HTTP/1.0 200 OK\13\10Server: SCOL HTTP server\13\10Content-Type: applicaton/x-unknown\13\10\13\10";; typeof http_clients_list = [Http_Chn_Client_Struct r1];; typeof http_servers_list = [Http_Chn_Server_Struct r1];;