comparison plugins/tcl/tcl_glib.c @ 13816:1b783830ca06

[gaim-migrate @ 16248] Fix some 64-bit nonos in tcl_glib committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Sat, 10 Jun 2006 19:27:21 +0000
parents 464e2b6bc7e6
children af56c955ec5f
comparison
equal deleted inserted replaced
13815:724e4c08391a 13816:1b783830ca06
1 /* 1 /*
2 * Tcl/Glib glue 2 * Tcl/Glib glue
3 * 3 *
4 * Copyright (C) 2003, 2004 Ethan Blanton <eblanton@cs.purdue.edu> 4 * Copyright (C) 2003, 2004, 2006 Ethan Blanton <eblanton@cs.purdue.edu>
5 * 5 *
6 * This file is dual-licensed under the two sets of terms below. You may 6 * This file is dual-licensed under the two sets of terms below. You may
7 * use, redistribute, or modify it pursuant to either the set of conditions 7 * use, redistribute, or modify it pursuant to either the set of conditions
8 * under "TERMS 1" or "TERMS 2", at your discretion. The DISCLAIMER 8 * under "TERMS 1" or "TERMS 2", at your discretion. The DISCLAIMER
9 * applies to both sets of terms. 9 * applies to both sets of terms.
155 { 155 {
156 struct tcl_file_handler *tfh = g_new0(struct tcl_file_handler, 1); 156 struct tcl_file_handler *tfh = g_new0(struct tcl_file_handler, 1);
157 GIOChannel *channel; 157 GIOChannel *channel;
158 GIOCondition cond = 0; 158 GIOCondition cond = 0;
159 159
160 if (g_hash_table_lookup(tcl_file_handlers, (gpointer)fd)) 160 if (g_hash_table_lookup(tcl_file_handlers, GINT_TO_POINTER(fd)))
161 tcl_delete_file_handler(fd); 161 tcl_delete_file_handler(fd);
162 162
163 if (mask & TCL_READABLE) 163 if (mask & TCL_READABLE)
164 cond |= G_IO_IN; 164 cond |= G_IO_IN;
165 if (mask & TCL_WRITABLE) 165 if (mask & TCL_WRITABLE)
166 cond |= G_IO_OUT; 166 cond |= G_IO_OUT;
174 174
175 channel = g_io_channel_unix_new(fd); 175 channel = g_io_channel_unix_new(fd);
176 tfh->source = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, tcl_file_callback, tfh, g_free); 176 tfh->source = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, tcl_file_callback, tfh, g_free);
177 g_io_channel_unref(channel); 177 g_io_channel_unref(channel);
178 178
179 g_hash_table_insert(tcl_file_handlers, (gpointer)fd, tfh); 179 g_hash_table_insert(tcl_file_handlers, GINT_TO_POINTER(fd), tfh);
180 180
181 Tcl_ServiceAll(); 181 Tcl_ServiceAll();
182 } 182 }
183 183
184 static void tcl_delete_file_handler(int fd) 184 static void tcl_delete_file_handler(int fd)
187 187
188 if (tfh == NULL) 188 if (tfh == NULL)
189 return; 189 return;
190 190
191 g_source_remove(tfh->source); 191 g_source_remove(tfh->source);
192 g_hash_table_remove(tcl_file_handlers, (gpointer)fd); 192 g_hash_table_remove(tcl_file_handlers, GINT_TO_POINTER(fd));
193 193
194 Tcl_ServiceAll(); 194 Tcl_ServiceAll();
195 } 195 }
196 196
197 static gboolean tcl_kick(gpointer data) 197 static gboolean tcl_kick(gpointer data)
239 239
240 if (!(flags & TCL_FILE_EVENTS)) { 240 if (!(flags & TCL_FILE_EVENTS)) {
241 return 0; 241 return 0;
242 } 242 }
243 243
244 tfh = g_hash_table_lookup(tcl_file_handlers, (gpointer)fev->fd); 244 tfh = g_hash_table_lookup(tcl_file_handlers, GINT_TO_POINTER(fev->fd));
245 if (tfh == NULL) 245 if (tfh == NULL)
246 return 1; 246 return 1;
247 247
248 mask = tfh->mask & tfh->pending; 248 mask = tfh->mask & tfh->pending;
249 if (mask) 249 if (mask)