1 /*
2  * Copyright (c) 2008-2010 Lu, Chao-Ming (Tetralet).  All rights reserved.
3  *
4  * This file is part of LilyTerm.
5  *
6  * LilyTerm is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * LilyTerm is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with LilyTerm.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <gtk/gtk.h>
21 // for g_get_tmp_dir()
22 #include <glib.h>
23 // for L10n
24 #include <locale.h>
25 #include <glib/gi18n.h>
26 // for exit()
27 #include <stdlib.h>
28 // for socket()
29 #include <sys/un.h>
30 #include <sys/socket.h>
31 #include <fcntl.h>
32 #include <unistd.h>
33 #include <errno.h>
34 
35 #include "lilyterm.h"
36 
37 // the max size of saddr.sun_path in Linux is 108!
38 #define UNIX_PATH_MAX 108
39 
40 #ifdef UNIT_TEST
41 int fake_main(int argc, char *argv[]);
42 #endif
43 
44 gboolean set_fd_non_block(gint *fd);
45 gboolean init_socket_server();
46 gboolean accept_socket(GIOChannel *source, GIOCondition condition, gpointer user_data);
47 gboolean read_socket(GIOChannel *channel, GIOCondition condition, gpointer user_data);
48 gboolean socket_fault(int i, GError *error, GIOChannel* channel, gboolean unref);
49 gboolean clear_channel(GIOChannel* channel, gboolean unref);
50 gint shutdown_socket_server(gpointer data);
51 gchar *get_locale_list();
52