conf.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * conf.c: implementation of the internal storage format used for
  3. * the configuration of a PuTTY session.
  4. */
  5. #include <stdio.h>
  6. #include <stddef.h>
  7. #include <assert.h>
  8. #include "tree234.h"
  9. #include "putty.h"
  10. /*
  11. * Configuration keys are primarily integers (big enum of all the
  12. * different configurable options); some keys have string-designated
  13. * subkeys, such as the list of environment variables (subkeys
  14. * defined by the variable names); some have integer-designated
  15. * subkeys (wordness, colours, preference lists).
  16. */
  17. struct key {
  18. int primary;
  19. union {
  20. int i;
  21. char *s;
  22. } secondary;
  23. };
  24. /* Variant form of struct key which doesn't contain dynamic data, used
  25. * for lookups. */
  26. struct constkey {
  27. int primary;
  28. union {
  29. int i;
  30. const char *s;
  31. } secondary;
  32. };
  33. struct value {
  34. union {
  35. bool boolval;
  36. int intval;
  37. struct {
  38. char *str;
  39. bool utf8;
  40. } stringval;
  41. Filename *fileval;
  42. FontSpec *fontval;
  43. } u;
  44. };
  45. struct conf_entry {
  46. struct key key;
  47. struct value value;
  48. };
  49. struct conf_tag {
  50. tree234 *tree;
  51. };
  52. /*
  53. * Because 'struct key' is the first element in 'struct conf_entry',
  54. * it's safe (guaranteed by the C standard) to cast arbitrarily back
  55. * and forth between the two types. Therefore, we only need one
  56. * comparison function, which can double as a main sort function for
  57. * the tree (comparing two conf_entry structures with each other)
  58. * and a search function (looking up an externally supplied key).
  59. */
  60. static int conf_cmp(void *av, void *bv)
  61. {
  62. struct key *a = (struct key *)av;
  63. struct key *b = (struct key *)bv;
  64. if (a->primary < b->primary)
  65. return -1;
  66. else if (a->primary > b->primary)
  67. return +1;
  68. switch (conf_key_info[a->primary].subkey_type) {
  69. case CONF_TYPE_INT:
  70. if (a->secondary.i < b->secondary.i)
  71. return -1;
  72. else if (a->secondary.i > b->secondary.i)
  73. return +1;
  74. return 0;
  75. case CONF_TYPE_STR:
  76. case CONF_TYPE_UTF8:
  77. return strcmp(a->secondary.s, b->secondary.s);
  78. case CONF_TYPE_NONE:
  79. return 0;
  80. default:
  81. unreachable("Unsupported subkey type");
  82. }
  83. }
  84. static int conf_cmp_constkey(void *av, void *bv)
  85. {
  86. struct key *a = (struct key *)av;
  87. struct constkey *b = (struct constkey *)bv;
  88. if (a->primary < b->primary)
  89. return -1;
  90. else if (a->primary > b->primary)
  91. return +1;
  92. switch (conf_key_info[a->primary].subkey_type) {
  93. case CONF_TYPE_INT:
  94. if (a->secondary.i < b->secondary.i)
  95. return -1;
  96. else if (a->secondary.i > b->secondary.i)
  97. return +1;
  98. return 0;
  99. case CONF_TYPE_STR:
  100. case CONF_TYPE_UTF8:
  101. return strcmp(a->secondary.s, b->secondary.s);
  102. case CONF_TYPE_NONE:
  103. return 0;
  104. default:
  105. unreachable("Unsupported subkey type");
  106. }
  107. }
  108. /*
  109. * Free any dynamic data items pointed to by a 'struct key'. We
  110. * don't free the structure itself, since it's probably part of a
  111. * larger allocated block.
  112. */
  113. static void free_key(struct key *key)
  114. {
  115. if (conf_key_info[key->primary].subkey_type == CONF_TYPE_STR ||
  116. conf_key_info[key->primary].subkey_type == CONF_TYPE_UTF8)
  117. sfree(key->secondary.s);
  118. }
  119. /*
  120. * Copy a 'struct key' into another one, copying its dynamic data
  121. * if necessary.
  122. */
  123. static void copy_key(struct key *to, struct key *from)
  124. {
  125. to->primary = from->primary;
  126. switch (conf_key_info[to->primary].subkey_type) {
  127. case CONF_TYPE_INT:
  128. to->secondary.i = from->secondary.i;
  129. break;
  130. case CONF_TYPE_STR:
  131. case CONF_TYPE_UTF8:
  132. to->secondary.s = dupstr(from->secondary.s);
  133. break;
  134. }
  135. }
  136. /*
  137. * Free any dynamic data items pointed to by a 'struct value'. We
  138. * don't free the value itself, since it's probably part of a larger
  139. * allocated block.
  140. */
  141. static void free_value(struct value *val, int type)
  142. {
  143. if (type == CONF_TYPE_STR || type == CONF_TYPE_UTF8 ||
  144. type == CONF_TYPE_STR_AMBI)
  145. sfree(val->u.stringval.str);
  146. else if (type == CONF_TYPE_FILENAME)
  147. filename_free(val->u.fileval);
  148. else if (type == CONF_TYPE_FONT)
  149. fontspec_free(val->u.fontval);
  150. }
  151. /*
  152. * Copy a 'struct value' into another one, copying its dynamic data
  153. * if necessary.
  154. */
  155. static void copy_value(struct value *to, struct value *from, int type)
  156. {
  157. switch (type) {
  158. case CONF_TYPE_BOOL:
  159. to->u.boolval = from->u.boolval;
  160. break;
  161. case CONF_TYPE_INT:
  162. to->u.intval = from->u.intval;
  163. break;
  164. case CONF_TYPE_STR:
  165. case CONF_TYPE_UTF8:
  166. case CONF_TYPE_STR_AMBI:
  167. to->u.stringval.str = dupstr(from->u.stringval.str);
  168. to->u.stringval.utf8 = from->u.stringval.utf8;
  169. break;
  170. case CONF_TYPE_FILENAME:
  171. to->u.fileval = filename_copy(from->u.fileval);
  172. break;
  173. case CONF_TYPE_FONT:
  174. to->u.fontval = fontspec_copy(from->u.fontval);
  175. break;
  176. }
  177. }
  178. /*
  179. * Free an entire 'struct conf_entry' and its dynamic data.
  180. */
  181. static void free_entry(struct conf_entry *entry)
  182. {
  183. free_key(&entry->key);
  184. free_value(&entry->value, conf_key_info[entry->key.primary].value_type);
  185. sfree(entry);
  186. }
  187. Conf *conf_new(void)
  188. {
  189. Conf *conf = snew(struct conf_tag);
  190. conf->tree = newtree234(conf_cmp);
  191. return conf;
  192. }
  193. void conf_clear(Conf *conf)
  194. {
  195. struct conf_entry *entry;
  196. while ((entry = delpos234(conf->tree, 0)) != NULL)
  197. free_entry(entry);
  198. }
  199. void conf_free(Conf *conf)
  200. {
  201. conf_clear(conf);
  202. freetree234(conf->tree);
  203. sfree(conf);
  204. }
  205. static void conf_insert(Conf *conf, struct conf_entry *entry)
  206. {
  207. struct conf_entry *oldentry = add234(conf->tree, entry);
  208. if (oldentry && oldentry != entry) {
  209. del234(conf->tree, oldentry);
  210. free_entry(oldentry);
  211. oldentry = add234(conf->tree, entry);
  212. assert(oldentry == entry);
  213. }
  214. }
  215. void conf_copy_into(Conf *newconf, Conf *oldconf)
  216. {
  217. struct conf_entry *entry, *entry2;
  218. int i;
  219. conf_clear(newconf);
  220. for (i = 0; (entry = index234(oldconf->tree, i)) != NULL; i++) {
  221. entry2 = snew(struct conf_entry);
  222. copy_key(&entry2->key, &entry->key);
  223. copy_value(&entry2->value, &entry->value,
  224. conf_key_info[entry->key.primary].value_type);
  225. add234(newconf->tree, entry2);
  226. }
  227. }
  228. Conf *conf_copy(Conf *oldconf)
  229. {
  230. Conf *newconf = conf_new();
  231. conf_copy_into(newconf, oldconf);
  232. return newconf;
  233. }
  234. bool conf_get_bool(Conf *conf, int primary)
  235. {
  236. struct key key;
  237. struct conf_entry *entry;
  238. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  239. assert(conf_key_info[primary].value_type == CONF_TYPE_BOOL);
  240. key.primary = primary;
  241. entry = find234(conf->tree, &key, NULL);
  242. assert(entry);
  243. return entry->value.u.boolval;
  244. }
  245. int conf_get_int(Conf *conf, int primary)
  246. {
  247. struct key key;
  248. struct conf_entry *entry;
  249. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  250. assert(conf_key_info[primary].value_type == CONF_TYPE_INT);
  251. key.primary = primary;
  252. entry = find234(conf->tree, &key, NULL);
  253. assert(entry);
  254. return entry->value.u.intval;
  255. }
  256. int conf_get_int_int(Conf *conf, int primary, int secondary)
  257. {
  258. struct key key;
  259. struct conf_entry *entry;
  260. assert(conf_key_info[primary].subkey_type == CONF_TYPE_INT);
  261. assert(conf_key_info[primary].value_type == CONF_TYPE_INT);
  262. key.primary = primary;
  263. key.secondary.i = secondary;
  264. entry = find234(conf->tree, &key, NULL);
  265. assert(entry);
  266. return entry->value.u.intval;
  267. }
  268. char *conf_get_str(Conf *conf, int primary)
  269. {
  270. struct key key;
  271. struct conf_entry *entry;
  272. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  273. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  274. key.primary = primary;
  275. entry = find234(conf->tree, &key, NULL);
  276. assert(entry);
  277. return entry->value.u.stringval.str;
  278. }
  279. char *conf_get_utf8(Conf *conf, int primary)
  280. {
  281. struct key key;
  282. struct conf_entry *entry;
  283. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  284. assert(conf_key_info[primary].value_type == CONF_TYPE_UTF8);
  285. key.primary = primary;
  286. entry = find234(conf->tree, &key, NULL);
  287. assert(entry);
  288. return entry->value.u.stringval.str;
  289. }
  290. char *conf_get_str_ambi(Conf *conf, int primary, bool *utf8)
  291. {
  292. struct key key;
  293. struct conf_entry *entry;
  294. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  295. assert(conf_key_info[primary].value_type == CONF_TYPE_STR ||
  296. conf_key_info[primary].value_type == CONF_TYPE_UTF8 ||
  297. conf_key_info[primary].value_type == CONF_TYPE_STR_AMBI);
  298. key.primary = primary;
  299. entry = find234(conf->tree, &key, NULL);
  300. assert(entry);
  301. if (utf8)
  302. *utf8 = entry->value.u.stringval.utf8;
  303. return entry->value.u.stringval.str;
  304. }
  305. char *conf_get_str_str_opt(Conf *conf, int primary, const char *secondary)
  306. {
  307. struct key key;
  308. struct conf_entry *entry;
  309. assert(conf_key_info[primary].subkey_type == CONF_TYPE_STR);
  310. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  311. key.primary = primary;
  312. key.secondary.s = (char *)secondary;
  313. entry = find234(conf->tree, &key, NULL);
  314. return entry ? entry->value.u.stringval.str : NULL;
  315. }
  316. char *conf_get_str_str(Conf *conf, int primary, const char *secondary)
  317. {
  318. char *ret = conf_get_str_str_opt(conf, primary, secondary);
  319. assert(ret);
  320. return ret;
  321. }
  322. char *conf_get_str_strs(Conf *conf, int primary,
  323. char *subkeyin, char **subkeyout)
  324. {
  325. struct constkey key;
  326. struct conf_entry *entry;
  327. assert(conf_key_info[primary].subkey_type == CONF_TYPE_STR);
  328. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  329. key.primary = primary;
  330. if (subkeyin) {
  331. key.secondary.s = subkeyin;
  332. entry = findrel234(conf->tree, &key, NULL, REL234_GT);
  333. } else {
  334. key.secondary.s = "";
  335. entry = findrel234(conf->tree, &key, conf_cmp_constkey, REL234_GE);
  336. }
  337. if (!entry || entry->key.primary != primary)
  338. return NULL;
  339. *subkeyout = entry->key.secondary.s;
  340. return entry->value.u.stringval.str;
  341. }
  342. char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
  343. {
  344. struct constkey key;
  345. struct conf_entry *entry;
  346. int index;
  347. assert(conf_key_info[primary].subkey_type == CONF_TYPE_STR);
  348. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  349. key.primary = primary;
  350. key.secondary.s = "";
  351. entry = findrelpos234(conf->tree, &key, conf_cmp_constkey,
  352. REL234_GE, &index);
  353. if (!entry || entry->key.primary != primary)
  354. return NULL;
  355. entry = index234(conf->tree, index + n);
  356. if (!entry || entry->key.primary != primary)
  357. return NULL;
  358. return entry->key.secondary.s;
  359. }
  360. Filename *conf_get_filename(Conf *conf, int primary)
  361. {
  362. struct key key;
  363. struct conf_entry *entry;
  364. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  365. assert(conf_key_info[primary].value_type == CONF_TYPE_FILENAME);
  366. key.primary = primary;
  367. entry = find234(conf->tree, &key, NULL);
  368. assert(entry);
  369. return entry->value.u.fileval;
  370. }
  371. FontSpec *conf_get_fontspec(Conf *conf, int primary)
  372. {
  373. struct key key;
  374. struct conf_entry *entry;
  375. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  376. assert(conf_key_info[primary].value_type == CONF_TYPE_FONT);
  377. key.primary = primary;
  378. entry = find234(conf->tree, &key, NULL);
  379. assert(entry);
  380. return entry->value.u.fontval;
  381. }
  382. void conf_set_bool(Conf *conf, int primary, bool value)
  383. {
  384. struct conf_entry *entry = snew(struct conf_entry);
  385. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  386. assert(conf_key_info[primary].value_type == CONF_TYPE_BOOL);
  387. entry->key.primary = primary;
  388. entry->value.u.boolval = value;
  389. conf_insert(conf, entry);
  390. }
  391. void conf_set_int(Conf *conf, int primary, int value)
  392. {
  393. struct conf_entry *entry = snew(struct conf_entry);
  394. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  395. assert(conf_key_info[primary].value_type == CONF_TYPE_INT);
  396. entry->key.primary = primary;
  397. entry->value.u.intval = value;
  398. conf_insert(conf, entry);
  399. }
  400. void conf_set_int_int(Conf *conf, int primary,
  401. int secondary, int value)
  402. {
  403. struct conf_entry *entry = snew(struct conf_entry);
  404. assert(conf_key_info[primary].subkey_type == CONF_TYPE_INT);
  405. assert(conf_key_info[primary].value_type == CONF_TYPE_INT);
  406. entry->key.primary = primary;
  407. entry->key.secondary.i = secondary;
  408. entry->value.u.intval = value;
  409. conf_insert(conf, entry);
  410. }
  411. bool conf_try_set_str(Conf *conf, int primary, const char *value)
  412. {
  413. struct conf_entry *entry = snew(struct conf_entry);
  414. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  415. if (conf_key_info[primary].value_type == CONF_TYPE_UTF8)
  416. return false;
  417. assert(conf_key_info[primary].value_type == CONF_TYPE_STR ||
  418. conf_key_info[primary].value_type == CONF_TYPE_STR_AMBI);
  419. entry->key.primary = primary;
  420. entry->value.u.stringval.str = dupstr(value);
  421. entry->value.u.stringval.utf8 = false;
  422. conf_insert(conf, entry);
  423. return true;
  424. }
  425. void conf_set_str(Conf *conf, int primary, const char *value)
  426. {
  427. bool success = conf_try_set_str(conf, primary, value);
  428. assert(success && "conf_set_str on CONF_TYPE_UTF8");
  429. }
  430. bool conf_try_set_utf8(Conf *conf, int primary, const char *value)
  431. {
  432. struct conf_entry *entry = snew(struct conf_entry);
  433. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  434. if (conf_key_info[primary].value_type == CONF_TYPE_STR)
  435. return false;
  436. assert(conf_key_info[primary].value_type == CONF_TYPE_UTF8 ||
  437. conf_key_info[primary].value_type == CONF_TYPE_STR_AMBI);
  438. entry->key.primary = primary;
  439. entry->value.u.stringval.str = dupstr(value);
  440. entry->value.u.stringval.utf8 = true;
  441. conf_insert(conf, entry);
  442. return true;
  443. }
  444. void conf_set_utf8(Conf *conf, int primary, const char *value)
  445. {
  446. bool success = conf_try_set_utf8(conf, primary, value);
  447. assert(success && "conf_set_utf8 on CONF_TYPE_STR");
  448. }
  449. void conf_set_str_str(Conf *conf, int primary, const char *secondary,
  450. const char *value)
  451. {
  452. struct conf_entry *entry = snew(struct conf_entry);
  453. assert(conf_key_info[primary].subkey_type == CONF_TYPE_STR);
  454. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  455. entry->key.primary = primary;
  456. entry->key.secondary.s = dupstr(secondary);
  457. entry->value.u.stringval.str = dupstr(value);
  458. entry->value.u.stringval.utf8 = false;
  459. conf_insert(conf, entry);
  460. }
  461. void conf_del_str_str(Conf *conf, int primary, const char *secondary)
  462. {
  463. struct key key;
  464. struct conf_entry *entry;
  465. assert(conf_key_info[primary].subkey_type == CONF_TYPE_STR);
  466. assert(conf_key_info[primary].value_type == CONF_TYPE_STR);
  467. key.primary = primary;
  468. key.secondary.s = (char *)secondary;
  469. entry = find234(conf->tree, &key, NULL);
  470. if (entry) {
  471. del234(conf->tree, entry);
  472. free_entry(entry);
  473. }
  474. }
  475. void conf_set_filename(Conf *conf, int primary, const Filename *value)
  476. {
  477. struct conf_entry *entry = snew(struct conf_entry);
  478. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  479. assert(conf_key_info[primary].value_type == CONF_TYPE_FILENAME);
  480. entry->key.primary = primary;
  481. entry->value.u.fileval = filename_copy(value);
  482. conf_insert(conf, entry);
  483. }
  484. void conf_set_fontspec(Conf *conf, int primary, const FontSpec *value)
  485. {
  486. struct conf_entry *entry = snew(struct conf_entry);
  487. assert(conf_key_info[primary].subkey_type == CONF_TYPE_NONE);
  488. assert(conf_key_info[primary].value_type == CONF_TYPE_FONT);
  489. entry->key.primary = primary;
  490. entry->value.u.fontval = fontspec_copy(value);
  491. conf_insert(conf, entry);
  492. }
  493. void conf_serialise(BinarySink *bs, Conf *conf)
  494. {
  495. int i;
  496. struct conf_entry *entry;
  497. for (i = 0; (entry = index234(conf->tree, i)) != NULL; i++) {
  498. put_uint32(bs, entry->key.primary);
  499. switch (conf_key_info[entry->key.primary].subkey_type) {
  500. case CONF_TYPE_INT:
  501. put_uint32(bs, entry->key.secondary.i);
  502. break;
  503. case CONF_TYPE_STR:
  504. put_asciz(bs, entry->key.secondary.s);
  505. break;
  506. }
  507. switch (conf_key_info[entry->key.primary].value_type) {
  508. case CONF_TYPE_BOOL:
  509. put_bool(bs, entry->value.u.boolval);
  510. break;
  511. case CONF_TYPE_INT:
  512. put_uint32(bs, entry->value.u.intval);
  513. break;
  514. case CONF_TYPE_STR:
  515. case CONF_TYPE_UTF8:
  516. put_asciz(bs, entry->value.u.stringval.str);
  517. break;
  518. case CONF_TYPE_STR_AMBI:
  519. put_asciz(bs, entry->value.u.stringval.str);
  520. put_bool(bs, entry->value.u.stringval.utf8);
  521. break;
  522. case CONF_TYPE_FILENAME:
  523. filename_serialise(bs, entry->value.u.fileval);
  524. break;
  525. case CONF_TYPE_FONT:
  526. fontspec_serialise(bs, entry->value.u.fontval);
  527. break;
  528. }
  529. }
  530. put_uint32(bs, 0xFFFFFFFFU);
  531. }
  532. bool conf_deserialise(Conf *conf, BinarySource *src)
  533. {
  534. struct conf_entry *entry;
  535. unsigned primary;
  536. while (1) {
  537. primary = get_uint32(src);
  538. if (get_err(src))
  539. return false;
  540. if (primary == 0xFFFFFFFFU)
  541. return true;
  542. if (primary >= N_CONFIG_OPTIONS)
  543. return false;
  544. entry = snew(struct conf_entry);
  545. entry->key.primary = primary;
  546. switch (conf_key_info[entry->key.primary].subkey_type) {
  547. case CONF_TYPE_INT:
  548. entry->key.secondary.i = toint(get_uint32(src));
  549. break;
  550. case CONF_TYPE_STR:
  551. entry->key.secondary.s = dupstr(get_asciz(src));
  552. break;
  553. }
  554. switch (conf_key_info[entry->key.primary].value_type) {
  555. case CONF_TYPE_BOOL:
  556. entry->value.u.boolval = get_bool(src);
  557. break;
  558. case CONF_TYPE_INT:
  559. entry->value.u.intval = toint(get_uint32(src));
  560. break;
  561. case CONF_TYPE_STR:
  562. entry->value.u.stringval.str = dupstr(get_asciz(src));
  563. entry->value.u.stringval.utf8 = false;
  564. break;
  565. case CONF_TYPE_UTF8:
  566. entry->value.u.stringval.str = dupstr(get_asciz(src));
  567. entry->value.u.stringval.utf8 = true;
  568. break;
  569. case CONF_TYPE_STR_AMBI:
  570. entry->value.u.stringval.str = dupstr(get_asciz(src));
  571. entry->value.u.stringval.utf8 = get_bool(src);
  572. break;
  573. case CONF_TYPE_FILENAME:
  574. entry->value.u.fileval = filename_deserialise(src);
  575. break;
  576. case CONF_TYPE_FONT:
  577. entry->value.u.fontval = fontspec_deserialise(src);
  578. break;
  579. }
  580. if (get_err(src)) {
  581. free_entry(entry);
  582. return false;
  583. }
  584. conf_insert(conf, entry);
  585. }
  586. }