diff --git a/conf/e2/config.json b/conf/e2/config.json
index beb582a97..c2514706a 100644
--- a/conf/e2/config.json
+++ b/conf/e2/config.json
@@ -1,30 +1,28 @@
{
"include": [
- "config://keywords.json",
- "config://calendar.json",
- "config://prefixes.json",
- "config://e2/terrains.json",
- "config://e2/locales.xml",
- "config://e2/rules.xml",
- "rules://core/ships.xml",
- "rules://core/spoils.xml",
- "rules://core/common/buildings.xml",
- "rules://core/common/items.xml",
- "rules://core/common/resources.xml",
- "rules://core/common/luxuries.xml",
- "rules://core/common/herbs.xml",
- "rules://core/common/potions.xml",
- "rules://core/common/armor.xml",
- "rules://core/common/weapons.xml",
- "rules://eressea/races.xml",
- "rules://eressea/artrewards.xml",
- "rules://eressea/buildings.xml",
- "rules://eressea/familiars.xml",
- "rules://eressea/buildings.xml",
- "rules://eressea/equipment.xml",
- "rules://eressea/items.xml",
- "rules://eressea/spells.xml",
- "rules://adamantium.xml"
+ "config://conf/keywords.json",
+ "config://conf/calendar.json",
+ "config://conf/prefixes.json",
+ "config://conf/e2/terrains.json",
+ "config://conf/e2/items.json",
+ "config://conf/e2/locales.json",
+ "config://conf/e2/rules.xml",
+ "config://res/core/ships.xml",
+ "config://res/core/spoils.xml",
+ "config://res/core/common/buildings.xml",
+ "config://res/eressea/buildings.xml",
+ "config://res/buildings/castle.xml",
+ "config://res/eressea/races.xml",
+ "config://res/eressea/artrewards.xml",
+ "config://res/eressea/familiars.xml",
+ "config://res/eressea/equipment.xml",
+ "config://res/eressea/spells.xml",
+ "config://res/eressea/spellbooks/gray.xml",
+ "config://res/eressea/spellbooks/gwyrrd.xml",
+ "config://res/eressea/spellbooks/draig.xml",
+ "config://res/eressea/spellbooks/illaun.xml",
+ "config://res/eressea/spellbooks/cerddor.xml",
+ "config://res/eressea/spellbooks/tybied.xml"
],
"disabled": [
"jsreport"
diff --git a/conf/e2/items.json b/conf/e2/items.json
new file mode 100644
index 000000000..dc4664cdc
--- /dev/null
+++ b/conf/e2/items.json
@@ -0,0 +1,49 @@
+{
+ "include": [
+ "config://res/core/common/items.xml",
+ "config://res/core/armor/chainmail.xml",
+ "config://res/core/armor/laenmail.xml",
+ "config://res/core/armor/laenshield.xml",
+ "config://res/core/armor/plate.xml",
+ "config://res/core/armor/rustychainmail.xml",
+ "config://res/core/armor/rustyshield.xml",
+ "config://res/core/armor/shield.xml",
+ "config://res/core/resources/cart.xml",
+ "config://res/core/resources/horse.xml",
+ "config://res/core/resources/hp.xml",
+ "config://res/core/resources/iron.xml",
+ "config://res/core/resources/laen.xml",
+ "config://res/core/resources/log.xml",
+ "config://res/core/resources/mallorn.xml",
+ "config://res/core/resources/mallornseed.xml",
+ "config://res/core/resources/seed.xml",
+ "config://res/core/resources/peasant.xml",
+ "config://res/core/resources/stone.xml",
+ "config://res/core/common/luxuries.xml",
+ "config://res/core/common/herbs.xml",
+ "config://res/core/common/potions.xml",
+ "config://res/core/weapons/axe.xml",
+ "config://res/core/weapons/bow.xml",
+ "config://res/core/weapons/catapult.xml",
+ "config://res/core/weapons/crossbow.xml",
+ "config://res/core/weapons/firesword.xml",
+ "config://res/core/weapons/greatbow.xml",
+ "config://res/core/weapons/greatsword.xml",
+ "config://res/core/weapons/halberd.xml",
+ "config://res/core/weapons/laensword.xml",
+ "config://res/core/weapons/lance.xml",
+ "config://res/core/weapons/mallornbow.xml",
+ "config://res/core/weapons/mallorncrossbow.xml",
+ "config://res/core/weapons/mallornlance.xml",
+ "config://res/core/weapons/mallornspear.xml",
+ "config://res/core/weapons/runesword.xml",
+ "config://res/core/weapons/rustyaxe.xml",
+ "config://res/core/weapons/rustygreatsword.xml",
+ "config://res/core/weapons/rustyhalberd.xml",
+ "config://res/core/weapons/rustysword.xml",
+ "config://res/core/weapons/spear.xml",
+ "config://res/core/weapons/sword.xml",
+ "config://res/eressea/items.xml",
+ "config://res/adamantium.xml"
+ ]
+}
diff --git a/conf/e2/locales.json b/conf/e2/locales.json
new file mode 100644
index 000000000..4a3a100ef
--- /dev/null
+++ b/conf/e2/locales.json
@@ -0,0 +1,14 @@
+{
+ "include": [
+ "config://res/core/messages.xml",
+ "config://res/core/de/strings.xml",
+ "config://res/core/en/strings.xml",
+ "config://res/eressea/strings.xml",
+ "config://res/eressea/spellinfo.xml",
+ "config://res/names-undead.xml",
+ "config://res/names-skeletons.xml",
+ "config://res/names-zombies.xml",
+ "config://res/names-ghouls.xml",
+ "config://res/names-dragons.xml"
+ ]
+}
diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml
deleted file mode 100644
index 7a31bbc17..000000000
--- a/conf/e2/locales.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/adamantium.xml b/res/adamantium.xml
index e1f0643e2..563299e51 100644
--- a/res/adamantium.xml
+++ b/res/adamantium.xml
@@ -1,4 +1,5 @@
+
@@ -32,3 +33,4 @@
+
diff --git a/res/buildings/castle-2.xml b/res/buildings/castle-2.xml
index accb92c08..8117524ff 100644
--- a/res/buildings/castle-2.xml
+++ b/res/buildings/castle-2.xml
@@ -1,4 +1,5 @@
+
@@ -19,3 +20,4 @@
+
diff --git a/res/buildings/castle.xml b/res/buildings/castle.xml
index ce64e8030..14d959ed7 100644
--- a/res/buildings/castle.xml
+++ b/res/buildings/castle.xml
@@ -1,4 +1,6 @@
+
+
@@ -22,3 +24,5 @@
+
+
diff --git a/res/core/armor/chainmail.xml b/res/core/armor/chainmail.xml
index b03221b35..048a94ae9 100644
--- a/res/core/armor/chainmail.xml
+++ b/res/core/armor/chainmail.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/armor/laenmail.xml b/res/core/armor/laenmail.xml
index 0e1411945..f26e5363b 100644
--- a/res/core/armor/laenmail.xml
+++ b/res/core/armor/laenmail.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/armor/laenshield.xml b/res/core/armor/laenshield.xml
index 8a9d6d5c3..03f9f479a 100644
--- a/res/core/armor/laenshield.xml
+++ b/res/core/armor/laenshield.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/armor/plate.xml b/res/core/armor/plate.xml
index 97d855a73..f43a704b8 100644
--- a/res/core/armor/plate.xml
+++ b/res/core/armor/plate.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/armor/rustychainmail.xml b/res/core/armor/rustychainmail.xml
index b46380634..f7947bbb1 100644
--- a/res/core/armor/rustychainmail.xml
+++ b/res/core/armor/rustychainmail.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,4 +8,4 @@
-
+
diff --git a/res/core/armor/rustyshield.xml b/res/core/armor/rustyshield.xml
index 56a8abe5a..218b4fa6a 100644
--- a/res/core/armor/rustyshield.xml
+++ b/res/core/armor/rustyshield.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/armor/shield.xml b/res/core/armor/shield.xml
index b0ee7de3a..af099dc2e 100644
--- a/res/core/armor/shield.xml
+++ b/res/core/armor/shield.xml
@@ -1,4 +1,5 @@
+
-
@@ -7,3 +8,4 @@
+
diff --git a/res/core/common/armor.xml b/res/core/common/armor.xml
deleted file mode 100644
index 58abae47f..000000000
--- a/res/core/common/armor.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml
index 932326f1c..3b8719b3b 100644
--- a/res/core/common/buildings.xml
+++ b/res/core/common/buildings.xml
@@ -1,4 +1,5 @@
+
@@ -167,4 +168,4 @@
-
+
diff --git a/res/core/common/construction.xml b/res/core/common/construction.xml
deleted file mode 100644
index 089ddfe1c..000000000
--- a/res/core/common/construction.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/res/core/common/herbs.xml b/res/core/common/herbs.xml
index d7d0ef2e6..9175b4a42 100644
--- a/res/core/common/herbs.xml
+++ b/res/core/common/herbs.xml
@@ -1,4 +1,5 @@
+
@@ -87,3 +88,4 @@
+
diff --git a/res/core/common/luxuries.xml b/res/core/common/luxuries.xml
index bdf9c110b..05e125b33 100644
--- a/res/core/common/luxuries.xml
+++ b/res/core/common/luxuries.xml
@@ -1,4 +1,5 @@
+
@@ -24,3 +25,4 @@
+
diff --git a/res/core/common/potions.xml b/res/core/common/potions.xml
index 4812727dd..bb4556eb7 100644
--- a/res/core/common/potions.xml
+++ b/res/core/common/potions.xml
@@ -1,4 +1,5 @@
+
@@ -180,3 +181,4 @@
+
diff --git a/res/core/common/resources.xml b/res/core/common/resources.xml
deleted file mode 100644
index 91d0e8afc..000000000
--- a/res/core/common/resources.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/core/common/weapons.xml b/res/core/common/weapons.xml
deleted file mode 100644
index e91b15e69..000000000
--- a/res/core/common/weapons.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/core/resources/cart.xml b/res/core/resources/cart.xml
index 17dbdcb41..c98e202b0 100644
--- a/res/core/resources/cart.xml
+++ b/res/core/resources/cart.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -6,3 +8,5 @@
+
+
diff --git a/res/core/resources/horse.xml b/res/core/resources/horse.xml
index 608fca20a..6021692e0 100644
--- a/res/core/resources/horse.xml
+++ b/res/core/resources/horse.xml
@@ -1,6 +1,10 @@
+
+
-
+
+
diff --git a/res/core/resources/hp.xml b/res/core/resources/hp.xml
index aa0ad4d29..5d038e7b2 100644
--- a/res/core/resources/hp.xml
+++ b/res/core/resources/hp.xml
@@ -1,4 +1,8 @@
+
+
+
+
diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml
index 1aff826fc..38ddb33c8 100644
--- a/res/core/resources/iron.xml
+++ b/res/core/resources/iron.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -8,3 +10,5 @@
+
+
diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml
index e584fe485..1c14c2eff 100644
--- a/res/core/resources/laen.xml
+++ b/res/core/resources/laen.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -6,3 +8,5 @@
+
+
diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml
index e3710d496..5720c2fd4 100644
--- a/res/core/resources/log.xml
+++ b/res/core/resources/log.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -6,3 +8,5 @@
+
+
diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml
index 3dff091c6..8e50785ca 100644
--- a/res/core/resources/mallorn.xml
+++ b/res/core/resources/mallorn.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -6,3 +8,5 @@
+
+
diff --git a/res/core/resources/mallornseed.xml b/res/core/resources/mallornseed.xml
index 7a5a0310f..7a50c1233 100644
--- a/res/core/resources/mallornseed.xml
+++ b/res/core/resources/mallornseed.xml
@@ -1,6 +1,10 @@
+
+
-
+
+
diff --git a/res/core/resources/peasant.xml b/res/core/resources/peasant.xml
index bce23430c..8c5b22c19 100644
--- a/res/core/resources/peasant.xml
+++ b/res/core/resources/peasant.xml
@@ -1,4 +1,8 @@
+
+
+
+
diff --git a/res/core/resources/seed.xml b/res/core/resources/seed.xml
index 99f5f5804..6696b761f 100644
--- a/res/core/resources/seed.xml
+++ b/res/core/resources/seed.xml
@@ -1,6 +1,10 @@
+
+
-
+
+
diff --git a/res/core/resources/stone.xml b/res/core/resources/stone.xml
index e1c5651ed..b8f91eadc 100644
--- a/res/core/resources/stone.xml
+++ b/res/core/resources/stone.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -7,3 +9,5 @@
+
+
diff --git a/res/core/ships.xml b/res/core/ships.xml
index 33d0dc52a..d26975285 100644
--- a/res/core/ships.xml
+++ b/res/core/ships.xml
@@ -1,4 +1,5 @@
+
@@ -73,4 +74,4 @@
-
+
diff --git a/res/core/spoils.xml b/res/core/spoils.xml
index 952971cab..8cd39a455 100644
--- a/res/core/spoils.xml
+++ b/res/core/spoils.xml
@@ -1,4 +1,5 @@
+
@@ -57,3 +58,4 @@
+
diff --git a/res/core/weapons/axe.xml b/res/core/weapons/axe.xml
index 3f97a5b8a..07f511a62 100644
--- a/res/core/weapons/axe.xml
+++ b/res/core/weapons/axe.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -11,3 +13,5 @@
+
+
diff --git a/res/core/weapons/bow.xml b/res/core/weapons/bow.xml
index 4fb9b2000..a62f90b58 100644
--- a/res/core/weapons/bow.xml
+++ b/res/core/weapons/bow.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -11,3 +13,5 @@
+
+
diff --git a/res/core/weapons/catapult.xml b/res/core/weapons/catapult.xml
index e05c5a025..6312dd4d6 100644
--- a/res/core/weapons/catapult.xml
+++ b/res/core/weapons/catapult.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -12,3 +14,5 @@
+
+
diff --git a/res/core/weapons/crossbow.xml b/res/core/weapons/crossbow.xml
index c7bf4715d..c048e3dcd 100644
--- a/res/core/weapons/crossbow.xml
+++ b/res/core/weapons/crossbow.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -11,3 +13,5 @@
+
+
diff --git a/res/core/weapons/firesword.xml b/res/core/weapons/firesword.xml
index d716e6013..dc3b47af5 100644
--- a/res/core/weapons/firesword.xml
+++ b/res/core/weapons/firesword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -8,3 +10,5 @@
+
+
diff --git a/res/core/weapons/greatbow.xml b/res/core/weapons/greatbow.xml
index 452ac0250..b30cae8c6 100644
--- a/res/core/weapons/greatbow.xml
+++ b/res/core/weapons/greatbow.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -15,3 +17,5 @@
+
+
diff --git a/res/core/weapons/greatsword.xml b/res/core/weapons/greatsword.xml
index 56285f6af..af2420700 100644
--- a/res/core/weapons/greatsword.xml
+++ b/res/core/weapons/greatsword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/halberd.xml b/res/core/weapons/halberd.xml
index 7abc86902..8475d53e1 100644
--- a/res/core/weapons/halberd.xml
+++ b/res/core/weapons/halberd.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -12,3 +14,5 @@
+
+
diff --git a/res/core/weapons/laensword.xml b/res/core/weapons/laensword.xml
index 3053d5f1b..325d25d10 100644
--- a/res/core/weapons/laensword.xml
+++ b/res/core/weapons/laensword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/lance.xml b/res/core/weapons/lance.xml
index 4a02bc06f..9325494fa 100644
--- a/res/core/weapons/lance.xml
+++ b/res/core/weapons/lance.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/mallornbow.xml b/res/core/weapons/mallornbow.xml
index abdcc4810..9164d2c4b 100644
--- a/res/core/weapons/mallornbow.xml
+++ b/res/core/weapons/mallornbow.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -14,3 +16,5 @@
+
+
diff --git a/res/core/weapons/mallorncrossbow.xml b/res/core/weapons/mallorncrossbow.xml
index 385720d8c..e5ec685c0 100644
--- a/res/core/weapons/mallorncrossbow.xml
+++ b/res/core/weapons/mallorncrossbow.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -11,3 +13,5 @@
+
+
diff --git a/res/core/weapons/mallornlance.xml b/res/core/weapons/mallornlance.xml
index 4024d4578..952839fda 100644
--- a/res/core/weapons/mallornlance.xml
+++ b/res/core/weapons/mallornlance.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/mallornspear.xml b/res/core/weapons/mallornspear.xml
index 516f59540..ee827c754 100644
--- a/res/core/weapons/mallornspear.xml
+++ b/res/core/weapons/mallornspear.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -12,3 +14,5 @@
+
+
diff --git a/res/core/weapons/runesword.xml b/res/core/weapons/runesword.xml
index 1bfae2544..6f23697f2 100644
--- a/res/core/weapons/runesword.xml
+++ b/res/core/weapons/runesword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -8,3 +10,5 @@
+
+
diff --git a/res/core/weapons/rustyaxe.xml b/res/core/weapons/rustyaxe.xml
index fea6b8642..ff4172059 100644
--- a/res/core/weapons/rustyaxe.xml
+++ b/res/core/weapons/rustyaxe.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -11,3 +13,5 @@
+
+
diff --git a/res/core/weapons/rustygreatsword.xml b/res/core/weapons/rustygreatsword.xml
index 7f21cce17..b67e2cf4b 100644
--- a/res/core/weapons/rustygreatsword.xml
+++ b/res/core/weapons/rustygreatsword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/rustyhalberd.xml b/res/core/weapons/rustyhalberd.xml
index 3f0bd93b7..9d3c4ae6b 100644
--- a/res/core/weapons/rustyhalberd.xml
+++ b/res/core/weapons/rustyhalberd.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -12,3 +14,5 @@
+
+
diff --git a/res/core/weapons/rustysword.xml b/res/core/weapons/rustysword.xml
index 2a76c109b..e5c9a9442 100644
--- a/res/core/weapons/rustysword.xml
+++ b/res/core/weapons/rustysword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/core/weapons/spear.xml b/res/core/weapons/spear.xml
index 32a79b9a2..e81f608ab 100644
--- a/res/core/weapons/spear.xml
+++ b/res/core/weapons/spear.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -12,3 +14,5 @@
+
+
diff --git a/res/core/weapons/sword.xml b/res/core/weapons/sword.xml
index 4bd2ebdb1..21b481079 100644
--- a/res/core/weapons/sword.xml
+++ b/res/core/weapons/sword.xml
@@ -1,4 +1,6 @@
+
+
-
@@ -10,3 +12,5 @@
+
+
diff --git a/res/eressea/artrewards.xml b/res/eressea/artrewards.xml
index b18fd5b20..9a144da07 100644
--- a/res/eressea/artrewards.xml
+++ b/res/eressea/artrewards.xml
@@ -1,5 +1,5 @@
-
+
@@ -11,4 +11,4 @@
-
+
diff --git a/res/eressea/buildings.xml b/res/eressea/buildings.xml
index 1559fd987..b3ab4b6c0 100644
--- a/res/eressea/buildings.xml
+++ b/res/eressea/buildings.xml
@@ -1,8 +1,9 @@
+
-
+
diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml
index e4d48aefe..94d0deb07 100644
--- a/res/eressea/equipment.xml
+++ b/res/eressea/equipment.xml
@@ -1,5 +1,5 @@
-
+
@@ -271,3 +271,5 @@
+
+
diff --git a/res/eressea/familiars.xml b/res/eressea/familiars.xml
index 7e9bb75dc..112a82420 100644
--- a/res/eressea/familiars.xml
+++ b/res/eressea/familiars.xml
@@ -1,4 +1,5 @@
+
@@ -129,4 +130,4 @@
-
+
diff --git a/res/eressea/items.xml b/res/eressea/items.xml
index 3f5cc3d17..2cfa9e653 100644
--- a/res/eressea/items.xml
+++ b/res/eressea/items.xml
@@ -1,4 +1,5 @@
+
@@ -128,3 +129,4 @@
+
diff --git a/res/eressea/races.xml b/res/eressea/races.xml
index cdd483851..654a859bd 100644
--- a/res/eressea/races.xml
+++ b/res/eressea/races.xml
@@ -1,4 +1,5 @@
+
+
diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 6b2e43a15..089ec1a6c 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -1,12 +1,6 @@
-
-
-
-
-
-
-
-
+
+
@@ -616,3 +610,5 @@
+
+
diff --git a/src/jsonconf.c b/src/jsonconf.c
index 56ff2e675..2fff42b83 100644
--- a/src/jsonconf.c
+++ b/src/jsonconf.c
@@ -887,24 +887,45 @@ static void json_races(cJSON *json) {
const char * json_relpath;
-static const char * uri_to_file(const char * uri, char *name, size_t size) {
- const char *pos, *path = json_relpath;
+/* TODO: much more configurable authority-to-file lookup */
+static const char * authority_to_path(const char *authority, char *name, size_t size) {
+ /* source and destination cannot share the same buffer */
+ assert(authority < name || authority > name + size);
- pos = strstr(uri, "://");
+ return join_path(json_relpath, authority, name, size);
+}
+
+static const char * uri_to_file(const char * uri, char *name, size_t size) {
+ const char *pos, *scheme, *path = uri;
+
+ /* source and destination cannot share the same buffer */
+ assert(uri < name || uri > name + size);
+
+ /* identify scheme */
+ scheme = uri;
+ pos = strstr(scheme, "://");
if (pos) {
- size_t slen = pos - uri;
- /* identify scheme */
- if (strncmp(uri, "config", slen) == 0) {
- path = path_join(path, "conf", name, size);
+ size_t slen = pos - scheme;
+ if (strncmp(scheme, "config", slen) == 0) {
+ const char *authority = pos + 3;
+ /* authority */
+ pos = strstr(authority, "/");
+ if (pos) {
+ char buffer[16];
+ size_t alen = pos - authority;
+ assert(alen < sizeof(buffer));
+ memcpy(buffer, authority, alen);
+ buffer[alen] = 0;
+
+ path = authority_to_path(buffer, name, size);
+ path = path_join(path, pos + 1, name, size);
+ }
}
- else if (strncmp(uri, "rules", slen) == 0) {
- path = path_join(path, "res", name, size);
- }
- if (path) {
- return path_join(path, pos + 3, name, size);
+ else {
+ log_fatal("unknown URI scheme: %s", uri);
}
}
- return uri;
+ return path;
}
static void include_json(const char *uri) {