+static void
+define_group_icon_rcdata (rc_res_id id, const rc_res_res_info *resinfo,
+ rc_rcdata_item *data)
+{
+ rc_res_resource *r;
+ rc_group_icon *cg, *first, *cur;
+ rc_uint_type len_data;
+ bfd_byte *pb_data;
+
+ pb_data = rcdata_render_as_buffer (data, &len_data);
+
+ cur = NULL;
+ first = NULL;
+
+ while (len_data >= 6)
+ {
+ int c, i;
+ unsigned short type;
+ type = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2);
+ if (type != 1)
+ fatal (_("unexpected group icon type %d"), type);
+ c = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4);
+ len_data -= 6;
+ pb_data += 6;
+
+ for (i = 0; i < c; i++)
+ {
+ if (len_data < 14)
+ fatal ("too small group icon rcdata");
+ cg = (rc_group_icon *) res_alloc (sizeof (rc_group_icon));
+ cg->next = NULL;
+ cg->width = pb_data[0];
+ cg->height = pb_data[1];
+ cg->colors = pb_data[2];
+ cg->planes = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4);
+ cg->bits = windres_get_16 (&wrtarget, pb_data + 6, len_data - 6);
+ cg->bytes = windres_get_32 (&wrtarget, pb_data + 8, len_data - 8);
+ cg->index = windres_get_16 (&wrtarget, pb_data + 12, len_data - 12);
+ if (! first)
+ first = cg;
+ else
+ cur->next = cg;
+ cur = cg;
+ pb_data += 14;
+ len_data -= 14;
+ }
+ }
+ r = define_standard_resource (&resources, RT_GROUP_ICON, id,
+ resinfo->language, 0);
+ r->type = RES_TYPE_GROUP_ICON;
+ r->u.group_icon = first;
+ r->res_info = *resinfo;
+}
+
+static void
+define_group_cursor_rcdata (rc_res_id id, const rc_res_res_info *resinfo,
+ rc_rcdata_item *data)
+{
+ rc_res_resource *r;
+ rc_group_cursor *cg, *first, *cur;
+ rc_uint_type len_data;
+ bfd_byte *pb_data;
+
+ pb_data = rcdata_render_as_buffer (data, &len_data);
+
+ first = cur = NULL;
+
+ while (len_data >= 6)
+ {
+ int c, i;
+ unsigned short type;
+ type = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2);
+ if (type != 2)
+ fatal (_("unexpected group cursor type %d"), type);
+ c = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4);
+ len_data -= 6;
+ pb_data += 6;
+
+ for (i = 0; i < c; i++)
+ {
+ if (len_data < 14)
+ fatal ("too small group icon rcdata");
+ cg = (rc_group_cursor *) res_alloc (sizeof (rc_group_cursor));
+ cg->next = NULL;
+ cg->width = windres_get_16 (&wrtarget, pb_data, len_data);
+ cg->height = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2);
+ cg->planes = windres_get_16 (&wrtarget, pb_data + 4, len_data - 4);
+ cg->bits = windres_get_16 (&wrtarget, pb_data + 6, len_data - 6);
+ cg->bytes = windres_get_32 (&wrtarget, pb_data + 8, len_data - 8);
+ cg->index = windres_get_16 (&wrtarget, pb_data + 12, len_data - 12);
+ if (! first)
+ first = cg;
+ else
+ cur->next = cg;
+ cur = cg;
+ pb_data += 14;
+ len_data -= 14;
+ }
+ }
+
+ r = define_standard_resource (&resources, RT_GROUP_ICON, id,
+ resinfo->language, 0);
+ r->type = RES_TYPE_GROUP_CURSOR;
+ r->u.group_cursor = first;
+ r->res_info = *resinfo;
+}
+
+static void
+define_cursor_rcdata (rc_res_id id, const rc_res_res_info *resinfo,
+ rc_rcdata_item *data)
+{
+ rc_cursor *c;
+ rc_res_resource *r;
+ rc_uint_type len_data;
+ bfd_byte *pb_data;
+
+ pb_data = rcdata_render_as_buffer (data, &len_data);
+
+ c = (rc_cursor *) res_alloc (sizeof (rc_cursor));
+ c->xhotspot = windres_get_16 (&wrtarget, pb_data, len_data);
+ c->yhotspot = windres_get_16 (&wrtarget, pb_data + 2, len_data - 2);
+ c->length = len_data - BIN_CURSOR_SIZE;
+ c->data = (const bfd_byte *) (data + BIN_CURSOR_SIZE);
+
+ r = define_standard_resource (&resources, RT_CURSOR, id, resinfo->language, 0);
+ r->type = RES_TYPE_CURSOR;
+ r->u.cursor = c;
+ r->res_info = *resinfo;
+}
+
+static void
+define_bitmap_rcdata (rc_res_id id, const rc_res_res_info *resinfo,
+ rc_rcdata_item *data)
+{
+ rc_res_resource *r;
+ rc_uint_type len_data;
+ bfd_byte *pb_data;
+
+ pb_data = rcdata_render_as_buffer (data, &len_data);
+
+ r = define_standard_resource (&resources, RT_BITMAP, id, resinfo->language, 0);
+ r->type = RES_TYPE_BITMAP;
+ r->u.data.length = len_data;
+ r->u.data.data = pb_data;
+ r->res_info = *resinfo;
+}
+
+static void
+define_icon_rcdata (rc_res_id id, const rc_res_res_info *resinfo,
+ rc_rcdata_item *data)
+{
+ rc_res_resource *r;
+ rc_uint_type len_data;
+ bfd_byte *pb_data;
+
+ pb_data = rcdata_render_as_buffer (data, &len_data);
+
+ r = define_standard_resource (&resources, RT_ICON, id, resinfo->language, 0);
+ r->type = RES_TYPE_ICON;
+ r->u.data.length = len_data;
+ r->u.data.data = pb_data;
+ r->res_info = *resinfo;
+}
+