author | Jayson Vantuyl <jvantuyl@engineyard.com> |
Wed, 25 Mar 2009 11:28:18 -0700 | |
changeset 596 | 9096d2549372 |
parent 518 | cdd6a0c5b439 |
child 607 | e2bd14357c9a |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
2 |
/* |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
3 |
* Copyright (C) 2006 Imendio AB |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
4 |
* |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; either version 2 of the |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
8 |
* License, or (at your option) any later version. |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
9 |
* |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
13 |
* Lesser General Public License for more details. |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
14 |
* |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU Lesser General Public |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
16 |
* License along with this program; if not, write to the |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
18 |
* Boston, MA 02111-1307, USA. |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
19 |
*/ |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
20 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
21 |
#include <config.h> |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
22 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
23 |
#include <string.h> |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
24 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
25 |
#include "lm-misc.h" |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
26 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
27 |
static void |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
28 |
misc_setup_source (GMainContext *context, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
29 |
GSource *source, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
30 |
GSourceFunc function, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
31 |
gpointer data) |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
32 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
33 |
g_source_set_callback (source, (GSourceFunc)function, data, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
34 |
g_source_attach (source, context); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
35 |
g_source_unref (source); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
36 |
} |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
37 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
38 |
GSource * |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
39 |
lm_misc_add_io_watch (GMainContext *context, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
40 |
GIOChannel *channel, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
41 |
GIOCondition condition, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
42 |
GIOFunc function, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
43 |
gpointer data) |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
44 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
45 |
GSource *source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
46 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
47 |
g_return_val_if_fail (channel != NULL, 0); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
48 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
49 |
source = g_io_create_watch (channel, condition); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
50 |
misc_setup_source (context, source, (GSourceFunc) function, data); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
51 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
52 |
return source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
53 |
} |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
54 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
55 |
GSource * |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
56 |
lm_misc_add_idle (GMainContext *context, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
57 |
GSourceFunc function, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
58 |
gpointer data) |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
59 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
60 |
GSource *source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
61 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
62 |
g_return_val_if_fail (function != NULL, 0); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
63 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
64 |
source = g_idle_source_new (); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
65 |
misc_setup_source (context, source, function, data); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
66 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
67 |
return source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
68 |
} |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
69 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
70 |
GSource * |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
71 |
lm_misc_add_timeout (GMainContext *context, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
72 |
guint interval, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
73 |
GSourceFunc function, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
74 |
gpointer data) |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
75 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
76 |
GSource *source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
77 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
78 |
g_return_val_if_fail (function != NULL, 0); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
79 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
80 |
source = g_timeout_source_new (interval); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
81 |
misc_setup_source (context, source, function, data); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
82 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
83 |
return source; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
84 |
} |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
85 |
|
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
86 |
const char * |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
87 |
lm_misc_io_condition_to_str (GIOCondition condition) |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
88 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
89 |
static char buf[256]; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
90 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
91 |
buf[0] = '\0'; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
92 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
93 |
if(condition & G_IO_ERR) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
94 |
strcat(buf, "G_IO_ERR "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
95 |
if(condition & G_IO_HUP) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
96 |
strcat(buf, "G_IO_HUP "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
97 |
if(condition & G_IO_NVAL) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
98 |
strcat(buf, "G_IO_NVAL "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
99 |
if(condition & G_IO_IN) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
100 |
strcat(buf, "G_IO_IN "); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
101 |
if(condition & G_IO_OUT) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
102 |
strcat(buf, "G_IO_OUT "); |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
103 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
104 |
return buf; |
196
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
105 |
} |
209bfa124066
Imported LmConnection refactor from old repository.
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
106 |