From 353472953ada54d5e1b5d235ca472254478d17ad Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Wed, 22 Jul 2009 19:46:43 +0000 Subject: Add talk_to_socket handler This handler talks directly to a daemon using a Unix SOCK_SEQPACKET socket, allowing e.g. cookie handlers to be implemented without having to fork and and execute an external program or script interpreter. A little explanation of the functioning of talk_to_socket(): 1. We receive our argument as a string in the format of "HANDLER EXTRA_ARGS". 2. Copy "HANDLER" into our Unix socket address structure and connect to that address (blocking). Error out if connection fails. 3. Write "EXTRA_ARGS" to the socket. Error out if writing fails. 4. Use poll() to wait for a response, timing out after 500ms of inactivity. 5. Use ioctl(FIONREAD) to find out how long the pending datagram is. 6. Allocate an appropriately sized buffer (len+1) and write a null at the end, so our output is always null-terminated no matter what. 7. Read from socket into buffer. Error out if read fails. 8. Close socket. --- uzbl.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'uzbl.h') diff --git a/uzbl.h b/uzbl.h index c9d81b2..4b0a98b 100644 --- a/uzbl.h +++ b/uzbl.h @@ -337,6 +337,9 @@ run_command(const gchar *command, const guint npre, char* build_progressbar_ascii(int percent); +void +talk_to_socket(WebKitWebView *web_view, GArray *argv, GString *result); + void spawn(WebKitWebView *web_view, GArray *argv, GString *result); -- cgit v1.2.3