A couple more filters for guile features.
[tlb/tomd.git] / src / dumb-client / main.c
CommitLineData
e46bd334
TB
1/* Copyright (C) 2018 Thomas Balzer */
2
3/* This file is part of tomd. */
4
5/* tomd is free software: you can redistribute it and/or modify */
6/* it under the terms of the GNU General Public License as published by */
7/* the Free Software Foundation, either version 3 of the License, or */
8/* (at your option) any later version. */
9
10/* tomd is distributed in the hope that it will be useful, */
11/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13/* GNU General Public License for more details. */
14
15/* You should have received a copy of the GNU General Public License */
16/* along with tomd. If not, see <http://www.gnu.org/licenses/>. */
17
e46bd334 18#include <stdlib.h>
72af8b59 19#include <stdio.h>
da4c0e62
TB
20#include <sys/un.h>
21#include <sys/socket.h>
22#include <unistd.h>
e46bd334 23
da4c0e62
TB
24static int sfd;
25
26static void init(void)
e46bd334 27{
72af8b59 28 /* init socket connection */
da4c0e62
TB
29 sfd =
30 socket(PF_LOCAL,
31 SOCK_STREAM,
32 0);
33 if(sfd < 0){
34 perror("socket");
35 exit(EXIT_FAILURE);
36 }
37
38 struct sockaddr_un addr;
39 addr.sun_family = AF_LOCAL;
40 sprintf(addr.sun_path, "/run/user/1000/tomd/socket");
72af8b59 41
da4c0e62
TB
42 if(connect(sfd, (struct sockaddr *) &addr, SUN_LEN(&addr)) != 0){
43 perror("connect");
44 exit(EXIT_FAILURE);
45 }
46}
47
48#define HALLO "hallo there from dumb-client"
49
50void write_hallo(void)
51{
52 printf("writing hallo\n");
53 ssize_t wrote =
54 write(sfd, HALLO, sizeof HALLO);
55 printf("wrote %d bytes.\n", wrote);
e46bd334
TB
56}
57
58int main(int argc, char **argv)
59{
72af8b59
TB
60 printf("dumb client startup.\n");
61
da4c0e62
TB
62 init();
63 write_hallo();
e46bd334
TB
64
65 return EXIT_SUCCESS;
66}