int
main(int argc, char* argv[]) {
GError *error = NULL;
- GOptionContext* context = g_option_context_new ("- utility for controlling and interacting with uzbl through its socket file"); //TODO: get stuff back from uzbl
+ GOptionContext* context = g_option_context_new ("- utility for controlling and interacting with uzbl through its socket file"); /* TODO: get stuff back from uzbl */
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
g_option_context_parse (context, &argc, &argv, &error);
int s, len;
struct sockaddr_un remote;
char tmp;
-
+
if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) {
perror ("socket");
- exit (1);
+ exit (EXIT_FAILURE);
}
-
+
remote.sun_family = AF_UNIX;
strcpy (remote.sun_path, (char *) sockpath);
len = strlen (remote.sun_path) + sizeof (remote.sun_family);
-
+
if (connect (s, (struct sockaddr *) &remote, len) == -1) {
perror ("connect");
- exit (1);
+ exit (EXIT_FAILURE);
}
-
+
if ((send (s, command, strlen (command), 0) == -1) ||
(send (s, "\n", 1, 0) == -1)) {
perror ("send");
- exit (1);
+ exit (EXIT_FAILURE);
}
-
+
while ((len = recv (s, &tmp, 1, 0))) {
putchar(tmp);
if (tmp == '\n')
}
close(s);
-
+
return 0;
} else {
- puts ("Usage: uzblctrl -s /path/to/socket -c \"command\"");
+ fprintf(stderr, "Usage: uzblctrl -s /path/to/socket -c \"command\"");
return 1;
}
}