comparison src/core.c @ 2544:271011bbe14e

[gaim-migrate @ 2557] fine. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 19 Oct 2001 02:43:18 +0000
parents 8229710b343b
children 35c23df11d16
comparison
equal deleted inserted replaced
2543:830a83209475 2544:271011bbe14e
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(guint32 *len, guchar type, guchar subtype, va_list args1) 44 static guchar *UI_build(guint32 *len, guchar type, guchar subtype, va_list args)
45 { 45 {
46 va_list args2;
47 guchar *buffer; 46 guchar *buffer;
48 guint32 pos; 47 guint32 pos;
49 int size; 48 int size;
50 void *data; 49 void *data;
51 50
52 G_VA_COPY(args2, args1);
53
54 *len = sizeof(guchar) * 2 + 4; 51 *len = sizeof(guchar) * 2 + 4;
55 buffer = g_malloc(*len); 52 buffer = g_malloc(*len);
56 pos = 0; 53 pos = 0;
57 54
58 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type); 55 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type);
59 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype); 56 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype);
60 57
61 /* we come back and do size last */ 58 /* we come back and do size last */
62 pos += 4; 59 pos += 4;
63 60
64 size = va_arg(args2, int); 61 size = va_arg(args, int);
65 while (size != -1) { 62 while (size != -1) {
66 *len += size; 63 *len += size;
67 buffer = g_realloc(buffer, *len); 64 buffer = g_realloc(buffer, *len);
68 65
69 data = va_arg(args2, void *); 66 data = va_arg(args, void *);
70 memcpy(buffer + pos, data, size); 67 memcpy(buffer + pos, data, size);
71 pos += size; 68 pos += size;
72 69
73 size = va_arg(args2, int); 70 size = va_arg(args, int);
74 } 71 }
75 72
76 pos -= sizeof(guchar) * 2 + 4; 73 pos -= sizeof(guchar) * 2 + 4;
77 74
78 /* now we do size */ 75 /* now we do size */
79 memcpy(buffer + sizeof(guchar) * 2, &pos, 4); 76 memcpy(buffer + sizeof(guchar) * 2, &pos, 4);
80
81 va_end(args2);
82 77
83 return buffer; 78 return buffer;
84 } 79 }
85 80
86 gint UI_write(struct UI *ui, guchar *data, gint len) 81 gint UI_write(struct UI *ui, guchar *data, gint len)