Add gbs.conf
[profile/ivi/psplash.git] / psplash-write.c
1 /* 
2  *  pslash - a lightweight framebuffer splashscreen for embedded devices. 
3  *
4  *  Copyright (c) 2006 Matthew Allum <mallum@o-hand.com>
5  *
6  *  Parts of this file based on 'usplash' copyright Matthew Garret.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  */
19
20 #include <string.h>
21 #include <unistd.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27 #include <errno.h>
28 #include "psplash.h"
29
30 int main(int argc, char **argv) 
31 {
32   char *tmpdir;
33   int   pipe_fd;
34
35   tmpdir = getenv("TMPDIR");
36
37   if (!tmpdir)
38     tmpdir = "/tmp";
39
40   if (argc!=2) 
41     {
42       fprintf(stderr, "Wrong number of arguments\n");
43       exit(-1);
44     }
45   
46   chdir(tmpdir);
47   
48   if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1)
49     {
50       /* Silently error out instead of covering the boot process in 
51          errors when psplash has exitted due to a VC switch */
52       /* perror("Error unable to open fifo"); */
53       exit (-1);
54     }
55
56   write(pipe_fd, argv[1], strlen(argv[1])+1);
57
58   return 0;
59 }
60