From 8556d0cdf7058be2c519bd4d8e7006ea9e913527 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 10 Jan 2015 13:30:30 +0100 Subject: Added integral source of mongoose (nw) --- .../examples/websocket_ssl_proxy/ssl_wrapper.c | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 3rdparty/mongoose/examples/websocket_ssl_proxy/ssl_wrapper.c (limited to '3rdparty/mongoose/examples/websocket_ssl_proxy/ssl_wrapper.c') diff --git a/3rdparty/mongoose/examples/websocket_ssl_proxy/ssl_wrapper.c b/3rdparty/mongoose/examples/websocket_ssl_proxy/ssl_wrapper.c new file mode 100644 index 00000000000..969aa979345 --- /dev/null +++ b/3rdparty/mongoose/examples/websocket_ssl_proxy/ssl_wrapper.c @@ -0,0 +1,123 @@ +// Copyright (c) 2014 Cesanta Software Limited +// All rights reserved +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. For the terms of this +// license, see . +// +// You are free to use this software under the terms of the GNU General +// Public License, but WITHOUT ANY WARRANTY; without even the implied +// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// Alternatively, you can license this software under a commercial +// license, as set out in . +// +// $Date$ + +#include "net_skeleton.h" +#include "ssl_wrapper.h" + +static void ev_handler(struct ns_connection *nc, int ev, void *p) { + const char *target_addr = (const char *) nc->mgr->user_data; + struct ns_connection *pc = (struct ns_connection *) nc->user_data; + struct iobuf *io = &nc->recv_iobuf; + + (void) p; + switch (ev) { + case NS_ACCEPT: + // Create a connection to the target, and interlink both connections + nc->user_data = ns_connect(nc->mgr, target_addr, ev_handler, nc); + if (nc->user_data == NULL) { + nc->flags |= NSF_CLOSE_IMMEDIATELY; + } + break; + + case NS_CLOSE: + // If either connection closes, unlink them and shedule closing + if (pc != NULL) { + pc->flags |= NSF_FINISHED_SENDING_DATA; + pc->user_data = NULL; + } + nc->user_data = NULL; + break; + + case NS_RECV: + // Forward arrived data to the other connection, and discard from buffer + if (pc != NULL) { + ns_send(pc, io->buf, io->len); + iobuf_remove(io, io->len); + } + break; + + default: + break; + } +} + +void *ssl_wrapper_init(const char *local_addr, const char *target_addr, + const char **err_msg) { + struct ns_mgr *mgr = (struct ns_mgr *) calloc(1, sizeof(mgr[0])); + *err_msg = NULL; + + if (mgr == NULL) { + *err_msg = "malloc failed"; + } else { + ns_mgr_init(mgr, (void *) target_addr); + if (ns_bind(mgr, local_addr, ev_handler, NULL) == NULL) { + *err_msg = "ns_bind() failed: bad listening_port"; + ns_mgr_free(mgr); + free(mgr); + mgr = NULL; + } + } + + return mgr; +} + +void ssl_wrapper_serve(void *param, volatile int *quit) { + struct ns_mgr *mgr = (struct ns_mgr *) param; + + while (*quit == 0) { + ns_mgr_poll(mgr, 1000); + } + ns_mgr_free(mgr); + free(mgr); +} + +#ifndef SSL_WRAPPER_USE_AS_LIBRARY +static int s_received_signal = 0; + +static void signal_handler(int sig_num) { + signal(sig_num, signal_handler); + s_received_signal = sig_num; +} + +static void show_usage_and_exit(const char *prog) { + fprintf(stderr, "Usage: %s \n", prog); + exit(EXIT_FAILURE); +} + +int main(int argc, char *argv[]) { + void *wrapper; + const char *err_msg; + + if (argc != 3) { + show_usage_and_exit(argv[0]); + } + + // Setup signal handlers + signal(SIGTERM, signal_handler); + signal(SIGINT, signal_handler); + signal(SIGPIPE, SIG_IGN); + + if ((wrapper = ssl_wrapper_init(argv[1], argv[2], &err_msg)) == NULL) { + fprintf(stderr, "Error: %s\n", err_msg); + exit(EXIT_FAILURE); + } + ssl_wrapper_serve(wrapper, &s_received_signal); + + return EXIT_SUCCESS; +} +#endif // SSL_WRAPPER_USE_AS_LIBRARY -- cgit v1.2.3-70-g09d2 a7ef37'>root/src/mame/drivers/vic20.cpp
Commit message (Expand)AuthorAgeFilesLines
* 6522via.cpp: Distinguish some different VIA types AJR2021-01-211-2/+2
* Simplify snapshot/quickload callback parameters; remove some uses of auto_all... AJR2021-01-051-1/+1
* vic20: Added ^ natural key Robbbert2020-09-131-1/+1
* drivers starting with t, u, v, w, x: more macro removal + some others (nw) Ivan Vangelista2020-06-041-6/+6
* lots of files: simplified handlers (nw) Ivan Vangelista2020-05-141-12/+12
* removed more dummy_space() and other miscellaneous space passing (nw) smf-2020-04-021-2/+2
* devices/sound: more handler simplification (nw) Ivan Vangelista2020-03-121-2/+2
* softlist_dev.cpp: get some stuff out of the global namespace (nw) Vas Crabb2019-12-081-3/+3
* m6502: Eliminate the disable_cache hack (nw) AJR2019-11-021-1/+0
* Make devdelegate more like devcb for configuration. This is a Vas Crabb2019-10-261-1/+1
* -snapquik: Modernized delegate and removed MCFG macros. [Ryan Holtz] MooglyGuy2019-06-301-4/+3
* (nw) Clean up the mess on master Vas Crabb2019-03-261-5/+5
* Revert "conflict resolution (nw)" andreasnaive2019-03-251-5/+5
* bus/adam, bus/cbm2, bus/coleco, bus/vic20: Eliminate unnecessary address_spac... AJR2019-02-191-3/+3
* Make the delay for snapshot/quickload an attotime, and allow implicit zero. ... Vas Crabb2019-02-061-2/+2
* Previous commit examples of use (nw) Olivier Galibert2018-08-021-4/+4
* -vic20: Removed MCFG and duplicated machine configs. [Ryan Holtz] mooglyguy2018-08-011-128/+108
* private: use (S, T, U, V) (nw) (#3720) David Haywood2018-07-011-3/+6
* more macro removal and overload disambiguation (nw) Vas Crabb2018-06-171-6/+6
* as if millions of this pointers suddenly cried out in terror, and were sudden... Vas Crabb2018-06-081-2/+2
* Move the +1 to the proper place in the ROM BIOS macros - that's been Vas Crabb2018-05-291-4/+4
* Removed DRIVER_INIT-related macros, made driver init entry in GAME/COMP/CONS ... MooglyGuy2018-05-131-5/+5
* emumem: Rename direct_read_handler to memory_access_cache. Parametrize the t... Olivier Galibert2018-05-111-2/+2
* dsp16: fix condition mask in disassembler (nw) Vas Crabb2018-05-091-2/+2
* (nw) few more macros replaced with constructors Vas Crabb2018-05-071-2/+2
* Streamline machine configuration macros - everyone's a device edition. Vas Crabb2018-05-061-51/+51
* Address maps macros removal, pass 1 [O. Galibert] Olivier Galibert2018-03-141-9/+12
* (nw) screw you macros and the horse you rode in on Vas Crabb2018-02-141-2/+4
* API change: Memory maps are now methods of the owner class [O. Galibert] Olivier Galibert2018-02-121-3/+6
* API Change: Machine configs are now a method of the owner class, and the prot... Olivier Galibert2018-01-171-3/+6
* Revert "Revert "Merge branch 'master' of https://github.com/mamedev/mame"" Firehawke2017-12-131-17/+34
* Revert "Merge branch 'master' of https://github.com/mamedev/mame" Firehawke2017-12-131-34/+17
* via6522: Eliminate truly ancient hack to default clock to that of first CPU (nw) AJR2017-12-071-17/+34
* Added a natural keyboard validation to check for valid natural keyboard (uni)... npwoods2017-09-051-2/+2
* dimemory: Lift the cap on the number of address spaces per device [O. Galibert] Olivier Galibert2017-07-031-2/+2
* Move static data out of devices into the device types. This is a significant... Vas Crabb2017-05-141-6/+6
* Self-registering devices prep: Vas Crabb2017-02-271-0/+2
* NOTICE (TYPE NAME CONSOLIDATION) Miodrag Milanovic2016-10-221-12/+12
* DAC WIP, started documenting the DACs in use. [smf] smf-2016-10-171-1/+0
* required_ioport_array. (nw) Curt Coder2016-10-091-9/+140
* Further IRQ passthrough cleanup AJR2016-07-081-2/+2
* clang-modernize part 4 Miodrag Milanovic2015-12-041-3/+3