1 /* Socket code more or less completely copied from here: http://www.ecst.csuchico.edu/~beej/guide/ipc/usock.html */
5 #include <gdk/gdkkeysyms.h>
6 #include <webkit/webkit.h>
11 #include <sys/types.h>
16 #include <sys/types.h>
17 #include <sys/socket.h>
20 static gchar
* sockpath
;
21 static gchar
* command
;
23 static GOptionEntry entries
[] =
25 { "socket", 's', 0, G_OPTION_ARG_STRING
, &sockpath
, "Socket path of the client uzbl", NULL
},
26 { "command", 'c', 0, G_OPTION_ARG_STRING
, &command
, "The uzbl command to execute", NULL
},
27 { NULL
, 0, 0, 0, NULL
, NULL
, NULL
}
31 main(int argc
, char* argv
[]) {
33 GOptionContext
* context
= g_option_context_new ("- some stuff here maybe someday");
34 g_option_context_add_main_entries (context
, entries
, NULL
);
35 g_option_context_add_group (context
, gtk_get_option_group (TRUE
));
36 g_option_context_parse (context
, &argc
, &argv
, &error
);
39 struct sockaddr_un remote
;
41 if ((s
= socket (AF_UNIX
, SOCK_STREAM
, 0)) == -1) {
46 remote
.sun_family
= AF_UNIX
;
47 strcpy (remote
.sun_path
, (char *) sockpath
);
48 len
= strlen (remote
.sun_path
) + sizeof (remote
.sun_family
);
50 if (connect (s
, (struct sockaddr
*) &remote
, len
) == -1) {
55 if (send (s
, command
, strlen (command
), 0) == -1) {
64 /* vi: set et ts=4: */