9 static const char *vendor = "John Tsiombikas";
11 static int calc_add_size(void);
12 static int calc_info_size(void);
14 int server_info(void *buf, int sz)
16 struct xconn_accept_header *info;
18 struct xformat *pixfmt;
19 int addsz = calc_add_size();
20 int infosz = addsz + sizeof *info;
21 int vendsz = strlen(vendor);
23 if(!buf) return infosz;
24 if(sz < infosz) return -1;
27 vendptr = (char*)buf + sizeof *info;
28 pixfmt = (struct xformat*)(vendptr + padded_size(vendsz));
31 info->proto_major = PROTO_MAJOR;
32 info->proto_minor = PROTO_MINOR;
33 info->add_length = addsz / 4; /* in words */
36 info->resid_mask = 0xffff;
37 info->motionbuf_size = 0;
38 info->vendor_length = vendsz;
39 info->max_req_length = CLIENT_BUF_SIZE;
40 info->num_screens = NUM_SCR;
41 info->num_pixfmt = NUM_PIXFMT;
42 info->img_byteorder = 0; /* LSB first */
43 info->bm_fmt_bitorder = 0; /* least significant */
44 info->bm_fmt_scanline_unit = 1; /* TODO */
45 info->bm_fmt_scanline_pad = 0;
46 info->min_keycode = 0;
47 info->max_keycode = 0xff;
49 memcpy(vendptr, vendor, vendsz);
53 pixfmt->scanline_pad = 0;
58 static int calc_add_size(void)
60 int ven_len = strlen(vendor);
61 int ven_pad = padding(ven_len);
62 int max_scr = padded_size(NUM_SCR); /* must be multiple of 4 */
64 /* additional data size */
65 return 32 + 8 * NUM_PIXFMT + ven_len + ven_pad + max_scr;
68 static int calc_info_size(void)
70 return sizeof(struct xconn_accept_header) + calc_add_size();