comparison src/core.c @ 2438:5cbe86a444d9

[gaim-migrate @ 2451] more updates to core. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 06 Oct 2001 00:10:29 +0000
parents b4f2a53c0ee5
children 932adc1ac9ed
comparison
equal deleted inserted replaced
2437:aa63f3ceea03 2438:5cbe86a444d9
65 UI_write(ui, data, len); 65 UI_write(ui, data, len);
66 u = u->next; 66 u = u->next;
67 } 67 }
68 } 68 }
69 69
70 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len) 70 static gint gaim_recv(GIOChannel *source, void *buf, gint len)
71 { 71 {
72 gint total = 0; 72 gint total = 0;
73 gint cur; 73 gint cur;
74 74
75 while (total < len) { 75 while (total < len) {
85 85
86 static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data) 86 static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data)
87 { 87 {
88 struct UI *ui = data; 88 struct UI *ui = data;
89 89
90 guchar buf[2] = {0, 0}; 90 guchar type;
91 guchar subtype;
91 guint32 len; 92 guint32 len;
92 93
93 guchar *in; 94 guchar *in;
94 95
95 gushort type;
96
97 /* buf[0] is to specify gaim, buf[1] is for protocol version */
98 if ((gaim_recv(source, buf, 2) != 2) || (buf[0] != 102) || (buf[1] != 1)) {
99 debug_printf("UI has abandoned us! (%d %d)\n", buf[0], buf[1]);
100 uis = g_slist_remove(uis, ui);
101 g_io_channel_close(ui->channel);
102 g_source_remove(ui->inpa);
103 g_free(ui);
104 return FALSE;
105 }
106
107 /* no byte order worries! this'll change if we go to TCP */ 96 /* no byte order worries! this'll change if we go to TCP */
108 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) { 97 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
109 debug_printf("UI has abandoned us!\n"); 98 debug_printf("UI has abandoned us!\n");
110 uis = g_slist_remove(uis, ui); 99 uis = g_slist_remove(uis, ui);
111 g_io_channel_close(ui->channel); 100 g_io_channel_close(ui->channel);
112 g_source_remove(ui->inpa); 101 g_source_remove(ui->inpa);
113 g_free(ui); 102 g_free(ui);
114 return FALSE; 103 return FALSE;
115 } 104 }
116 105
117 in = g_new0(guchar, len + 1); 106 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
118 gaim_recv(source, in, len); 107 debug_printf("UI has abandoned us!\n");
119 108 uis = g_slist_remove(uis, ui);
120 memcpy(&type, in, sizeof(type)); 109 g_io_channel_close(ui->channel);
110 g_source_remove(ui->inpa);
111 g_free(ui);
112 return FALSE;
113 }
114
115 if (gaim_recv(source, &len, sizeof(len)) != sizeof(len)) {
116 debug_printf("UI has abandoned us!\n");
117 uis = g_slist_remove(uis, ui);
118 g_io_channel_close(ui->channel);
119 g_source_remove(ui->inpa);
120 g_free(ui);
121 return FALSE;
122 }
123
124 in = g_new0(guchar, len);
125 if (gaim_recv(source, in, len) != len) {
126 debug_printf("UI has abandoned us!\n");
127 uis = g_slist_remove(uis, ui);
128 g_io_channel_close(ui->channel);
129 g_source_remove(ui->inpa);
130 g_free(ui);
131 return FALSE;
132 }
133
121 switch (type) { 134 switch (type) {
122 /* 135 /*
123 case CUI_TYPE_META: 136 case CUI_TYPE_META:
124 meta_handler(ui, in); 137 meta_handler(ui, in);
125 break; 138 break;