2007-10-27 18:47:13 +02:00
|
|
|
/*
|
|
|
|
* awesome-client.c - awesome client, communicate with socket
|
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
* Copyright © 2007 daniel@brinkers.de
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-10-27 13:22:47 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
|
2007-10-27 18:47:13 +02:00
|
|
|
#include "awesome-client.h"
|
2007-10-27 13:22:47 +02:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
int
|
2007-10-29 17:29:58 +01:00
|
|
|
main(int argc, char **argv)
|
2007-10-27 13:22:47 +02:00
|
|
|
{
|
2007-10-29 16:14:50 +01:00
|
|
|
struct sockaddr_un *addr;
|
2007-10-27 13:22:47 +02:00
|
|
|
char buf[1024];
|
|
|
|
int csfd;
|
2007-10-29 17:29:58 +01:00
|
|
|
|
2007-10-29 16:14:50 +01:00
|
|
|
csfd = get_client_socket();
|
2007-10-29 17:29:58 +01:00
|
|
|
if(argc > 1)
|
|
|
|
addr = get_client_addr(argv[1]);
|
|
|
|
else
|
|
|
|
addr = get_client_addr(":0");
|
2007-10-29 16:14:50 +01:00
|
|
|
|
2007-10-29 16:20:11 +01:00
|
|
|
if(!addr || csfd < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2007-10-27 13:22:47 +02:00
|
|
|
while(fgets(buf, sizeof(buf), stdin))
|
2007-10-29 16:14:50 +01:00
|
|
|
if(sendto(csfd, buf, a_strlen(buf), MSG_NOSIGNAL,
|
|
|
|
(const struct sockaddr *) addr, sizeof(struct sockaddr_un)) == -1)
|
2007-10-27 13:22:47 +02:00
|
|
|
perror("error sending datagram");
|
2007-10-29 16:14:50 +01:00
|
|
|
|
2007-10-29 16:23:05 +01:00
|
|
|
p_delete(&addr);
|
|
|
|
|
2007-10-29 16:14:50 +01:00
|
|
|
return EXIT_SUCCESS;
|
2007-10-27 13:22:47 +02:00
|
|
|
}
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|