mirror of
https://github.com/Lienol/openwrt
synced 2025-01-08 11:37:34 +08:00
Modify
This commit is contained in:
parent
a82b097635
commit
1464bd2936
@ -81,7 +81,7 @@ menu "Target Images"
|
||||
|
||||
config TARGET_ROOTFS_TARGZ
|
||||
bool "tar.gz"
|
||||
default y if USES_TARGZ
|
||||
default n if USES_TARGZ
|
||||
help
|
||||
Build a compressed tar archive of the root filesystem.
|
||||
|
||||
@ -89,7 +89,7 @@ menu "Target Images"
|
||||
|
||||
menuconfig TARGET_ROOTFS_EXT4FS
|
||||
bool "ext4"
|
||||
default y if USES_EXT4
|
||||
default n if USES_EXT4
|
||||
help
|
||||
Build an ext4 root filesystem.
|
||||
|
||||
@ -240,7 +240,7 @@ menu "Target Images"
|
||||
config GRUB_TIMEOUT
|
||||
string "Seconds to wait before booting the default entry"
|
||||
depends on GRUB_IMAGES || GRUB_EFI_IMAGES
|
||||
default "5"
|
||||
default "0"
|
||||
help
|
||||
If you don't know, 5 seconds is a reasonable default.
|
||||
|
||||
@ -303,7 +303,7 @@ menu "Target Images"
|
||||
depends on USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS
|
||||
default 232 if TARGET_loongarch64
|
||||
default 448 if TARGET_mediatek
|
||||
default 104
|
||||
default 200
|
||||
help
|
||||
Select the root filesystem partition size.
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
src-git packages https://git.openwrt.org/feed/packages.git;openwrt-24.10
|
||||
src-git luci https://git.openwrt.org/project/luci.git;openwrt-24.10
|
||||
src-git routing https://git.openwrt.org/feed/routing.git;openwrt-24.10
|
||||
src-git telephony https://git.openwrt.org/feed/telephony.git;openwrt-24.10
|
||||
src-git packages https://github.com/Lienol/openwrt-packages.git;24.10
|
||||
src-git luci https://github.com/Lienol/openwrt-luci.git;24.10
|
||||
src-git routing https://github.com/openwrt/routing.git;openwrt-24.10
|
||||
src-git telephony https://github.com/openwrt/telephony.git;openwrt-24.10
|
||||
src-git lienol https://github.com/Lienol/openwrt-package.git;main
|
||||
src-git other https://github.com/Lienol/openwrt-package.git;other
|
||||
|
@ -25,6 +25,10 @@ DEFAULT_PACKAGES:=\
|
||||
uci \
|
||||
uclient-fetch \
|
||||
urandom-seed \
|
||||
luci luci-compat wget-ssl curl ca-certificates htop \
|
||||
default-settings luci-app-upnp luci-app-wol luci-app-vlmcsd luci-app-ramfree \
|
||||
luci-app-ddns ddns-scripts-cloudflare ddns-scripts_aliyun ddns-scripts_dnspod \
|
||||
luci-app-timecontrol luci-app-control-timewol luci-app-control-webrestriction luci-app-control-weburl \
|
||||
urngd
|
||||
|
||||
# For the basic set
|
||||
@ -37,10 +41,9 @@ DEFAULT_PACKAGES.nas:=\
|
||||
mdadm
|
||||
# For router targets
|
||||
DEFAULT_PACKAGES.router:=\
|
||||
dnsmasq \
|
||||
dnsmasq-full \
|
||||
firewall4 \
|
||||
nftables \
|
||||
kmod-nft-offload \
|
||||
odhcp6c \
|
||||
odhcpd-ipv6only \
|
||||
ppp \
|
||||
|
49
package/default-settings/Makefile
Normal file
49
package/default-settings/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright (C) 2016-2017 GitHub
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=default-settings
|
||||
PKG_VERSION:=1.1
|
||||
PKG_RELEASE:=51
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/default-settings
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
TITLE:=LuCI support for Default Settings
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+luci-base +@LUCI_LANG_zh_Hans
|
||||
endef
|
||||
|
||||
define Package/default-settings/description
|
||||
Language Support Packages.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(foreach po,$(wildcard ${CURDIR}/i18n/*.po), \
|
||||
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/default-settings/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/*.lmo $(1)/usr/lib/lua/luci/i18n/
|
||||
$(INSTALL_BIN) ./files/zzz-default-settings $(1)/etc/uci-defaults/99-default-settings
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,default-settings))
|
69
package/default-settings/files/zzz-default-settings
Normal file
69
package/default-settings/files/zzz-default-settings
Normal file
@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
|
||||
touch /etc/crontabs/root
|
||||
|
||||
uci set luci.main.lang=zh_cn
|
||||
#设置默认主题
|
||||
uci set luci.main.mediaurlbase=/luci-static/bootstrap
|
||||
uci commit luci
|
||||
|
||||
uci set system.@system[0].timezone=CST-8
|
||||
uci set system.@system[0].zonename=Asia/Shanghai
|
||||
uci commit system
|
||||
|
||||
uci set fstab.@global[0].anon_mount=1
|
||||
uci commit fstab
|
||||
|
||||
ln -sf /sbin/ip /usr/bin/ip
|
||||
|
||||
sed -i '/lienol/d' /etc/opkg/distfeeds.conf
|
||||
sed -i '/other/d' /etc/opkg/distfeeds.conf
|
||||
#sed -i 's/downloads.openwrt.org/openwrt.proxy.ustclug.org/g' /etc/opkg/distfeeds.conf
|
||||
#sed -i 's/http/https/g' /etc/opkg/distfeeds.conf
|
||||
sed -i "s/# //g" /etc/opkg/distfeeds.conf
|
||||
|
||||
#sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow
|
||||
|
||||
uci set dhcp.lan.ra='server'
|
||||
uci -q del dhcp.lan.dhcpv6
|
||||
uci set dhcp.lan.dns_service='0'
|
||||
uci set dhcp.lan.ra_management='1'
|
||||
uci -q del dhcp.lan.ra_slaac
|
||||
#uci set dhcp.@dnsmasq[0].localservice=0
|
||||
#uci set dhcp.@dnsmasq[0].nonwildcard=0
|
||||
uci commit dhcp
|
||||
|
||||
#uci set network.lan.ipaddr='192.168.119.254'
|
||||
#uci set network.lan.netmask='255.255.255.0'
|
||||
#uci set network.lan.ip6assign='64'
|
||||
#uci commit network
|
||||
|
||||
sed -i '/option disabled/d' /etc/config/wireless
|
||||
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
|
||||
wifi up
|
||||
|
||||
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
|
||||
echo "DISTRIB_DESCRIPTION='OpenWrt 24.10'" >> /etc/openwrt_release
|
||||
|
||||
# 删除状态页不需显示的
|
||||
rm -rf /usr/lib/lua/luci/view/admin_status/index
|
||||
#mv -f /usr/lib/lua/luci/view/admin_status/index /usr/lib/lua/luci/view/admin_status/index_backup 2>/dev/null
|
||||
|
||||
sed -i 's#openwrt/luci#lienol/openwrt-luci#g' /usr/lib/lua/luci/view/themes/*/footer.htm
|
||||
|
||||
#禁用某些可能会自启动且用不上的依赖包服务
|
||||
/etc/init.d/php7-fastcgi disable 2>/dev/null
|
||||
/etc/init.d/php7-fpm disable 2>/dev/null
|
||||
/etc/init.d/php8-fastcgi disable 2>/dev/null
|
||||
/etc/init.d/php8-fpm disable 2>/dev/null
|
||||
/etc/init.d/softethervpnbridge disable 2>/dev/null
|
||||
/etc/init.d/softethervpnserver disable 2>/dev/null
|
||||
/etc/init.d/softethervpnclient disable 2>/dev/null
|
||||
/etc/init.d/haproxy disable 2>/dev/null
|
||||
/etc/init.d/kcptun disable 2>/dev/null
|
||||
|
||||
chmod 0755 /etc/init.d/*
|
||||
|
||||
rm -rf /tmp/luci-*cache
|
||||
|
||||
exit 0
|
67
package/default-settings/i18n/default.zh-cn.po
Normal file
67
package/default-settings/i18n/default.zh-cn.po
Normal file
@ -0,0 +1,67 @@
|
||||
msgid "Processor"
|
||||
msgstr "处理器"
|
||||
|
||||
msgid "Architecture"
|
||||
msgstr "架构"
|
||||
|
||||
msgid "CPU Temperature"
|
||||
msgstr "CPU温度"
|
||||
|
||||
msgid "CPU Info"
|
||||
msgstr "CPU信息"
|
||||
|
||||
msgid "CPU Model"
|
||||
msgstr "处理器型号"
|
||||
|
||||
msgid "CPU frequency"
|
||||
msgstr "CPU频率"
|
||||
|
||||
msgid "RAM frequency"
|
||||
msgstr "RAM频率"
|
||||
|
||||
msgid "Flash Size"
|
||||
msgstr "闪存大小"
|
||||
|
||||
msgid "Free Memory"
|
||||
msgstr "释放内存"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "ZRam Settings"
|
||||
msgstr "ZRam 设置"
|
||||
|
||||
msgid "ZRam Compression Algorithm"
|
||||
msgstr "ZRAM压缩算法"
|
||||
|
||||
msgid "ZRam Compression Streams"
|
||||
msgstr "ZRam 压缩数据流线程数"
|
||||
|
||||
msgid "ZRam Size"
|
||||
msgstr "ZRam 大小"
|
||||
|
||||
msgid "Size of the ZRam device in megabytes"
|
||||
msgstr "划分给ZRam 分区的内存大小(MB),推荐留空由系统自动管理"
|
||||
|
||||
msgid "Number of parallel threads used for compression"
|
||||
msgstr "用于压缩内存数据的CPU并发线程数"
|
||||
|
||||
msgid "Swap"
|
||||
msgstr "虚拟内存"
|
||||
|
||||
msgid "Force 40MHz mode"
|
||||
msgstr "强制40MHz频宽"
|
||||
|
||||
msgid ""
|
||||
"Always use 40MHz channels even if the secondary channel overlaps. Using this "
|
||||
"option does not comply with IEEE 802.11n-2009!"
|
||||
msgstr "强制启用40MHz频宽并忽略辅助信道重叠。此选项可能不兼容某些无线硬件导致无法启用!"
|
||||
|
||||
msgid "Disassociate On Low Acknowledgement"
|
||||
msgstr "弱信号剔除"
|
||||
|
||||
msgid "Allow AP mode to disconnect STAs based on low ACK condition"
|
||||
msgstr "允许AP模式基于低ACK条件判断剔除弱信号的客户端"
|
1037
package/default-settings/i18n/more.zh-cn.po
Normal file
1037
package/default-settings/i18n/more.zh-cn.po
Normal file
File diff suppressed because it is too large
Load Diff
12
package/default-settings/tools/po2lmo/Makefile
Normal file
12
package/default-settings/tools/po2lmo/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
INSTALL = install
|
||||
PREFIX = /usr/bin
|
||||
|
||||
po2lmo: src/po2lmo.o src/template_lmo.o
|
||||
$(CC) $(LDFLAGS) -o src/po2lmo src/po2lmo.o src/template_lmo.o
|
||||
|
||||
install:
|
||||
$(INSTALL) -m 755 src/po2lmo $(PREFIX)
|
||||
|
||||
clean:
|
||||
$(RM) src/po2lmo src/*.o
|
BIN
package/default-settings/tools/po2lmo/src/po2lmo
Normal file
BIN
package/default-settings/tools/po2lmo/src/po2lmo
Normal file
Binary file not shown.
247
package/default-settings/tools/po2lmo/src/po2lmo.c
Normal file
247
package/default-settings/tools/po2lmo/src/po2lmo.c
Normal file
@ -0,0 +1,247 @@
|
||||
/*
|
||||
* lmo - Lua Machine Objects - PO to LMO conversion tool
|
||||
*
|
||||
* Copyright (C) 2009-2012 Jo-Philipp Wich <xm@subsignal.org>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "template_lmo.h"
|
||||
|
||||
static void die(const char *msg)
|
||||
{
|
||||
fprintf(stderr, "Error: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s input.po output.lmo\n", name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void print(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
if( fwrite(ptr, size, nmemb, stream) == 0 )
|
||||
die("Failed to write stdout");
|
||||
}
|
||||
|
||||
static int extract_string(const char *src, char *dest, int len)
|
||||
{
|
||||
int pos = 0;
|
||||
int esc = 0;
|
||||
int off = -1;
|
||||
|
||||
for( pos = 0; (pos < strlen(src)) && (pos < len); pos++ )
|
||||
{
|
||||
if( (off == -1) && (src[pos] == '"') )
|
||||
{
|
||||
off = pos + 1;
|
||||
}
|
||||
else if( off >= 0 )
|
||||
{
|
||||
if( esc == 1 )
|
||||
{
|
||||
switch (src[pos])
|
||||
{
|
||||
case '"':
|
||||
case '\\':
|
||||
off++;
|
||||
break;
|
||||
}
|
||||
dest[pos-off] = src[pos];
|
||||
esc = 0;
|
||||
}
|
||||
else if( src[pos] == '\\' )
|
||||
{
|
||||
dest[pos-off] = src[pos];
|
||||
esc = 1;
|
||||
}
|
||||
else if( src[pos] != '"' )
|
||||
{
|
||||
dest[pos-off] = src[pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
dest[pos-off] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (off > -1) ? strlen(dest) : -1;
|
||||
}
|
||||
|
||||
static int cmp_index(const void *a, const void *b)
|
||||
{
|
||||
uint32_t x = ((const lmo_entry_t *)a)->key_id;
|
||||
uint32_t y = ((const lmo_entry_t *)b)->key_id;
|
||||
|
||||
if (x < y)
|
||||
return -1;
|
||||
else if (x > y)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_uint32(uint32_t x, FILE *out)
|
||||
{
|
||||
uint32_t y = htonl(x);
|
||||
print(&y, sizeof(uint32_t), 1, out);
|
||||
}
|
||||
|
||||
static void print_index(void *array, int n, FILE *out)
|
||||
{
|
||||
lmo_entry_t *e;
|
||||
|
||||
qsort(array, n, sizeof(*e), cmp_index);
|
||||
|
||||
for (e = array; n > 0; n--, e++)
|
||||
{
|
||||
print_uint32(e->key_id, out);
|
||||
print_uint32(e->val_id, out);
|
||||
print_uint32(e->offset, out);
|
||||
print_uint32(e->length, out);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char line[4096];
|
||||
char key[4096];
|
||||
char val[4096];
|
||||
char tmp[4096];
|
||||
int state = 0;
|
||||
int offset = 0;
|
||||
int length = 0;
|
||||
int n_entries = 0;
|
||||
void *array = NULL;
|
||||
lmo_entry_t *entry = NULL;
|
||||
uint32_t key_id, val_id;
|
||||
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
|
||||
if( (argc != 3) || ((in = fopen(argv[1], "r")) == NULL) || ((out = fopen(argv[2], "w")) == NULL) )
|
||||
usage(argv[0]);
|
||||
|
||||
memset(line, 0, sizeof(key));
|
||||
memset(key, 0, sizeof(val));
|
||||
memset(val, 0, sizeof(val));
|
||||
|
||||
while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) )
|
||||
{
|
||||
if( state == 0 && strstr(line, "msgid \"") == line )
|
||||
{
|
||||
switch(extract_string(line, key, sizeof(key)))
|
||||
{
|
||||
case -1:
|
||||
die("Syntax error in msgid");
|
||||
case 0:
|
||||
state = 1;
|
||||
break;
|
||||
default:
|
||||
state = 2;
|
||||
}
|
||||
}
|
||||
else if( state == 1 || state == 2 )
|
||||
{
|
||||
if( strstr(line, "msgstr \"") == line || state == 2 )
|
||||
{
|
||||
switch(extract_string(line, val, sizeof(val)))
|
||||
{
|
||||
case -1:
|
||||
state = 4;
|
||||
break;
|
||||
default:
|
||||
state = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(extract_string(line, tmp, sizeof(tmp)))
|
||||
{
|
||||
case -1:
|
||||
state = 2;
|
||||
break;
|
||||
default:
|
||||
strcat(key, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( state == 3 )
|
||||
{
|
||||
switch(extract_string(line, tmp, sizeof(tmp)))
|
||||
{
|
||||
case -1:
|
||||
state = 4;
|
||||
break;
|
||||
default:
|
||||
strcat(val, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if( state == 4 )
|
||||
{
|
||||
if( strlen(key) > 0 && strlen(val) > 0 )
|
||||
{
|
||||
key_id = sfh_hash(key, strlen(key));
|
||||
val_id = sfh_hash(val, strlen(val));
|
||||
|
||||
if( key_id != val_id )
|
||||
{
|
||||
n_entries++;
|
||||
array = realloc(array, n_entries * sizeof(lmo_entry_t));
|
||||
entry = (lmo_entry_t *)array + n_entries - 1;
|
||||
|
||||
if (!array)
|
||||
die("Out of memory");
|
||||
|
||||
entry->key_id = key_id;
|
||||
entry->val_id = val_id;
|
||||
entry->offset = offset;
|
||||
entry->length = strlen(val);
|
||||
|
||||
length = strlen(val) + ((4 - (strlen(val) % 4)) % 4);
|
||||
|
||||
print(val, length, 1, out);
|
||||
offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
state = 0;
|
||||
memset(key, 0, sizeof(key));
|
||||
memset(val, 0, sizeof(val));
|
||||
}
|
||||
|
||||
memset(line, 0, sizeof(line));
|
||||
}
|
||||
|
||||
print_index(array, n_entries, out);
|
||||
|
||||
if( offset > 0 )
|
||||
{
|
||||
print_uint32(offset, out);
|
||||
fsync(fileno(out));
|
||||
fclose(out);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(out);
|
||||
unlink(argv[2]);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
return(0);
|
||||
}
|
328
package/default-settings/tools/po2lmo/src/template_lmo.c
Normal file
328
package/default-settings/tools/po2lmo/src/template_lmo.c
Normal file
@ -0,0 +1,328 @@
|
||||
/*
|
||||
* lmo - Lua Machine Objects - Base functions
|
||||
*
|
||||
* Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "template_lmo.h"
|
||||
|
||||
/*
|
||||
* Hash function from http://www.azillionmonkeys.com/qed/hash.html
|
||||
* Copyright (C) 2004-2008 by Paul Hsieh
|
||||
*/
|
||||
|
||||
uint32_t sfh_hash(const char *data, int len)
|
||||
{
|
||||
uint32_t hash = len, tmp;
|
||||
int rem;
|
||||
|
||||
if (len <= 0 || data == NULL) return 0;
|
||||
|
||||
rem = len & 3;
|
||||
len >>= 2;
|
||||
|
||||
/* Main loop */
|
||||
for (;len > 0; len--) {
|
||||
hash += sfh_get16(data);
|
||||
tmp = (sfh_get16(data+2) << 11) ^ hash;
|
||||
hash = (hash << 16) ^ tmp;
|
||||
data += 2*sizeof(uint16_t);
|
||||
hash += hash >> 11;
|
||||
}
|
||||
|
||||
/* Handle end cases */
|
||||
switch (rem) {
|
||||
case 3: hash += sfh_get16(data);
|
||||
hash ^= hash << 16;
|
||||
hash ^= data[sizeof(uint16_t)] << 18;
|
||||
hash += hash >> 11;
|
||||
break;
|
||||
case 2: hash += sfh_get16(data);
|
||||
hash ^= hash << 11;
|
||||
hash += hash >> 17;
|
||||
break;
|
||||
case 1: hash += *data;
|
||||
hash ^= hash << 10;
|
||||
hash += hash >> 1;
|
||||
}
|
||||
|
||||
/* Force "avalanching" of final 127 bits */
|
||||
hash ^= hash << 3;
|
||||
hash += hash >> 5;
|
||||
hash ^= hash << 4;
|
||||
hash += hash >> 17;
|
||||
hash ^= hash << 25;
|
||||
hash += hash >> 6;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint32_t lmo_canon_hash(const char *str, int len)
|
||||
{
|
||||
char res[4096];
|
||||
char *ptr, prev;
|
||||
int off;
|
||||
|
||||
if (!str || len >= sizeof(res))
|
||||
return 0;
|
||||
|
||||
for (prev = ' ', ptr = res, off = 0; off < len; prev = *str, off++, str++)
|
||||
{
|
||||
if (isspace(*str))
|
||||
{
|
||||
if (!isspace(prev))
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = *str;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ptr > res) && isspace(*(ptr-1)))
|
||||
ptr--;
|
||||
|
||||
return sfh_hash(res, ptr - res);
|
||||
}
|
||||
|
||||
lmo_archive_t * lmo_open(const char *file)
|
||||
{
|
||||
int in = -1;
|
||||
uint32_t idx_offset = 0;
|
||||
struct stat s;
|
||||
|
||||
lmo_archive_t *ar = NULL;
|
||||
|
||||
if (stat(file, &s) == -1)
|
||||
goto err;
|
||||
|
||||
if ((in = open(file, O_RDONLY)) == -1)
|
||||
goto err;
|
||||
|
||||
if ((ar = (lmo_archive_t *)malloc(sizeof(*ar))) != NULL)
|
||||
{
|
||||
memset(ar, 0, sizeof(*ar));
|
||||
|
||||
ar->fd = in;
|
||||
ar->size = s.st_size;
|
||||
|
||||
fcntl(ar->fd, F_SETFD, fcntl(ar->fd, F_GETFD) | FD_CLOEXEC);
|
||||
|
||||
if ((ar->mmap = mmap(NULL, ar->size, PROT_READ, MAP_SHARED, ar->fd, 0)) == MAP_FAILED)
|
||||
goto err;
|
||||
|
||||
idx_offset = ntohl(*((const uint32_t *)
|
||||
(ar->mmap + ar->size - sizeof(uint32_t))));
|
||||
|
||||
if (idx_offset >= ar->size)
|
||||
goto err;
|
||||
|
||||
ar->index = (lmo_entry_t *)(ar->mmap + idx_offset);
|
||||
ar->length = (ar->size - idx_offset - sizeof(uint32_t)) / sizeof(lmo_entry_t);
|
||||
ar->end = ar->mmap + ar->size;
|
||||
|
||||
return ar;
|
||||
}
|
||||
|
||||
err:
|
||||
if (in > -1)
|
||||
close(in);
|
||||
|
||||
if (ar != NULL)
|
||||
{
|
||||
if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED))
|
||||
munmap(ar->mmap, ar->size);
|
||||
|
||||
free(ar);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void lmo_close(lmo_archive_t *ar)
|
||||
{
|
||||
if (ar != NULL)
|
||||
{
|
||||
if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED))
|
||||
munmap(ar->mmap, ar->size);
|
||||
|
||||
close(ar->fd);
|
||||
free(ar);
|
||||
|
||||
ar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lmo_catalog_t *_lmo_catalogs = NULL;
|
||||
lmo_catalog_t *_lmo_active_catalog = NULL;
|
||||
|
||||
int lmo_load_catalog(const char *lang, const char *dir)
|
||||
{
|
||||
DIR *dh = NULL;
|
||||
char pattern[16];
|
||||
char path[PATH_MAX];
|
||||
struct dirent *de = NULL;
|
||||
|
||||
lmo_archive_t *ar = NULL;
|
||||
lmo_catalog_t *cat = NULL;
|
||||
|
||||
if (!lmo_change_catalog(lang))
|
||||
return 0;
|
||||
|
||||
if (!dir || !(dh = opendir(dir)))
|
||||
goto err;
|
||||
|
||||
if (!(cat = malloc(sizeof(*cat))))
|
||||
goto err;
|
||||
|
||||
memset(cat, 0, sizeof(*cat));
|
||||
|
||||
snprintf(cat->lang, sizeof(cat->lang), "%s", lang);
|
||||
snprintf(pattern, sizeof(pattern), "*.%s.lmo", lang);
|
||||
|
||||
while ((de = readdir(dh)) != NULL)
|
||||
{
|
||||
if (!fnmatch(pattern, de->d_name, 0))
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/%s", dir, de->d_name);
|
||||
ar = lmo_open(path);
|
||||
|
||||
if (ar)
|
||||
{
|
||||
ar->next = cat->archives;
|
||||
cat->archives = ar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dh);
|
||||
|
||||
cat->next = _lmo_catalogs;
|
||||
_lmo_catalogs = cat;
|
||||
|
||||
if (!_lmo_active_catalog)
|
||||
_lmo_active_catalog = cat;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
if (dh) closedir(dh);
|
||||
if (cat) free(cat);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lmo_change_catalog(const char *lang)
|
||||
{
|
||||
lmo_catalog_t *cat;
|
||||
|
||||
for (cat = _lmo_catalogs; cat; cat = cat->next)
|
||||
{
|
||||
if (!strncmp(cat->lang, lang, sizeof(cat->lang)))
|
||||
{
|
||||
_lmo_active_catalog = cat;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
|
||||
{
|
||||
unsigned int m, l, r;
|
||||
uint32_t k;
|
||||
|
||||
l = 0;
|
||||
r = ar->length - 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
m = l + ((r - l) / 2);
|
||||
|
||||
if (r < l)
|
||||
break;
|
||||
|
||||
k = ntohl(ar->index[m].key_id);
|
||||
|
||||
if (k == hash)
|
||||
return &ar->index[m];
|
||||
|
||||
if (k > hash)
|
||||
{
|
||||
if (!m)
|
||||
break;
|
||||
|
||||
r = m - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = m + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int lmo_translate(const char *key, int keylen, char **out, int *outlen)
|
||||
{
|
||||
uint32_t hash;
|
||||
lmo_entry_t *e;
|
||||
lmo_archive_t *ar;
|
||||
|
||||
if (!key || !_lmo_active_catalog)
|
||||
return -2;
|
||||
|
||||
hash = lmo_canon_hash(key, keylen);
|
||||
|
||||
for (ar = _lmo_active_catalog->archives; ar; ar = ar->next)
|
||||
{
|
||||
if ((e = lmo_find_entry(ar, hash)) != NULL)
|
||||
{
|
||||
*out = ar->mmap + ntohl(e->offset);
|
||||
*outlen = ntohl(e->length);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void lmo_close_catalog(const char *lang)
|
||||
{
|
||||
lmo_archive_t *ar, *next;
|
||||
lmo_catalog_t *cat, *prev;
|
||||
|
||||
for (prev = NULL, cat = _lmo_catalogs; cat; prev = cat, cat = cat->next)
|
||||
{
|
||||
if (!strncmp(cat->lang, lang, sizeof(cat->lang)))
|
||||
{
|
||||
if (prev)
|
||||
prev->next = cat->next;
|
||||
else
|
||||
_lmo_catalogs = cat->next;
|
||||
|
||||
for (ar = cat->archives; ar; ar = next)
|
||||
{
|
||||
next = ar->next;
|
||||
lmo_close(ar);
|
||||
}
|
||||
|
||||
free(cat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
92
package/default-settings/tools/po2lmo/src/template_lmo.h
Normal file
92
package/default-settings/tools/po2lmo/src/template_lmo.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* lmo - Lua Machine Objects - General header
|
||||
*
|
||||
* Copyright (C) 2009-2012 Jo-Philipp Wich <xm@subsignal.org>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _TEMPLATE_LMO_H_
|
||||
#define _TEMPLATE_LMO_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if (defined(__GNUC__) && defined(__i386__))
|
||||
#define sfh_get16(d) (*((const uint16_t *) (d)))
|
||||
#else
|
||||
#define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
|
||||
+(uint32_t)(((const uint8_t *)(d))[0]) )
|
||||
#endif
|
||||
|
||||
|
||||
struct lmo_entry {
|
||||
uint32_t key_id;
|
||||
uint32_t val_id;
|
||||
uint32_t offset;
|
||||
uint32_t length;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct lmo_entry lmo_entry_t;
|
||||
|
||||
|
||||
struct lmo_archive {
|
||||
int fd;
|
||||
int length;
|
||||
uint32_t size;
|
||||
lmo_entry_t *index;
|
||||
char *mmap;
|
||||
char *end;
|
||||
struct lmo_archive *next;
|
||||
};
|
||||
|
||||
typedef struct lmo_archive lmo_archive_t;
|
||||
|
||||
|
||||
struct lmo_catalog {
|
||||
char lang[6];
|
||||
struct lmo_archive *archives;
|
||||
struct lmo_catalog *next;
|
||||
};
|
||||
|
||||
typedef struct lmo_catalog lmo_catalog_t;
|
||||
|
||||
|
||||
uint32_t sfh_hash(const char *data, int len);
|
||||
uint32_t lmo_canon_hash(const char *data, int len);
|
||||
|
||||
lmo_archive_t * lmo_open(const char *file);
|
||||
void lmo_close(lmo_archive_t *ar);
|
||||
|
||||
|
||||
extern lmo_catalog_t *_lmo_catalogs;
|
||||
extern lmo_catalog_t *_lmo_active_catalog;
|
||||
|
||||
int lmo_load_catalog(const char *lang, const char *dir);
|
||||
int lmo_change_catalog(const char *lang);
|
||||
int lmo_translate(const char *key, int keylen, char **out, int *outlen);
|
||||
void lmo_close_catalog(const char *lang);
|
||||
|
||||
#endif
|
@ -124,7 +124,7 @@ endef
|
||||
|
||||
define Package/ppp-mod-pptp
|
||||
$(call Package/ppp/Default)
|
||||
DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pptp +kmod-mppe +resolveip
|
||||
DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pptp +kmod-mppe +resolveip +kmod-gre
|
||||
TITLE:=PPtP plugin
|
||||
endef
|
||||
|
||||
|
@ -11,3 +11,5 @@ proto_send_update "$PPP_IPPARAM"
|
||||
[ -x "$SCRIPT" ] && "$SCRIPT" "$@"
|
||||
done
|
||||
}
|
||||
|
||||
sleep 5
|
||||
|
@ -19,7 +19,13 @@ include $(INCLUDE_DIR)/target.mk
|
||||
DEFAULT_PACKAGES += \
|
||||
partx-utils mkf2fs \
|
||||
e2fsprogs kmod-button-hotplug \
|
||||
grub2-bios-setup
|
||||
grub2-bios-setup \
|
||||
fdisk kmod-usb-hid kmod-ath5k kmod-ath9k kmod-ath9k-htc kmod-ath10k kmod-rt2800-usb kmod-e1000e kmod-igb kmod-igbvf kmod-igc kmod-ixgbe kmod-pcnet32 kmod-tulip kmod-vmxnet3 kmod-i40e kmod-i40evf kmod-8139cp kmod-8139too kmod-fs-f2fs \
|
||||
lm-sensors \
|
||||
ath10k-firmware-qca988x ath10k-firmware-qca9888 ath10k-firmware-qca9984 brcmfmac-firmware-43602a1-pcie \
|
||||
alsa-utils kmod-ac97 kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-usb-audio \
|
||||
kmod-usb-net kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-ipheth kmod-usb-net-rndis kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 \
|
||||
luci-app-usb-printer luci-app-vsftpd
|
||||
|
||||
$(eval $(call BuildTarget))
|
||||
|
||||
|
@ -21,4 +21,3 @@ config GCC_VERSION
|
||||
config GCC_USE_DEFAULT_VERSION
|
||||
bool
|
||||
default y if !TOOLCHAINOPTS || GCC_USE_VERSION_13
|
||||
imply KERNEL_WERROR
|
||||
|
Loading…
Reference in New Issue
Block a user