• Home
  • Raw
  • Download

Lines Matching refs:buf

57 struct buf {  struct
58 char *buf; member
64 do_realloc(struct buf *buf, size_t at_least) in do_realloc() argument
68 buf->alloc += BUF_CHUNK_SIZE; in do_realloc()
70 buf->alloc += at_least; in do_realloc()
72 new = realloc(buf->buf, buf->alloc); in do_realloc()
76 buf->buf = new; in do_realloc()
81 check_write_buf(struct buf *buf, const char *fmt, ...) in check_write_buf() argument
87 available = buf->alloc - buf->size; in check_write_buf()
89 printed = vsnprintf(buf->buf + buf->size, available, fmt, args); in check_write_buf()
96 if (!do_realloc(buf, printed)) in check_write_buf()
101 available = buf->alloc - buf->size; in check_write_buf()
103 printed = vsnprintf(buf->buf + buf->size, available, fmt, args); in check_write_buf()
109 buf->size += printed; in check_write_buf()
113 free(buf->buf); in check_write_buf()
114 buf->buf = NULL; in check_write_buf()
118 #define write_buf(buf, ...) do { \ argument
119 if (!check_write_buf(buf, __VA_ARGS__)) \
124 write_vmods(struct xkb_keymap *keymap, struct buf *buf) in write_vmods() argument
134 write_buf(buf, "\tvirtual_modifiers "); in write_vmods()
136 write_buf(buf, ","); in write_vmods()
137 write_buf(buf, "%s", xkb_atom_text(keymap->ctx, mod->name)); in write_vmods()
142 write_buf(buf, ";\n\n"); in write_vmods()
148 write_keycodes(struct xkb_keymap *keymap, struct buf *buf) in write_keycodes() argument
155 write_buf(buf, "xkb_keycodes \"%s\" {\n", in write_keycodes()
158 write_buf(buf, "xkb_keycodes {\n"); in write_keycodes()
164 write_buf(buf, "\tminimum = %u;\n", min(keymap->min_key_code, 8)); in write_keycodes()
165 write_buf(buf, "\tmaximum = %u;\n", max(keymap->max_key_code, 255)); in write_keycodes()
171 write_buf(buf, "\t%-20s = %u;\n", in write_keycodes()
177 write_buf(buf, "\tindicator %u = \"%s\";\n", in write_keycodes()
182 write_buf(buf, "\talias %-14s = %s;\n", in write_keycodes()
186 write_buf(buf, "};\n\n"); in write_keycodes()
191 write_types(struct xkb_keymap *keymap, struct buf *buf) in write_types() argument
194 write_buf(buf, "xkb_types \"%s\" {\n", in write_types()
197 write_buf(buf, "xkb_types {\n"); in write_types()
199 write_vmods(keymap, buf); in write_types()
204 write_buf(buf, "\ttype \"%s\" {\n", in write_types()
207 write_buf(buf, "\t\tmodifiers= %s;\n", in write_types()
222 write_buf(buf, "\t\tmap[%s]= Level%u;\n", in write_types()
226 write_buf(buf, "\t\tpreserve[%s]= %s;\n", in write_types()
233 write_buf(buf, "\t\tlevel_name[Level%u]= \"%s\";\n", n + 1, in write_types()
236 write_buf(buf, "\t};\n"); in write_types()
239 write_buf(buf, "};\n\n"); in write_types()
244 write_led_map(struct xkb_keymap *keymap, struct buf *buf, in write_led_map() argument
247 write_buf(buf, "\tindicator \"%s\" {\n", in write_led_map()
252 write_buf(buf, "\t\twhichGroupState= %s;\n", in write_led_map()
255 write_buf(buf, "\t\tgroups= 0x%02x;\n", in write_led_map()
261 write_buf(buf, "\t\twhichModState= %s;\n", in write_led_map()
264 write_buf(buf, "\t\tmodifiers= %s;\n", in write_led_map()
269 write_buf(buf, "\t\tcontrols= %s;\n", in write_led_map()
273 write_buf(buf, "\t};\n"); in write_led_map()
292 write_action(struct xkb_keymap *keymap, struct buf *buf, in write_action() argument
315 write_buf(buf, "%s%s(modifiers=%s%s%s%s)%s", prefix, type, args, in write_action()
325 write_buf(buf, "%s%s(group=%s%d%s%s)%s", prefix, type, in write_action()
334 write_buf(buf, "%s%s()%s", prefix, type, suffix); in write_action()
338 write_buf(buf, "%s%s(x=%s%d,y=%s%d%s)%s", prefix, type, in write_action()
351 write_buf(buf, "%s%s(button=", prefix, type); in write_action()
353 write_buf(buf, "%d", action->btn.button); in write_action()
355 write_buf(buf, "default"); in write_action()
357 write_buf(buf, ",count=%d", action->btn.count); in write_action()
359 write_buf(buf, "%s", args); in write_action()
360 write_buf(buf, ")%s", suffix); in write_action()
364 write_buf(buf, "%s%s(", prefix, type); in write_action()
365 write_buf(buf, "affect=button,button=%s%d", in write_action()
368 write_buf(buf, ")%s", suffix); in write_action()
372 write_buf(buf, "%s%s(screen=%s%d,%ssame)%s", prefix, type, in write_action()
381 write_buf(buf, "%s%s(controls=%s%s)%s", prefix, type, in write_action()
388 write_buf(buf, "%sNoAction()%s", prefix, suffix); in write_action()
392 write_buf(buf, in write_action()
406 write_compat(struct xkb_keymap *keymap, struct buf *buf) in write_compat() argument
411 write_buf(buf, "xkb_compatibility \"%s\" {\n", in write_compat()
414 write_buf(buf, "xkb_compatibility {\n"); in write_compat()
416 write_vmods(keymap, buf); in write_compat()
418 write_buf(buf, "\tinterpret.useModMapMods= AnyLevel;\n"); in write_compat()
419 write_buf(buf, "\tinterpret.repeat= False;\n"); in write_compat()
424 write_buf(buf, "\tinterpret %s+%s(%s) {\n", in write_compat()
430 write_buf(buf, "\t\tvirtualModifier= %s;\n", in write_compat()
435 write_buf(buf, "\t\tuseModMapMods=level1;\n"); in write_compat()
438 write_buf(buf, "\t\trepeat= True;\n"); in write_compat()
440 write_action(keymap, buf, &si->action, "\t\taction= ", ";\n"); in write_compat()
441 write_buf(buf, "\t};\n"); in write_compat()
447 write_led_map(keymap, buf, led); in write_compat()
449 write_buf(buf, "};\n\n"); in write_compat()
455 write_keysyms(struct xkb_keymap *keymap, struct buf *buf, in write_keysyms() argument
464 write_buf(buf, ", "); in write_keysyms()
469 write_buf(buf, "%15s", "NoSymbol"); in write_keysyms()
472 write_buf(buf, "%15s", KeysymText(keymap->ctx, syms[0])); in write_keysyms()
475 write_buf(buf, "{ "); in write_keysyms()
478 write_buf(buf, ", "); in write_keysyms()
479 write_buf(buf, "%s", KeysymText(keymap->ctx, syms[s])); in write_keysyms()
481 write_buf(buf, " }"); in write_keysyms()
489 write_key(struct xkb_keymap *keymap, struct buf *buf, in write_key() argument
498 write_buf(buf, "\tkey %-20s {", KeyNameText(keymap->ctx, key->name)); in write_key()
518 write_buf(buf, "\n\t\ttype[group%u]= \"%s\",", in write_key()
525 write_buf(buf, "\n\t\ttype= \"%s\",", in write_key()
532 write_buf(buf, "\n\t\trepeat= Yes,"); in write_key()
534 write_buf(buf, "\n\t\trepeat= No,"); in write_key()
539 write_buf(buf, "\n\t\tvirtualMods= %s,", in write_key()
544 write_buf(buf, "\n\t\tgroupsClamp,"); in write_key()
548 write_buf(buf, "\n\t\tgroupsRedirect= Group%u,", in write_key()
562 write_buf(buf, "\t[ "); in write_key()
563 if (!write_keysyms(keymap, buf, key, 0)) in write_key()
565 write_buf(buf, " ] };\n"); in write_key()
572 write_buf(buf, ","); in write_key()
573 write_buf(buf, "\n\t\tsymbols[Group%u]= [ ", group + 1); in write_key()
574 if (!write_keysyms(keymap, buf, key, group)) in write_key()
576 write_buf(buf, " ]"); in write_key()
578 write_buf(buf, ",\n\t\tactions[Group%u]= [ ", group + 1); in write_key()
581 write_buf(buf, ", "); in write_key()
582 write_action(keymap, buf, in write_key()
586 write_buf(buf, " ]"); in write_key()
589 write_buf(buf, "\n\t};\n"); in write_key()
596 write_symbols(struct xkb_keymap *keymap, struct buf *buf) in write_symbols() argument
604 write_buf(buf, "xkb_symbols \"%s\" {\n", in write_symbols()
607 write_buf(buf, "xkb_symbols {\n"); in write_symbols()
611 write_buf(buf, in write_symbols()
615 write_buf(buf, "\n"); in write_symbols()
619 write_key(keymap, buf, key); in write_symbols()
626 write_buf(buf, "\tmodifier_map %s { ", in write_symbols()
628 write_buf(buf, "%s%s", in write_symbols()
635 write_buf(buf, " };\n"); in write_symbols()
638 write_buf(buf, "};\n\n"); in write_symbols()
643 write_keymap(struct xkb_keymap *keymap, struct buf *buf) in write_keymap() argument
645 return (check_write_buf(buf, "xkb_keymap {\n") && in write_keymap()
646 write_keycodes(keymap, buf) && in write_keymap()
647 write_types(keymap, buf) && in write_keymap()
648 write_compat(keymap, buf) && in write_keymap()
649 write_symbols(keymap, buf) && in write_keymap()
650 check_write_buf(buf, "};\n")); in write_keymap()
656 struct buf buf = { NULL, 0, 0 }; in text_v1_keymap_get_as_string() local
658 if (!write_keymap(keymap, &buf)) { in text_v1_keymap_get_as_string()
659 free(buf.buf); in text_v1_keymap_get_as_string()
663 return buf.buf; in text_v1_keymap_get_as_string()