Mercurial > pidgin
comparison src/core.c @ 2462:cf2f2450f7cc
[gaim-migrate @ 2475]
stupid
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 09 Oct 2001 20:19:42 +0000 |
parents | 6bdeb91abe4e |
children | 7e4757801725 |
comparison
equal
deleted
inserted
replaced
2461:0edec72bc72f | 2462:cf2f2450f7cc |
---|---|
39 #include "gaim.h" | 39 #include "gaim.h" |
40 | 40 |
41 static gint UI_fd = -1; | 41 static gint UI_fd = -1; |
42 GSList *uis = NULL; | 42 GSList *uis = NULL; |
43 | 43 |
44 static guchar *UI_build(int *len, guchar type, guchar subtype, va_list args1) | 44 static guchar *UI_build(guint32 *len, guchar type, guchar subtype, va_list args1) |
45 { | 45 { |
46 va_list args2; | 46 va_list args2; |
47 guchar *buffer; | 47 guchar *buffer; |
48 int pos; | 48 guint32 pos; |
49 int size; | 49 int size; |
50 void *data; | 50 void *data; |
51 | 51 |
52 G_VA_COPY(args2, args1); | 52 G_VA_COPY(args2, args1); |
53 | 53 |
54 buffer = g_malloc(sizeof(guchar) * 2 + 4); | |
55 *len = sizeof(guchar) * 2 + 4; | 54 *len = sizeof(guchar) * 2 + 4; |
55 buffer = g_malloc(*len); | |
56 pos = 0; | 56 pos = 0; |
57 | 57 |
58 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type); | 58 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type); |
59 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype); | 59 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype); |
60 | 60 |
70 memcpy(buffer + pos, data, size); | 70 memcpy(buffer + pos, data, size); |
71 pos += size; | 71 pos += size; |
72 | 72 |
73 size = va_arg(args2, int); | 73 size = va_arg(args2, int); |
74 } | 74 } |
75 | |
76 /* now we do size */ | |
77 memcpy(buffer + sizeof(guchar) * 2, &pos, 4); | |
75 | 78 |
76 va_end(args2); | 79 va_end(args2); |
77 | 80 |
78 return buffer; | 81 return buffer; |
79 } | 82 } |
93 | 96 |
94 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) | 97 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) |
95 { | 98 { |
96 va_list ap; | 99 va_list ap; |
97 gchar *data; | 100 gchar *data; |
98 int len; | 101 guint32 len; |
99 | 102 |
100 va_start(ap, subtype); | 103 va_start(ap, subtype); |
101 data = UI_build(&len, type, subtype, ap); | 104 data = UI_build(&len, type, subtype, ap); |
102 va_end(ap); | 105 va_end(ap); |
103 | 106 |
118 | 121 |
119 void UI_build_broadcast(guchar type, guchar subtype, ...) | 122 void UI_build_broadcast(guchar type, guchar subtype, ...) |
120 { | 123 { |
121 va_list ap; | 124 va_list ap; |
122 gchar *data; | 125 gchar *data; |
123 int len; | 126 guint32 len; |
124 | 127 |
125 if (!uis) | 128 if (!uis) |
126 return; | 129 return; |
127 | 130 |
128 va_start(ap, subtype); | 131 va_start(ap, subtype); |