Merge branch 'master' of http://git.komect.net/ISG/secogateway
This commit is contained in:
commit
e4feabf89f
|
@ -8,6 +8,7 @@
|
|||
Module.symvers
|
||||
modules.order
|
||||
*.o.d
|
||||
Common/compile.h
|
||||
|
||||
GPATH
|
||||
GRTAGS
|
||||
|
@ -25,5 +26,5 @@ _install/
|
|||
kernel/arm64_rootfs/
|
||||
kernel/*arm64_rootfs.tar.gz
|
||||
kernel/linux-4.14.83/build/
|
||||
|
||||
autom4te.cache/
|
||||
/ControlPlatform/web/node_modules
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
[submodule "libs/src/cJSON"]
|
||||
path = libs/src/cJSON
|
||||
url = https://github.com/DaveGamble/cJSON.git
|
||||
[submodule "libs/src/libev"]
|
||||
path = libs/src/libev
|
||||
url = https://github.com/enki/libev.git
|
||||
[submodule "libs/src/hiredis"]
|
||||
path = libs/src/hiredis
|
||||
url = https://github.com/redis/hiredis.git
|
||||
[submodule "libs/src/jemalloc"]
|
||||
path = libs/src/jemalloc
|
||||
url = https://github.com/jemalloc/jemalloc.git
|
||||
[submodule "libs/src/json-c"]
|
||||
path = libs/src/json-c
|
||||
url = https://github.com/json-c/json-c.git
|
||||
[submodule "libs/src/libevent"]
|
||||
path = libs/src/libevent
|
||||
url = https://github.com/libevent/libevent.git
|
||||
[submodule "libs/src/libconfig"]
|
||||
path = libs/src/libconfig
|
||||
url = https://github.com/hyperrealm/libconfig.git
|
||||
[submodule "libs/src/bzip2-1.0.6"]
|
||||
path = libs/src/bzip2-1.0.6
|
||||
url = https://github.com/enthought/bzip2-1.0.6.git
|
||||
|
|
|
@ -337,7 +337,7 @@ PLAT_LINUX_TARGET := $(TARGET_PREFIX)$(TARGET_NAME)-linux$(TARGET_EXT)
|
|||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
BUILD_TARGET += $(PLAT_ARM64_TARGET)
|
||||
PLAT_ARM64_CFLAGS += -DPLATFORM_ARM64 $(ARM64_EXTFLAG)
|
||||
PLAT_ARM64_LDFLAGS += $(ARM64_DRV_LDFLAGS)
|
||||
PLAT_ARM64_LDFLAGS += $(ARM64_DRV_LDFLAGS) -L ./debug
|
||||
PLAT_ARM64_LIBFLAGS := $(ARM64_LIBFLAGS)
|
||||
PLAT_ARM64_LIBS := $(ARM64_LIBS)
|
||||
endif
|
||||
|
@ -346,7 +346,7 @@ endif
|
|||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
BUILD_TARGET += $(PLAT_LINUX_TARGET)
|
||||
PLAT_LINUX_CFLAGS += -DPLATFORM_LINUX $(LINUX_EXTFLAG)
|
||||
PLAT_LINUX_LDFLAGS += $(LINUX_DRV_LDFLAGS)
|
||||
PLAT_LINUX_LDFLAGS += $(LINUX_DRV_LDFLAGS) -L ./debug
|
||||
PLAT_LINUX_LIBFLAGS := $(LINUX_LIBFLAGS)
|
||||
PLAT_LINUX_LIBS := $(LINUX_LIBS)
|
||||
endif
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/* This file is auto generated,for sGATE version info */
|
||||
/* Used readelf to get this information form driver of application */
|
||||
/* "readelf --debug-dump=macro <filename>" */
|
||||
#define sGATE_COMPILE_DATE "2019-07-08"
|
||||
#define sGATE_COMPILE_TIME "16:43:21"
|
||||
#define sGATE_COMPILE_MAJOR "20190708"
|
||||
#define sGATE_COMPILE_SUB "164321"
|
||||
#define sGATE_COMPILE_BY "cl"
|
||||
#define sGATE_COMPILE_HOST "esgwdev01"
|
||||
#define sGATE_GIT_TAGS "422ab40d7-dev"
|
||||
#define sGATE_GIT_VERS "422ab40d72986d1bba93e7eba5379cd61f5d9c24"
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef _CONFIG_MANAGER_H
|
||||
#define _CONFIG_MANAGER_H
|
||||
|
||||
/* 类型定义 */
|
||||
|
||||
/* IP CONFIG */
|
||||
#define NETCONFIG_MODULE 0x00000001
|
||||
|
||||
/* USER MANAGER CONFIG */
|
||||
#define USER_MANAGER_CONFIG_MODULE 0x00000002
|
||||
|
||||
/*PORTAL SERVER CONFIG */
|
||||
#define LOCALAUTH_CONFIG_MODULE 0x00000003
|
||||
|
||||
#define LOG_CONFIG_MODULE 0x00000004
|
||||
|
||||
/*nat config */
|
||||
#define NAT_CONFIG_MODULE 0x00000008
|
||||
|
||||
|
||||
|
||||
/* config id define*/
|
||||
#define IPCONFIG_V4 (uint64)((uint64)NETCONFIG_MODULE<<32|1)
|
||||
#define BR_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|2)
|
||||
#define BRIF_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|3)
|
||||
#define BRFDB_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|4)
|
||||
|
||||
|
||||
#define USER_MANAGER_CONFIG_GROUP (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|1)
|
||||
#define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2)
|
||||
|
||||
#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1)
|
||||
#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2)
|
||||
|
||||
|
||||
#define LOG_CONFIG_CONSOLE (uint64)((uint64)LOG_CONFIG_MODULE<<32|1)
|
||||
#define LOG_CONFIG_MONITOR (uint64)((uint64)LOG_CONFIG_MODULE<<32|2)
|
||||
#define LOG_CONFIG_REMOTE_ADD_HOST (uint64)((uint64)LOG_CONFIG_MODULE<<32|3)
|
||||
#define LOG_CONFIG_REMOTE_DEL_HOST (uint64)((uint64)LOG_CONFIG_MODULE<<32|4)
|
||||
#define LOG_CONFIG_REMOTE_LEVEL (uint64)((uint64)LOG_CONFIG_MODULE<<32|5)
|
||||
#define LOG_CONFIG_FILE (uint64)((uint64)LOG_CONFIG_MODULE<<32|6)
|
||||
|
||||
#define NAT4_CONFIG (uint64)((uint64)NAT_CONFIG_MODULE<<32|1)
|
||||
|
||||
|
||||
#endif
|
|
@ -1,14 +1,56 @@
|
|||
#ifndef _LOG_CONFIG_API_H
|
||||
#define _LOG_CONFIG_API_H
|
||||
#ifndef _LOG_TYPES_H
|
||||
#define _LOG_TYPES_H
|
||||
|
||||
#include "ulog_api.h"
|
||||
|
||||
#define LOG_HOST_SZ 256
|
||||
|
||||
|
||||
#define MAX_LINE_SZ 1024
|
||||
#define MAX_PATH_SZ MAX_LINE_SZ
|
||||
|
||||
|
||||
typedef enum {
|
||||
LOG_OFF = 0,
|
||||
LOG_ON
|
||||
} log_sw_t;
|
||||
|
||||
typedef struct _log_console {
|
||||
u8 level;
|
||||
u8 on;
|
||||
char module_name[MAX_MODULE_NAME_SZ];
|
||||
u8 level;
|
||||
log_sw_t on;
|
||||
char module[MAX_MODULE_NAME_SZ];
|
||||
} log_console_t;
|
||||
|
||||
typedef log_console_t log_pty_t;
|
||||
|
||||
#endif
|
||||
typedef enum {
|
||||
LOG_RFC_UNKNOWN = -1,
|
||||
LOG_RFC_3164 = 0,
|
||||
LOG_RFC_5424
|
||||
} log_rfc_t;
|
||||
|
||||
typedef struct _log_remote_host {
|
||||
log_rfc_t rfc;
|
||||
char host[LOG_HOST_SZ];
|
||||
u16 port;
|
||||
} log_remote_host_t;
|
||||
|
||||
typedef struct _log_remote_level {
|
||||
u8 level;
|
||||
} log_remote_level_t;
|
||||
|
||||
typedef enum {
|
||||
LOG_UNCOMPRESS = 0,
|
||||
LOG_COMPRESS
|
||||
} log_compress_t;
|
||||
|
||||
typedef struct _log_file {
|
||||
u8 level;
|
||||
char path[MAX_PATH_SZ];
|
||||
log_compress_t is_compress;
|
||||
u32 del_over_days;
|
||||
u64 del_over_size;
|
||||
} log_file_t;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
62
Makefile
62
Makefile
|
@ -3,7 +3,7 @@ OUTPUT_MAKE_DEBUG ?= FALSE
|
|||
CMD_MSG_ON ?= FALSE
|
||||
|
||||
ifeq ($(CMD_MSG_ON), TRUE)
|
||||
MLOG :=
|
||||
MLOG :=
|
||||
else
|
||||
MLOG := @
|
||||
endif
|
||||
|
@ -28,9 +28,9 @@ MAKE_FLAGS += -j$(shell cat /proc/cpuinfo | grep processor | wc -l)
|
|||
endif
|
||||
endif
|
||||
|
||||
.PHONY : demo conntrack netlink trace openrpc redismq usermanager configm ulog database webauth matchrule
|
||||
.PHONY : demo database openrpc ulog conntrack netlink trace redismq usermanager configm webauth matchrule logging
|
||||
|
||||
all: demo conntrack netlink trace openrpc redismq usermanager configm ulog database webauth matchrule
|
||||
all: demo database openrpc ulog conntrack netlink trace redismq usermanager configm webauth matchrule logging
|
||||
|
||||
ifeq ($(OPT), install)
|
||||
#$(shell `find ../release -name "*.zip" -delete`)
|
||||
|
@ -44,7 +44,7 @@ ifeq ($(OPT), clean)
|
|||
#
|
||||
endif
|
||||
|
||||
|
||||
|
||||
demo:
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f module.demo.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=demo
|
||||
|
@ -55,7 +55,7 @@ else ifeq ($(OPT), install)
|
|||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f module.demo.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=demo
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.demo.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=demo
|
||||
endif
|
||||
endif
|
||||
|
||||
conntrack:
|
||||
ifeq ($(OPT), clean)
|
||||
|
@ -76,78 +76,78 @@ netlink:
|
|||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.netlink_api.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=netlink_api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.cfgrcv.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=cfgrcv
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.pdelivery.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=pdeliv
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.pdelivery.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=pdeliv
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv_u.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=pdeliv_u
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=pdeliv_rcvtest
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=pdeliv_rcvtest
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.netlink_uapi.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=netlink_uapi
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.netlink_api.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=netlink_api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.cfgrcv.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=cfgrcv
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.pdelivery.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=pdeliv
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.netlink_uapi.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=netlink_uapi
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv_u.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=pdeliv_u
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=pdeliv_rcvtest
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=pdeliv_rcvtest
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f module.netlink_api.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=netlink_api
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f module.cfgrcv.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=cfgrcv
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f module.pdelivery.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=pdeliv
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.netlink_uapi.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=netlink_uapi
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.netlink_uapi.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=netlink_uapi
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.cfg2kernel.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=cfg2kernel
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.pdeliv_u.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=pdeliv_u
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=pdeliv_rcvtest
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.pdeliv.rcvtest.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=pdeliv_rcvtest
|
||||
endif
|
||||
|
||||
trace:
|
||||
ifeq ($(OPT), clean)
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.trace_relay.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=trace-relay
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.trace.api.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=trace-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.trace.test.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=trace-test
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f module.trace_relay.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=trace-relay
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.trace.api.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=trace-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.trace.api.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=trace-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.trace.test.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=trace-test
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f module.trace_relay.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=trace-relay
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.trace.api.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=trace-api
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.trace.api.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=trace-api
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.trace.test.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=trace-test
|
||||
endif
|
||||
|
||||
openrpc:
|
||||
ifeq ($(OPT), clean)
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=openrpc
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=openrpc
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=openrpc
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=openrpc
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=openrpc
|
||||
endif
|
||||
|
||||
usermanager:
|
||||
ifeq ($(OPT), clean)
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-auth.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=usermanager-auth
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=usermanager-test
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-auth.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=usermanager-auth
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=usermanager-test
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=usermanager-test
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.usermanager-auth.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=usermanager-auth
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=usermanager-test
|
||||
endif
|
||||
|
||||
configm:
|
||||
ifeq ($(OPT), clean)
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configm
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configm-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configmtest
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configm
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configm-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configmtest
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configmtest
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configm
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configm-api
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configmtest
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configmtest
|
||||
endif
|
||||
|
||||
|
||||
|
@ -188,7 +188,7 @@ else ifeq ($(OPT), install)
|
|||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.web-auth.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=webauth
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.web-auth.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=webauth
|
||||
endif
|
||||
endif
|
||||
|
||||
matchrule:
|
||||
ifeq ($(OPT), clean)
|
||||
|
@ -201,7 +201,17 @@ else ifeq ($(OPT), install)
|
|||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f module.khash.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=khashtable
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f module.matchrule.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=matchrule
|
||||
endif
|
||||
endif
|
||||
|
||||
logging:
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.logging.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=logging
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.logging.Makefile install MLOG=$(MLOG) MAKE_TARGET=logging
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.logging.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=logging
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=cfgchannel_sample
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,26 +38,13 @@ PLAT_ARM64_CFLAGS := -I../../Common -I../user/netlink_uapi
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
ARM64_LIBS := ./libnetlinku-arm64.so
|
||||
LINUX_LIBS := ./libnetlinku-linux.so
|
||||
ARM64_LIBS := -lnetlinku-arm64
|
||||
LINUX_LIBS := -lnetlinku-linux
|
||||
|
||||
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=configm
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -31,47 +31,32 @@ COMMON_SRCS = configserver.c \
|
|||
netconfig/ipconfig/ipconfig.c \
|
||||
netconfig/bridge/brconfig.c netconfig/bridge/brnetlink.c \
|
||||
netconfig/bridge/libbridge/libbridge_if.c netconfig/bridge/libbridge/libbridge_init.c netconfig/bridge/libbridge/libbridge_devif.c\
|
||||
web_config/authfree.c web_config/auth_parameters.c
|
||||
web_config/authfree.c web_config/auth_parameters.c\
|
||||
user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
|
||||
user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c \
|
||||
log_config/log_config_console.c log_config/log_config_init.c
|
||||
log_config/log_config_console.c log_config/log_config_init.c log_config/log_config_cm.c log_config/log_config_monitor.c log_config/log_config_remote.c log_config/log_config_file.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/database -I../common/configm -I../common/rpc -I../common/rpc/hashtable -I../common/ulog -I../user/configm/config-server/netconfig/ -I../user/configm/config-server/netconfig/bridge/include
|
||||
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/database -I../common/configm -I../common/rpc -I../common/rpc/hashtable -I../common/ulog -I../user/configm/config-server/netconfig/ -I../user/configm/config-server/netconfig/bridge/include
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/arm64/usr/local/include
|
||||
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/x86_64/usr/local/include
|
||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS)
|
||||
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS)
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so ./libulogapi-arm64.so ./libdatabase-arm64.so
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
ARM64_LIBS += ../thirdparty/arm64/usr/local/lib/libodbc.so
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lnetlinku-arm64 -lredismq-arm64 -lulogapi-arm64 -ldatabase-arm64
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lodbc -lev
|
||||
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so ./libulogapi-linux.so ./libdatabase-linux.so
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
LINUX_LIBS += ../thirdparty/x86_64/usr/local/lib/libodbc.so
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libnetlinku-arm64.so ./debug/libredismq-arm64.so ./debug/libdatabase-arm64.so
|
||||
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so ./libdatabase-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so ./libnetlinku-linux.so ./debug/libredismq-linux.so ./debug/libdatabase-linux.so
|
||||
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so ./libdatabase-linux.so
|
||||
|
||||
endif
|
||||
LINUX_LIBS := -lopenrpc-linux -lnetlinku-linux -lredismq-linux -lulogapi-linux -ldatabase-linux
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lodbc -lev
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libconfigmapi
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,25 +38,15 @@ PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/configm -I../common/rpc -
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so -lpthread -lm
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lpthread -lm -lev
|
||||
LINUX_LIBS := -lopenrpc-linux -lpthread -lm -lev
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=configmtest
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -27,7 +27,7 @@ VPATH = ../user/configm/config-test
|
|||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = configtest.c
|
||||
COMMON_SRCS = configtest.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
|
@ -38,25 +38,14 @@ PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I..
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libconfigmapi-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libconfigmapi-linux.so -lpthread -lm
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lconfigmapi-arm64 -lpthread -lm -lev
|
||||
LINUX_LIBS := -lopenrpc-linux -lconfigmapi-linux -lpthread -lm -lev
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libconfigmapi-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libconfigmapi-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so ./debug/libconfigmapi-linux.so
|
||||
USER_CLEAN_ITEMS += ./libconfigmapi-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libdatabase
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -34,29 +34,19 @@ PLAT_LINUX_SRCS = $(COMMON_DB)
|
|||
PLAT_ARM64_SRCS = $(COMMON_DB)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/database -I../thirdparty/arm64/usr/local/include/database -I../thirdparty/arm64/usr/local/lib
|
||||
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common/database -I../thirdparty/x86_64/usr/local/include/database -I../thirdparty/x86_64/usr/local/lib
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/database
|
||||
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common/database
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := -fPIC -shared
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/usr/local/lib/libodbc.so -lcjson
|
||||
LINUX_LIBS := ../thirdparty/x86_64/usr/local/lib/libodbc.so -lcjson
|
||||
ARM64_LIBS := -lodbc -lcjson
|
||||
LINUX_LIBS := -lodbc -lcjson
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libodbc.so -lcjson
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libodbc.so -lcjson
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=freeauth
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -26,44 +26,29 @@ VPATH = ../user/configm/config-server
|
|||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = web_config/auth_parameters.c
|
||||
COMMON_SRCS = web_config/auth_parameters.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/database -I../common/configm -I../common/rpc -I../common/rpc/hashtable -I../common/ulog -I../user/configm/config-server/netconfig/ -I../user/configm/config-server/netconfig/bridge/include
|
||||
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/database -I../common/configm -I../common/rpc -I../common/rpc/hashtable -I../common/ulog -I../user/configm/config-server/netconfig/ -I../user/configm/config-server/netconfig/bridge/include
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/arm64/usr/local/include
|
||||
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/x86_64/usr/local/include
|
||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS)
|
||||
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS)
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so ./libdatabase-arm64.so
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
ARM64_LIBS += ../thirdparty/arm64/usr/local/lib/libodbc.so
|
||||
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so ./libdatabase-linux.so
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
LINUX_LIBS += ../thirdparty/x86_64/usr/local/lib/libodbc.so
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libnetlinku-arm64.so ./debug/libredismq-arm64.so ./debug/libdatabase-arm64.so
|
||||
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so ./libdatabase-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so ./libnetlinku-linux.so ./debug/libredismq-linux.so ./debug/libdatabase-linux.so
|
||||
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so ./libdatabase-linux.so
|
||||
|
||||
endif
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lnetlinku-arm64 -lredismq-arm64 -ldatabase-arm64
|
||||
LINUX_LIBS := -lopenrpc-linux -lnetlinku-linux -lredismq-linux -ldatabase-linux
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lev -lodbc
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lodbc
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=logging
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
||||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
|
||||
VPATH = ../user/logging
|
||||
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = logging_main.c cmd_console.c logging_common.c cmd_monitor.c cmd_remote.c cmd_file.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common -I../common/rpc -I../common/configm -I../common/ulog -I../user/ulog -I../user/configm/config-server/include
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lulogapi-arm64 -lconfigmapi-arm64 -lpthread -lcjson
|
||||
LINUX_LIBS := -lopenrpc-linux -lulogapi-linux -lconfigmapi-linux -lpthread -lcjson
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
ifneq ($(MAKECMDGOALS), cleanall)
|
||||
ifneq ($(notdir $(DEPEND_LIB)), $(wildcard $(DEPEND_LIB)))
|
||||
$(shell $(CP) $(DEPEND_LIB) ./)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MAKECMDGOALS), )
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
else
|
||||
ifeq ($(MAKECMDGOALS), all)
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libnetlinku
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -41,7 +41,7 @@ PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
|||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifeq ($(MAKECMDGOALS), )
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libopenrpc
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -43,20 +43,10 @@ PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
|||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so -lpthread -lm
|
||||
ARM64_LIBS := -lpthread -lm -lev
|
||||
LINUX_LIBS := -lpthread -lm -lev
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=pdeliv_rcvtest
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,26 +38,13 @@ PLAT_ARM64_CFLAGS := -I../../Common -I../user/netlink_uapi
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
ARM64_LIBS := ./libnetlinku-arm64.so
|
||||
LINUX_LIBS := ./libnetlinku-linux.so
|
||||
ARM64_LIBS := -lnetlinku-arm64
|
||||
LINUX_LIBS := -lnetlinku-linux
|
||||
|
||||
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=pdeliv
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,26 +38,13 @@ PLAT_ARM64_CFLAGS := -I../../Common -I../user/netlink_uapi
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
ARM64_LIBS := ./libnetlinku-arm64.so
|
||||
LINUX_LIBS := ./libnetlinku-linux.so
|
||||
ARM64_LIBS := -lnetlinku-arm64
|
||||
LINUX_LIBS := -lnetlinku-linux
|
||||
|
||||
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=pdeliv
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,26 +38,13 @@ PLAT_ARM64_CFLAGS := -I../../Common -I../user/netlink_uapi
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
ARM64_LIBS := ./pdeliv-rcvtest-arm64.so
|
||||
LINUX_LIBS := ./pdeliv-rcvtest-linux.so
|
||||
ARM64_LIBS :=
|
||||
LINUX_LIBS :=
|
||||
|
||||
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libredismq
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -34,11 +34,11 @@ PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
|||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/redismq -I../thirdparty/arm64/usr/local/include
|
||||
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common/redismq -I../thirdparty/x86_64/usr/local/include
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/redismq
|
||||
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common/redismq
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared -lpthread
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
|
||||
|
@ -46,17 +46,7 @@ PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
|||
ARM64_LIBS := -lhiredis -ljson-c -levent
|
||||
LINUX_LIBS := -lhiredis -ljson-c -levent
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libjemalloc.so
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libjemalloc.so
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libtraceapi
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,25 +38,15 @@ PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/trace -I../user/netlink_ua
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./libnetlinku-arm64.so
|
||||
LINUX_LIBS := ./libnetlinku-linux.so
|
||||
ARM64_LIBS := -lnetlinku-arm64
|
||||
LINUX_LIBS := -lnetlinku-linux
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libnetlinku-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=test-trace
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -37,26 +37,14 @@ PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
|||
PLAT_ARM64_CFLAGS := -I../user/trace/trace-api -I../../Common -I../common/trace
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -lpthread
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./libtraceapi-arm64.so ./libnetlinku-arm64.so
|
||||
LINUX_LIBS := ./libtraceapi-linux.so ./libnetlinku-linux.so -lpthread
|
||||
ARM64_LIBS := -ltraceapi-arm64 -lnetlinku-arm64
|
||||
LINUX_LIBS := -ltraceapi-linux -lnetlinku-linux -lpthread
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libtraceapi-arm64.so ./debug/libnetlinku-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libtraceapi-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libtraceapi-linux.so ./debug/libnetlinku-linux.so
|
||||
USER_CLEAN_ITEMS += ./libtraceapi-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libulogapi
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -45,7 +45,7 @@ PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
|||
#gcc libs
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=log-sched
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,24 +38,14 @@ PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/rpc -I../common/ulog -I../
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./libopenrpc-arm64.so ./libulogapi-arm64.so ../thirdparty/arm64/libev-arm64.so -lpthread
|
||||
LINUX_LIBS := ./libopenrpc-linux.so ./libulogapi-linux.so ../thirdparty/x86_64/libev-linux.so -lpthread
|
||||
ARM64_LIBS := -lopenrpc-arm64 -lulogapi-arm64 -lev -lpthread
|
||||
LINUX_LIBS := -lopenrpc-linux -lulogapi-linux -lev -lpthread
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libopenrpc-arm64.so ./debug/libulogapi-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so ./libulogapi-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libopenrpc-linux.so ./debug/libulogapi-linux.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so ./libulogapi-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef enum {
|
|||
RET_NOTSUPPORT = 11,
|
||||
RET_INPUTERR = 12,
|
||||
RET_IPINVALID = 13,
|
||||
RET_BR_INVALID = 14,
|
||||
RET_NAMEINVAL = 14,
|
||||
RET_EXIST = 15,
|
||||
RET_FULL = 16
|
||||
} ret_code;
|
||||
|
@ -57,9 +57,9 @@ typedef enum {
|
|||
{ RET_NOTSUPPORT, "NotSupport"},\
|
||||
{ RET_INPUTERR, "InputError"},\
|
||||
{ RET_IPINVALID, "IpInvalid"},\
|
||||
{ RET_BR_INVALID, "BrNameInvalid"},\
|
||||
{ RET_NAMEINVAL, "NameInvalid"},\
|
||||
{ RET_EXIST, "AlreadyExist"},\
|
||||
{ RET_FULL, "FULL"}\
|
||||
{ RET_FULL, "Full"}\
|
||||
}
|
||||
|
||||
#define RET_BUFF_SIZE 256;
|
||||
|
|
|
@ -106,13 +106,13 @@ do { \
|
|||
do { \
|
||||
if(ret == RET_SYSERR)\
|
||||
{\
|
||||
sprintf(buff, "%s\n", strerror(errno));\
|
||||
sprintf(buff, "%s", strerror(errno));\
|
||||
(buff_size) = strlen(buff);\
|
||||
(buff_size)++;\
|
||||
}\
|
||||
else if(ret != RET_OK)\
|
||||
{\
|
||||
sprintf(buff, "%s\n", rpc_code_format(ret));\
|
||||
sprintf(buff, "%s", rpc_code_format(ret));\
|
||||
(buff_size) = strlen(buff);\
|
||||
(buff_size)++;\
|
||||
}\
|
||||
|
|
|
@ -1,11 +1,60 @@
|
|||
#ifndef _ULOG_IN_H
|
||||
#define _ULOG_IN_H
|
||||
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "common_types.h"
|
||||
#include "log_types.h"
|
||||
|
||||
#define SERVICE_LOG_FILE_NAME "log-file"
|
||||
#define SERIVCE_LOG_CONSOLE_NAME "log-console"
|
||||
#define SERVICE_LOG_PTY_NAME "log-pty"
|
||||
#define SERVICE_LOG_REMOTE_NAME "log-remote"
|
||||
|
||||
#define CONF_LOG_CONSOLE_FUNC "conf_log_console"
|
||||
#define CONF_LOG_FILE_FUNC "conf_log_file"
|
||||
#define CONF_LOG_CONSOLE_FUNC "conf_log_console"
|
||||
#define CONF_LOG_PTY_FUNC "conf_log_pty"
|
||||
#define CONF_LOG_REMOTE_ADD_HOST_FUNC "conf_log_add_remote"
|
||||
#define CONF_LOG_REMOTE_DEL_HOST_FUNC "conf_log_del_remote"
|
||||
#define CONF_LOG_REMOTE_LEVEL_FUNC "conf_log_remote_level"
|
||||
|
||||
typedef struct _level_str {
|
||||
u32 level;
|
||||
char str[10];
|
||||
} level_str_t;
|
||||
|
||||
typedef struct _rfc_key_fmt {
|
||||
log_rfc_t rfc;
|
||||
char fmt[20];
|
||||
} rfc_key_fmt;
|
||||
|
||||
static level_str_t g_level_array[] = {
|
||||
{LOG_EMERG, "emerg"},
|
||||
{LOG_ALERT, "alert"},
|
||||
{LOG_CRIT, "crit"},
|
||||
{LOG_ERR, "err"},
|
||||
{LOG_WARNING, "warn"},
|
||||
{LOG_NOTICE, "notice"},
|
||||
{LOG_INFO, "info"},
|
||||
{LOG_DEBUG, "debug"}
|
||||
};
|
||||
|
||||
static rfc_key_fmt rfc_tbl[] = {
|
||||
{LOG_RFC_3164, "RFC3164fmt"},
|
||||
{LOG_RFC_5424, "RFC5424fmt"}
|
||||
};
|
||||
|
||||
static inline int log_str_to_level(const char *str_level)
|
||||
{
|
||||
int n = sizeof(g_level_array) / sizeof(level_str_t);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (strcmp(g_level_array[i].str, str_level) == 0) {
|
||||
return g_level_array[i].level;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef CONFIGM_H_
|
||||
#define CONFIGM_H_
|
||||
|
||||
#include "config_manager.h"
|
||||
#include "s2j/s2j.h"
|
||||
#include "../../../../common/rpc/rpc_common.h"
|
||||
#include "../../../../../Common/commuapinl.h"
|
||||
|
@ -9,45 +9,8 @@
|
|||
#include "netconfig.h"
|
||||
#include "log_config.h"
|
||||
#include "../web_config/authfree.h"
|
||||
#include "localportal.h"
|
||||
#include "jumppage.h"
|
||||
#include "userlock.h"
|
||||
#include "agingtime.h"
|
||||
#include "../web_config/auth_parameters.h"
|
||||
|
||||
/* 类型定义 */
|
||||
|
||||
/* IP CONFIG */
|
||||
#define NETCONFIG_MODULE 0x00000001
|
||||
|
||||
/* USER MANAGER CONFIG */
|
||||
#define USER_MANAGER_CONFIG_MODULE 0x00000002
|
||||
|
||||
/*PORTAL SERVER CONFIG */
|
||||
#define LOCALAUTH_CONFIG_MODULE 0x00000003
|
||||
|
||||
#define LOG_CONFIG_MODULE 0x00000004
|
||||
|
||||
/*nat config */
|
||||
#define NAT_CONFIG_MODULE 0x00000008
|
||||
|
||||
|
||||
|
||||
/* config id define*/
|
||||
#define IPCONFIG_V4 (uint64)((uint64)NETCONFIG_MODULE<<32|1)
|
||||
#define BR_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|2)
|
||||
#define BRIF_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|3)
|
||||
#define BRFDB_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|4)
|
||||
|
||||
|
||||
#define USER_MANAGER_CONFIG_GROUP (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|1)
|
||||
#define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2)
|
||||
|
||||
#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1)
|
||||
#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2)
|
||||
|
||||
|
||||
#define LOG_CONFIG_CONSOLE (uint64)((uint64)LOG_CONFIG_MODULE<<32|1)
|
||||
#define NAT4_CONFIG (uint64)((uint64)NAT_CONFIG_MODULE<<32|1)
|
||||
|
||||
#define CONFIG_INIT_ARRAY \
|
||||
{\
|
||||
|
@ -156,13 +119,49 @@
|
|||
NULL \
|
||||
},\
|
||||
{\
|
||||
NAT4_CONFIG, \
|
||||
CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \
|
||||
FALSE, \
|
||||
nat_config_chk, \
|
||||
nat_config_proc, \
|
||||
NULL, \
|
||||
nat_config_get_all \
|
||||
LOG_CONFIG_MONITOR, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
log_monitor_config_chk, \
|
||||
log_monitor_config_proc, \
|
||||
NULL, \
|
||||
NULL \
|
||||
},\
|
||||
{\
|
||||
LOG_CONFIG_REMOTE_ADD_HOST, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
log_remote_host_config_chk, \
|
||||
log_remote_add_host_config_proc, \
|
||||
NULL, \
|
||||
NULL \
|
||||
},\
|
||||
{\
|
||||
LOG_CONFIG_REMOTE_DEL_HOST, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
log_remote_host_config_chk, \
|
||||
log_remote_del_host_config_proc, \
|
||||
NULL, \
|
||||
NULL \
|
||||
},\
|
||||
{\
|
||||
LOG_CONFIG_REMOTE_LEVEL, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
log_remote_level_config_chk, \
|
||||
log_remote_level_config_proc, \
|
||||
NULL, \
|
||||
NULL \
|
||||
},\
|
||||
{\
|
||||
LOG_CONFIG_FILE, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
log_file_config_chk, \
|
||||
log_file_config_proc, \
|
||||
NULL, \
|
||||
NULL \
|
||||
}\
|
||||
}
|
||||
|
||||
|
|
|
@ -13,5 +13,32 @@ ret_code log_console_config_chk(uint source, uint *config_type,
|
|||
ret_code log_console_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_monitor_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_monitor_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_remote_host_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_remote_add_host_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_remote_del_host_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_remote_level_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_remote_level_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_file_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
ret_code log_file_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,22 @@
|
|||
#include "log_config_cm.h"
|
||||
#include "rpc_server.h"
|
||||
#include "rpc_client.h"
|
||||
|
||||
ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth)
|
||||
{
|
||||
if ((input == NULL)
|
||||
&& input_len < last_lenth /*sizeof(log_console_t) */) {
|
||||
ULOG_ERR(g_log_h, "log rpc input actual length:%d, need length:%d", input_len, last_lenth);
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
ret_code ret = rpc_client_call(g_log_client, service_name,
|
||||
method_name, input, input_len, NULL, NULL);
|
||||
if (ret != RET_OK) {
|
||||
ULOG_ERR(g_log_h, "rpc call is failure[ret:%u, service:%s, method:%s]", ret, service_name, method_name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef _LOG_CONFIG_H_H
|
||||
#define _LOG_CONFIG_H_H
|
||||
|
||||
#include "log_types.h"
|
||||
#include "ulog_in.h"
|
||||
#include "cjson/cJSON.h"
|
||||
#include "s2j/s2j.h"
|
||||
#include "rpc_types.h"
|
||||
#include "rpc_common.h"
|
||||
|
||||
#define TERMINAL_GEN_JSON(s, o) { \
|
||||
s2j_struct_get_basic_element(s, o, int, level); \
|
||||
s2j_struct_get_basic_element(s, o, int, on); \
|
||||
S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, module, MAX_MODULE_NAME_SZ); \
|
||||
}
|
||||
|
||||
#define COMMON_CHK(type, input, input_len, str_conf, cb) { \
|
||||
ULOG_DEBUG(g_log_h, "Checking %s configuration:%s", str_conf, input); \
|
||||
if (input == NULL) { \
|
||||
ULOG_ERR(g_log_h, "input can't null"); \
|
||||
return RET_INPUTERR; \
|
||||
} \
|
||||
\
|
||||
cJSON *json_obj = cJSON_Parse(input); \
|
||||
if(!json_obj) { \
|
||||
ULOG_ERR(g_log_h, "Error log %s format", str_conf); \
|
||||
return RET_INPUTERR; \
|
||||
} \
|
||||
\
|
||||
ULOG_DEBUG(g_log_h, "json input: %s", cJSON_Print(json_obj)); \
|
||||
\
|
||||
s2j_create_struct_obj(st, type /*log_console_t*/); \
|
||||
if(st == NULL) { \
|
||||
cJSON_Delete(json_obj); \
|
||||
ULOG_ERR(g_log_h, "Creating log %s of object is failure", str_conf); \
|
||||
return RET_NOMEM; \
|
||||
} \
|
||||
\
|
||||
cb(st, json_obj); \
|
||||
\
|
||||
*input_len = sizeof(*st); \
|
||||
memcpy(input, st, *input_len); \
|
||||
\
|
||||
return RET_OK; \
|
||||
}
|
||||
|
||||
#define TERMINAL_CHK(type, input, input_len, str_conf) { \
|
||||
COMMON_CHK(type, input, input_len, str_conf, TERMINAL_GEN_JSON) \
|
||||
}
|
||||
|
||||
extern rpc_client *g_log_client;
|
||||
extern ulog_t *g_log_h;
|
||||
|
||||
ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth);
|
||||
|
||||
#endif
|
|
@ -1,63 +1,16 @@
|
|||
#include <cjson/cJSON.h>
|
||||
|
||||
#include "rpc_server.h"
|
||||
#include "log_config.h"
|
||||
#include "configm.h"
|
||||
#include "log_types.h"
|
||||
#include "ulog_in.h"
|
||||
#include "log_config_h.h"
|
||||
#include "log_config_cm.h"
|
||||
|
||||
ret_code log_console_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
if (input == NULL) {
|
||||
ULOG_ERR(g_log_h, "input can't null");
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
cJSON *json_obj = cJSON_Parse(input);
|
||||
if(!json_obj)
|
||||
{
|
||||
ULOG_ERR(g_log_h, "Error log console format");
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
ULOG_DEBUG("json input: %s", cJSON_Print(json_obj));
|
||||
|
||||
s2j_create_struct_obj(log_console, log_console_t);
|
||||
if(log_console == NULL)
|
||||
{
|
||||
cJSON_Delete(json_obj);
|
||||
ULOG_ERR(g_log_h, "Creating log console of object is failure");
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
s2j_struct_get_basic_element(log_console, json_obj, int, level);
|
||||
s2j_struct_get_basic_element(log_console, json_obj, int, on);
|
||||
S2J_STRUCT_GET_STRING_ELEMENT_N(log_console, json_obj, module_name, MAX_MODULE_NAME_SZ);
|
||||
|
||||
*input_len = sizeof(*log_console);
|
||||
memcpy(input, log_console, *input_len);
|
||||
|
||||
return RET_OK;
|
||||
{
|
||||
TERMINAL_CHK(log_console_t, input, input_len, "console");
|
||||
}
|
||||
|
||||
ret_code log_console_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
if ((input == NULL)
|
||||
&& input_len < sizeof(log_console_t)) {
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
ret_code ret = rpc_client_call(g_log_client, SERIVCE_LOG_CONSOLE_NAME,
|
||||
CONF_LOG_CONSOLE_FUNC, input, input_len, NULL, NULL);
|
||||
if (ret != RET_OK) {
|
||||
ULOG_ERR(g_log_h, "rpc call is failure[ret:%u, method:%s]", ret, CONF_LOG_CONSOLE_FUNC);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return log_rpc_exec(SERVICE_LOG_PTY_NAME, CONF_LOG_CONSOLE_FUNC, input, input_len, sizeof(log_console_t));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#include "log_config.h"
|
||||
#include "log_config_cm.h"
|
||||
|
||||
#define FILE_JSON(s, o) { \
|
||||
s2j_struct_get_basic_element(s, o, int, level); \
|
||||
S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, path, MAX_PATH_SZ); \
|
||||
s2j_struct_get_basic_element(s, o, int, is_compress); \
|
||||
s2j_struct_get_basic_element(s, o, int, del_over_days); \
|
||||
s2j_struct_get_basic_element(s, o, int, del_over_size); \
|
||||
}
|
||||
|
||||
ret_code log_file_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
COMMON_CHK(log_file_t, input, input_len, "file", FILE_JSON);
|
||||
}
|
||||
|
||||
ret_code log_file_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
return log_rpc_exec(SERVICE_LOG_FILE_NAME, CONF_LOG_FILE_FUNC, input, input_len, sizeof(log_file_t));
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef _LOG_CONFIG_H_H
|
||||
#define _LOG_CONFIG_H_H
|
||||
|
||||
extern rpc_client *g_log_client;
|
||||
extern ulog_t *g_log_h;
|
||||
|
||||
#endif
|
|
@ -1,3 +1,4 @@
|
|||
#include "rpc_client.h"
|
||||
#include "rpc_server.h"
|
||||
#include "log_config.h"
|
||||
#include "ulog_in.h"
|
||||
|
@ -10,7 +11,7 @@ ulog_t *g_log_h;
|
|||
ret_code log_config_init()
|
||||
{
|
||||
g_log_h = ulog_init("log_config", 1);
|
||||
if (g_log_h) {
|
||||
if (g_log_h == NULL) {
|
||||
fprintf(stderr, "Initiating log_config is failure");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "log_config.h"
|
||||
#include "log_config_cm.h"
|
||||
|
||||
ret_code log_monitor_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
TERMINAL_CHK(log_console_t, input, input_len, "pty");
|
||||
}
|
||||
|
||||
ret_code log_monitor_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
return log_rpc_exec(SERVICE_LOG_PTY_NAME, CONF_LOG_PTY_FUNC, input, input_len, sizeof(log_console_t));
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include "log_config.h"
|
||||
#include "log_config_cm.h"
|
||||
|
||||
#define REMOTE_HOST_JSON(s, o) { \
|
||||
s2j_struct_get_basic_element(s, o, int, rfc); \
|
||||
s2j_struct_get_basic_element(s, o, int, port); \
|
||||
S2J_STRUCT_GET_STRING_ELEMENT_N(s, o, host, LOG_HOST_SZ); \
|
||||
}
|
||||
|
||||
#define REMOTE_LEVEL_JSON(s, o) { \
|
||||
s2j_struct_get_basic_element(s, o, int, level); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
ret_code log_remote_host_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
COMMON_CHK(log_remote_host_t, input, input_len, "remote host", REMOTE_HOST_JSON);
|
||||
}
|
||||
|
||||
ret_code log_remote_add_host_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
return log_rpc_exec(SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_ADD_HOST_FUNC, input, input_len, sizeof(log_remote_host_t));
|
||||
}
|
||||
|
||||
ret_code log_remote_del_host_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
return log_rpc_exec(SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_DEL_HOST_FUNC, input, input_len, sizeof(log_remote_host_t));
|
||||
}
|
||||
|
||||
ret_code log_remote_level_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
COMMON_CHK(log_remote_level_t, input, input_len, "remote level", REMOTE_LEVEL_JSON);
|
||||
}
|
||||
|
||||
ret_code log_remote_level_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
return log_rpc_exec(SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_LEVEL_FUNC, input, input_len, sizeof(log_remote_level_t));
|
||||
}
|
||||
|
||||
|
|
@ -122,11 +122,11 @@ ret_code br_name_chk(char *br_name)
|
|||
|| strlen(br_name) > BR_NAMSIZ - 1
|
||||
|| strstr(br_name, "br-vl") != NULL)
|
||||
{
|
||||
return RET_BR_INVALID;
|
||||
return RET_NAMEINVAL;
|
||||
}
|
||||
if(br_name[0] != 'b' || br_name[1] != 'r')
|
||||
{
|
||||
return RET_BR_INVALID;
|
||||
return RET_NAMEINVAL;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
|
@ -603,6 +603,7 @@ ret_code br_config_chk(uint source,uint *config_type,
|
|||
if(strcasecmp(br_name, "br0") == 0)
|
||||
{
|
||||
ret = RET_NOTSUPPORT;
|
||||
break;
|
||||
}
|
||||
case CM_CONFIG_GET:
|
||||
ret = br_name_chk(br_name);
|
||||
|
|
|
@ -548,9 +548,4 @@ ret_code authpara_config_proc(uint source, uint config_type,
|
|||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ ret_code authpara_config_json_parse(pointer input, uint *conf_type, auth_paramet
|
|||
/*检查增加的参数格式是否正确 */
|
||||
ret_code authpara_config_add_chk(uint source,uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code authpara_config_mod_chk(uint source,uint config_type,
|
||||
pointer input, int input_len,
|
||||
|
@ -51,7 +51,7 @@ ret_code authpara_config_mod_chk(uint source,uint config_type,
|
|||
|
||||
ret_code authpara_config_chk(uint source,uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code authpara_config_add_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
|
|
|
@ -628,9 +628,5 @@ ret_code freeauth_config_proc(uint source, uint config_type,
|
|||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "cmd_console.h"
|
||||
#include "ulog_api.h"
|
||||
#include "log_types.h"
|
||||
#include "logging_common.h"
|
||||
#include "ulog/ulog_in.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
int conf_console(cJSON *json_obj, int argc, char **argv)
|
||||
{
|
||||
CMD_PARSE_AND_CONFIG_TERMINAL(log_console_t, json_obj, argc, argv, LOG_CONFIG_CONSOLE);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _CMD_CONSOLE_H
|
||||
#define _CMD_CONSOLE_H
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
|
||||
//int conf_console(cJSON *json_obj, const char *str_level, const char *module_name);
|
||||
int conf_console(cJSON *json_obj, int argc, char **argv);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,66 @@
|
|||
#include "cmd_file.h"
|
||||
#include "ulog_api.h"
|
||||
#include "log_types.h"
|
||||
#include "logging_common.h"
|
||||
#include "ulog/ulog_in.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
int conf_file(cJSON *json_obj, int argc, char **argv)
|
||||
{
|
||||
log_file_t log_file = {0};
|
||||
log_file.is_compress = LOG_UNCOMPRESS;
|
||||
|
||||
int level = LOG_INFO;
|
||||
if (argc >= 3) {
|
||||
if ((level = log_str_to_level(argv[2])) < 0) {
|
||||
ULOG_WARNING(g_log, "Unknown log level:%s", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
log_file.level = level;
|
||||
|
||||
if (argc >= 4) {
|
||||
strncpy(log_file.path, argv[3], sizeof(log_file.path));
|
||||
}
|
||||
|
||||
if (argc >= 5) {
|
||||
if (atoi(argv[4]) > 0) {
|
||||
log_file.is_compress = LOG_COMPRESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc >= 6) {
|
||||
int day = atoi(argv[5]);
|
||||
if (day > 0) {
|
||||
log_file.del_over_days = day;
|
||||
} else if (day < 0) {
|
||||
ULOG_WARNING(g_log, "Deleting day(%d) mustn't be less than 0", day);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc >= 7) {
|
||||
int64_t size = atoll(argv[6]);
|
||||
if (size > 0) {
|
||||
log_file.del_over_size = (u64)size;
|
||||
} else if (size < 0) {
|
||||
ULOG_WARNING(g_log, "Deleting size(%d) mustn't be less than 0", size);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
s2j_json_set_basic_element(json_obj, &log_file, int, level);
|
||||
s2j_json_set_basic_element(json_obj, &log_file, string, path);
|
||||
s2j_json_set_basic_element(json_obj, &log_file, int, is_compress);
|
||||
s2j_json_set_basic_element(json_obj, &log_file, int, del_over_days);
|
||||
s2j_json_set_basic_element(json_obj, &log_file, int, del_over_size);
|
||||
|
||||
int ret = set_log_conf(json_obj, LOG_CONFIG_FILE);
|
||||
if (ret != 0) {
|
||||
ULOG_ERR(g_log, "File log which is configured is failure");
|
||||
} else {
|
||||
ULOG_DEBUG(g_log, "File log whice is configured is success");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _CMD_FILE_H
|
||||
#define _CMD_FILE_H
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
|
||||
int conf_file(cJSON *json_obj, int argc, char **argv);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#include "cmd_monitor.h"
|
||||
#include "ulog_api.h"
|
||||
#include "log_types.h"
|
||||
#include "logging_common.h"
|
||||
#include "ulog/ulog_in.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
int conf_monitor(cJSON *json_obj, int argc, char **argv)
|
||||
{
|
||||
CMD_PARSE_AND_CONFIG_TERMINAL(log_pty_t, json_obj, argc, argv, LOG_CONFIG_MONITOR);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _CMD_MONITOR_H
|
||||
#define _CMD_MONITOR_H
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
|
||||
//int conf_console(cJSON *json_obj, const char *str_level, const char *module_name);
|
||||
int conf_monitor(cJSON *json_obj, int argc, char **argv);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
#include "cmd_remote.h"
|
||||
#include "logging_common.h"
|
||||
#include "common_types.h"
|
||||
#include "log_types.h"
|
||||
#include "ulog_in.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
#define DEFAULT_REMOTE_HOST 514
|
||||
|
||||
static log_rfc_t get_rfc_by_name(const char *name)
|
||||
{
|
||||
for (int i = 0; i < (sizeof(rfc_tbl) / sizeof(rfc_key_fmt)); i++) {
|
||||
if (strcasecmp(name, rfc_tbl[i].fmt) == 0) {
|
||||
return rfc_tbl[i].rfc;
|
||||
}
|
||||
}
|
||||
|
||||
return LOG_RFC_UNKNOWN;
|
||||
}
|
||||
|
||||
static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16 port, const log_rfc_t rfc, uint64 config_id)
|
||||
{
|
||||
log_remote_host_t remote;
|
||||
|
||||
strncpy(remote.host, host, sizeof(remote.host));
|
||||
remote.port = port;
|
||||
remote.rfc = rfc;
|
||||
|
||||
s2j_json_set_basic_element(json_obj, &remote, int, port);
|
||||
s2j_json_set_basic_element(json_obj, &remote, int, rfc);
|
||||
s2j_json_set_basic_element(json_obj, &remote, string, host);
|
||||
|
||||
int ret = set_log_conf(json_obj, config_id);
|
||||
if (ret != 0) {
|
||||
ULOG_ERR(g_log, "Host of log which is configured is failure");
|
||||
} else {
|
||||
ULOG_DEBUG(g_log, "Host of log whice is configured is success");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int conf_remote(cJSON *json_obj, int argc, char **argv)
|
||||
{
|
||||
int ret = -1;
|
||||
uint64 config_id;
|
||||
|
||||
if (argc <= 3) {
|
||||
ULOG_WARNING(g_log, "Parameter too less");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[2], "add") == 0) {
|
||||
config_id = LOG_CONFIG_REMOTE_ADD_HOST;
|
||||
} else if (strcasecmp(argv[2], "del") == 0) {
|
||||
config_id = LOG_CONFIG_REMOTE_DEL_HOST;
|
||||
} else {
|
||||
ULOG_WARNING(g_log, "Unknown operation command:%s", argv[2]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *host = argv[3];
|
||||
u16 port = DEFAULT_REMOTE_HOST;
|
||||
if (argc >= 5) {
|
||||
port= atoi(argv[4]);
|
||||
}
|
||||
|
||||
log_rfc_t rfc = LOG_RFC_3164;
|
||||
if (argc >= 6) {
|
||||
rfc = get_rfc_by_name(argv[5]);
|
||||
if (rfc == LOG_RFC_UNKNOWN) {
|
||||
ULOG_WARNING(g_log, "Unknown rfc standard:%s of log", argv[5]);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return conf_remote_by_config_id(json_obj, host, port, rfc, config_id);
|
||||
}
|
||||
|
||||
int conf_remote_level(cJSON *json_obj, int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
ULOG_WARNING(g_log, "Not input log level");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int level;
|
||||
|
||||
if ((level = log_str_to_level(argv[2])) < 0) {
|
||||
ULOG_WARNING(g_log, "Unknown log level:%s", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_remote_level_t log_level;
|
||||
|
||||
log_level.level = (u8)level;
|
||||
s2j_json_set_basic_element(json_obj, &log_level, int, level);
|
||||
int ret = set_log_conf(json_obj, LOG_CONFIG_REMOTE_LEVEL);
|
||||
if (ret != 0) {
|
||||
ULOG_ERR(g_log, "Remote level of log which is configured is failure");
|
||||
} else {
|
||||
ULOG_DEBUG(g_log, "Remote level of log whice is configured is success");
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _CMD_REMOTE_H
|
||||
#define _CMD_REMOTE_H
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
|
||||
int conf_remote(cJSON *json_obj, int argc, char **argv);
|
||||
int conf_remote_level(cJSON *json_obj, int argc, char **argv);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,36 @@
|
|||
#include "logging_common.h"
|
||||
#include "ulog_api.h"
|
||||
#include "log_types.h"
|
||||
#include "configm.h"
|
||||
#include "configmapi.h"
|
||||
#include "ulog/ulog_in.h"
|
||||
|
||||
int set_log_conf(cJSON *json_obj, uint64 config_id)
|
||||
{
|
||||
int ret = -1;
|
||||
char *output;
|
||||
int output_len;
|
||||
|
||||
char *json = cJSON_PrintUnformatted(json_obj);
|
||||
if (json == NULL) {
|
||||
ULOG_ERR(g_log, "Converting struct to json is failure");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ULOG_DEBUG(g_log, "Setting log json is %s", json);
|
||||
ret_code ret_c = web_config_exec_sync(CM_CONFIG_SET, config_id,
|
||||
json, strlen(json),
|
||||
&output, &output_len);
|
||||
if (ret_c != RET_OK) {
|
||||
ULOG_ERR(g_log, "Log of Web config is failure:%d", ret_c);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (json != NULL) {
|
||||
free(json);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef _LOGGING_COMMON_H
|
||||
#define _LOGGING_COMMON_H
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "ulog_api.h"
|
||||
#include "common_types.h"
|
||||
#include "configm.h"
|
||||
#include "configmapi.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
|
||||
#define DEFAULT_LOG_LEVEL "info"
|
||||
|
||||
extern ulog_t *g_log;
|
||||
|
||||
int set_log_conf(cJSON *json_obj, uint64 config_id);
|
||||
|
||||
#define CONF_TERMINAL(type, json_obj, str_level, on, module_name, conf_id) { \
|
||||
type terminal = {0}; \
|
||||
int level; \
|
||||
\
|
||||
if ((level = log_str_to_level(str_level)) < 0) { \
|
||||
ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \
|
||||
return -1; \
|
||||
} \
|
||||
\
|
||||
terminal.level = (u8)level; \
|
||||
terminal.on = on; \
|
||||
if (module_name != NULL) { \
|
||||
strncpy(terminal.module, module_name, sizeof(terminal.module)); \
|
||||
} \
|
||||
\
|
||||
s2j_json_set_basic_element(json_obj, &terminal, int, level); \
|
||||
s2j_json_set_basic_element(json_obj, &terminal, int, on); \
|
||||
s2j_json_set_basic_element(json_obj, &terminal, string, module); \
|
||||
\
|
||||
int ret = set_log_conf(json_obj, conf_id); \
|
||||
if (ret != 0) { \
|
||||
ULOG_ERR(g_log, "Setting terminal configure of log is failure"); \
|
||||
} else { \
|
||||
ULOG_DEBUG(g_log, "Setting terminal configure of log is success"); \
|
||||
} \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define CMD_PARSE_AND_CONFIG_TERMINAL(type, json_obj, argc, argv, conf_id) { \
|
||||
log_sw_t on = LOG_ON; \
|
||||
char *str_level = DEFAULT_LOG_LEVEL; \
|
||||
if (argc >= 3) { \
|
||||
if (strcasecmp(argv[2], "off") == 0) { \
|
||||
on = LOG_OFF; \
|
||||
} else { \
|
||||
str_level = argv[2]; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
char *module = NULL; \
|
||||
if (argc >= 4) { \
|
||||
module = argv[3]; \
|
||||
} \
|
||||
\
|
||||
CONF_TERMINAL(type, json_obj, str_level, on, module, conf_id); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,79 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "cmd_console.h"
|
||||
#include "cmd_monitor.h"
|
||||
#include "cmd_remote.h"
|
||||
#include "cmd_file.h"
|
||||
#include "ulog_api.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
#define LOGGING_MODULE_NAME "logging"
|
||||
|
||||
typedef int (*cmd_cb)(cJSON *, int, char **);
|
||||
|
||||
typedef struct _log_cmd {
|
||||
char cmd[20];
|
||||
cmd_cb cb;
|
||||
} log_cmd_t;
|
||||
|
||||
ulog_t *g_log;
|
||||
log_cmd_t g_log_cmd[] = {
|
||||
{"console", conf_console},
|
||||
{"monitor", conf_monitor},
|
||||
{"host", conf_remote},
|
||||
{"trap", conf_remote_level},
|
||||
{"file", conf_file}
|
||||
};
|
||||
|
||||
log_cmd_t *get_cb_by_cmd(const char *cmd)
|
||||
{
|
||||
for (int i = 0; i < (sizeof(g_log_cmd) / sizeof(log_cmd_t)); i++) {
|
||||
if (strcasecmp(cmd, g_log_cmd[i].cmd) == 0) {
|
||||
return &g_log_cmd[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = -1;
|
||||
if (argc < 2) {
|
||||
fprintf(stdout, "Parameter too few");
|
||||
return ret;
|
||||
}
|
||||
|
||||
g_log = ulog_init(LOGGING_MODULE_NAME, 1);
|
||||
if (g_log == NULL) {
|
||||
fprintf(stderr, "Initiating ulog is failure");
|
||||
return ret;
|
||||
}
|
||||
|
||||
log_cmd_t *log_cmd = get_cb_by_cmd(argv[1]);
|
||||
if (log_cmd == NULL) {
|
||||
ulog_close(g_log);
|
||||
ULOG_WARNING(g_log, "Not find logging cmd:%s", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
s2j_create_json_obj(json_obj);
|
||||
if(json_obj == NULL)
|
||||
{
|
||||
ULOG_ERR(g_log, "Creating json object is failure");
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (log_cmd->cb(json_obj, argc, argv) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring %s is failure", log_cmd->cmd);
|
||||
goto END;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
END:
|
||||
if(json_obj != NULL) {
|
||||
cJSON_Delete(json_obj);
|
||||
}
|
||||
ulog_close(g_log);
|
||||
return ret;
|
||||
}
|
|
@ -267,7 +267,7 @@ static void cb_rsp_read(struct ev_loop *l, struct ev_io *watcher, int revents) {
|
|||
//TODO why null
|
||||
//sessionpool has
|
||||
req = (rpc_request*) rpc_sessionpool_get(th->req_pool, rsp->seq);
|
||||
if (req->seq != rsp->seq) {
|
||||
if ((req == NULL) || (req->seq != rsp->seq)) {
|
||||
fprintf(stderr, "seq not equal!\n");
|
||||
return;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ void rpc_return_null(rpc_conn *conn) {
|
|||
|
||||
void rpc_return_error(rpc_conn *conn, ret_code err_code, char* err_message) {
|
||||
int len = strlen(err_message);
|
||||
err_message[len]='\0';
|
||||
//err_message[len]='\0';
|
||||
len++;
|
||||
rpc_send_response(conn, err_code, err_message, len);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "ulog.h"
|
||||
#include "log_common.h"
|
||||
#include "ulog_in.h"
|
||||
|
||||
#define FILTER_CONTENT ":msg,contains,\""MODULE_FMT"\"\n"
|
||||
|
||||
|
@ -205,4 +206,27 @@ int write_conf_content_authorizing(FILE *fp, const u8 level, const c
|
|||
return 0;
|
||||
}
|
||||
|
||||
int log_off_with_file(const char *path, const char *file_name)
|
||||
{
|
||||
char file[MAX_PATH_SZ];
|
||||
int ret = -1;
|
||||
|
||||
if (snprintf(file, sizeof(file), "%s%s", path, file_name) < 0) {
|
||||
ULOG_ERR(g_log, "Setting file path(dir:%s, file:%s) is failure",
|
||||
path, file_name);
|
||||
return ret;
|
||||
}
|
||||
if (unlink(file) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
ULOG_ERR(g_log, "Deleting configure file(dir:%s, file:%s) is failure:%s",
|
||||
path, file_name, strerror(errno));
|
||||
return ret;
|
||||
} else {
|
||||
ULOG_DEBUG(g_log, "File(dir:%s, file:%s) is not exist", path, file_name);
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#define _LOG_COMMON_H
|
||||
|
||||
#include "ulog_api.h"
|
||||
|
||||
#define MAX_LINE_SZ 1024
|
||||
#define MAX_PATH_SZ MAX_LINE_SZ
|
||||
#include "log_types.h"
|
||||
|
||||
#define LOG_CONF_PATH "/etc/rsyslog.d/"
|
||||
|
||||
|
@ -14,27 +12,10 @@
|
|||
|
||||
#define REDIRECT_SEPERATE " "
|
||||
|
||||
|
||||
typedef struct _level_str {
|
||||
u32 level;
|
||||
char str[10];
|
||||
} level_str_t;
|
||||
|
||||
extern ulog_t *g_log;
|
||||
extern FILE *g_conf_fp;
|
||||
extern char g_conf_file[MAX_PATH_SZ];
|
||||
|
||||
static level_str_t g_level_array[] = {
|
||||
{LOG_EMERG, "emerg"},
|
||||
{LOG_ALERT, "alert"},
|
||||
{LOG_CRIT, "crit"},
|
||||
{LOG_ERR, "err"},
|
||||
{LOG_WARNING, "warn"},
|
||||
{LOG_NOTICE, "notice"},
|
||||
{LOG_INFO, "info"},
|
||||
{LOG_DEBUG, "debug"}
|
||||
};
|
||||
|
||||
int log_conf(const u8 level, const char *conf_path, const char *conf_file, const char *filter_mod,
|
||||
int (*cb_content)(FILE *fp, const u8 level, const char *filter_mod, void *arg), void *arg);
|
||||
int log_conf_append(const u8 level, const char *conf_path, const char *conf_file, const char *filter_mod,
|
||||
|
@ -42,6 +23,7 @@ int log_conf_append(const u8 level, const char *conf_path, const char *conf_file
|
|||
int write_conf_content(FILE *fp, const u8 level, const char *filter_mod, void *arg);
|
||||
int write_conf_content_authorizing(FILE *fp, const u8 level, const char *filter_mod, void *arg);
|
||||
int log_level_to_str(const u8 level, char *str, u32 len);
|
||||
int log_off_with_file(const char *path, const char *file_name);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "log_console.h"
|
||||
#include "log_types.h"
|
||||
#include "log_common.h"
|
||||
#include "rpc_conn.h"
|
||||
|
||||
#define LOG_CONF_COSOLE_FILE_NAME "log-console.conf"
|
||||
|
||||
|
@ -15,7 +16,7 @@ static int write_console_content(FILE *fp, const u8 level, const char *filter_mo
|
|||
DIR *dir;
|
||||
|
||||
if ((dir = opendir(LOG_DEV_DIR)) == NULL) {
|
||||
ULOG_ERR(g_log, "Open dir:[%s] is failure:%d\n", LOG_DEV_DIR, strerror(errno));
|
||||
ULOG_ERR(g_log, "Open dir:[%s] is failure:%d", LOG_DEV_DIR, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -25,12 +26,12 @@ static int write_console_content(FILE *fp, const u8 level, const char *filter_mo
|
|||
if ((strcmp(ptr->d_name, ".") == 0)
|
||||
|| (strcmp(ptr->d_name, "..") == 0)
|
||||
|| (ptr->d_type == DT_DIR)) { ///current dir OR parrent dir
|
||||
ULOG_DEBUG(g_log,"The file:[%s] or directory jump over\n", ptr->d_name);
|
||||
ULOG_DEBUG(g_log,"The file:[%s] or directory jump over", ptr->d_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((strstr(ptr->d_name, "ttyS") == NULL)) {
|
||||
ULOG_DEBUG(g_log,"The file:[%s] isn't redirected\n", ptr->d_name);
|
||||
ULOG_DEBUG(g_log,"The file:[%s] isn't redirected", ptr->d_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -51,14 +52,29 @@ static int write_console_content(FILE *fp, const u8 level, const char *filter_mo
|
|||
|
||||
|
||||
static int config_log_console(const log_console_t *conf)
|
||||
{
|
||||
if (log_conf(conf->level, LOG_CONF_PATH, LOG_CONF_COSOLE_FILE_NAME, conf->module_name,
|
||||
write_console_content, NULL) != 0) {
|
||||
ULOG_ERR(g_log, "Log's console configure which is written is failure");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
switch (conf->on)
|
||||
{
|
||||
case LOG_OFF:
|
||||
ret = log_off_with_file(LOG_CONF_PATH, LOG_CONF_COSOLE_FILE_NAME);
|
||||
break;
|
||||
case LOG_ON:
|
||||
if (log_conf(conf->level, LOG_CONF_PATH, LOG_CONF_COSOLE_FILE_NAME, conf->module,
|
||||
write_console_content, NULL) != 0) {
|
||||
ULOG_ERR(g_log, "Log's console configure which is written is failure");
|
||||
ret = -1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ULOG_WARNING(g_log, "Unknown on value:%u", conf->on);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data)
|
||||
|
@ -71,6 +87,11 @@ void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer
|
|||
return;
|
||||
}
|
||||
|
||||
config_log_console((const log_console_t *)input);
|
||||
if (config_log_console((const log_console_t *)input) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring console of log is faiure");
|
||||
rpc_return_error(conn, RET_ERR, "Configuring console of log is faiure");
|
||||
return;
|
||||
}
|
||||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "log_file.h"
|
||||
#include "log_common.h"
|
||||
#include "ulog_in.h"
|
||||
#include "rpc_conn.h"
|
||||
|
||||
|
||||
#define LOG_CONF_FILE_NAME "log-file.conf"
|
||||
|
||||
|
@ -119,7 +122,8 @@ static int conf_log_file(const log_file_t *conf)
|
|||
|
||||
if (conf->del_over_size > 0) {
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -133,7 +137,11 @@ void rpc_conf_log_file(rpc_conn *conn, pointer input, int input_len, pointer dat
|
|||
return;
|
||||
}
|
||||
|
||||
conf_log_file((const log_file_t *)input);
|
||||
//rpc_return_null(conn);
|
||||
if (conf_log_file((const log_file_t *)input) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring file of log is faiure");
|
||||
rpc_return_error(conn, RET_ERR, "Configuring file of log is faiure");
|
||||
return;
|
||||
}
|
||||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,21 +7,8 @@
|
|||
#include "common_types.h"
|
||||
#include "rpc_common.h"
|
||||
#include "log_common.h"
|
||||
|
||||
typedef enum {
|
||||
LOG_UNCOMPRESS = 0,
|
||||
LOG_COMPRESS
|
||||
} log_compress_t;
|
||||
|
||||
typedef struct _log_file {
|
||||
u8 level;
|
||||
char path[MAX_PATH_SZ];
|
||||
log_compress_t is_compress;
|
||||
u32 del_over_days;
|
||||
u64 del_over_size;
|
||||
} log_file_t;
|
||||
#include "log_types.h"
|
||||
|
||||
void rpc_conf_log_file(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,13 +52,28 @@ static int write_pty_content(FILE *fp, const u8 level, const char *filter_mod, v
|
|||
|
||||
static int config_log_pty(const log_pty_t *conf)
|
||||
{
|
||||
if (log_conf(conf->level, LOG_CONF_PATH, LOG_CONF_PTY_FILE_NAME, conf->module_name,
|
||||
write_pty_content, NULL) != 0) {
|
||||
ULOG_ERR(g_log, "Log's pty configure which is written is failure");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
int ret = -1;
|
||||
|
||||
switch (conf->on)
|
||||
{
|
||||
case LOG_OFF:
|
||||
ret = log_off_with_file(LOG_CONF_PATH, LOG_CONF_PTY_FILE_NAME);
|
||||
break;
|
||||
case LOG_ON:
|
||||
if (log_conf(conf->level, LOG_CONF_PATH, LOG_CONF_PTY_FILE_NAME, conf->module,
|
||||
write_pty_content, NULL) != 0) {
|
||||
ULOG_ERR(g_log, "Log's pty configure which is written is failure");
|
||||
ret = -1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ULOG_WARNING(g_log, "Unknown on value:%u", conf->on);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rpc_conf_log_pty(rpc_conn *conn, pointer input, int input_len, pointer data)
|
||||
|
@ -71,6 +86,11 @@ void rpc_conf_log_pty(rpc_conn *conn, pointer input, int input_len, pointer data
|
|||
return;
|
||||
}
|
||||
|
||||
config_log_pty((const log_pty_t *)input);
|
||||
if (config_log_pty((const log_pty_t *)input) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring pty of log is faiure");
|
||||
rpc_return_error(conn, RET_ERR, "Configuring pty of log is faiure");
|
||||
return;
|
||||
}
|
||||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _LOG_PTY_H
|
||||
|
||||
#include "log_console.h"
|
||||
#include "rpc.h"
|
||||
|
||||
void rpc_conf_log_pty(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
|
||||
|
||||
#include "log_remote.h"
|
||||
#include "log_common.h"
|
||||
#include "ulog_in.h"
|
||||
#include "rpc_conn.h"
|
||||
|
||||
#define LOG_CONF_REMOTE_FILE_NAME "log-remote.conf"
|
||||
|
||||
|
@ -20,17 +22,6 @@ typedef enum {
|
|||
LOG_REMOTE_MAX
|
||||
} log_op_t;
|
||||
|
||||
|
||||
typedef struct _rfc_key_fmt {
|
||||
log_rfc_t rfc;
|
||||
char fmt[20];
|
||||
} rfc_key_fmt;
|
||||
|
||||
static rfc_key_fmt rfc_tbl[] = {
|
||||
{LOG_RFC_3164, "RFC3164fmt"},
|
||||
{LOG_RFC_5424, "RFC5424fmt"}
|
||||
};
|
||||
|
||||
typedef int (*op_func)(const log_remote_host_t *conf);
|
||||
|
||||
static int add_remote_host(const log_remote_host_t *conf);
|
||||
|
@ -94,7 +85,7 @@ static int remote_conf_content(FILE *fp, const u8 level, const char *filter_mod,
|
|||
while ((n = getline(&line, &n, bak_fp)) != -1) {
|
||||
int match = match_cb(line, arg);
|
||||
if (match == -1) {
|
||||
ULOG_ERR(g_log, "Configure which is matched is failure");
|
||||
ULOG_ERR(g_log, "Configuration which is matched is failure");
|
||||
} else if (match == 0) {
|
||||
ULOG_DEBUG(g_log, "Be matched");
|
||||
continue;
|
||||
|
@ -212,7 +203,7 @@ static int get_log_level()
|
|||
}
|
||||
|
||||
ssize_t n, n1, n2;
|
||||
char *line;
|
||||
char *line = NULL;
|
||||
u8 value;
|
||||
while ((n1 = getline(&line, &n, g_conf_fp)) != -1) {
|
||||
n2 = sscanf(line, LOG_CONF_KEY_REMOTE_LEVEL"%u", &value);
|
||||
|
@ -262,7 +253,7 @@ static int add_remote_host(const log_remote_host_t *conf)
|
|||
|
||||
static int del_remote_host(const log_remote_host_t *conf)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
char prefix[1] = "";
|
||||
|
||||
ULOG_INFO(g_log, "Deleting remote log server[%s:%u], rfc is %s", conf->host, conf->port, rfc_tbl[conf->rfc].fmt);
|
||||
|
@ -273,13 +264,19 @@ static int del_remote_host(const log_remote_host_t *conf)
|
|||
if (snprintf(redirect, sizeof(redirect), "%s@%s:%u:%s",
|
||||
prefix, conf->host, conf->port, rfc_tbl[conf->rfc].fmt) < 0) {
|
||||
ULOG_ERR(g_log, "Setting remote redirect[%s:%u:%s] is faulure", conf->host, conf->port, rfc_tbl[conf->rfc].fmt);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (log_conf(7, LOG_CONF_PATH, LOG_CONF_REMOTE_FILE_NAME, NULL,
|
||||
del_remote_conf_content, (void *)redirect) != 0) {
|
||||
int level = get_log_level();
|
||||
if (level == -1) {
|
||||
ULOG_ERR(g_log, "Getting log level is failure");
|
||||
return ret;
|
||||
}
|
||||
ret = log_conf(level, LOG_CONF_PATH, LOG_CONF_REMOTE_FILE_NAME, NULL,
|
||||
del_remote_conf_content, (void *)redirect);
|
||||
if (ret != 0) {
|
||||
ULOG_ERR(g_log, "Adding remote server[%s:%u:%s] is faulure", conf->host, conf->port, rfc_tbl[conf->rfc].fmt);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -344,7 +341,12 @@ static void rpc_conf_log_remote(const log_op_t op, rpc_conn *conn, point
|
|||
return;
|
||||
}
|
||||
|
||||
config_log_remote_host(op, (const log_remote_host_t *)input);
|
||||
if (config_log_remote_host(op, (const log_remote_host_t *)input) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring remote of log is faiure");
|
||||
rpc_return_error(conn, RET_ERR, "Configuring remote of log is faiure");
|
||||
return;
|
||||
}
|
||||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
void rpc_conf_log_add_remote(rpc_conn *conn, pointer input, int input_len, pointer data)
|
||||
|
@ -373,6 +375,11 @@ void rpc_conf_log_remote_level(rpc_conn *conn, pointer input, int input_len, poi
|
|||
return;
|
||||
}
|
||||
|
||||
config_log_remote_level((const log_remote_level_t *)input);
|
||||
if (config_log_remote_level((const log_remote_level_t *)input) != 0) {
|
||||
ULOG_ERR(g_log, "Configuring remote level of log is faiure");
|
||||
rpc_return_error(conn, RET_ERR, "Configuring remote level of log is faiure");
|
||||
return;
|
||||
}
|
||||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,21 +4,7 @@
|
|||
#include "ulog_api.h"
|
||||
#include "common_types.h"
|
||||
#include "rpc_common.h"
|
||||
|
||||
typedef enum {
|
||||
LOG_RFC_3164 = 0,
|
||||
LOG_RFC_5424
|
||||
} log_rfc_t;
|
||||
|
||||
typedef struct _log_remote_host {
|
||||
log_rfc_t rfc;
|
||||
char host[256];
|
||||
u16 port;
|
||||
} log_remote_host_t;
|
||||
|
||||
typedef struct _log_remote_level {
|
||||
u8 level;
|
||||
} log_remote_level_t;
|
||||
#include "log_types.h"
|
||||
|
||||
void rpc_conf_log_add_remote(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||
void rpc_conf_log_del_remote(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||
|
|
|
@ -84,12 +84,12 @@ int main(int argc, char **argv)
|
|||
ULOG_INFO(g_log, "Server of log schedule is started");
|
||||
|
||||
/* 注册配置处理函数 */
|
||||
rpc_server_regservice(server, SERVICE_LOG_FILE_NAME, "conf_log_file", rpc_conf_log_file);
|
||||
rpc_server_regservice(server, SERVICE_LOG_FILE_NAME, CONF_LOG_FILE_FUNC, rpc_conf_log_file);
|
||||
rpc_server_regservice(server, SERIVCE_LOG_CONSOLE_NAME, CONF_LOG_CONSOLE_FUNC, rpc_conf_log_console);
|
||||
rpc_server_regservice(server, SERVICE_LOG_PTY_NAME, "conf_log_pty", rpc_conf_log_pty);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_add_remote", rpc_conf_log_add_remote);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_del_remote", rpc_conf_log_del_remote);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_remote_level", rpc_conf_log_remote_level);
|
||||
rpc_server_regservice(server, SERVICE_LOG_PTY_NAME, CONF_LOG_PTY_FUNC, rpc_conf_log_pty);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_ADD_HOST_FUNC, rpc_conf_log_add_remote);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_DEL_HOST_FUNC, rpc_conf_log_del_remote);
|
||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, CONF_LOG_REMOTE_LEVEL_FUNC, rpc_conf_log_remote_level);
|
||||
/*
|
||||
|
||||
log_file_t log = {0};
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=userauthapi
|
||||
TARGET_NAME=libuserauthapi
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -34,35 +34,22 @@ PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
|||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common -I../../Platform/common/database
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common -I../../Platform/common
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared -L ../../Platform/build/debug
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
THIRDLIB_LINUX_DIR := ../../Platform/thirdparty/x86_64/usr/local/lib
|
||||
THIRDLIB_ARM64_DIR := ../../Platform/thirdparty/arm64/usr/local/lib
|
||||
PLATLIB_DIR := ../../Platform/build/debug
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./libdatabase-arm64.so
|
||||
ARM64_LIBS := -ldatabase-arm64
|
||||
ARM64_LIBS += -lcjson -lpthread -lm
|
||||
|
||||
LINUX_LIBS := ./libdatabase-linux.so
|
||||
LINUX_LIBS := -ldatabase-linux
|
||||
LINUX_LIBS += -lcjson -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += $(PLATLIB_DIR)/libdatabase-arm64.so $(THIRDLIB_ARM64_DIR)/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libdatabase-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += $(PLATLIB_DIR)/libdatabase-linux.so $(THIRDLIB_LINUX_DIR)/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./libdatabase-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=usermanager-test
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,7 +38,7 @@ PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
|||
PLAT_ARM64_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common \
|
||||
-I../../Platform/user/configm/config-server/include -I../../Platform/common/database -I../../Platform/common/redismq -I../../Platform/common/configm -I../../Platform/common/rpc -I../../Platform/common/rpc/hashtable \
|
||||
-I../user/user_manager/usermanager-auth \
|
||||
-I../../Platform/thirdparty/arm64/usr/local/include
|
||||
-I../../Platform/thirdparty/arm64/usr/local/include
|
||||
|
||||
PLAT_LINUX_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common \
|
||||
-I../../Platform/user/configm/config-server/include -I../../Platform/common/database -I../../Platform/common/redismq -I../../Platform/common/configm -I../../Platform/common/rpc -I../../Platform/common/rpc/hashtable \
|
||||
|
@ -46,33 +46,18 @@ PLAT_LINUX_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_co
|
|||
-I../../Platform/thirdparty/x86_64/usr/local/include
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS := -L ../../Platform/build/debug
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
THIRDLIB_LINUX_DIR := ../../Platform/thirdparty/x86_64/usr/local/lib
|
||||
THIRDLIB_ARM64_DIR := ../../Platform/thirdparty/arm64/usr/local/lib
|
||||
PLATLIB_DIR := ../../Platform/build/debug
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./userauthapi-arm64.so ./libredismq-arm64.so ./libdatabase-arm64.so
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
ARM64_LIBS += $(THIRDLIB_ARM64_DIR)/libodbc.so
|
||||
ARM64_LIBS := -luserauthapi-arm64 -lredismq-arm64 -ldatabase-arm64
|
||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lodbc
|
||||
|
||||
LINUX_LIBS := ./userauthapi-linux.so ./libredismq-linux.so ./libdatabase-linux.so
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||
LINUX_LIBS += $(THIRDLIB_LINUX_DIR)/libodbc.so
|
||||
LINUX_LIBS := -luserauthapi-linux -lredismq-linux -ldatabase-linux
|
||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis -lodbc
|
||||
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/userauthapi-arm64.so $(PLATLIB_DIR)/libredismq-arm64.so $(PLATLIB_DIR)/libdatabase-arm64.so $(THIRDLIB_ARM64_DIR)/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./userauthapi-arm64.so ./libredismq-arm64.so ./libdatabase-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/userauthapi-linux.so $(PLATLIB_DIR)/libredismq-linux.so $(PLATLIB_DIR)/libdatabase-linux.so $(THIRDLIB_LINUX_DIR)/libodbc.so
|
||||
USER_CLEAN_ITEMS += ./userauthapi-linux.so ./libredismq-linux.so ./libdatabase-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=webauth
|
||||
|
||||
# target
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
@ -38,25 +38,14 @@ PLAT_ARM64_CFLAGS := -I../../Common -I../../Platform/common -I../../Product/user
|
|||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_ARM64_LDFLAGS := -L ../../Platform/build/debug
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ./userauthapi-arm64.so
|
||||
LINUX_LIBS := -lcjson ./userauthapi-linux.so
|
||||
ARM64_LIBS := -luserauthapi-arm64 -ldatabase-arm64
|
||||
LINUX_LIBS := -lcjson -luserauthapi-linux -ldatabase-linux
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/userauthapi-arm64.so
|
||||
USER_CLEAN_ITEMS += ./userauthapi-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/userauthapi-linux.so
|
||||
USER_CLEAN_ITEMS += ./userauthapi-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
|
|
|
@ -15,22 +15,68 @@
|
|||
#include "../../common/cJSON/cJSON.h"
|
||||
#include "obj_api.h"
|
||||
|
||||
#define OBJ_DEV_NAME ("isg_objs")
|
||||
#define VERSION ("obj0.0.0.2")
|
||||
#define SHM_MEM_SIZE (1024 * 1024)
|
||||
/**
|
||||
* @def OBJ_DEV_NAME
|
||||
* @brief
|
||||
*/
|
||||
#define OBJ_DEV_NAME ("isg_objs") ///< 设备节点名称
|
||||
|
||||
/**
|
||||
* @def VERSION
|
||||
* @brief
|
||||
*/
|
||||
#define VERSION ("obj0.0.0.2")
|
||||
|
||||
/**
|
||||
* @def SHM_MEM_SIZE
|
||||
* @brief
|
||||
*/
|
||||
#define SHM_MEM_SIZE (1024 * 1024) ///< 1M字节共享内存
|
||||
|
||||
/**
|
||||
* @var typedef {anonOBJECT_DRV} OBJECT_DRV
|
||||
* @brief
|
||||
*/
|
||||
/**
|
||||
* @var typedef {anonOBJECT_DRV} POBJECT_DRV
|
||||
* @brief
|
||||
*/
|
||||
/**
|
||||
* @struct {anonOBJECT_DRV}
|
||||
* @brief
|
||||
*/
|
||||
typedef struct {
|
||||
struct class *dev_class;
|
||||
int dev_major;
|
||||
atomic_t ref_count;
|
||||
unsigned int mem_size;
|
||||
unsigned char *mem_buf;
|
||||
struct class *dev_class; ///< 设备类,用于自动在 /dev 下创建文件节点
|
||||
int dev_major; ///< 设备主版本号
|
||||
atomic_t ref_count; ///< 驱动程序打开计数
|
||||
unsigned int mem_size; ///< 共享内存大小
|
||||
unsigned char *mem_buf; ///< 共享内存指针
|
||||
} OBJECT_DRV, *POBJECT_DRV;
|
||||
|
||||
/**
|
||||
* @var g_obj_device
|
||||
* @brief
|
||||
* @see POBJECT_DRV
|
||||
*/
|
||||
static POBJECT_DRV g_obj_device = NULL;
|
||||
DEFINE_RWLOCK(g_obj_lock);
|
||||
|
||||
/**
|
||||
* @var g_obj_data
|
||||
* @brief
|
||||
* @see PCMHI_OBJECT
|
||||
*/
|
||||
PCMHI_OBJECT g_obj_data = NULL;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param buf
|
||||
* @param size
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
void obj_upgrade_dev_buffer(unsigned char *buf, unsigned int size)
|
||||
{
|
||||
if(buf && size < g_obj_device->mem_size - 1) {
|
||||
|
@ -41,21 +87,155 @@ void obj_upgrade_dev_buffer(unsigned char *buf, unsigned int size)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 根据对象名称获取对象
|
||||
*
|
||||
* @param name: 对象名称
|
||||
* @param type: 对象类型
|
||||
*
|
||||
* @return: 对象指针 或 NULL 空指针
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
PCMHI_OBJECT get_object(const char *name, int type)
|
||||
{
|
||||
PCMHI_OBJECT obj, tmp;
|
||||
PSERVER_OBJ_CONTENT req = NULL;
|
||||
|
||||
HASH_FIND_STR(g_obj_data, name, obj);
|
||||
|
||||
if(!obj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(type >= OBJ_TYPE_ADDR && type < OBJ_TYPE_MAX) {
|
||||
if(obj->type != type) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断当前服务是否在对象中
|
||||
*
|
||||
* @param obj: 对象指针
|
||||
* @param port: 协议端口
|
||||
* @param proType: 协议类型
|
||||
*
|
||||
* @return: 存在:0, 不存在:1
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
int item_belong_server_obj(PCMHI_OBJECT obj, __be16 port, int proType)
|
||||
{
|
||||
PSERVER_OBJ_CONTENT req = NULL;
|
||||
|
||||
if(!obj) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_for_each_entry(req, &obj->data->content, list) {
|
||||
if(proType == req->pro_type && port >= req->min_port && port <= req->max_port) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断当前时间是否在对象中
|
||||
*
|
||||
* @param obj: 对象指针
|
||||
* @param tm: 时间戳
|
||||
*
|
||||
* @return: 存在:0, 不存在:1
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
int item_belong_dt_obj(PCMHI_OBJECT obj, unsigned long tm)
|
||||
{
|
||||
PDT_OBJ_CONTENT req = NULL;
|
||||
|
||||
if(!obj) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_for_each_entry(req, &obj->data->content, list) {
|
||||
if(MODE_NONE == req->rep_mode && tm >= req->min_time && tm <= req->max_time) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断IPv4地址是否在对象中
|
||||
*
|
||||
* @param obj: 对象指针
|
||||
* @param addr: IPv4地址
|
||||
*
|
||||
* @return: 存在:0, 不存在:1
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
int ipv4_belong_addr_obj(PCMHI_OBJECT obj, __be32 addr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断IPv6地址是否在对象中
|
||||
*
|
||||
* @param obj: 对象指针
|
||||
* @param addr: IPv6地址
|
||||
*
|
||||
* @return: 存在:0, 不存在:1
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
int ipv6_belong_addr_obj(PCMHI_OBJECT obj, unsigned char addr[16])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static int obj_proc_init(void)
|
||||
{
|
||||
return server_proc_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static int obj_proc_uninit(void)
|
||||
{
|
||||
return server_proc_uninit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
const char *obj_version(void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
PCMHI_OBJECT new_object(void)
|
||||
{
|
||||
PCMHI_OBJECT obj = (PCMHI_OBJECT)kmalloc(sizeof(CMHI_OBJECT), GFP_KERNEL);
|
||||
|
@ -71,6 +251,14 @@ PCMHI_OBJECT new_object(void)
|
|||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pObj
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
void free_object(PCMHI_OBJECT pObj)
|
||||
{
|
||||
if(pObj) {
|
||||
|
@ -78,9 +266,15 @@ void free_object(PCMHI_OBJECT pObj)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
void object_init(void)
|
||||
{
|
||||
PCMHI_OBJECT pObj = create_server_object("list1", OBJ_TYPE_SERVER);
|
||||
PCMHI_OBJECT pObj = create_server_object("list1");
|
||||
|
||||
if(!pObj) {
|
||||
printk(KERN_ERR "%s(%d): Create Object Error\n", __FUNCTION__, __LINE__);
|
||||
|
@ -105,6 +299,12 @@ void object_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
void object_uninit(void)
|
||||
{
|
||||
PCMHI_OBJECT obj, tmp;
|
||||
|
@ -115,20 +315,50 @@ void object_uninit(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param inode
|
||||
* @param filp
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static int obj_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
// 增加引用计数
|
||||
atomic_inc(&g_obj_device->ref_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param inode
|
||||
* @param filp
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static int obj_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
// 减少引用计数
|
||||
atomic_dec(&g_obj_device->ref_count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param fd
|
||||
* @param vma
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
int obj_mmap(struct file *fd, struct vm_area_struct *vma)
|
||||
{
|
||||
// 重新映射内存页表
|
||||
int ret = remap_pfn_range(vma, vma->vm_start,
|
||||
virt_to_phys(g_obj_device->mem_buf) >> PAGE_SHIFT,
|
||||
g_obj_device->mem_size,
|
||||
|
@ -136,12 +366,22 @@ int obj_mmap(struct file *fd, struct vm_area_struct *vma)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var obj_fops
|
||||
* @brief
|
||||
*/
|
||||
static struct file_operations obj_fops = {
|
||||
.open = obj_open,
|
||||
.release = obj_release,
|
||||
.mmap = obj_mmap,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static int object_module_init(void)
|
||||
{
|
||||
struct page *p = NULL;
|
||||
|
@ -149,11 +389,13 @@ static int object_module_init(void)
|
|||
|
||||
printk(KERN_INFO "Hello ISG objects manager version: %s\n", VERSION);
|
||||
|
||||
// 自动分配设备版本号
|
||||
if(alloc_chrdev_region(&dev, 0, 1, OBJ_DEV_NAME) != 0) {
|
||||
printk(KERN_ERR "Alloc driver dev id error\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
// 分配驱动程序结构内存
|
||||
g_obj_device = (POBJECT_DRV)kmalloc(sizeof(OBJECT_DRV), GFP_KERNEL);
|
||||
|
||||
if(g_obj_device == NULL) {
|
||||
|
@ -162,8 +404,10 @@ static int object_module_init(void)
|
|||
}
|
||||
|
||||
memset(g_obj_device, 0, sizeof(OBJECT_DRV));
|
||||
g_obj_device->dev_major = MAJOR(dev);
|
||||
g_obj_device->dev_major = MAJOR(dev); // 保存驱动版本号
|
||||
atomic_set(&g_obj_device->ref_count, 0);
|
||||
|
||||
// 初始化共享内存
|
||||
g_obj_device->mem_size = PAGE_ALIGN(SHM_MEM_SIZE);
|
||||
g_obj_device->mem_buf = (unsigned char *)__get_free_pages(GFP_KERNEL, get_order(g_obj_device->mem_size));
|
||||
|
||||
|
@ -180,11 +424,15 @@ static int object_module_init(void)
|
|||
}
|
||||
|
||||
memset(g_obj_device->mem_buf, 0, g_obj_device->mem_size);
|
||||
// 注册字符设备
|
||||
register_chrdev(g_obj_device->dev_major, OBJ_DEV_NAME, &obj_fops);
|
||||
// 创建字符设备类
|
||||
g_obj_device->dev_class = class_create(THIS_MODULE, "obj");
|
||||
// 创建字符设备节点
|
||||
device_create(g_obj_device->dev_class, NULL, MKDEV(g_obj_device->dev_major, 0),
|
||||
NULL, "isg_objs/dev%d", 0);
|
||||
|
||||
// 初始化 proc 接口
|
||||
obj_proc_init();
|
||||
object_init();
|
||||
|
||||
|
@ -192,6 +440,12 @@ static int object_module_init(void)
|
|||
}
|
||||
module_init(object_module_init);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/07
|
||||
*/
|
||||
static void __exit object_module_exit(void)
|
||||
{
|
||||
struct page *p = NULL;
|
||||
|
|
|
@ -11,34 +11,90 @@
|
|||
#define OBJ_DBG_DIR ("obj")
|
||||
|
||||
typedef int (*belong_server_objs)(__be32, int);
|
||||
typedef int (*belong_dt_objs)(unsigned long, int);
|
||||
|
||||
typedef enum {
|
||||
OBJ_TYPE_ADDR = 0,
|
||||
OBJ_TYPE_SERVER,
|
||||
OBJ_TYPE_DATETIME,
|
||||
OBJ_TYPE_ADDR = 0, ///< 地址对象
|
||||
OBJ_TYPE_SERVER, ///< 服务对象
|
||||
OBJ_TYPE_DATETIME, ///< 日期时间对象
|
||||
OBJ_TYPE_MAX
|
||||
} OBJ_TYPES;
|
||||
|
||||
typedef enum {
|
||||
MODE_NONE = 1, ///< 不重复
|
||||
MODE_EVERY_DAY = 2, ///< 每天重复
|
||||
MODE_WORKDAY = 3, ///< 工作日重复
|
||||
MODE_WEEKEND = 4, ///< 周末重复
|
||||
MODE_WEEKDAY = 5, ///< 非周末重复
|
||||
MODE_EVERY_MONTH_DAY = 6, ///< 每月重复
|
||||
MODE_EVERY_YEAR_DAY = 7, ///< 每年重复
|
||||
MODE_MONTH_LAST_DAY = 8, ///< 每月最后一天重复
|
||||
MODE_HOLIDAY = 9, ///< 节假日重复
|
||||
MODE_MAX
|
||||
} REPEAT_MODE;
|
||||
|
||||
typedef enum {
|
||||
IP_V4 = 0, ///< IPv4 协议
|
||||
IP_V6, ///< IPv6 协议
|
||||
IP_VER_MAX
|
||||
} IP_VERSION;
|
||||
|
||||
typedef struct {
|
||||
__be16 min_port;
|
||||
__be16 max_port;
|
||||
int pro_type;
|
||||
__be32 ip4_add; ///< IPv4 地址
|
||||
unsigned char net_mask; ///< IPv4 子网掩码 FF.FF.FF.FF 格式
|
||||
} IP4_ADDR, *PIP4_ADDR;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned char addr8[16]; ///< IPv6 地址, 字节表示形式
|
||||
__be16 addr16[8]; ///< IPv6 地址, 双字节表示形式
|
||||
__be32 addr32[4]; ///< IPv6 地址, 4字节表示形式
|
||||
} addr;
|
||||
unsigned char net_mask; ///< IPv6 子网掩码, :/24 格式
|
||||
} IP6_ADDR, *PIP6_ADDR;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
IP4_ADDR addr_v4; ///< IPv4 地址
|
||||
IP6_ADDR addr_v6; ///< IPv6 地址
|
||||
} min_addr; ///< 最小 IP 地址
|
||||
union {
|
||||
IP4_ADDR addr_v4; ///< IPv4 地址
|
||||
IP6_ADDR addr_v6; ///< IPv6 地址
|
||||
} max_addr; ///< 最大 IP 地址
|
||||
IP_VERSION ip_version; ///< IP地址类型
|
||||
struct list_head list;
|
||||
} ADDR_OBJ_CONTENT, *PADDR_OBJ_CONTENT;
|
||||
|
||||
typedef struct {
|
||||
__be16 min_port; ///< 最小端口
|
||||
__be16 max_port; ///< 最大端口
|
||||
int pro_type; ///< 协议类型
|
||||
struct list_head list;
|
||||
} SERVER_OBJ_CONTENT, *PSERVER_OBJ_CONTENT;
|
||||
|
||||
typedef struct {
|
||||
struct list_head content;
|
||||
belong_server_objs callback;
|
||||
unsigned long min_time; ///< 起始时间
|
||||
unsigned long max_time; ///< 终止时间
|
||||
REPEAT_MODE rep_mode; ///< 重复模式
|
||||
struct list_head list;
|
||||
} DT_OBJ_CONTENT, *PDT_OBJ_CONTENT;
|
||||
|
||||
typedef struct {
|
||||
struct list_head content; ///< 数据链表头
|
||||
union {
|
||||
belong_server_objs callback;
|
||||
};
|
||||
} OBJECT_DATA, *POBJECT_DATA;
|
||||
|
||||
typedef struct {
|
||||
char name[MAX_NAME_LEN];
|
||||
char desc[MAX_PATH];
|
||||
OBJ_TYPES type;
|
||||
POBJECT_DATA data;
|
||||
atomic_t ref_count;
|
||||
rwlock_t lock;
|
||||
UT_hash_handle hh;
|
||||
char name[MAX_NAME_LEN]; ///< 对象名称
|
||||
char desc[MAX_PATH]; ///< 对象说明
|
||||
OBJ_TYPES type; ///< 对象类型
|
||||
POBJECT_DATA data; ///< 对象数据
|
||||
atomic_t ref_count; ///< 对象引用计数
|
||||
rwlock_t lock; ///< 对象锁
|
||||
UT_hash_handle hh; ///< Hash链表头
|
||||
} CMHI_OBJECT, *PCMHI_OBJECT;
|
||||
|
||||
void obj_upgrade_dev_buffer(unsigned char* buf, unsigned int size);
|
||||
|
@ -47,7 +103,7 @@ void object_init(void);
|
|||
void free_object(PCMHI_OBJECT pObj);
|
||||
PCMHI_OBJECT new_object(void);
|
||||
|
||||
PCMHI_OBJECT create_server_object(const char *name, OBJ_TYPES type);
|
||||
PCMHI_OBJECT create_server_object(const char *name);
|
||||
void cleanup_server_object(PCMHI_OBJECT pObj);
|
||||
int add_server_obj_data(PCMHI_OBJECT pObj, __be16 minPort, __be32 maxPort, int proType);
|
||||
int server_proc_init(void);
|
||||
|
|
|
@ -5,11 +5,30 @@
|
|||
|
||||
#include "obj_api.h"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param port
|
||||
* @param proType
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
static int server_objs_cmp(__be32 port, int proType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param minPort
|
||||
* @param maxPort
|
||||
* @param proType
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
static PSERVER_OBJ_CONTENT new_server_content(__be16 minPort, __be16 maxPort, int proType)
|
||||
{
|
||||
PSERVER_OBJ_CONTENT dt = (PSERVER_OBJ_CONTENT)kmalloc(sizeof(SERVER_OBJ_CONTENT), GFP_KERNEL);
|
||||
|
@ -19,28 +38,51 @@ static PSERVER_OBJ_CONTENT new_server_content(__be16 minPort, __be16 maxPort, in
|
|||
} else {
|
||||
memset(dt, 0, sizeof(SERVER_OBJ_CONTENT));
|
||||
dt->min_port = minPort;
|
||||
dt->max_port = maxPort;
|
||||
|
||||
if(maxPort < minPort) {
|
||||
dt->max_port = minPort;
|
||||
} else {
|
||||
dt->max_port = maxPort;
|
||||
}
|
||||
|
||||
dt->pro_type = proType;
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
static POBJECT_DATA new_server_object(void)
|
||||
{
|
||||
POBJECT_DATA obj = (POBJECT_DATA)kmalloc(sizeof(POBJECT_DATA), GFP_KERNEL);
|
||||
POBJECT_DATA obj = (POBJECT_DATA)kmalloc(sizeof(OBJECT_DATA), GFP_KERNEL);
|
||||
|
||||
if(obj == NULL) {
|
||||
printk(KERN_ERR "Malloc CMHI_OBJECT Error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(obj, 0, sizeof(CMHI_OBJECT));
|
||||
memset(obj, 0, sizeof(OBJECT_DATA));
|
||||
|
||||
obj->callback = server_objs_cmp;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加服务到服务对象中
|
||||
*
|
||||
* @param pObj: 对象指针
|
||||
* @param minPort: 最小端口
|
||||
* @param proType: 协议类型
|
||||
* @param maxPort: 最大端口
|
||||
*
|
||||
* @return: 0: 添加成功; -EINVAL: 参数错误; -ENOMEM: 分配内存错误
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
int add_server_obj_data(PCMHI_OBJECT pObj, __be16 minPort, __be32 maxPort, int proType)
|
||||
{
|
||||
PSERVER_OBJ_CONTENT dt;
|
||||
|
@ -57,14 +99,20 @@ int add_server_obj_data(PCMHI_OBJECT pObj, __be16 minPort, __be32 maxPort, int p
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
//write_lock(&pObj->lock);
|
||||
list_add_tail(&dt->list, &pObj->data->content);
|
||||
//write_unlock(&pObj->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PCMHI_OBJECT create_server_object(const char *name, OBJ_TYPES type)
|
||||
/**
|
||||
* @brief 创建服务对象
|
||||
*
|
||||
* @param name: 对象名称
|
||||
*
|
||||
* @return: 失败: NULL; 成功: 返回新建对象指针
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
PCMHI_OBJECT create_server_object(const char *name)
|
||||
{
|
||||
POBJECT_DATA pObjData = NULL;
|
||||
PCMHI_OBJECT pObj = new_object();
|
||||
|
@ -83,13 +131,21 @@ PCMHI_OBJECT create_server_object(const char *name, OBJ_TYPES type)
|
|||
}
|
||||
|
||||
strncpy(pObj->name, name, MAX_NAME_LEN - 1);
|
||||
pObj->type = type;
|
||||
pObj->type = OBJ_TYPE_SERVER;
|
||||
pObj->data = pObjData;
|
||||
INIT_LIST_HEAD(&pObj->data->content);
|
||||
|
||||
return pObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清理对象资源
|
||||
*
|
||||
* @param pObj: 对象指针
|
||||
*
|
||||
* @return
|
||||
* @date 2019/08/05
|
||||
*/
|
||||
void cleanup_server_object(PCMHI_OBJECT pObj)
|
||||
{
|
||||
PSERVER_OBJ_CONTENT req = NULL, temp_req = NULL;
|
||||
|
@ -98,12 +154,11 @@ void cleanup_server_object(PCMHI_OBJECT pObj)
|
|||
return;
|
||||
}
|
||||
|
||||
//write_lock(&pObj->lock);
|
||||
list_for_each_entry_safe(req, temp_req, &pObj->data->content, list) {
|
||||
list_del(&req->list);
|
||||
kfree(req);
|
||||
}
|
||||
//write_unlock(&pObj->lock);
|
||||
|
||||
kfree(pObj->data);
|
||||
kfree(pObj);
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
#define PROC_API_DBG_DIR ("api")
|
||||
|
||||
typedef struct {
|
||||
char key[MAX_PATH];
|
||||
char dir_name[MAX_NAME_LEN];
|
||||
PDBGFS_PRIV data;
|
||||
struct proc_dir_entry* entry;
|
||||
UT_hash_handle hh;
|
||||
char key[MAX_PATH]; ///< 节点名称
|
||||
char dir_name[MAX_NAME_LEN]; ///< 目录名称
|
||||
PDBGFS_PRIV data; ///< 节点数据
|
||||
struct proc_dir_entry* entry; ///< proc 目录数据结构
|
||||
UT_hash_handle hh; ///< Hash链表节点
|
||||
} PROC_INFO, *PPROC_INFO;
|
||||
|
||||
static const struct file_operations g_DbgSeq_fops;
|
||||
|
@ -116,13 +116,19 @@ static void proc_api_uninit(const char* proc_dir_name)
|
|||
remove_proc_entry(proc_dir_name, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 注册proc模块
|
||||
*
|
||||
* @param pv: 模块proc信息
|
||||
* @return int: 0 成功, -EINVAL 参数错误
|
||||
*/
|
||||
int proc_api_register(PPROC_API pv)
|
||||
{
|
||||
struct proc_dir_entry* pdir;
|
||||
int i = 0;
|
||||
|
||||
if(pv == NULL || pv->data == NULL || pv->num_data <= 0) {
|
||||
return ERR_PARA_OUTOFRANGE;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if(pv->dir_name && strlen(pv->dir_name) > 0) {
|
||||
|
@ -162,9 +168,15 @@ int proc_api_register(PPROC_API pv)
|
|||
write_unlock(&g_proc_lock);
|
||||
}
|
||||
|
||||
return ERR_DBGFS_NO_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清除proc模块注册
|
||||
*
|
||||
* @param pv: 模块proc信息
|
||||
* @return int: 0 成功, -EINVAL 参数错误
|
||||
*/
|
||||
int proc_api_unregister(PPROC_API pv)
|
||||
{
|
||||
PPROC_INFO pInfo = NULL;
|
||||
|
@ -172,7 +184,7 @@ int proc_api_unregister(PPROC_API pv)
|
|||
int i;
|
||||
|
||||
if(pv == NULL || pv->data == NULL || pv->num_data <= 0) {
|
||||
return ERR_PARA_OUTOFRANGE;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < pv->num_data; i++) {
|
||||
|
@ -199,7 +211,7 @@ int proc_api_unregister(PPROC_API pv)
|
|||
remove_proc_subtree(pv->dir_name, g_DebugProcFS);
|
||||
}
|
||||
|
||||
return ERR_DBGFS_NO_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int proc_seq_open(struct inode* inode, struct file* file)
|
||||
|
@ -243,6 +255,15 @@ static int get_value_base(unsigned char* pBuf)
|
|||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取参数中的字符串数据类型值
|
||||
*
|
||||
* @param pBuf: 字符串缓冲区
|
||||
* @param index: 指定参数位置
|
||||
* @param pValue: 返回提取的字符串值
|
||||
* @param maxBytes: 最大参数限制
|
||||
* @return int: 0 成功, -EINVAL 参数错误,-ENOENT 没有对应的值
|
||||
*/
|
||||
int get_string_value(unsigned char* pBuf, int index, unsigned char* pValue, unsigned int maxBytes)
|
||||
{
|
||||
char tmpBuf[128];
|
||||
|
@ -251,7 +272,7 @@ int get_string_value(unsigned char* pBuf, int index, unsigned char* pValue, unsi
|
|||
int paramIndex = 0;
|
||||
|
||||
if(pBuf == NULL || index < 0 || pValue == NULL) {
|
||||
return ERR_PARA_OUTOFRANGE;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(pValue, 0, maxBytes);
|
||||
|
@ -269,14 +290,22 @@ int get_string_value(unsigned char* pBuf, int index, unsigned char* pValue, unsi
|
|||
|
||||
strcpy(pValue, token);
|
||||
|
||||
return ERR_DBGFS_NO_ERROR;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ERR_DBGFS_WRITEOPTS;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
int get_int_value(unsigned char* pBuf, int index)
|
||||
/**
|
||||
* @brief 从参数的指定位置提取整数值
|
||||
*
|
||||
* @param pBuf: 字符串缓冲区
|
||||
* @param index: 指定参数位置
|
||||
* @param pValue: 返回获取的值
|
||||
* @return int: 0 成功, -EINVAL 参数错误,-ENOENT 没有对应的值,-EFAULT 字符串转整数错误
|
||||
*/
|
||||
int get_int_value(unsigned char* pBuf, int index, int* pValue)
|
||||
{
|
||||
char tmpBuf[128];
|
||||
char* token;
|
||||
|
@ -284,8 +313,8 @@ int get_int_value(unsigned char* pBuf, int index)
|
|||
int paramIndex = 0;
|
||||
int paramValue = -1;
|
||||
|
||||
if(pBuf == NULL || index < 0) {
|
||||
return -1;
|
||||
if(pBuf == NULL || index < 0 || pValue == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
strcpy(tmpBuf, pBuf);
|
||||
|
@ -301,14 +330,15 @@ int get_int_value(unsigned char* pBuf, int index)
|
|||
|
||||
if(kstrtol(token, get_value_base(token), (long*)¶mValue) != 0) {
|
||||
printk(KERN_ERR "strict_strtol [%s] Error\n", token);
|
||||
return -1;
|
||||
return -EFAULT;
|
||||
} else {
|
||||
return paramValue;
|
||||
*pValue = paramValue;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int process_input_content(struct seq_file* seq, unsigned char* pBuf, PDBGFS_PRIV pv)
|
||||
|
|
|
@ -19,25 +19,25 @@ typedef enum {
|
|||
} PROC_ERRCODE;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
unsigned int params;
|
||||
unsigned long mask;
|
||||
char* cmd;
|
||||
char* cmd_data;
|
||||
int (* show)(struct seq_file*, void*);
|
||||
int (* ioctl)(struct seq_file*, void*);
|
||||
int (* help)(struct seq_file*, void*);
|
||||
const char* name; ///< 节点名称
|
||||
unsigned int params; ///< 参数
|
||||
unsigned long mask; ///< 命令掩码
|
||||
char* cmd; ///< 命令
|
||||
char* cmd_data; ///< 命令参数
|
||||
int (* show)(struct seq_file*, void*); ///< 输出接口
|
||||
int (* ioctl)(struct seq_file*, void*); ///< 输入接口
|
||||
int (* help)(struct seq_file*, void*); ///< 帮助接口
|
||||
} DBGFS_PRIV, *PDBGFS_PRIV;
|
||||
|
||||
typedef struct {
|
||||
const char* dir_name;
|
||||
PDBGFS_PRIV data;
|
||||
int num_data;
|
||||
const char* dir_name; ///< 目录名称
|
||||
PDBGFS_PRIV data; ///< 节点数组
|
||||
int num_data; ///< 节点个数
|
||||
} PROC_API, *PPROC_API;
|
||||
|
||||
int proc_api_register(PPROC_API pv);
|
||||
int proc_api_unregister(PPROC_API pv);
|
||||
int get_int_value(unsigned char* pBuf, int index);
|
||||
int get_int_value(unsigned char* pBuf, int index, int* pValue);
|
||||
int get_string_value(unsigned char* pBuf, int index, unsigned char* pValue, unsigned int maxBytes);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
#include "offline_user_force.h"
|
||||
#include "user_auth.h"
|
||||
#include "redisMq.h"
|
||||
#include "cjson/cJSON.h"
|
||||
|
||||
/* 回调函数-按照userid强制下线用户 */
|
||||
void offline_userid_func_recv(struct RecvMsg_t *mmsg)
|
||||
{
|
||||
if (!mmsg->msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON * root = cJSON_Parse(mmsg->msg);
|
||||
if (!root)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int num_ids = cJSON_GetArraySize(root);
|
||||
|
||||
int ids[num_ids];
|
||||
for (int i = 0; i < num_ids; i++)
|
||||
{
|
||||
cJSON * uid = cJSON_GetArrayItem(root, i);
|
||||
if (!uid)
|
||||
{
|
||||
cJSON_Delete(root);
|
||||
return;
|
||||
}
|
||||
ids[i] = uid->valueint;
|
||||
}
|
||||
|
||||
reset_online_by_userid(ids, num_ids);
|
||||
|
||||
printf("%s,%d,%llu,%s,%d\n", __FUNCTION__, __LINE__, pthread_self(), mmsg->msg, mmsg->len);
|
||||
freeMsg(mmsg);
|
||||
}
|
||||
|
||||
/* 回调函数-按照groupid强制下线用户 */
|
||||
void offline_groupid_func_recv(struct RecvMsg_t *mmsg)
|
||||
{
|
||||
if (!mmsg->msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON * root = cJSON_Parse(mmsg->msg);
|
||||
if(!root)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int num_gids = cJSON_GetArraySize(root);
|
||||
|
||||
int gids[num_gids];
|
||||
|
||||
for (int i = 0; i < num_gids; i++)
|
||||
{
|
||||
cJSON * gid = cJSON_GetArrayItem(root, i);
|
||||
if (!gid)
|
||||
{
|
||||
cJSON_Delete(root);
|
||||
return;
|
||||
}
|
||||
gids[i] = gid->valueint;
|
||||
}
|
||||
|
||||
reset_online_by_groupid(gids);
|
||||
|
||||
printf("%s,%d,%llu,%s,%d\n", __FUNCTION__, __LINE__, pthread_self(), mmsg->msg, mmsg->len);
|
||||
freeMsg(mmsg);
|
||||
}
|
||||
|
||||
/* 消费者订阅 */
|
||||
void redis_consunmer_usermanager(CONINFO * consumer_info)
|
||||
{
|
||||
if(NULL == consumer_info || NULL == consumer_info->topic || NULL == consumer_info->func)
|
||||
{
|
||||
printf("redis_consunmer_usermanager -> NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = redisSubInit(8);
|
||||
if (!ret)
|
||||
{
|
||||
//printf("Init failed.\n");
|
||||
return;
|
||||
}
|
||||
redisRegisterChannelFunc(consumer_info->topic,consumer_info->func);
|
||||
|
||||
ret = redisSubConnect();
|
||||
if (!ret)
|
||||
{
|
||||
//printf("Connect failed.\n");
|
||||
return;
|
||||
}
|
||||
redisSubscriber(consumer_info->topic);
|
||||
|
||||
while (true)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
redisSubDisconnect();
|
||||
redisSubUninit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* */
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef OFFLINE_USER_FROCE_H_
|
||||
#define OFFLINE_USER_FROCE_H_
|
||||
|
||||
#include "redisMq.h"
|
||||
|
||||
typedef struct consumer_info
|
||||
{
|
||||
char * topic; //订阅频道
|
||||
pChanneCallBack func; //回调函数
|
||||
}CONINFO;
|
||||
|
||||
|
||||
/* 消费者订阅-按用户ID或用户组id下线 */
|
||||
void redis_consunmer_usermanager(CONINFO * consumer_info);
|
||||
|
||||
/* 按ip下线用户 */
|
||||
|
||||
|
||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <cjson/cJSON.h>
|
||||
#include "user_auth.h"
|
||||
#include "database.h"
|
||||
#include "database/database.h"
|
||||
|
||||
#define NOT_LOCK 0
|
||||
#define DATA_EMPTY 0
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 288acf97a15d558f96c24c89f578b724d6e06b0c
|
|
@ -0,0 +1 @@
|
|||
Subproject commit ac49287c3dc5abd92545024484194275ce7899fd
|
|
@ -0,0 +1 @@
|
|||
Subproject commit eb70fef8ca86363a036a962852808675ed1598c1
|
|
@ -0,0 +1 @@
|
|||
Subproject commit d0b87ee87b282e9b91a1af924050e217b0b2ae8b
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6868939663c5be4907840012de471158d886b7bf
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 93823e6ca699df195a6c7b8bfa6006ec40ee0003
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9c151f3c3413c5ee6bad498aca84be481196bbc7
|
|
@ -0,0 +1,314 @@
|
|||
#! /usr/bin/perl -w
|
||||
|
||||
# Script to turn PCRE2 man pages into HTML
|
||||
|
||||
|
||||
# Subroutine to handle font changes and other escapes
|
||||
|
||||
sub do_line {
|
||||
my($s) = $_[0];
|
||||
|
||||
$s =~ s/</</g; # Deal with < and >
|
||||
$s =~ s/>/>/g;
|
||||
$s =~ s"\\fI(.*?)\\f[RP]"<i>$1</i>"g;
|
||||
$s =~ s"\\fB(.*?)\\f[RP]"<b>$1</b>"g;
|
||||
$s =~ s"\\e"\\"g;
|
||||
$s =~ s/(?<=Copyright )\(c\)/©/g;
|
||||
$s;
|
||||
}
|
||||
|
||||
# Subroutine to ensure not in a paragraph
|
||||
|
||||
sub end_para {
|
||||
if ($inpara)
|
||||
{
|
||||
print TEMP "</PRE>\n" if ($inpre);
|
||||
print TEMP "</P>\n";
|
||||
}
|
||||
$inpara = $inpre = 0;
|
||||
$wrotetext = 0;
|
||||
}
|
||||
|
||||
# Subroutine to start a new paragraph
|
||||
|
||||
sub new_para {
|
||||
&end_para();
|
||||
print TEMP "<P>\n";
|
||||
$inpara = 1;
|
||||
}
|
||||
|
||||
|
||||
# Main program
|
||||
|
||||
$innf = 0;
|
||||
$inpara = 0;
|
||||
$inpre = 0;
|
||||
$wrotetext = 0;
|
||||
$toc = 0;
|
||||
$ref = 1;
|
||||
|
||||
while ($#ARGV >= 0 && $ARGV[0] =~ /^-/)
|
||||
{
|
||||
$toc = 1 if $ARGV[0] eq "-toc";
|
||||
shift;
|
||||
}
|
||||
|
||||
# Initial output to STDOUT
|
||||
|
||||
print <<End ;
|
||||
<html>
|
||||
<head>
|
||||
<title>$ARGV[0] specification</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
|
||||
<h1>$ARGV[0] man page</h1>
|
||||
<p>
|
||||
Return to the <a href="index.html">PCRE2 index page</a>.
|
||||
</p>
|
||||
<p>
|
||||
This page is part of the PCRE2 HTML documentation. It was generated
|
||||
automatically from the original man page. If there is any nonsense in it,
|
||||
please consult the man page, in case the conversion went wrong.
|
||||
<br>
|
||||
End
|
||||
|
||||
print "<ul>\n" if ($toc);
|
||||
|
||||
open(TEMP, ">/tmp/$$") || die "Can't open /tmp/$$ for output\n";
|
||||
|
||||
while (<STDIN>)
|
||||
{
|
||||
# Handle lines beginning with a dot
|
||||
|
||||
if (/^\./)
|
||||
{
|
||||
# Some of the PCRE2 man pages used to contain instances of .br. However,
|
||||
# they should have all been removed because they cause trouble in some
|
||||
# (other) automated systems that translate man pages to HTML. Complain if
|
||||
# we find .br or .in (another macro that is deprecated).
|
||||
|
||||
if (/^\.br/ || /^\.in/)
|
||||
{
|
||||
print STDERR "\n*** Deprecated macro encountered - rewrite needed\n";
|
||||
print STDERR "*** $_\n";
|
||||
die "*** Processing abandoned\n";
|
||||
}
|
||||
|
||||
# Instead of .br, relevent "literal" sections are enclosed in .nf/.fi.
|
||||
|
||||
elsif (/^\.nf/)
|
||||
{
|
||||
$innf = 1;
|
||||
}
|
||||
|
||||
elsif (/^\.fi/)
|
||||
{
|
||||
$innf = 0;
|
||||
}
|
||||
|
||||
# Handling .sp is subtle. If it is inside a literal section, do nothing if
|
||||
# the next line is a non literal text line; similarly, if not inside a
|
||||
# literal section, do nothing if a literal follows, unless we are inside
|
||||
# a .nf/.fi section or about to enter one. The point being that the <pre>
|
||||
# and </pre> that delimit literal sections will do the spacing. Always skip
|
||||
# if no previous output.
|
||||
|
||||
elsif (/^\.sp/)
|
||||
{
|
||||
if ($wrotetext)
|
||||
{
|
||||
$_ = <STDIN>;
|
||||
if ($inpre)
|
||||
{
|
||||
print TEMP "\n" if (/^[\s.]/);
|
||||
}
|
||||
else
|
||||
{
|
||||
print TEMP "<br>\n<br>\n" if ($innf || /^\.nf/ || !/^[\s.]/);
|
||||
}
|
||||
redo; # Now process the lookahead line we just read
|
||||
}
|
||||
}
|
||||
elsif (/^\.TP/ || /^\.PP/ || /^\.P/)
|
||||
{
|
||||
&new_para();
|
||||
}
|
||||
elsif (/^\.SH\s*("?)(.*)\1/)
|
||||
{
|
||||
# Ignore the NAME section
|
||||
if ($2 =~ /^NAME\b/)
|
||||
{
|
||||
<STDIN>;
|
||||
next;
|
||||
}
|
||||
|
||||
&end_para();
|
||||
my($title) = &do_line($2);
|
||||
if ($toc)
|
||||
{
|
||||
printf("<li><a name=\"TOC%d\" href=\"#SEC%d\">$title</a>\n",
|
||||
$ref, $ref);
|
||||
printf TEMP ("<br><a name=\"SEC%d\" href=\"#TOC1\">$title</a><br>\n",
|
||||
$ref);
|
||||
$ref++;
|
||||
}
|
||||
else
|
||||
{
|
||||
print TEMP "<br><b>\n$title\n</b><br>\n";
|
||||
}
|
||||
}
|
||||
elsif (/^\.SS\s*("?)(.*)\1/)
|
||||
{
|
||||
&end_para();
|
||||
my($title) = &do_line($2);
|
||||
print TEMP "<br><b>\n$title\n</b><br>\n";
|
||||
}
|
||||
elsif (/^\.B\s*(.*)/)
|
||||
{
|
||||
&new_para() if (!$inpara);
|
||||
$_ = &do_line($1);
|
||||
s/"(.*?)"/$1/g;
|
||||
print TEMP "<b>$_</b>\n";
|
||||
$wrotetext = 1;
|
||||
}
|
||||
elsif (/^\.I\s*(.*)/)
|
||||
{
|
||||
&new_para() if (!$inpara);
|
||||
$_ = &do_line($1);
|
||||
s/"(.*?)"/$1/g;
|
||||
print TEMP "<i>$_</i>\n";
|
||||
$wrotetext = 1;
|
||||
}
|
||||
|
||||
# A comment that starts "HREF" takes the next line as a name that
|
||||
# is turned into a hyperlink, using the text given, which might be
|
||||
# in a special font. If it ends in () or (digits) or punctuation, they
|
||||
# aren't part of the link.
|
||||
|
||||
elsif (/^\.\\"\s*HREF/)
|
||||
{
|
||||
$_=<STDIN>;
|
||||
chomp;
|
||||
$_ = &do_line($_);
|
||||
$_ =~ s/\s+$//;
|
||||
$_ =~ /^(?:<.>)?([^<(]+)(?:\(\))?(?:<\/.>)?(?:\(\d+\))?[.,;:]?$/;
|
||||
print TEMP "<a href=\"$1.html\">$_</a>\n";
|
||||
}
|
||||
|
||||
# A comment that starts "HTML" inserts literal HTML
|
||||
|
||||
elsif (/^\.\\"\s*HTML\s*(.*)/)
|
||||
{
|
||||
print TEMP $1;
|
||||
}
|
||||
|
||||
# A comment that starts < inserts that HTML at the end of the
|
||||
# *next* input line - so as not to get a newline between them.
|
||||
|
||||
elsif (/^\.\\"\s*(<.*>)/)
|
||||
{
|
||||
my($markup) = $1;
|
||||
$_=<STDIN>;
|
||||
chomp;
|
||||
$_ = &do_line($_);
|
||||
$_ =~ s/\s+$//;
|
||||
print TEMP "$_$markup\n";
|
||||
}
|
||||
|
||||
# A comment that starts JOIN joins the next two lines together, with one
|
||||
# space between them. Then that line is processed. This is used in some
|
||||
# displays where two lines are needed for the "man" version. JOINSH works
|
||||
# the same, except that it assumes this is a shell command, so removes
|
||||
# continuation backslashes.
|
||||
|
||||
elsif (/^\.\\"\s*JOIN(SH)?/)
|
||||
{
|
||||
my($one,$two);
|
||||
$one = <STDIN>;
|
||||
$two = <STDIN>;
|
||||
$one =~ s/\s*\\e\s*$// if (defined($1));
|
||||
chomp($one);
|
||||
$two =~ s/^\s+//;
|
||||
$_ = "$one $two";
|
||||
redo; # Process the joined lines
|
||||
}
|
||||
|
||||
# .EX/.EE are used in the pcre2demo page to bracket the entire program,
|
||||
# which is unmodified except for turning backslash into "\e".
|
||||
|
||||
elsif (/^\.EX\s*$/)
|
||||
{
|
||||
print TEMP "<PRE>\n";
|
||||
while (<STDIN>)
|
||||
{
|
||||
last if /^\.EE\s*$/;
|
||||
s/\\e/\\/g;
|
||||
s/&/&/g;
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
print TEMP;
|
||||
}
|
||||
}
|
||||
|
||||
# Ignore anything not recognized
|
||||
|
||||
next;
|
||||
}
|
||||
|
||||
# Line does not begin with a dot. Replace blank lines with new paragraphs
|
||||
|
||||
if (/^\s*$/)
|
||||
{
|
||||
&end_para() if ($wrotetext);
|
||||
next;
|
||||
}
|
||||
|
||||
# Convert fonts changes and output an ordinary line. Ensure that indented
|
||||
# lines are marked as literal.
|
||||
|
||||
$_ = &do_line($_);
|
||||
&new_para() if (!$inpara);
|
||||
|
||||
if (/^\s/)
|
||||
{
|
||||
if (!$inpre)
|
||||
{
|
||||
print TEMP "<pre>\n";
|
||||
$inpre = 1;
|
||||
}
|
||||
}
|
||||
elsif ($inpre)
|
||||
{
|
||||
print TEMP "</pre>\n";
|
||||
$inpre = 0;
|
||||
}
|
||||
|
||||
# Add <br> to the end of a non-literal line if we are within .nf/.fi
|
||||
|
||||
$_ .= "<br>\n" if (!$inpre && $innf);
|
||||
|
||||
print TEMP;
|
||||
$wrotetext = 1;
|
||||
}
|
||||
|
||||
# The TOC, if present, will have been written - terminate it
|
||||
|
||||
print "</ul>\n" if ($toc);
|
||||
|
||||
# Copy the remainder to the standard output
|
||||
|
||||
close(TEMP);
|
||||
open(TEMP, "/tmp/$$") || die "Can't open /tmp/$$ for input\n";
|
||||
|
||||
print while (<TEMP>);
|
||||
|
||||
print <<End ;
|
||||
<p>
|
||||
Return to the <a href="index.html">PCRE2 index page</a>.
|
||||
</p>
|
||||
End
|
||||
|
||||
close(TEMP);
|
||||
unlink("/tmp/$$");
|
||||
|
||||
# End
|
|
@ -0,0 +1,36 @@
|
|||
THE MAIN PCRE2 LIBRARY CODE
|
||||
---------------------------
|
||||
|
||||
Written by: Philip Hazel
|
||||
Email local part: ph10
|
||||
Email domain: cam.ac.uk
|
||||
|
||||
University of Cambridge Computing Service,
|
||||
Cambridge, England.
|
||||
|
||||
Copyright (c) 1997-2019 University of Cambridge
|
||||
All rights reserved
|
||||
|
||||
|
||||
PCRE2 JUST-IN-TIME COMPILATION SUPPORT
|
||||
--------------------------------------
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Emain domain: freemail.hu
|
||||
|
||||
Copyright(c) 2010-2019 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
|
||||
STACK-LESS JUST-IN-TIME COMPILER
|
||||
--------------------------------
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Emain domain: freemail.hu
|
||||
|
||||
Copyright(c) 2009-2019 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
####
|
|
@ -0,0 +1,876 @@
|
|||
# CMakeLists.txt
|
||||
#
|
||||
#
|
||||
# This file enables PCRE2 to be built with the CMake configuration and build
|
||||
# tool. Download CMake in source or binary form from http://www.cmake.org/
|
||||
# Converted to support PCRE2 from the original PCRE file, August 2014.
|
||||
#
|
||||
# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
|
||||
# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
# 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered
|
||||
# 2007-09-19 Adjusted by PH to retain previous default settings
|
||||
# 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre
|
||||
# (b) Ensure pcretest and pcregrep link with the local library,
|
||||
# not a previously-installed one.
|
||||
# (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and
|
||||
# PCRE_SUPPORT_LIBBZ2.
|
||||
# 2008-01-20 Brought up to date to include several new features by Christian
|
||||
# Ehrlicher.
|
||||
# 2008-01-22 Sheri added options for backward compatibility of library names
|
||||
# when building with minGW:
|
||||
# if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
|
||||
# be built without "lib" as prefix. (The libraries will be named
|
||||
# pcre.dll, pcreposix.dll and pcrecpp.dll).
|
||||
# if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
|
||||
# be built with suffix of "-0.dll". (The libraries will be named
|
||||
# libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
|
||||
# built by default with Configure and Make.
|
||||
# 2008-01-23 PH removed the automatic build of pcredemo.
|
||||
# 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
|
||||
# 2008-07-03 PH updated for revised UCP property support (change of files)
|
||||
# 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
|
||||
# CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
|
||||
# is included within another project.
|
||||
# 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to
|
||||
# add options to stop the building of pcregrep and the tests, and
|
||||
# to disable the final configuration report.
|
||||
# 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
|
||||
# are set by specifying a release type.
|
||||
# 2010-01-02 PH added test for stdint.h
|
||||
# 2010-03-02 PH added test for inttypes.h
|
||||
# 2011-08-01 PH added PCREGREP_BUFSIZE
|
||||
# 2011-08-22 PH added PCRE_SUPPORT_JIT
|
||||
# 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
|
||||
# 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
|
||||
# 2011-10-04 Sheri added support for including coff data in windows shared libraries
|
||||
# compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
|
||||
# the source dir by the user prior to building
|
||||
# 2011-10-04 Sheri changed various add_test's to use exes' location built instead
|
||||
# of DEBUG location only (likely only matters in MSVC)
|
||||
# 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
|
||||
# RunGrepTest (used for UNIX and Msys)
|
||||
# 2011-10-04 Sheri added scripts to provide needed variables and to execute
|
||||
# RunTest.bat in Win32 (for effortless testing with "make test")
|
||||
# 2011-10-04 Sheri Increased minimum required cmake version
|
||||
# 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
|
||||
# 2012-01-10 Zoltan Herczeg added libpcre16 support
|
||||
# 2012-01-13 Stephen Kelly added out of source build support
|
||||
# 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
|
||||
# of the configure.ac file
|
||||
# 2012-02-26 PH added support for libedit
|
||||
# 2012-09-06 PH added support for PCRE_EBCDIC_NL25
|
||||
# 2012-09-08 ChPe added PCRE32 support
|
||||
# 2012-10-23 PH added support for VALGRIND and GCOV
|
||||
# 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings
|
||||
# 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and
|
||||
# so it has been removed.
|
||||
# 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".")
|
||||
# 2013-11-05 PH added support for PARENS_NEST_LIMIT
|
||||
# 2014-08-29 PH converted the file for PCRE2 (which has no C++).
|
||||
# 2015-04-24 PH added support for PCRE2_DEBUG
|
||||
# 2015-07-16 PH updated for new pcre2_find_bracket source module
|
||||
# 2015-08-24 PH correct C_FLAGS setting (patch from Roy Ivy III)
|
||||
# 2015-10=16 PH added support for never-backslash-C
|
||||
# 2016-03-01 PH applied Chris Wilson's patch for MSVC static
|
||||
# 2016-06-24 PH applied Chris Wilson's second patch, putting the first under
|
||||
# a new option instead of being unconditional.
|
||||
# 2016-10-05 PH fixed a typo (PCRE should be PCRE2) in above patch
|
||||
# fix by David Gaussmann
|
||||
# 2016-10-07 PH added PCREGREP_MAX_BUFSIZE
|
||||
# 2017-03-11 PH turned HEAP_MATCH_RECURSE into a NO-OP for 10.30
|
||||
# 2017-04-08 PH added HEAP_LIMIT
|
||||
# 2017-06-15 ZH added SUPPORT_JIT_SEALLOC support
|
||||
# 2018-06-19 PH added checks for stdint.h and inttypes.h (later removed)
|
||||
# 2018-06-27 PH added Daniel's patch to increase the stack for MSVC
|
||||
# 2018-11-14 PH removed unnecessary checks for stdint.h and inttypes.h
|
||||
# 2018-11-16 PH added PCRE2GREP_SUPPORT_CALLOUT_FORK support and tidied
|
||||
# 2019-02-16 PH hacked to avoid CMP0026 policy issue (see comments below)
|
||||
|
||||
PROJECT(PCRE2 C)
|
||||
|
||||
# Increased minimum to 2.8.0 to support newer add_test features.
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
|
||||
|
||||
# Set policy CMP0026 to avoid warnings for the use of LOCATION in
|
||||
# GET_TARGET_PROPERTY. This should no longer be required.
|
||||
# CMAKE_POLICY(SET CMP0026 OLD)
|
||||
|
||||
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/src")
|
||||
|
||||
# external packages
|
||||
FIND_PACKAGE( BZip2 )
|
||||
FIND_PACKAGE( ZLIB )
|
||||
FIND_PACKAGE( Readline )
|
||||
FIND_PACKAGE( Editline )
|
||||
|
||||
# Configuration checks
|
||||
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckTypeSize)
|
||||
|
||||
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
|
||||
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
|
||||
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
|
||||
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
|
||||
|
||||
# User-configurable options
|
||||
#
|
||||
# Note: CMakeSetup displays these in alphabetical order, regardless of
|
||||
# the order we use here.
|
||||
|
||||
SET(BUILD_SHARED_LIBS OFF CACHE BOOL
|
||||
"Build shared libraries instead of static ones.")
|
||||
|
||||
OPTION(PCRE2_BUILD_PCRE2_8 "Build 8 bit PCRE2 library" ON)
|
||||
|
||||
OPTION(PCRE2_BUILD_PCRE2_16 "Build 16 bit PCRE2 library" OFF)
|
||||
|
||||
OPTION(PCRE2_BUILD_PCRE2_32 "Build 32 bit PCRE2 library" OFF)
|
||||
|
||||
OPTION(PCRE2_DEBUG "Include debugging code" OFF)
|
||||
|
||||
OPTION(PCRE2_DISABLE_PERCENT_ZT "Disable the use of %zu and %td (rarely needed)" OFF)
|
||||
|
||||
SET(PCRE2_EBCDIC OFF CACHE BOOL
|
||||
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")
|
||||
|
||||
SET(PCRE2_EBCDIC_NL25 OFF CACHE BOOL
|
||||
"Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.")
|
||||
|
||||
SET(PCRE2_LINK_SIZE "2" CACHE STRING
|
||||
"Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
|
||||
|
||||
SET(PCRE2_PARENS_NEST_LIMIT "250" CACHE STRING
|
||||
"Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.")
|
||||
|
||||
SET(PCRE2_HEAP_LIMIT "20000000" CACHE STRING
|
||||
"Default limit on heap memory (kibibytes). See HEAP_LIMIT in config.h.in for details.")
|
||||
|
||||
SET(PCRE2_MATCH_LIMIT "10000000" CACHE STRING
|
||||
"Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
|
||||
|
||||
SET(PCRE2_MATCH_LIMIT_DEPTH "MATCH_LIMIT" CACHE STRING
|
||||
"Default limit on internal depth of search. See MATCH_LIMIT_DEPTH in config.h.in for details.")
|
||||
|
||||
SET(PCRE2GREP_BUFSIZE "20480" CACHE STRING
|
||||
"Buffer starting size parameter for pcre2grep. See PCRE2GREP_BUFSIZE in config.h.in for details.")
|
||||
|
||||
SET(PCRE2GREP_MAX_BUFSIZE "1048576" CACHE STRING
|
||||
"Buffer maximum size parameter for pcre2grep. See PCRE2GREP_MAX_BUFSIZE in config.h.in for details.")
|
||||
|
||||
SET(PCRE2_NEWLINE "LF" CACHE STRING
|
||||
"What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF, NUL).")
|
||||
|
||||
SET(PCRE2_HEAP_MATCH_RECURSE OFF CACHE BOOL
|
||||
"Obsolete option: do not use")
|
||||
|
||||
SET(PCRE2_SUPPORT_JIT OFF CACHE BOOL
|
||||
"Enable support for Just-in-time compiling.")
|
||||
|
||||
SET(PCRE2_SUPPORT_JIT_SEALLOC OFF CACHE BOOL
|
||||
"Enable SELinux compatible execmem allocator in JIT.")
|
||||
|
||||
SET(PCRE2GREP_SUPPORT_JIT ON CACHE BOOL
|
||||
"Enable use of Just-in-time compiling in pcre2grep.")
|
||||
|
||||
SET(PCRE2GREP_SUPPORT_CALLOUT ON CACHE BOOL
|
||||
"Enable callout string support in pcre2grep.")
|
||||
|
||||
SET(PCRE2GREP_SUPPORT_CALLOUT_FORK ON CACHE BOOL
|
||||
"Enable callout string fork support in pcre2grep.")
|
||||
|
||||
SET(PCRE2_SUPPORT_UNICODE ON CACHE BOOL
|
||||
"Enable support for Unicode and UTF-8/UTF-16/UTF-32 encoding.")
|
||||
|
||||
SET(PCRE2_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
|
||||
"ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
|
||||
|
||||
SET(PCRE2_NEVER_BACKSLASH_C OFF CACHE BOOL
|
||||
"If ON, backslash-C (upper case C) is locked out.")
|
||||
|
||||
SET(PCRE2_SUPPORT_VALGRIND OFF CACHE BOOL
|
||||
"Enable Valgrind support.")
|
||||
|
||||
OPTION(PCRE2_SHOW_REPORT "Show the final configuration report" ON)
|
||||
OPTION(PCRE2_BUILD_PCRE2GREP "Build pcre2grep" ON)
|
||||
OPTION(PCRE2_BUILD_TESTS "Build the tests" ON)
|
||||
|
||||
IF (MINGW)
|
||||
OPTION(NON_STANDARD_LIB_PREFIX
|
||||
"ON=Shared libraries built in mingw will be named pcre2.dll, etc., instead of libpcre2.dll, etc."
|
||||
OFF)
|
||||
|
||||
OPTION(NON_STANDARD_LIB_SUFFIX
|
||||
"ON=Shared libraries built in mingw will be named libpcre2-0.dll, etc., instead of libpcre2.dll, etc."
|
||||
OFF)
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(MSVC)
|
||||
OPTION(PCRE2_STATIC_RUNTIME
|
||||
"ON=Compile against the static runtime (/MT)."
|
||||
OFF)
|
||||
OPTION(INSTALL_MSVC_PDB
|
||||
"ON=Install .pdb files built by MSVC, if generated"
|
||||
OFF)
|
||||
ENDIF(MSVC)
|
||||
|
||||
# bzip2 lib
|
||||
IF(BZIP2_FOUND)
|
||||
OPTION (PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON)
|
||||
ENDIF(BZIP2_FOUND)
|
||||
IF(PCRE2_SUPPORT_LIBBZ2)
|
||||
INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
|
||||
ENDIF(PCRE2_SUPPORT_LIBBZ2)
|
||||
|
||||
# zlib
|
||||
IF(ZLIB_FOUND)
|
||||
OPTION (PCRE2_SUPPORT_LIBZ "Enable support for linking pcre2grep with libz." ON)
|
||||
ENDIF(ZLIB_FOUND)
|
||||
IF(PCRE2_SUPPORT_LIBZ)
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
ENDIF(PCRE2_SUPPORT_LIBZ)
|
||||
|
||||
# editline lib
|
||||
IF(EDITLINE_FOUND)
|
||||
OPTION (PCRE2_SUPPORT_LIBEDIT "Enable support for linking pcre2test with libedit." OFF)
|
||||
ENDIF(EDITLINE_FOUND)
|
||||
IF(PCRE2_SUPPORT_LIBEDIT)
|
||||
INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
|
||||
ENDIF(PCRE2_SUPPORT_LIBEDIT)
|
||||
|
||||
# readline lib
|
||||
IF(READLINE_FOUND)
|
||||
OPTION (PCRE2_SUPPORT_LIBREADLINE "Enable support for linking pcre2test with libreadline." ON)
|
||||
ENDIF(READLINE_FOUND)
|
||||
IF(PCRE2_SUPPORT_LIBREADLINE)
|
||||
INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
|
||||
ENDIF(PCRE2_SUPPORT_LIBREADLINE)
|
||||
|
||||
# Prepare build configuration
|
||||
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
SET(PCRE2_STATIC 1)
|
||||
ENDIF(NOT BUILD_SHARED_LIBS)
|
||||
|
||||
IF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32)
|
||||
MESSAGE(FATAL_ERROR "At least one of PCRE2_BUILD_PCRE2_8, PCRE2_BUILD_PCRE2_16 or PCRE2_BUILD_PCRE2_32 must be enabled")
|
||||
ENDIF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_8)
|
||||
SET(SUPPORT_PCRE2_8 1)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_8)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_16)
|
||||
SET(SUPPORT_PCRE2_16 1)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_16)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_32)
|
||||
SET(SUPPORT_PCRE2_32 1)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_32)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8)
|
||||
MESSAGE(STATUS "** PCRE2_BUILD_PCRE2_8 must be enabled for the pcre2grep program")
|
||||
SET(PCRE2_BUILD_PCRE2GREP OFF)
|
||||
ENDIF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8)
|
||||
|
||||
IF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT)
|
||||
MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified")
|
||||
ENDIF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT)
|
||||
|
||||
IF(PCRE2_SUPPORT_BSR_ANYCRLF)
|
||||
SET(BSR_ANYCRLF 1)
|
||||
ENDIF(PCRE2_SUPPORT_BSR_ANYCRLF)
|
||||
|
||||
IF(PCRE2_NEVER_BACKSLASH_C)
|
||||
SET(NEVER_BACKSLASH_C 1)
|
||||
ENDIF(PCRE2_NEVER_BACKSLASH_C)
|
||||
|
||||
IF(PCRE2_SUPPORT_UNICODE)
|
||||
SET(SUPPORT_UNICODE 1)
|
||||
ENDIF(PCRE2_SUPPORT_UNICODE)
|
||||
|
||||
IF(PCRE2_SUPPORT_JIT)
|
||||
SET(SUPPORT_JIT 1)
|
||||
ENDIF(PCRE2_SUPPORT_JIT)
|
||||
|
||||
IF(PCRE2_SUPPORT_JIT_SEALLOC)
|
||||
SET(SLJIT_PROT_EXECUTABLE_ALLOCATOR 1)
|
||||
ENDIF(PCRE2_SUPPORT_JIT_SEALLOC)
|
||||
|
||||
IF(PCRE2GREP_SUPPORT_JIT)
|
||||
SET(SUPPORT_PCRE2GREP_JIT 1)
|
||||
ENDIF(PCRE2GREP_SUPPORT_JIT)
|
||||
|
||||
IF(PCRE2GREP_SUPPORT_CALLOUT)
|
||||
SET(SUPPORT_PCRE2GREP_CALLOUT 1)
|
||||
IF(PCRE2GREP_SUPPORT_CALLOUT_FORK)
|
||||
SET(SUPPORT_PCRE2GREP_CALLOUT_FORK 1)
|
||||
ENDIF(PCRE2GREP_SUPPORT_CALLOUT_FORK)
|
||||
ENDIF(PCRE2GREP_SUPPORT_CALLOUT)
|
||||
|
||||
IF(PCRE2_SUPPORT_VALGRIND)
|
||||
SET(SUPPORT_VALGRIND 1)
|
||||
ENDIF(PCRE2_SUPPORT_VALGRIND)
|
||||
|
||||
IF(PCRE2_DISABLE_PERCENT_ZT)
|
||||
SET(DISABLE_PERCENT_ZT 1)
|
||||
ENDIF(PCRE2_DISABLE_PERCENT_ZT)
|
||||
|
||||
# This next one used to reference ${READLINE_LIBRARY})
|
||||
# but I was advised to add the NCURSES test as well, along with
|
||||
# some modifications to cmake/FindReadline.cmake which should
|
||||
# make it possible to override the default if necessary. PH
|
||||
|
||||
IF(PCRE2_SUPPORT_LIBREADLINE)
|
||||
SET(SUPPORT_LIBREADLINE 1)
|
||||
SET(PCRE2TEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
|
||||
ENDIF(PCRE2_SUPPORT_LIBREADLINE)
|
||||
|
||||
# libedit is a plug-compatible alternative to libreadline
|
||||
|
||||
IF(PCRE2_SUPPORT_LIBEDIT)
|
||||
SET(SUPPORT_LIBEDIT 1)
|
||||
SET(PCRE2TEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
|
||||
ENDIF(PCRE2_SUPPORT_LIBEDIT)
|
||||
|
||||
IF(PCRE2_SUPPORT_LIBZ)
|
||||
SET(SUPPORT_LIBZ 1)
|
||||
SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${ZLIB_LIBRARIES})
|
||||
ENDIF(PCRE2_SUPPORT_LIBZ)
|
||||
|
||||
IF(PCRE2_SUPPORT_LIBBZ2)
|
||||
SET(SUPPORT_LIBBZ2 1)
|
||||
SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${BZIP2_LIBRARIES})
|
||||
ENDIF(PCRE2_SUPPORT_LIBBZ2)
|
||||
|
||||
SET(NEWLINE_DEFAULT "")
|
||||
|
||||
IF(PCRE2_NEWLINE STREQUAL "CR")
|
||||
SET(NEWLINE_DEFAULT "1")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "CR")
|
||||
IF(PCRE2_NEWLINE STREQUAL "LF")
|
||||
SET(NEWLINE_DEFAULT "2")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "LF")
|
||||
IF(PCRE2_NEWLINE STREQUAL "CRLF")
|
||||
SET(NEWLINE_DEFAULT "3")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "CRLF")
|
||||
IF(PCRE2_NEWLINE STREQUAL "ANY")
|
||||
SET(NEWLINE_DEFAULT "4")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "ANY")
|
||||
IF(PCRE2_NEWLINE STREQUAL "ANYCRLF")
|
||||
SET(NEWLINE_DEFAULT "5")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "ANYCRLF")
|
||||
IF(PCRE2_NEWLINE STREQUAL "NUL")
|
||||
SET(NEWLINE_DEFAULT "6")
|
||||
ENDIF(PCRE2_NEWLINE STREQUAL "NUL")
|
||||
|
||||
IF(NEWLINE_DEFAULT STREQUAL "")
|
||||
MESSAGE(FATAL_ERROR "The PCRE2_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
|
||||
ENDIF(NEWLINE_DEFAULT STREQUAL "")
|
||||
|
||||
IF(PCRE2_EBCDIC)
|
||||
SET(EBCDIC 1)
|
||||
ENDIF(PCRE2_EBCDIC)
|
||||
|
||||
IF(PCRE2_EBCDIC_NL25)
|
||||
SET(EBCDIC 1)
|
||||
SET(EBCDIC_NL25 1)
|
||||
ENDIF(PCRE2_EBCDIC_NL25)
|
||||
|
||||
# Output files
|
||||
|
||||
CONFIGURE_FILE(config-cmake.h.in
|
||||
${PROJECT_BINARY_DIR}/config.h
|
||||
@ONLY)
|
||||
|
||||
# Parse version numbers and date out of configure.ac
|
||||
|
||||
file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
|
||||
configure_lines
|
||||
LIMIT_COUNT 50 # Read only the first 50 lines of the file
|
||||
)
|
||||
|
||||
set(SEARCHED_VARIABLES "pcre2_major" "pcre2_minor" "pcre2_prerelease" "pcre2_date")
|
||||
foreach(configure_line ${configure_lines})
|
||||
foreach(_substitution_variable ${SEARCHED_VARIABLES})
|
||||
string(TOUPPER ${_substitution_variable} _substitution_variable_upper)
|
||||
if (NOT ${_substitution_variable_upper})
|
||||
string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line})
|
||||
if (CMAKE_MATCH_1)
|
||||
set(${_substitution_variable_upper} ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
CONFIGURE_FILE(src/pcre2.h.in
|
||||
${PROJECT_BINARY_DIR}/pcre2.h
|
||||
@ONLY)
|
||||
|
||||
# What about pcre2-config and libpcre2.pc?
|
||||
|
||||
# Character table generation
|
||||
|
||||
OPTION(PCRE2_REBUILD_CHARTABLES "Rebuild char tables" OFF)
|
||||
IF(PCRE2_REBUILD_CHARTABLES)
|
||||
ADD_EXECUTABLE(dftables src/dftables.c)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
COMMENT "Generating character tables (pcre2_chartables.c) for current locale"
|
||||
DEPENDS dftables
|
||||
COMMAND dftables
|
||||
ARGS ${PROJECT_BINARY_DIR}/pcre2_chartables.c
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/pcre2_chartables.c
|
||||
)
|
||||
ELSE(PCRE2_REBUILD_CHARTABLES)
|
||||
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist
|
||||
${PROJECT_BINARY_DIR}/pcre2_chartables.c
|
||||
COPYONLY)
|
||||
ENDIF(PCRE2_REBUILD_CHARTABLES)
|
||||
|
||||
# Source code
|
||||
|
||||
SET(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/pcre2.h)
|
||||
|
||||
SET(PCRE2_SOURCES
|
||||
src/pcre2_auto_possess.c
|
||||
${PROJECT_BINARY_DIR}/pcre2_chartables.c
|
||||
src/pcre2_compile.c
|
||||
src/pcre2_config.c
|
||||
src/pcre2_context.c
|
||||
src/pcre2_convert.c
|
||||
src/pcre2_dfa_match.c
|
||||
src/pcre2_error.c
|
||||
src/pcre2_extuni.c
|
||||
src/pcre2_find_bracket.c
|
||||
src/pcre2_jit_compile.c
|
||||
src/pcre2_maketables.c
|
||||
src/pcre2_match.c
|
||||
src/pcre2_match_data.c
|
||||
src/pcre2_newline.c
|
||||
src/pcre2_ord2utf.c
|
||||
src/pcre2_pattern_info.c
|
||||
src/pcre2_script_run.c
|
||||
src/pcre2_serialize.c
|
||||
src/pcre2_string_utils.c
|
||||
src/pcre2_study.c
|
||||
src/pcre2_substitute.c
|
||||
src/pcre2_substring.c
|
||||
src/pcre2_tables.c
|
||||
src/pcre2_ucd.c
|
||||
src/pcre2_valid_utf.c
|
||||
src/pcre2_xclass.c
|
||||
)
|
||||
|
||||
SET(PCRE2POSIX_HEADERS src/pcre2posix.h)
|
||||
SET(PCRE2POSIX_SOURCES src/pcre2posix.c)
|
||||
|
||||
IF(MINGW AND NOT PCRE2_STATIC)
|
||||
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2.o
|
||||
PRE-LINK
|
||||
COMMAND windres ARGS pcre2.rc pcre2.o
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT Using pcre2 coff info in mingw build)
|
||||
SET(PCRE2_SOURCES
|
||||
${PCRE2_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2.o
|
||||
)
|
||||
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
|
||||
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2posix.o
|
||||
PRE-LINK
|
||||
COMMAND windres ARGS pcre2posix.rc pcre2posix.o
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT Using pcre2posix coff info in mingw build)
|
||||
SET(PCRE2POSIX_SOURCES
|
||||
${PCRE2POSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2posix.o
|
||||
)
|
||||
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
|
||||
ENDIF(MINGW AND NOT PCRE2_STATIC)
|
||||
|
||||
IF(MSVC AND NOT PCRE2_STATIC)
|
||||
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
|
||||
SET(PCRE2_SOURCES
|
||||
${PCRE2_SOURCES} pcre2.rc)
|
||||
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
|
||||
IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
|
||||
SET(PCRE2POSIX_SOURCES
|
||||
${PCRE2POSIX_SOURCES} pcre2posix.rc)
|
||||
ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
|
||||
ENDIF(MSVC AND NOT PCRE2_STATIC)
|
||||
|
||||
# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
|
||||
# This code was taken from the CMake wiki, not from WebM.
|
||||
|
||||
IF(MSVC AND PCRE2_STATIC_RUNTIME)
|
||||
MESSAGE(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library")
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endforeach()
|
||||
ENDIF(MSVC AND PCRE2_STATIC_RUNTIME)
|
||||
|
||||
# Build setup
|
||||
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
|
||||
IF(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF(MSVC)
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
|
||||
# needed to make sure to not link debug libs
|
||||
# against release libs and vice versa
|
||||
IF(WIN32)
|
||||
SET(CMAKE_DEBUG_POSTFIX "d")
|
||||
ENDIF(WIN32)
|
||||
|
||||
SET(targets)
|
||||
|
||||
# 8-bit library
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_8)
|
||||
ADD_LIBRARY(pcre2-8 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
|
||||
SET_PROPERTY(TARGET pcre2-8
|
||||
PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8)
|
||||
SET(targets ${targets} pcre2-8)
|
||||
ADD_LIBRARY(pcre2-posix ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES})
|
||||
SET_PROPERTY(TARGET pcre2-posix
|
||||
PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8)
|
||||
SET(targets ${targets} pcre2-posix)
|
||||
TARGET_LINK_LIBRARIES(pcre2-posix pcre2-8)
|
||||
|
||||
IF(MINGW AND NOT PCRE2_STATIC)
|
||||
IF(NON_STANDARD_LIB_PREFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-8 pcre2-posix PROPERTIES PREFIX "")
|
||||
ENDIF(NON_STANDARD_LIB_PREFIX)
|
||||
IF(NON_STANDARD_LIB_SUFFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-8 pcre2-posix PROPERTIES SUFFIX "-0.dll")
|
||||
ENDIF(NON_STANDARD_LIB_SUFFIX)
|
||||
ENDIF(MINGW AND NOT PCRE2_STATIC)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_8)
|
||||
|
||||
# 16-bit library
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_16)
|
||||
ADD_LIBRARY(pcre2-16 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
|
||||
SET_PROPERTY(TARGET pcre2-16
|
||||
PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16)
|
||||
SET(targets ${targets} pcre2-16)
|
||||
|
||||
IF(MINGW AND NOT PCRE2_STATIC)
|
||||
IF(NON_STANDARD_LIB_PREFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES PREFIX "")
|
||||
ENDIF(NON_STANDARD_LIB_PREFIX)
|
||||
IF(NON_STANDARD_LIB_SUFFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES SUFFIX "-0.dll")
|
||||
ENDIF(NON_STANDARD_LIB_SUFFIX)
|
||||
ENDIF(MINGW AND NOT PCRE2_STATIC)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_16)
|
||||
|
||||
# 32-bit library
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2_32)
|
||||
ADD_LIBRARY(pcre2-32 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
|
||||
SET_PROPERTY(TARGET pcre2-32
|
||||
PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32)
|
||||
SET(targets ${targets} pcre2-32)
|
||||
|
||||
IF(MINGW AND NOT PCRE2_STATIC)
|
||||
IF(NON_STANDARD_LIB_PREFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES PREFIX "")
|
||||
ENDIF(NON_STANDARD_LIB_PREFIX)
|
||||
IF(NON_STANDARD_LIB_SUFFIX)
|
||||
SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES SUFFIX "-0.dll")
|
||||
ENDIF(NON_STANDARD_LIB_SUFFIX)
|
||||
ENDIF(MINGW AND NOT PCRE2_STATIC)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_32)
|
||||
|
||||
# Executables
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2GREP)
|
||||
ADD_EXECUTABLE(pcre2grep src/pcre2grep.c)
|
||||
SET_PROPERTY(TARGET pcre2grep
|
||||
PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8)
|
||||
SET(targets ${targets} pcre2grep)
|
||||
TARGET_LINK_LIBRARIES(pcre2grep pcre2-posix ${PCRE2GREP_LIBS})
|
||||
ENDIF(PCRE2_BUILD_PCRE2GREP)
|
||||
|
||||
# Testing
|
||||
|
||||
IF(PCRE2_BUILD_TESTS)
|
||||
ENABLE_TESTING()
|
||||
|
||||
SET(PCRE2TEST_SOURCES src/pcre2test.c)
|
||||
|
||||
IF(MSVC)
|
||||
# This is needed to avoid a stack overflow error in the standard tests. The
|
||||
# flag should be indicated with a forward-slash instead of a hyphen, but
|
||||
# then CMake treats it as a file path.
|
||||
SET(PCRE2TEST_LINKER_FLAGS -STACK:2500000)
|
||||
ENDIF(MSVC)
|
||||
|
||||
ADD_EXECUTABLE(pcre2test ${PCRE2TEST_SOURCES})
|
||||
SET(targets ${targets} pcre2test)
|
||||
IF(PCRE2_BUILD_PCRE2_8)
|
||||
LIST(APPEND PCRE2TEST_LIBS pcre2-posix pcre2-8)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_8)
|
||||
IF(PCRE2_BUILD_PCRE2_16)
|
||||
LIST(APPEND PCRE2TEST_LIBS pcre2-16)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_16)
|
||||
IF(PCRE2_BUILD_PCRE2_32)
|
||||
LIST(APPEND PCRE2TEST_LIBS pcre2-32)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_32)
|
||||
TARGET_LINK_LIBRARIES(pcre2test ${PCRE2TEST_LIBS} ${PCRE2TEST_LINKER_FLAGS})
|
||||
|
||||
IF(PCRE2_SUPPORT_JIT)
|
||||
ADD_EXECUTABLE(pcre2_jit_test src/pcre2_jit_test.c)
|
||||
SET(targets ${targets} pcre2_jit_test)
|
||||
SET(PCRE2_JIT_TEST_LIBS )
|
||||
IF(PCRE2_BUILD_PCRE2_8)
|
||||
LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-8)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_8)
|
||||
IF(PCRE2_BUILD_PCRE2_16)
|
||||
LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-16)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_16)
|
||||
IF(PCRE2_BUILD_PCRE2_32)
|
||||
LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-32)
|
||||
ENDIF(PCRE2_BUILD_PCRE2_32)
|
||||
TARGET_LINK_LIBRARIES(pcre2_jit_test ${PCRE2_JIT_TEST_LIBS})
|
||||
ENDIF(PCRE2_SUPPORT_JIT)
|
||||
|
||||
# exes in Debug location tested by the RunTest and RunGrepTest shell scripts
|
||||
# via "make test"
|
||||
|
||||
# The commented out code below provokes a warning about future removal
|
||||
# of the facility, and requires policy CMP0026 to be set to "OLD". I have
|
||||
# got fed-up with the warnings, but my plea for help on the mailing list
|
||||
# produced no response. So, I've hacked. The new code below seems to work on
|
||||
# Linux.
|
||||
|
||||
# IF(PCRE2_BUILD_PCRE2GREP)
|
||||
# GET_TARGET_PROPERTY(PCRE2GREP_EXE pcre2grep DEBUG_LOCATION)
|
||||
# ENDIF(PCRE2_BUILD_PCRE2GREP)
|
||||
#
|
||||
# GET_TARGET_PROPERTY(PCRE2TEST_EXE pcre2test DEBUG_LOCATION)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2GREP)
|
||||
SET(PCRE2GREP_EXE $<TARGET_FILE:pcre2grep>)
|
||||
ENDIF(PCRE2_BUILD_PCRE2GREP)
|
||||
|
||||
SET(PCRE2TEST_EXE $<TARGET_FILE:pcre2test>)
|
||||
|
||||
|
||||
# =================================================
|
||||
# Write out a CTest configuration file
|
||||
#
|
||||
FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
|
||||
"# This is a generated file.
|
||||
MESSAGE(\"When testing is complete, review test output in the
|
||||
\\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\")
|
||||
MESSAGE(\" \")
|
||||
")
|
||||
|
||||
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.sh
|
||||
"#! /bin/sh
|
||||
# This is a generated file.
|
||||
. ${PROJECT_SOURCE_DIR}/RunTest
|
||||
if test \"$?\" != \"0\"; then exit 1; fi
|
||||
# End
|
||||
")
|
||||
|
||||
IF(UNIX)
|
||||
ADD_TEST(pcre2_test sh ${PROJECT_BINARY_DIR}/pcre2_test.sh)
|
||||
ENDIF(UNIX)
|
||||
|
||||
IF(PCRE2_BUILD_PCRE2GREP)
|
||||
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh
|
||||
"#! /bin/sh
|
||||
# This is a generated file.
|
||||
. ${PROJECT_SOURCE_DIR}/RunGrepTest
|
||||
if test \"$?\" != \"0\"; then exit 1; fi
|
||||
# End
|
||||
")
|
||||
|
||||
IF(UNIX)
|
||||
ADD_TEST(pcre2_grep_test sh ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
|
||||
ENDIF(UNIX)
|
||||
ENDIF(PCRE2_BUILD_PCRE2GREP)
|
||||
|
||||
IF(WIN32)
|
||||
# Provide environment for executing the bat file version of RunTest
|
||||
FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc)
|
||||
FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin)
|
||||
FILE(TO_NATIVE_PATH ${PCRE2TEST_EXE} winexe)
|
||||
|
||||
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.bat
|
||||
"\@REM This is a generated file.
|
||||
\@echo off
|
||||
setlocal
|
||||
SET srcdir=\"${winsrc}\"
|
||||
SET pcre2test=\"${winexe}\"
|
||||
if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\"
|
||||
call %srcdir%\\RunTest.Bat
|
||||
if errorlevel 1 exit /b 1
|
||||
echo RunTest.bat tests successfully completed
|
||||
")
|
||||
|
||||
ADD_TEST(NAME pcre2_test_bat
|
||||
COMMAND pcre2_test.bat)
|
||||
SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
|
||||
|
||||
IF("$ENV{OSTYPE}" STREQUAL "msys")
|
||||
# Both the sh and bat file versions of RunTest are run if make test is used
|
||||
# in msys
|
||||
ADD_TEST(pcre2_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre2_test.sh)
|
||||
IF(PCRE2_BUILD_PCRE2GREP)
|
||||
ADD_TEST(pcre2_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
|
||||
ENDIF(PCRE2_BUILD_PCRE2GREP)
|
||||
ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Changed to accommodate testing whichever location was just built
|
||||
|
||||
IF(PCRE2_SUPPORT_JIT)
|
||||
ADD_TEST(pcre2_jit_test pcre2_jit_test)
|
||||
ENDIF(PCRE2_SUPPORT_JIT)
|
||||
|
||||
ENDIF(PCRE2_BUILD_TESTS)
|
||||
|
||||
# Installation
|
||||
|
||||
SET(CMAKE_INSTALL_ALWAYS 1)
|
||||
|
||||
INSTALL(TARGETS ${targets}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
|
||||
INSTALL(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include)
|
||||
|
||||
FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
|
||||
FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
|
||||
FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
|
||||
|
||||
FOREACH(man ${man3})
|
||||
GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
|
||||
SET(man3_new ${man3} ${man})
|
||||
ENDFOREACH(man ${man3})
|
||||
SET(man3 ${man3_new})
|
||||
|
||||
INSTALL(FILES ${man1} DESTINATION man/man1)
|
||||
INSTALL(FILES ${man3} DESTINATION man/man3)
|
||||
INSTALL(FILES ${html} DESTINATION share/doc/pcre2/html)
|
||||
|
||||
IF(MSVC AND INSTALL_MSVC_PDB)
|
||||
INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2.pdb
|
||||
${PROJECT_BINARY_DIR}/pcre2posix.pdb
|
||||
DESTINATION bin
|
||||
CONFIGURATIONS RelWithDebInfo)
|
||||
INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2d.pdb
|
||||
${PROJECT_BINARY_DIR}/pcre2posixd.pdb
|
||||
DESTINATION bin
|
||||
CONFIGURATIONS Debug)
|
||||
ENDIF(MSVC AND INSTALL_MSVC_PDB)
|
||||
|
||||
# Help, only for nice output
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET(BUILD_STATIC_LIBS OFF)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
SET(BUILD_STATIC_LIBS ON)
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
|
||||
IF(PCRE2_HEAP_MATCH_RECURSE)
|
||||
MESSAGE(WARNING "HEAP_MATCH_RECURSE is obsolete and does nothing.")
|
||||
ENDIF(PCRE2_HEAP_MATCH_RECURSE)
|
||||
|
||||
IF(PCRE2_SHOW_REPORT)
|
||||
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
|
||||
IF (CMAKE_C_FLAGS)
|
||||
SET(cfsp " ")
|
||||
ENDIF(CMAKE_C_FLAGS)
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "PCRE2 configuration summary:")
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
|
||||
MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
|
||||
MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS " Build 8 bit PCRE2 library ....... : ${PCRE2_BUILD_PCRE2_8}")
|
||||
MESSAGE(STATUS " Build 16 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_16}")
|
||||
MESSAGE(STATUS " Build 32 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_32}")
|
||||
MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE2_SUPPORT_JIT}")
|
||||
MESSAGE(STATUS " Use SELinux allocator in JIT .... : ${PCRE2_SUPPORT_JIT_SEALLOC}")
|
||||
MESSAGE(STATUS " Enable Unicode support .......... : ${PCRE2_SUPPORT_UNICODE}")
|
||||
MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE2_NEWLINE}")
|
||||
MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE2_SUPPORT_BSR_ANYCRLF}")
|
||||
MESSAGE(STATUS " \\C is disabled .................. : ${PCRE2_NEVER_BACKSLASH_C}")
|
||||
MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE2_EBCDIC}")
|
||||
MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE2_EBCDIC_NL25}")
|
||||
MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE2_REBUILD_CHARTABLES}")
|
||||
MESSAGE(STATUS " Internal link size .............. : ${PCRE2_LINK_SIZE}")
|
||||
MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE2_PARENS_NEST_LIMIT}")
|
||||
MESSAGE(STATUS " Heap limit ...................... : ${PCRE2_HEAP_LIMIT}")
|
||||
MESSAGE(STATUS " Match limit ..................... : ${PCRE2_MATCH_LIMIT}")
|
||||
MESSAGE(STATUS " Match depth limit ............... : ${PCRE2_MATCH_LIMIT_DEPTH}")
|
||||
MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
|
||||
MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
|
||||
MESSAGE(STATUS " Build pcre2grep ................. : ${PCRE2_BUILD_PCRE2GREP}")
|
||||
MESSAGE(STATUS " Enable JIT in pcre2grep ......... : ${PCRE2GREP_SUPPORT_JIT}")
|
||||
MESSAGE(STATUS " Enable callouts in pcre2grep .... : ${PCRE2GREP_SUPPORT_CALLOUT}")
|
||||
MESSAGE(STATUS " Enable callout fork in pcre2grep. : ${PCRE2GREP_SUPPORT_CALLOUT_FORK}")
|
||||
MESSAGE(STATUS " Buffer size for pcre2grep ....... : ${PCRE2GREP_BUFSIZE}")
|
||||
MESSAGE(STATUS " Build tests (implies pcre2test .. : ${PCRE2_BUILD_TESTS}")
|
||||
MESSAGE(STATUS " and pcre2grep)")
|
||||
IF(ZLIB_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2grep with libz ........ : ${PCRE2_SUPPORT_LIBZ}")
|
||||
ELSE(ZLIB_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2grep with libz ........ : Library not found" )
|
||||
ENDIF(ZLIB_FOUND)
|
||||
IF(BZIP2_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : ${PCRE2_SUPPORT_LIBBZ2}")
|
||||
ELSE(BZIP2_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : Library not found" )
|
||||
ENDIF(BZIP2_FOUND)
|
||||
IF(EDITLINE_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2test with libeditline . : ${PCRE2_SUPPORT_LIBEDIT}")
|
||||
ELSE(EDITLINE_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2test with libeditline . : Library not found" )
|
||||
ENDIF(EDITLINE_FOUND)
|
||||
IF(READLINE_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2test with libreadline . : ${PCRE2_SUPPORT_LIBREADLINE}")
|
||||
ELSE(READLINE_FOUND)
|
||||
MESSAGE(STATUS " Link pcre2test with libreadline . : Library not found" )
|
||||
ENDIF(READLINE_FOUND)
|
||||
MESSAGE(STATUS " Support Valgrind .................: ${PCRE2_SUPPORT_VALGRIND}")
|
||||
IF(PCRE2_DISABLE_PERCENT_ZT)
|
||||
MESSAGE(STATUS " Use %zu and %td ..................: OFF" )
|
||||
ELSE(PCRE2_DISABLE_PERCENT_ZT)
|
||||
MESSAGE(STATUS " Use %zu and %td ..................: AUTO" )
|
||||
ENDIF(PCRE2_DISABLE_PERCENT_ZT)
|
||||
|
||||
IF(MINGW AND NOT PCRE2_STATIC)
|
||||
MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
|
||||
MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
|
||||
ENDIF(MINGW AND NOT PCRE2_STATIC)
|
||||
|
||||
IF(MSVC)
|
||||
MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}")
|
||||
ENDIF(MSVC)
|
||||
|
||||
MESSAGE(STATUS "")
|
||||
ENDIF(PCRE2_SHOW_REPORT)
|
||||
|
||||
# end CMakeLists.txt
|
|
@ -0,0 +1,5 @@
|
|||
PCRE2 LICENCE
|
||||
|
||||
Please see the file LICENCE in the PCRE2 distribution for licensing details.
|
||||
|
||||
End
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
|||
#! /usr/bin/perl
|
||||
|
||||
# A script to scan PCRE2's man pages to check for typos in the control
|
||||
# sequences. I use only a small set of the available repertoire, so it is
|
||||
# straightforward to check that nothing else has slipped in by mistake. This
|
||||
# script should be called in the doc directory.
|
||||
|
||||
$yield = 0;
|
||||
|
||||
while (scalar(@ARGV) > 0)
|
||||
{
|
||||
$line = 0;
|
||||
$file = shift @ARGV;
|
||||
|
||||
open (IN, $file) || die "Failed to open $file\n";
|
||||
|
||||
while (<IN>)
|
||||
{
|
||||
$line++;
|
||||
if (/^\s*$/)
|
||||
{
|
||||
printf "Empty line $line of $file\n";
|
||||
$yield = 1;
|
||||
}
|
||||
elsif (/^\./)
|
||||
{
|
||||
if (!/^\.\s*$|
|
||||
^\.B\s+\S|
|
||||
^\.TH\s\S|
|
||||
^\.SH\s\S|
|
||||
^\.SS\s\S|
|
||||
^\.TP(?:\s?\d+)?\s*$|
|
||||
^\.SM\s*$|
|
||||
^\.br\s*$|
|
||||
^\.rs\s*$|
|
||||
^\.sp\s*$|
|
||||
^\.nf\s*$|
|
||||
^\.fi\s*$|
|
||||
^\.P\s*$|
|
||||
^\.PP\s*$|
|
||||
^\.\\"(?:\ HREF)?\s*$|
|
||||
^\.\\"\sHTML\s<a\shref="[^"]+?">\s*$|
|
||||
^\.\\"\sHTML\s<a\sname="[^"]+?"><\/a>\s*$|
|
||||
^\.\\"\s<\/a>\s*$|
|
||||
^\.\\"\sJOINSH\s*$|
|
||||
^\.\\"\sJOIN\s*$/x
|
||||
)
|
||||
{
|
||||
printf "Bad control line $line of $file\n";
|
||||
$yield = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (/\\[^ef]|\\f[^IBP]/)
|
||||
{
|
||||
printf "Bad backslash in line $line of $file\n";
|
||||
$yield = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(IN);
|
||||
}
|
||||
|
||||
exit $yield;
|
||||
# End
|
|
@ -0,0 +1,113 @@
|
|||
#! /usr/bin/perl -w
|
||||
|
||||
# Script to take the output of nroff -man and remove all the backspacing and
|
||||
# the page footers and the screen commands etc so that it is more usefully
|
||||
# readable online. In fact, in the latest nroff, intermediate footers don't
|
||||
# seem to be generated any more.
|
||||
|
||||
$blankcount = 0;
|
||||
$lastwascut = 0;
|
||||
$firstheader = 1;
|
||||
|
||||
# Input on STDIN; output to STDOUT.
|
||||
|
||||
while (<STDIN>)
|
||||
{
|
||||
s/\x1b\[\d+m//g; # Remove screen controls "ESC [ number m"
|
||||
s/.\x8//g; # Remove "char, backspace"
|
||||
|
||||
# Handle header lines. Retain only the first one we encounter, but remove
|
||||
# the blank line that follows. Any others (e.g. at end of document) and the
|
||||
# following blank line are dropped.
|
||||
|
||||
if (/^PCRE(\w*)\(([13])\)\s+PCRE\1\(\2\)$/)
|
||||
{
|
||||
if ($firstheader)
|
||||
{
|
||||
$firstheader = 0;
|
||||
print;
|
||||
$lastprinted = $_;
|
||||
$lastwascut = 0;
|
||||
}
|
||||
$_=<STDIN>; # Remove a blank that follows
|
||||
next;
|
||||
}
|
||||
|
||||
# Count runs of empty lines
|
||||
|
||||
if (/^\s*$/)
|
||||
{
|
||||
$blankcount++;
|
||||
$lastwascut = 0;
|
||||
next;
|
||||
}
|
||||
|
||||
# If a chunk of lines has been cut out (page footer) and the next line
|
||||
# has a different indentation, put back one blank line.
|
||||
|
||||
if ($lastwascut && $blankcount < 1 && defined($lastprinted))
|
||||
{
|
||||
($a) = $lastprinted =~ /^(\s*)/;
|
||||
($b) = $_ =~ /^(\s*)/;
|
||||
$blankcount++ if ($a ne $b);
|
||||
}
|
||||
|
||||
# We get here only when we have a non-blank line in hand. If it was preceded
|
||||
# by 3 or more blank lines, read the next 3 lines and see if they are blank.
|
||||
# If so, remove all 7 lines, and remember that we have just done a cut.
|
||||
|
||||
if ($blankcount >= 3)
|
||||
{
|
||||
for ($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$next[$i] = <STDIN>;
|
||||
$next[$i] = "" if !defined $next[$i];
|
||||
$next[$i] =~ s/\x1b\[\d+m//g; # Remove screen controls "ESC [ number m"
|
||||
$next[$i] =~ s/.\x8//g; # Remove "char, backspace"
|
||||
}
|
||||
|
||||
# Cut out chunks of the form <3 blanks><non-blank><3 blanks>
|
||||
|
||||
if ($next[0] =~ /^\s*$/ &&
|
||||
$next[1] =~ /^\s*$/ &&
|
||||
$next[2] =~ /^\s*$/)
|
||||
{
|
||||
$blankcount -= 3;
|
||||
$lastwascut = 1;
|
||||
}
|
||||
|
||||
# Otherwise output the saved blanks, the current, and the next three
|
||||
# lines. Remember the last printed line.
|
||||
|
||||
else
|
||||
{
|
||||
for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
|
||||
print;
|
||||
for ($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$next[$i] =~ s/.\x8//g;
|
||||
print $next[$i];
|
||||
$lastprinted = $_;
|
||||
}
|
||||
$lastwascut = 0;
|
||||
$blankcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
# This non-blank line is not preceded by 3 or more blank lines. Output
|
||||
# any blanks there are, and the line. Remember it. Force two blank lines
|
||||
# before headings.
|
||||
|
||||
else
|
||||
{
|
||||
$blankcount = 2 if /^\S/ && !/^Last updated/ && !/^Copyright/ &&
|
||||
defined($lastprinted);
|
||||
for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
|
||||
print;
|
||||
$lastprinted = $_;
|
||||
$lastwascut = 0;
|
||||
$blankcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
# End
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# This is a script for removing trailing whitespace from lines in files that
|
||||
# are listed on the command line.
|
||||
|
||||
# This subroutine does the work for one file.
|
||||
|
||||
sub detrail {
|
||||
my($file) = $_[0];
|
||||
my($changed) = 0;
|
||||
open(IN, "$file") || die "Can't open $file for input";
|
||||
@lines = <IN>;
|
||||
close(IN);
|
||||
foreach (@lines)
|
||||
{
|
||||
if (/\s+\n$/)
|
||||
{
|
||||
s/\s+\n$/\n/;
|
||||
$changed = 1;
|
||||
}
|
||||
}
|
||||
if ($changed)
|
||||
{
|
||||
open(OUT, ">$file") || die "Can't open $file for output";
|
||||
print OUT @lines;
|
||||
close(OUT);
|
||||
}
|
||||
}
|
||||
|
||||
# This is the main program
|
||||
|
||||
$, = ""; # Output field separator
|
||||
for ($i = 0; $i < @ARGV; $i++) { &detrail($ARGV[$i]); }
|
||||
|
||||
# End
|
|
@ -0,0 +1,826 @@
|
|||
Technical Notes about PCRE2
|
||||
---------------------------
|
||||
|
||||
These are very rough technical notes that record potentially useful information
|
||||
about PCRE2 internals. PCRE2 is a library based on the original PCRE library,
|
||||
but with a revised (and incompatible) API. To avoid confusion, the original
|
||||
library is referred to as PCRE1 below. For information about testing PCRE2, see
|
||||
the pcre2test documentation and the comment at the head of the RunTest file.
|
||||
|
||||
PCRE1 releases were up to 8.3x when PCRE2 was developed, and later bug fix
|
||||
releases remain in the 8.xx series. PCRE2 releases started at 10.00 to avoid
|
||||
confusion with PCRE1.
|
||||
|
||||
|
||||
Historical note 1
|
||||
-----------------
|
||||
|
||||
Many years ago I implemented some regular expression functions to an algorithm
|
||||
suggested by Martin Richards. The rather simple patterns were not Unix-like in
|
||||
form, and were quite restricted in what they could do by comparison with Perl.
|
||||
The interesting part about the algorithm was that the amount of space required
|
||||
to hold the compiled form of an expression was known in advance. The code to
|
||||
apply an expression did not operate by backtracking, as the original Henry
|
||||
Spencer code and current PCRE2 and Perl code does, but instead checked all
|
||||
possibilities simultaneously by keeping a list of current states and checking
|
||||
all of them as it advanced through the subject string. In the terminology of
|
||||
Jeffrey Friedl's book, it was a "DFA algorithm", though it was not a
|
||||
traditional Finite State Machine (FSM). When the pattern was all used up, all
|
||||
remaining states were possible matches, and the one matching the longest subset
|
||||
of the subject string was chosen. This did not necessarily maximize the
|
||||
individual wild portions of the pattern, as is expected in Unix and Perl-style
|
||||
regular expressions.
|
||||
|
||||
|
||||
Historical note 2
|
||||
-----------------
|
||||
|
||||
By contrast, the code originally written by Henry Spencer (which was
|
||||
subsequently heavily modified for Perl) compiles the expression twice: once in
|
||||
a dummy mode in order to find out how much store will be needed, and then for
|
||||
real. (The Perl version probably doesn't do this any more; I'm talking about
|
||||
the original library.) The execution function operates by backtracking and
|
||||
maximizing (or, optionally, minimizing, in Perl) the amount of the subject that
|
||||
matches individual wild portions of the pattern. This is an "NFA algorithm" in
|
||||
Friedl's terminology.
|
||||
|
||||
|
||||
OK, here's the real stuff
|
||||
-------------------------
|
||||
|
||||
For the set of functions that formed the original PCRE1 library in 1997 (which
|
||||
are unrelated to those mentioned above), I tried at first to invent an
|
||||
algorithm that used an amount of store bounded by a multiple of the number of
|
||||
characters in the pattern, to save on compiling time. However, because of the
|
||||
greater complexity in Perl regular expressions, I couldn't do this, even though
|
||||
the then current Perl 5.004 patterns were much simpler than those supported
|
||||
nowadays. In any case, a first pass through the pattern is helpful for other
|
||||
reasons.
|
||||
|
||||
|
||||
Support for 16-bit and 32-bit data strings
|
||||
-------------------------------------------
|
||||
|
||||
The PCRE2 library can be compiled in any combination of 8-bit, 16-bit or 32-bit
|
||||
modes, creating up to three different libraries. In the description that
|
||||
follows, the word "short" is used for a 16-bit data quantity, and the phrase
|
||||
"code unit" is used for a quantity that is a byte in 8-bit mode, a short in
|
||||
16-bit mode and a 32-bit word in 32-bit mode. The names of PCRE2 functions are
|
||||
given in generic form, without the _8, _16, or _32 suffix.
|
||||
|
||||
|
||||
Computing the memory requirement: how it was
|
||||
--------------------------------------------
|
||||
|
||||
Up to and including release 6.7, PCRE1 worked by running a very degenerate
|
||||
first pass to calculate a maximum memory requirement, and then a second pass to
|
||||
do the real compile - which might use a bit less than the predicted amount of
|
||||
memory. The idea was that this would turn out faster than the Henry Spencer
|
||||
code because the first pass is degenerate and the second pass can just store
|
||||
stuff straight into memory, which it knows is big enough.
|
||||
|
||||
|
||||
Computing the memory requirement: how it is
|
||||
-------------------------------------------
|
||||
|
||||
By the time I was working on a potential 6.8 release, the degenerate first pass
|
||||
had become very complicated and hard to maintain. Indeed one of the early
|
||||
things I did for 6.8 was to fix Yet Another Bug in the memory computation. Then
|
||||
I had a flash of inspiration as to how I could run the real compile function in
|
||||
a "fake" mode that enables it to compute how much memory it would need, while
|
||||
in most cases only ever using a small amount of working memory, and without too
|
||||
many tests of the mode that might slow it down. So I refactored the compiling
|
||||
functions to work this way. This got rid of about 600 lines of source and made
|
||||
further maintenance and development easier. As this was such a major change, I
|
||||
never released 6.8, instead upping the number to 7.0 (other quite major changes
|
||||
were also present in the 7.0 release).
|
||||
|
||||
A side effect of this work was that the previous limit of 200 on the nesting
|
||||
depth of parentheses was removed. However, there was a downside: compiling ran
|
||||
more slowly than before (30% or more, depending on the pattern) because it now
|
||||
did a full analysis of the pattern. My hope was that this would not be a big
|
||||
issue, and in the event, nobody has commented on it.
|
||||
|
||||
At release 8.34, a limit on the nesting depth of parentheses was re-introduced
|
||||
(default 250, settable at build time) so as to put a limit on the amount of
|
||||
system stack used by the compile function, which uses recursive function calls
|
||||
for nested parenthesized groups. This is a safety feature for environments with
|
||||
small stacks where the patterns are provided by users.
|
||||
|
||||
|
||||
Yet another pattern scan
|
||||
------------------------
|
||||
|
||||
History repeated itself for PCRE2 release 10.20. A number of bugs relating to
|
||||
named subpatterns had been discovered by fuzzers. Most of these were related to
|
||||
the handling of forward references when it was not known if the named group was
|
||||
unique. (References to non-unique names use a different opcode and more
|
||||
memory.) The use of duplicate group numbers (the (?| facility) also caused
|
||||
issues.
|
||||
|
||||
To get around these problems I adopted a new approach by adding a third pass
|
||||
over the pattern (really a "pre-pass"), which did nothing other than identify
|
||||
all the named subpatterns and their corresponding group numbers. This means
|
||||
that the actual compile (both the memory-computing dummy run and the real
|
||||
compile) has full knowledge of group names and numbers throughout. Several
|
||||
dozen lines of messy code were eliminated, though the new pre-pass was not
|
||||
short. In particular, parsing and skipping over [] classes is complicated.
|
||||
|
||||
While working on 10.22 I realized that I could simplify yet again by moving
|
||||
more of the parsing into the pre-pass, thus avoiding doing it in two places, so
|
||||
after 10.22 was released, the code underwent yet another big refactoring. This
|
||||
is how it is from 10.23 onwards:
|
||||
|
||||
The function called parse_regex() scans the pattern characters, parsing them
|
||||
into literal data and meta characters. It converts escapes such as \x{123}
|
||||
into literals, handles \Q...\E, and skips over comments and non-significant
|
||||
white space. The result of the scanning is put into a vector of 32-bit unsigned
|
||||
integers. Values less than 0x80000000 are literal data. Higher values represent
|
||||
meta-characters. The top 16-bits of such values identify the meta-character,
|
||||
and these are given names such as META_CAPTURE. The lower 16-bits are available
|
||||
for data, for example, the capturing group number. The only situation in which
|
||||
literal data values greater than 0x7fffffff can appear is when the 32-bit
|
||||
library is running in non-UTF mode. This is handled by having a special
|
||||
meta-character that is followed by the 32-bit data value.
|
||||
|
||||
The size of the parsed pattern vector, when auto-callouts are not enabled, is
|
||||
bounded by the length of the pattern (with one exception). The code is written
|
||||
so that each item in the pattern uses no more vector elements than the number
|
||||
of code units in the item itself. The exception is the aforementioned large
|
||||
32-bit number handling. For this reason, 32-bit non-UTF patterns are scanned in
|
||||
advance to check for such values. When auto-callouts are enabled, the generous
|
||||
assumption is made that there will be a callout for each pattern code unit
|
||||
(which of course is only actually true if all code units are literals) plus one
|
||||
at the end. There is a default parsed pattern vector on the system stack, but
|
||||
if this is not big enough, heap memory is used.
|
||||
|
||||
As before, the actual compiling function is run twice, the first time to
|
||||
determine the amount of memory needed for the final compiled pattern. It
|
||||
now processes the parsed pattern vector, not the pattern itself, although some
|
||||
of the parsed items refer to strings in the pattern - for example, group
|
||||
names. As escapes and comments have already been processed, the code is a bit
|
||||
simpler than before.
|
||||
|
||||
Most errors can be diagnosed during the parsing scan. For those that cannot
|
||||
(for example, "lookbehind assertion is not fixed length"), the parsed code
|
||||
contains offsets into the pattern so that the actual compiling code can
|
||||
report where errors are.
|
||||
|
||||
|
||||
The elements of the parsed pattern vector
|
||||
-----------------------------------------
|
||||
|
||||
The word "offset" below means a code unit offset into the pattern. When
|
||||
PCRE2_SIZE (which is usually size_t) is no bigger than uint32_t, an offset is
|
||||
stored in a single parsed pattern element. Otherwise (typically on 64-bit
|
||||
systems) it occupies two elements. The following meta items occupy just one
|
||||
element, with no data:
|
||||
|
||||
META_ACCEPT (*ACCEPT)
|
||||
META_ASTERISK *
|
||||
META_ASTERISK_PLUS *+
|
||||
META_ASTERISK_QUERY *?
|
||||
META_ATOMIC (?> start of atomic group
|
||||
META_CIRCUMFLEX ^ metacharacter
|
||||
META_CLASS [ start of non-empty class
|
||||
META_CLASS_EMPTY [] empty class - only with PCRE2_ALLOW_EMPTY_CLASS
|
||||
META_CLASS_EMPTY_NOT [^] negative empty class - ditto
|
||||
META_CLASS_END ] end of non-empty class
|
||||
META_CLASS_NOT [^ start non-empty negative class
|
||||
META_COMMIT (*COMMIT)
|
||||
META_COND_ASSERT (?(?assertion)
|
||||
META_DOLLAR $ metacharacter
|
||||
META_DOT . metacharacter
|
||||
META_END End of pattern (this value is 0x80000000)
|
||||
META_FAIL (*FAIL)
|
||||
META_KET ) closing parenthesis
|
||||
META_LOOKAHEAD (?= start of lookahead
|
||||
META_LOOKAHEADNOT (?! start of negative lookahead
|
||||
META_NOCAPTURE (?: no capture parens
|
||||
META_PLUS +
|
||||
META_PLUS_PLUS ++
|
||||
META_PLUS_QUERY +?
|
||||
META_PRUNE (*PRUNE) - no argument
|
||||
META_QUERY ?
|
||||
META_QUERY_PLUS ?+
|
||||
META_QUERY_QUERY ??
|
||||
META_RANGE_ESCAPED hyphen in class range with at least one escape
|
||||
META_RANGE_LITERAL hyphen in class range defined literally
|
||||
META_SKIP (*SKIP) - no argument
|
||||
META_THEN (*THEN) - no argument
|
||||
|
||||
The two RANGE values occur only in character classes. They are positioned
|
||||
between two literals that define the start and end of the range. In an EBCDIC
|
||||
evironment it is necessary to know whether either of the range values was
|
||||
specified as an escape. In an ASCII/Unicode environment the distinction is not
|
||||
relevant.
|
||||
|
||||
The following have data in the lower 16 bits, and may be followed by other data
|
||||
elements:
|
||||
|
||||
META_ALT | alternation
|
||||
META_BACKREF back reference
|
||||
META_CAPTURE start of capturing group
|
||||
META_ESCAPE non-literal escape sequence
|
||||
META_RECURSE recursion call
|
||||
|
||||
If the data for META_ALT is non-zero, it is inside a lookbehind, and the data
|
||||
is the length of its branch, for which OP_REVERSE must be generated.
|
||||
|
||||
META_BACKREF, META_CAPTURE, and META_RECURSE have the capture group number as
|
||||
their data in the lower 16 bits of the element.
|
||||
|
||||
META_BACKREF is followed by an offset if the back reference group number is 10
|
||||
or more. The offsets of the first ocurrences of references to groups whose
|
||||
numbers are less than 10 are put in cb->small_ref_offset[] (only the first
|
||||
occurrence is useful). On 64-bit systems this avoids using more than two parsed
|
||||
pattern elements for items such as \3. The offset is used when an error occurs
|
||||
because the reference is to a non-existent group.
|
||||
|
||||
META_RECURSE is always followed by an offset, for use in error messages.
|
||||
|
||||
META_ESCAPE has an ESC_xxx value as its data. For ESC_P and ESC_p, the next
|
||||
element contains the 16-bit type and data property values, packed together.
|
||||
ESC_g and ESC_k are used only for named references - numerical ones are turned
|
||||
into META_RECURSE or META_BACKREF as appropriate. ESC_g and ESC_k are followed
|
||||
by a length and an offset into the pattern to specify the name.
|
||||
|
||||
The following have one data item that follows in the next vector element:
|
||||
|
||||
META_BIGVALUE Next is a literal >= META_END
|
||||
META_OPTIONS (?i) and friends (data is new option bits)
|
||||
META_POSIX POSIX class item (data identifies the class)
|
||||
META_POSIX_NEG negative POSIX class item (ditto)
|
||||
|
||||
The following are followed by a length element, then a number of character code
|
||||
values (which should match with the length):
|
||||
|
||||
META_MARK (*MARK:xxxx)
|
||||
META_COMMIT_ARG )*COMMIT:xxxx)
|
||||
META_PRUNE_ARG (*PRUNE:xxx)
|
||||
META_SKIP_ARG (*SKIP:xxxx)
|
||||
META_THEN_ARG (*THEN:xxxx)
|
||||
|
||||
The following are followed by a length element, then an offset in the pattern
|
||||
that identifies the name:
|
||||
|
||||
META_COND_NAME (?(<name>) or (?('name') or (?(name)
|
||||
META_COND_RNAME (?(R&name)
|
||||
META_COND_RNUMBER (?(Rdigits)
|
||||
META_RECURSE_BYNAME (?&name)
|
||||
META_BACKREF_BYNAME \k'name'
|
||||
|
||||
META_COND_RNUMBER is used for names that start with R and continue with digits,
|
||||
because this is an ambiguous case. It could be a back reference to a group with
|
||||
that name, or it could be a recursion test on a numbered group.
|
||||
|
||||
This one is followed by an offset, for use in error messages, then a number:
|
||||
|
||||
META_COND_NUMBER (?([+-]digits)
|
||||
|
||||
The following is followed just by an offset, for use in error messages:
|
||||
|
||||
META_COND_DEFINE (?(DEFINE)
|
||||
|
||||
The following are also followed just by an offset, but also the lower 16 bits
|
||||
of the main word contain the length of the first branch of the lookbehind
|
||||
group; this is used when generating OP_REVERSE for that branch.
|
||||
|
||||
META_LOOKBEHIND (?<=
|
||||
META_LOOKBEHINDNOT (?<!
|
||||
|
||||
The following are followed by two elements, the minimum and maximum. Repeat
|
||||
values are limited to 65535 (MAX_REPEAT). A maximum value of "unlimited" is
|
||||
represented by UNLIMITED_REPEAT, which is bigger than MAX_REPEAT:
|
||||
|
||||
META_MINMAX {n,m} repeat
|
||||
META_MINMAX_PLUS {n,m}+ repeat
|
||||
META_MINMAX_QUERY {n,m}? repeat
|
||||
|
||||
This one is followed by three elements. The first is 0 for '>' and 1 for '>=';
|
||||
the next two are the major and minor numbers:
|
||||
|
||||
META_COND_VERSION (?(VERSION<op>x.y)
|
||||
|
||||
Callouts are converted into one of two items:
|
||||
|
||||
META_CALLOUT_NUMBER (?C with numerical argument
|
||||
META_CALLOUT_STRING (?C with string argument
|
||||
|
||||
In both cases, the next two elements contain the offset and length of the next
|
||||
item in the pattern. Then there is either one callout number, or a length and
|
||||
an offset for the string argument. The length includes both delimiters.
|
||||
|
||||
|
||||
Traditional matching function
|
||||
-----------------------------
|
||||
|
||||
The "traditional", and original, matching function is called pcre2_match(), and
|
||||
it implements an NFA algorithm, similar to the original Henry Spencer algorithm
|
||||
and the way that Perl works. This is not surprising, since it is intended to be
|
||||
as compatible with Perl as possible. This is the function most users of PCRE2
|
||||
will use most of the time. If PCRE2 is compiled with just-in-time (JIT)
|
||||
support, and studying a compiled pattern with JIT is successful, the JIT code
|
||||
is run instead of the normal pcre2_match() code, but the result is the same.
|
||||
|
||||
|
||||
Supplementary matching function
|
||||
-------------------------------
|
||||
|
||||
There is also a supplementary matching function called pcre2_dfa_match(). This
|
||||
implements a DFA matching algorithm that searches simultaneously for all
|
||||
possible matches that start at one point in the subject string. (Going back to
|
||||
my roots: see Historical Note 1 above.) This function intreprets the same
|
||||
compiled pattern data as pcre2_match(); however, not all the facilities are
|
||||
available, and those that are do not always work in quite the same way. See the
|
||||
user documentation for details.
|
||||
|
||||
The algorithm that is used for pcre2_dfa_match() is not a traditional FSM,
|
||||
because it may have a number of states active at one time. More work would be
|
||||
needed at compile time to produce a traditional FSM where only one state is
|
||||
ever active at once. I believe some other regex matchers work this way. JIT
|
||||
support is not available for this kind of matching.
|
||||
|
||||
|
||||
Changeable options
|
||||
------------------
|
||||
|
||||
The /i, /m, or /s options (PCRE2_CASELESS, PCRE2_MULTILINE, PCRE2_DOTALL, and
|
||||
others) may be changed in the middle of patterns by items such as (?i). Their
|
||||
processing is handled entirely at compile time by generating different opcodes
|
||||
for the different settings. The runtime functions do not need to keep track of
|
||||
an option's state.
|
||||
|
||||
PCRE2_DUPNAMES, PCRE2_EXTENDED, PCRE2_EXTENDED_MORE, and PCRE2_NO_AUTO_CAPTURE
|
||||
are tracked and processed during the parsing pre-pass. The others are handled
|
||||
from META_OPTIONS items during the main compile phase.
|
||||
|
||||
|
||||
Format of compiled patterns
|
||||
---------------------------
|
||||
|
||||
The compiled form of a pattern is a vector of unsigned code units (bytes in
|
||||
8-bit mode, shorts in 16-bit mode, 32-bit words in 32-bit mode), containing
|
||||
items of variable length. The first code unit in an item contains an opcode,
|
||||
and the length of the item is either implicit in the opcode or contained in the
|
||||
data that follows it.
|
||||
|
||||
In many cases listed below, LINK_SIZE data values are specified for offsets
|
||||
within the compiled pattern. LINK_SIZE always specifies a number of bytes. The
|
||||
default value for LINK_SIZE is 2, except for the 32-bit library, where it can
|
||||
only be 4. The 8-bit library can be compiled to used 3-byte or 4-byte values,
|
||||
and the 16-bit library can be compiled to use 4-byte values, though this
|
||||
impairs performance. Specifing a LINK_SIZE larger than 2 for these libraries is
|
||||
necessary only when patterns whose compiled length is greater than 65535 code
|
||||
units are going to be processed. When a LINK_SIZE value uses more than one code
|
||||
unit, the most significant unit is first.
|
||||
|
||||
In this description, we assume the "normal" compilation options. Data values
|
||||
that are counts (e.g. quantifiers) are always two bytes long in 8-bit mode
|
||||
(most significant byte first), and one code unit in 16-bit and 32-bit modes.
|
||||
|
||||
|
||||
Opcodes with no following data
|
||||
------------------------------
|
||||
|
||||
These items are all just one unit long:
|
||||
|
||||
OP_END end of pattern
|
||||
OP_ANY match any one character other than newline
|
||||
OP_ALLANY match any one character, including newline
|
||||
OP_ANYBYTE match any single code unit, even in UTF-8/16 mode
|
||||
OP_SOD match start of data: \A
|
||||
OP_SOM, start of match (subject + offset): \G
|
||||
OP_SET_SOM, set start of match (\K)
|
||||
OP_CIRC ^ (start of data)
|
||||
OP_CIRCM ^ multiline mode (start of data or after newline)
|
||||
OP_NOT_WORD_BOUNDARY \W
|
||||
OP_WORD_BOUNDARY \w
|
||||
OP_NOT_DIGIT \D
|
||||
OP_DIGIT \d
|
||||
OP_NOT_HSPACE \H
|
||||
OP_HSPACE \h
|
||||
OP_NOT_WHITESPACE \S
|
||||
OP_WHITESPACE \s
|
||||
OP_NOT_VSPACE \V
|
||||
OP_VSPACE \v
|
||||
OP_NOT_WORDCHAR \W
|
||||
OP_WORDCHAR \w
|
||||
OP_EODN match end of data or newline at end: \Z
|
||||
OP_EOD match end of data: \z
|
||||
OP_DOLL $ (end of data, or before final newline)
|
||||
OP_DOLLM $ multiline mode (end of data or before newline)
|
||||
OP_EXTUNI match an extended Unicode grapheme cluster
|
||||
OP_ANYNL match any Unicode newline sequence
|
||||
|
||||
OP_ASSERT_ACCEPT )
|
||||
OP_ACCEPT ) These are Perl 5.10's "backtracking control
|
||||
OP_COMMIT ) verbs". If OP_ACCEPT is inside capturing
|
||||
OP_FAIL ) parentheses, it may be preceded by one or more
|
||||
OP_PRUNE ) OP_CLOSE, each followed by a number that
|
||||
OP_SKIP ) indicates which parentheses must be closed.
|
||||
OP_THEN )
|
||||
|
||||
OP_ASSERT_ACCEPT is used when (*ACCEPT) is encountered within an assertion.
|
||||
This ends the assertion, not the entire pattern match. The assertion (?!) is
|
||||
always optimized to OP_FAIL.
|
||||
|
||||
OP_ALLANY is used for '.' when PCRE2_DOTALL is set. It is also used for \C in
|
||||
non-UTF modes and in UTF-32 mode (since one code unit still equals one
|
||||
character). Another use is for [^] when empty classes are permitted
|
||||
(PCRE2_ALLOW_EMPTY_CLASS is set).
|
||||
|
||||
|
||||
Backtracking control verbs
|
||||
--------------------------
|
||||
|
||||
Verbs with no arguments generate opcodes with no following data (as listed
|
||||
in the section above).
|
||||
|
||||
(*MARK:NAME) generates OP_MARK followed by the mark name, preceded by a
|
||||
length in one code unit, and followed by a binary zero. The name length is
|
||||
limited by the size of the code unit.
|
||||
|
||||
(*ACCEPT:NAME) and (*FAIL:NAME) are compiled as (*MARK:NAME)(*ACCEPT) and
|
||||
(*MARK:NAME)(*FAIL) respectively.
|
||||
|
||||
For (*COMMIT:NAME), (*PRUNE:NAME), (*SKIP:NAME), and (*THEN:NAME), the opcodes
|
||||
OP_COMMIT_ARG, OP_PRUNE_ARG, OP_SKIP_ARG, and OP_THEN_ARG are used, with the
|
||||
name following in the same format as for OP_MARK.
|
||||
|
||||
|
||||
Matching literal characters
|
||||
---------------------------
|
||||
|
||||
The OP_CHAR opcode is followed by a single character that is to be matched
|
||||
casefully. For caseless matching of characters that have at most two
|
||||
case-equivalent code points, OP_CHARI is used. In UTF-8 or UTF-16 modes, the
|
||||
character may be more than one code unit long. In UTF-32 mode, characters are
|
||||
always exactly one code unit long.
|
||||
|
||||
If there is only one character in a character class, OP_CHAR or OP_CHARI is
|
||||
used for a positive class, and OP_NOT or OP_NOTI for a negative one (that is,
|
||||
for something like [^a]).
|
||||
|
||||
Caseless matching (positive or negative) of characters that have more than two
|
||||
case-equivalent code points (which is possible only in UTF mode) is handled by
|
||||
compiling a Unicode property item (see below), with the pseudo-property
|
||||
PT_CLIST. The value of this property is an offset in a vector called
|
||||
"ucd_caseless_sets" which identifies the start of a short list of equivalent
|
||||
characters, terminated by the value NOTACHAR (0xffffffff).
|
||||
|
||||
|
||||
Repeating single characters
|
||||
---------------------------
|
||||
|
||||
The common repeats (*, +, ?), when applied to a single character, use the
|
||||
following opcodes, which come in caseful and caseless versions:
|
||||
|
||||
Caseful Caseless
|
||||
OP_STAR OP_STARI
|
||||
OP_MINSTAR OP_MINSTARI
|
||||
OP_POSSTAR OP_POSSTARI
|
||||
OP_PLUS OP_PLUSI
|
||||
OP_MINPLUS OP_MINPLUSI
|
||||
OP_POSPLUS OP_POSPLUSI
|
||||
OP_QUERY OP_QUERYI
|
||||
OP_MINQUERY OP_MINQUERYI
|
||||
OP_POSQUERY OP_POSQUERYI
|
||||
|
||||
Each opcode is followed by the character that is to be repeated. In ASCII or
|
||||
UTF-32 modes, these are two-code-unit items; in UTF-8 or UTF-16 modes, the
|
||||
length is variable. Those with "MIN" in their names are the minimizing
|
||||
versions. Those with "POS" in their names are possessive versions. Other kinds
|
||||
of repeat make use of these opcodes:
|
||||
|
||||
Caseful Caseless
|
||||
OP_UPTO OP_UPTOI
|
||||
OP_MINUPTO OP_MINUPTOI
|
||||
OP_POSUPTO OP_POSUPTOI
|
||||
OP_EXACT OP_EXACTI
|
||||
|
||||
Each of these is followed by a count and then the repeated character. The count
|
||||
is two bytes long in 8-bit mode (most significant byte first), or one code unit
|
||||
in 16-bit and 32-bit modes.
|
||||
|
||||
OP_UPTO matches from 0 to the given number. A repeat with a non-zero minimum
|
||||
and a fixed maximum is coded as an OP_EXACT followed by an OP_UPTO (or
|
||||
OP_MINUPTO or OPT_POSUPTO).
|
||||
|
||||
Another set of matching repeating opcodes (called OP_NOTSTAR, OP_NOTSTARI,
|
||||
etc.) are used for repeated, negated, single-character classes such as [^a]*.
|
||||
The normal single-character opcodes (OP_STAR, etc.) are used for repeated
|
||||
positive single-character classes.
|
||||
|
||||
|
||||
Repeating character types
|
||||
-------------------------
|
||||
|
||||
Repeats of things like \d are done exactly as for single characters, except
|
||||
that instead of a character, the opcode for the type (e.g. OP_DIGIT) is stored
|
||||
in the next code unit. The opcodes are:
|
||||
|
||||
OP_TYPESTAR
|
||||
OP_TYPEMINSTAR
|
||||
OP_TYPEPOSSTAR
|
||||
OP_TYPEPLUS
|
||||
OP_TYPEMINPLUS
|
||||
OP_TYPEPOSPLUS
|
||||
OP_TYPEQUERY
|
||||
OP_TYPEMINQUERY
|
||||
OP_TYPEPOSQUERY
|
||||
OP_TYPEUPTO
|
||||
OP_TYPEMINUPTO
|
||||
OP_TYPEPOSUPTO
|
||||
OP_TYPEEXACT
|
||||
|
||||
|
||||
Match by Unicode property
|
||||
-------------------------
|
||||
|
||||
OP_PROP and OP_NOTPROP are used for positive and negative matches of a
|
||||
character by testing its Unicode property (the \p and \P escape sequences).
|
||||
Each is followed by two code units that encode the desired property as a type
|
||||
and a value. The types are a set of #defines of the form PT_xxx, and the values
|
||||
are enumerations of the form ucp_xx, defined in the pcre2_ucp.h source file.
|
||||
The value is relevant only for PT_GC (General Category), PT_PC (Particular
|
||||
Category), PT_SC (Script), and the pseudo-property PT_CLIST, which is used to
|
||||
identify a list of case-equivalent characters when there are three or more.
|
||||
|
||||
Repeats of these items use the OP_TYPESTAR etc. set of opcodes, followed by
|
||||
three code units: OP_PROP or OP_NOTPROP, and then the desired property type and
|
||||
value.
|
||||
|
||||
|
||||
Character classes
|
||||
-----------------
|
||||
|
||||
If there is only one character in a class, OP_CHAR or OP_CHARI is used for a
|
||||
positive class, and OP_NOT or OP_NOTI for a negative one (that is, for
|
||||
something like [^a]), except when caselessly matching a character that has more
|
||||
than two case-equivalent code points (which can happen only in UTF mode). In
|
||||
this case a Unicode property item is used, as described above in "Matching
|
||||
literal characters".
|
||||
|
||||
A set of repeating opcodes (called OP_NOTSTAR etc.) are used for repeated,
|
||||
negated, single-character classes. The normal single-character opcodes
|
||||
(OP_STAR, etc.) are used for repeated positive single-character classes.
|
||||
|
||||
When there is more than one character in a class, and all the code points are
|
||||
less than 256, OP_CLASS is used for a positive class, and OP_NCLASS for a
|
||||
negative one. In either case, the opcode is followed by a 32-byte (16-short,
|
||||
8-word) bit map containing a 1 bit for every character that is acceptable. The
|
||||
bits are counted from the least significant end of each unit. In caseless mode,
|
||||
bits for both cases are set.
|
||||
|
||||
The reason for having both OP_CLASS and OP_NCLASS is so that, in UTF-8 and
|
||||
16-bit and 32-bit modes, subject characters with values greater than 255 can be
|
||||
handled correctly. For OP_CLASS they do not match, whereas for OP_NCLASS they
|
||||
do.
|
||||
|
||||
For classes containing characters with values greater than 255 or that contain
|
||||
\p or \P, OP_XCLASS is used. It optionally uses a bit map if any acceptable
|
||||
code points are less than 256, followed by a list of pairs (for a range) and/or
|
||||
single characters and/or properties. In caseless mode, all equivalent
|
||||
characters are explicitly listed.
|
||||
|
||||
OP_XCLASS is followed by a LINK_SIZE value containing the total length of the
|
||||
opcode and its data. This is followed by a code unit containing flag bits:
|
||||
XCL_NOT indicates that this is a negative class, and XCL_MAP indicates that a
|
||||
bit map is present. There follows the bit map, if XCL_MAP is set, and then a
|
||||
sequence of items coded as follows:
|
||||
|
||||
XCL_END marks the end of the list
|
||||
XCL_SINGLE one character follows
|
||||
XCL_RANGE two characters follow
|
||||
XCL_PROP a Unicode property (type, value) follows
|
||||
XCL_NOTPROP a Unicode property (type, value) follows
|
||||
|
||||
If a range starts with a code point less than 256 and ends with one greater
|
||||
than 255, it is split into two ranges, with characters less than 256 being
|
||||
indicated in the bit map, and the rest with XCL_RANGE.
|
||||
|
||||
When XCL_NOT is set, the bit map, if present, contains bits for characters that
|
||||
are allowed (exactly as for OP_NCLASS), but the list of items that follow it
|
||||
specifies characters and properties that are not allowed.
|
||||
|
||||
|
||||
Back references
|
||||
---------------
|
||||
|
||||
OP_REF (caseful) or OP_REFI (caseless) is followed by a count containing the
|
||||
reference number when the reference is to a unique capturing group (either by
|
||||
number or by name). When named groups are used, there may be more than one
|
||||
group with the same name. In this case, a reference to such a group by name
|
||||
generates OP_DNREF or OP_DNREFI. These are followed by two counts: the index
|
||||
(not the byte offset) in the group name table of the first entry for the
|
||||
required name, followed by the number of groups with the same name. The
|
||||
matching code can then search for the first one that is set.
|
||||
|
||||
|
||||
Repeating character classes and back references
|
||||
-----------------------------------------------
|
||||
|
||||
Single-character classes are handled specially (see above). This section
|
||||
applies to other classes and also to back references. In both cases, the repeat
|
||||
information follows the base item. The matching code looks at the following
|
||||
opcode to see if it is one of these:
|
||||
|
||||
OP_CRSTAR
|
||||
OP_CRMINSTAR
|
||||
OP_CRPOSSTAR
|
||||
OP_CRPLUS
|
||||
OP_CRMINPLUS
|
||||
OP_CRPOSPLUS
|
||||
OP_CRQUERY
|
||||
OP_CRMINQUERY
|
||||
OP_CRPOSQUERY
|
||||
OP_CRRANGE
|
||||
OP_CRMINRANGE
|
||||
OP_CRPOSRANGE
|
||||
|
||||
All but the last three are single-code-unit items, with no data. The range
|
||||
opcodes are followed by the minimum and maximum repeat counts.
|
||||
|
||||
|
||||
Brackets and alternation
|
||||
------------------------
|
||||
|
||||
A pair of non-capturing round brackets is wrapped round each expression at
|
||||
compile time, so alternation always happens in the context of brackets.
|
||||
|
||||
[Note for North Americans: "bracket" to some English speakers, including
|
||||
myself, can be round, square, curly, or pointy. Hence this usage rather than
|
||||
"parentheses".]
|
||||
|
||||
Non-capturing brackets use the opcode OP_BRA, capturing brackets use OP_CBRA. A
|
||||
bracket opcode is followed by a LINK_SIZE value which gives the offset to the
|
||||
next alternative OP_ALT or, if there aren't any branches, to the terminating
|
||||
opcode. Each OP_ALT is followed by a LINK_SIZE value giving the offset to the
|
||||
next one, or to the final opcode. For capturing brackets, the bracket number is
|
||||
a count that immediately follows the offset.
|
||||
|
||||
There are several opcodes that mark the end of a subpattern group. OP_KET is
|
||||
used for subpatterns that do not repeat indefinitely, OP_KETRMIN and
|
||||
OP_KETRMAX are used for indefinite repetitions, minimally or maximally
|
||||
respectively, and OP_KETRPOS for possessive repetitions (see below for more
|
||||
details). All four are followed by a LINK_SIZE value giving (as a positive
|
||||
number) the offset back to the matching bracket opcode.
|
||||
|
||||
If a subpattern is quantified such that it is permitted to match zero times, it
|
||||
is preceded by one of OP_BRAZERO, OP_BRAMINZERO, or OP_SKIPZERO. These are
|
||||
single-unit opcodes that tell the matcher that skipping the following
|
||||
subpattern entirely is a valid match. In the case of the first two, not
|
||||
skipping the pattern is also valid (greedy and non-greedy). The third is used
|
||||
when a pattern has the quantifier {0,0}. It cannot be entirely discarded,
|
||||
because it may be called as a subroutine from elsewhere in the pattern.
|
||||
|
||||
A subpattern with an indefinite maximum repetition is replicated in the
|
||||
compiled data its minimum number of times (or once with OP_BRAZERO if the
|
||||
minimum is zero), with the final copy terminating with OP_KETRMIN or OP_KETRMAX
|
||||
as appropriate.
|
||||
|
||||
A subpattern with a bounded maximum repetition is replicated in a nested
|
||||
fashion up to the maximum number of times, with OP_BRAZERO or OP_BRAMINZERO
|
||||
before each replication after the minimum, so that, for example, (abc){2,5} is
|
||||
compiled as (abc)(abc)((abc)((abc)(abc)?)?)?, except that each bracketed group
|
||||
has the same number.
|
||||
|
||||
When a repeated subpattern has an unbounded upper limit, it is checked to see
|
||||
whether it could match an empty string. If this is the case, the opcode in the
|
||||
final replication is changed to OP_SBRA or OP_SCBRA. This tells the matcher
|
||||
that it needs to check for matching an empty string when it hits OP_KETRMIN or
|
||||
OP_KETRMAX, and if so, to break the loop.
|
||||
|
||||
|
||||
Possessive brackets
|
||||
-------------------
|
||||
|
||||
When a repeated group (capturing or non-capturing) is marked as possessive by
|
||||
the "+" notation, e.g. (abc)++, different opcodes are used. Their names all
|
||||
have POS on the end, e.g. OP_BRAPOS instead of OP_BRA and OP_SCBRAPOS instead
|
||||
of OP_SCBRA. The end of such a group is marked by OP_KETRPOS. If the minimum
|
||||
repetition is zero, the group is preceded by OP_BRAPOSZERO.
|
||||
|
||||
|
||||
Once-only (atomic) groups
|
||||
-------------------------
|
||||
|
||||
These are just like other subpatterns, but they start with the opcode OP_ONCE.
|
||||
The check for matching an empty string in an unbounded repeat is handled
|
||||
entirely at runtime, so there is just this one opcode for atomic groups.
|
||||
|
||||
|
||||
Assertions
|
||||
----------
|
||||
|
||||
Forward assertions are also just like other subpatterns, but starting with one
|
||||
of the opcodes OP_ASSERT or OP_ASSERT_NOT. Backward assertions use the opcodes
|
||||
OP_ASSERTBACK and OP_ASSERTBACK_NOT, and the first opcode inside the assertion
|
||||
is OP_REVERSE, followed by a count of the number of characters to move back the
|
||||
pointer in the subject string. In ASCII or UTF-32 mode, the count is also the
|
||||
number of code units, but in UTF-8/16 mode each character may occupy more than
|
||||
one code unit. A separate count is present in each alternative of a lookbehind
|
||||
assertion, allowing them to have different (but fixed) lengths.
|
||||
|
||||
|
||||
Conditional subpatterns
|
||||
-----------------------
|
||||
|
||||
These are like other subpatterns, but they start with the opcode OP_COND, or
|
||||
OP_SCOND for one that might match an empty string in an unbounded repeat.
|
||||
|
||||
If the condition is a back reference, this is stored at the start of the
|
||||
subpattern using the opcode OP_CREF followed by a count containing the
|
||||
reference number, provided that the reference is to a unique capturing group.
|
||||
If the reference was by name and there is more than one group with that name,
|
||||
OP_DNCREF is used instead. It is followed by two counts: the index in the group
|
||||
names table, and the number of groups with the same name. The allows the
|
||||
matcher to check if any group with the given name is set.
|
||||
|
||||
If the condition is "in recursion" (coded as "(?(R)"), or "in recursion of
|
||||
group x" (coded as "(?(Rx)"), the group number is stored at the start of the
|
||||
subpattern using the opcode OP_RREF (with a value of RREF_ANY (0xffff) for "the
|
||||
whole pattern") or OP_DNRREF (with data as for OP_DNCREF).
|
||||
|
||||
For a DEFINE condition, OP_FALSE is used (with no associated data). During
|
||||
compilation, however, a DEFINE condition is coded as OP_DEFINE so that, when
|
||||
the conditional group is complete, there can be a check to ensure that it
|
||||
contains only one top-level branch. Once this has happened, the opcode is
|
||||
changed to OP_FALSE, so the matcher never sees OP_DEFINE.
|
||||
|
||||
There is a special PCRE2-specific condition of the form (VERSION[>]=x.y), which
|
||||
tests the PCRE2 version number. This compiles into one of the opcodes OP_TRUE
|
||||
or OP_FALSE.
|
||||
|
||||
If a condition is not a back reference, recursion test, DEFINE, or VERSION, it
|
||||
must start with a parenthesized assertion, whose opcode normally immediately
|
||||
follows OP_COND or OP_SCOND. However, if automatic callouts are enabled, a
|
||||
callout is inserted immediately before the assertion. It is also possible to
|
||||
insert a manual callout at this point. Only assertion conditions may have
|
||||
callouts preceding the condition.
|
||||
|
||||
A condition that is the negative assertion (?!) is optimized to OP_FAIL in all
|
||||
parts of the pattern, so this is another opcode that may appear as a condition.
|
||||
It is treated the same as OP_FALSE.
|
||||
|
||||
|
||||
Recursion
|
||||
---------
|
||||
|
||||
Recursion either matches the current pattern, or some subexpression. The opcode
|
||||
OP_RECURSE is followed by a LINK_SIZE value that is the offset to the starting
|
||||
bracket from the start of the whole pattern. OP_RECURSE is also used for
|
||||
"subroutine" calls, even though they are not strictly a recursion. Up till
|
||||
release 10.30 recursions were treated as atomic groups, making them
|
||||
incompatible with Perl (but PCRE had them well before Perl did). From 10.30,
|
||||
backtracking into recursions is supported.
|
||||
|
||||
Repeated recursions used to be wrapped inside OP_ONCE brackets, which not only
|
||||
forced no backtracking, but also allowed repetition to be handled as for other
|
||||
bracketed groups. From 10.30 onwards, repeated recursions are duplicated for
|
||||
their minimum repetitions, and then wrapped in non-capturing brackets for the
|
||||
remainder. For example, (?1){3} is treated as (?1)(?1)(?1), and (?1){2,4} is
|
||||
treated as (?1)(?1)(?:(?1)){0,2}.
|
||||
|
||||
|
||||
Callouts
|
||||
--------
|
||||
|
||||
A callout may have either a numerical argument or a string argument. These use
|
||||
OP_CALLOUT or OP_CALLOUT_STR, respectively. In each case these are followed by
|
||||
two LINK_SIZE values giving the offset in the pattern string to the start of
|
||||
the following item, and another count giving the length of this item. These
|
||||
values make it possible for pcre2test to output useful tracing information
|
||||
using callouts.
|
||||
|
||||
In the case of a numeric callout, after these two values there is a single code
|
||||
unit containing the callout number, in the range 0-255, with 255 being used for
|
||||
callouts that are automatically inserted as a result of the PCRE2_AUTO_CALLOUT
|
||||
option. Thus, this opcode item is of fixed length:
|
||||
|
||||
[OP_CALLOUT] [PATTERN_OFFSET] [PATTERN_LENGTH] [NUMBER]
|
||||
|
||||
For callouts with string arguments, OP_CALLOUT_STR has three more data items:
|
||||
a LINK_SIZE value giving the complete length of the entire opcode item, a
|
||||
LINK_SIZE item containing the offset within the pattern string to the start of
|
||||
the string argument, and the string itself, preceded by its starting delimiter
|
||||
and followed by a binary zero. When a callout function is called, a pointer to
|
||||
the actual string is passed, but the delimiter can be accessed as string[-1] if
|
||||
the application needs it. In the 8-bit library, the callout in /X(?C'abc')Y/ is
|
||||
compiled as the following bytes (decimal numbers represent binary values):
|
||||
|
||||
[OP_CALLOUT_STR] [0] [10] [0] [1] [0] [14] [0] [5] ['] [a] [b] [c] [0]
|
||||
-------- ------- -------- -------
|
||||
| | | |
|
||||
------- LINK_SIZE items ------
|
||||
|
||||
Opcode table checking
|
||||
---------------------
|
||||
|
||||
The last opcode that is defined in pcre2_internal.h is OP_TABLE_LENGTH. This is
|
||||
not a real opcode, but is used to check at compile time that tables indexed by
|
||||
opcode are the correct length, in order to catch updating errors.
|
||||
|
||||
Philip Hazel
|
||||
20 July 2018
|
|
@ -0,0 +1,368 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell command './configure && make && make install'
|
||||
should configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the 'README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
'INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
|
||||
The 'configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a 'Makefile' in each directory of the package.
|
||||
It may also create one or more '.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script 'config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file 'config.log' containing compiler output (useful mainly for
|
||||
debugging 'configure').
|
||||
|
||||
It can also use an optional file (typically called 'config.cache' and
|
||||
enabled with '--cache-file=config.cache' or simply '-C') that saves the
|
||||
results of its tests to speed up reconfiguring. Caching is disabled by
|
||||
default to prevent problems with accidental use of stale cache files.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how 'configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the 'README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point 'config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file 'configure.ac' (or 'configure.in') is used to create
|
||||
'configure' by a program called 'autoconf'. You need 'configure.ac' if
|
||||
you want to change it or regenerate 'configure' using a newer version of
|
||||
'autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. 'cd' to the directory containing the package's source code and type
|
||||
'./configure' to configure the package for your system.
|
||||
|
||||
Running 'configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type 'make' to compile the package.
|
||||
|
||||
3. Optionally, type 'make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type 'make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the 'make install' phase executed with root
|
||||
privileges.
|
||||
|
||||
5. Optionally, type 'make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior 'make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing 'make clean'. To also remove the
|
||||
files that 'configure' created (so you can compile the package for
|
||||
a different kind of computer), type 'make distclean'. There is
|
||||
also a 'make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
7. Often, you can also type 'make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide 'make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like 'make install' and 'make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the 'configure' script does not know about. Run './configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give 'configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here is
|
||||
an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU 'make'. 'cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the 'configure' script. 'configure' automatically checks for the source
|
||||
code in the directory that 'configure' is in and in '..'. This is known
|
||||
as a "VPATH" build.
|
||||
|
||||
With a non-GNU 'make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use 'make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple '-arch' options to the
|
||||
compiler but only a single '-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the 'lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, 'make install' installs the package's commands under
|
||||
'/usr/local/bin', include files under '/usr/local/include', etc. You
|
||||
can specify an installation prefix other than '/usr/local' by giving
|
||||
'configure' the option '--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like '--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run 'configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the default
|
||||
for these options is expressed in terms of '${prefix}', so that
|
||||
specifying just '--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to 'configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
'make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, 'make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
'${prefix}'. Any directories that were specified during 'configure',
|
||||
but not in terms of '${prefix}', must each be overridden at install time
|
||||
for the entire installation to be relocated. The approach of makefile
|
||||
variable overrides for each directory variable is required by the GNU
|
||||
Coding Standards, and ideally causes no recompilation. However, some
|
||||
platforms have known limitations with the semantics of shared libraries
|
||||
that end up requiring recompilation when using this method, particularly
|
||||
noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the 'DESTDIR' variable. For
|
||||
example, 'make install DESTDIR=/alternate/directory' will prepend
|
||||
'/alternate/directory' before all installation names. The approach of
|
||||
'DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of '${prefix}'
|
||||
at 'configure' time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving 'configure' the
|
||||
option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to '--enable-FEATURE' options to
|
||||
'configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
|
||||
is something like 'gnu-as' or 'x' (for the X Window System). The
|
||||
'README' should mention any '--enable-' and '--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, 'configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the 'configure' options '--x-includes=DIR' and
|
||||
'--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of 'make' will be. For these packages, running './configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with 'make V=1'; while running './configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with 'make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
|
||||
is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
HP-UX 'make' updates targets which have the same time stamps as their
|
||||
prerequisites, which makes it generally unusable when shipped generated
|
||||
files such as 'configure' are involved. Use GNU 'make' instead.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
|
||||
workaround. If GNU CC is not installed, it is therefore recommended to
|
||||
try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
|
||||
in your 'PATH', put it _after_ '/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in '/boot/common',
|
||||
not '/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features 'configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, 'configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
'--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as 'sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
See the file 'config.sub' for the possible values of each field. If
|
||||
'config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option '--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with '--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for 'configure' scripts to share,
|
||||
you can create a site shell script called 'config.site' that gives
|
||||
default values for variables like 'CC', 'cache_file', and 'prefix'.
|
||||
'configure' looks for 'PREFIX/share/config.site' if it exists, then
|
||||
'PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
'CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all 'configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to 'configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the 'configure' command line, using 'VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified 'gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
|
||||
Autoconf limitation. Until the limitation is lifted, you can use this
|
||||
workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
'configure' Invocation
|
||||
======================
|
||||
|
||||
'configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
'--help'
|
||||
'-h'
|
||||
Print a summary of all of the options to 'configure', and exit.
|
||||
|
||||
'--help=short'
|
||||
'--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
'configure', and exit. The 'short' variant lists options used only
|
||||
in the top level, while the 'recursive' variant lists options also
|
||||
present in any nested packages.
|
||||
|
||||
'--version'
|
||||
'-V'
|
||||
Print the version of Autoconf used to generate the 'configure'
|
||||
script, and exit.
|
||||
|
||||
'--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally 'config.cache'. FILE defaults to '/dev/null' to
|
||||
disable caching.
|
||||
|
||||
'--config-cache'
|
||||
'-C'
|
||||
Alias for '--cache-file=config.cache'.
|
||||
|
||||
'--quiet'
|
||||
'--silent'
|
||||
'-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to '/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
'--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
'configure' can determine that directory automatically.
|
||||
|
||||
'--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names:: for
|
||||
more details, including other options available for fine-tuning the
|
||||
installation locations.
|
||||
|
||||
'--no-create'
|
||||
'-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
'configure' also accepts some other, not widely useful, options. Run
|
||||
'configure --help' for more details.
|
|
@ -0,0 +1,94 @@
|
|||
PCRE2 LICENCE
|
||||
-------------
|
||||
|
||||
PCRE2 is a library of functions to support regular expressions whose syntax
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Releases 10.00 and above of PCRE2 are distributed under the terms of the "BSD"
|
||||
licence, as specified below, with one exemption for certain binary
|
||||
redistributions. The documentation for PCRE2, supplied in the "doc" directory,
|
||||
is distributed under the same terms as the software itself. The data in the
|
||||
testdata directory is not copyrighted and is in the public domain.
|
||||
|
||||
The basic library functions are written in C and are freestanding. Also
|
||||
included in the distribution is a just-in-time compiler that can be used to
|
||||
optimize pattern matching. This is an optional feature that can be omitted when
|
||||
the library is built.
|
||||
|
||||
|
||||
THE BASIC LIBRARY FUNCTIONS
|
||||
---------------------------
|
||||
|
||||
Written by: Philip Hazel
|
||||
Email local part: ph10
|
||||
Email domain: cam.ac.uk
|
||||
|
||||
University of Cambridge Computing Service,
|
||||
Cambridge, England.
|
||||
|
||||
Copyright (c) 1997-2019 University of Cambridge
|
||||
All rights reserved.
|
||||
|
||||
|
||||
PCRE2 JUST-IN-TIME COMPILATION SUPPORT
|
||||
--------------------------------------
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Email domain: freemail.hu
|
||||
|
||||
Copyright(c) 2010-2019 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
|
||||
STACK-LESS JUST-IN-TIME COMPILER
|
||||
--------------------------------
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Email domain: freemail.hu
|
||||
|
||||
Copyright(c) 2009-2019 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
|
||||
THE "BSD" LICENCE
|
||||
-----------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notices,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notices, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the University of Cambridge nor the names of any
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
EXEMPTION FOR BINARY LIBRARY-LIKE PACKAGES
|
||||
------------------------------------------
|
||||
|
||||
The second condition in the BSD licence (covering binary redistributions) does
|
||||
not apply all the way down a chain of software. If binary package A includes
|
||||
PCRE2, it must respect the condition, but if package B is software that
|
||||
includes package A, the condition is not imposed on package B unless it uses
|
||||
PCRE2 independently.
|
||||
|
||||
End
|
|
@ -0,0 +1,858 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
## This seems to have become necessary for building in non-source directory.
|
||||
|
||||
AM_CPPFLAGS="-I$(srcdir)/src"
|
||||
|
||||
## Specify the documentation files that are distributed.
|
||||
|
||||
dist_doc_DATA = \
|
||||
AUTHORS \
|
||||
COPYING \
|
||||
ChangeLog \
|
||||
LICENCE \
|
||||
NEWS \
|
||||
README \
|
||||
doc/pcre2.txt \
|
||||
doc/pcre2-config.txt \
|
||||
doc/pcre2grep.txt \
|
||||
doc/pcre2test.txt
|
||||
|
||||
dist_html_DATA = \
|
||||
doc/html/NON-AUTOTOOLS-BUILD.txt \
|
||||
doc/html/README.txt \
|
||||
doc/html/index.html \
|
||||
doc/html/pcre2-config.html \
|
||||
doc/html/pcre2.html \
|
||||
doc/html/pcre2_callout_enumerate.html \
|
||||
doc/html/pcre2_code_copy.html \
|
||||
doc/html/pcre2_code_copy_with_tables.html \
|
||||
doc/html/pcre2_code_free.html \
|
||||
doc/html/pcre2_compile.html \
|
||||
doc/html/pcre2_compile_context_copy.html \
|
||||
doc/html/pcre2_compile_context_create.html \
|
||||
doc/html/pcre2_compile_context_free.html \
|
||||
doc/html/pcre2_config.html \
|
||||
doc/html/pcre2_convert_context_copy.html \
|
||||
doc/html/pcre2_convert_context_create.html \
|
||||
doc/html/pcre2_convert_context_free.html \
|
||||
doc/html/pcre2_converted_pattern_free.html \
|
||||
doc/html/pcre2_dfa_match.html \
|
||||
doc/html/pcre2_general_context_copy.html \
|
||||
doc/html/pcre2_general_context_create.html \
|
||||
doc/html/pcre2_general_context_free.html \
|
||||
doc/html/pcre2_get_error_message.html \
|
||||
doc/html/pcre2_get_mark.html \
|
||||
doc/html/pcre2_get_ovector_count.html \
|
||||
doc/html/pcre2_get_ovector_pointer.html \
|
||||
doc/html/pcre2_get_startchar.html \
|
||||
doc/html/pcre2_jit_compile.html \
|
||||
doc/html/pcre2_jit_free_unused_memory.html \
|
||||
doc/html/pcre2_jit_match.html \
|
||||
doc/html/pcre2_jit_stack_assign.html \
|
||||
doc/html/pcre2_jit_stack_create.html \
|
||||
doc/html/pcre2_jit_stack_free.html \
|
||||
doc/html/pcre2_maketables.html \
|
||||
doc/html/pcre2_match.html \
|
||||
doc/html/pcre2_match_context_copy.html \
|
||||
doc/html/pcre2_match_context_create.html \
|
||||
doc/html/pcre2_match_context_free.html \
|
||||
doc/html/pcre2_match_data_create.html \
|
||||
doc/html/pcre2_match_data_create_from_pattern.html \
|
||||
doc/html/pcre2_match_data_free.html \
|
||||
doc/html/pcre2_pattern_convert.html \
|
||||
doc/html/pcre2_pattern_info.html \
|
||||
doc/html/pcre2_serialize_decode.html \
|
||||
doc/html/pcre2_serialize_encode.html \
|
||||
doc/html/pcre2_serialize_free.html \
|
||||
doc/html/pcre2_serialize_get_number_of_codes.html \
|
||||
doc/html/pcre2_set_bsr.html \
|
||||
doc/html/pcre2_set_callout.html \
|
||||
doc/html/pcre2_set_character_tables.html \
|
||||
doc/html/pcre2_set_compile_extra_options.html \
|
||||
doc/html/pcre2_set_compile_recursion_guard.html \
|
||||
doc/html/pcre2_set_depth_limit.html \
|
||||
doc/html/pcre2_set_glob_escape.html \
|
||||
doc/html/pcre2_set_glob_separator.html \
|
||||
doc/html/pcre2_set_heap_limit.html \
|
||||
doc/html/pcre2_set_match_limit.html \
|
||||
doc/html/pcre2_set_max_pattern_length.html \
|
||||
doc/html/pcre2_set_offset_limit.html \
|
||||
doc/html/pcre2_set_newline.html \
|
||||
doc/html/pcre2_set_parens_nest_limit.html \
|
||||
doc/html/pcre2_set_recursion_limit.html \
|
||||
doc/html/pcre2_set_recursion_memory_management.html \
|
||||
doc/html/pcre2_set_substitute_callout.html \
|
||||
doc/html/pcre2_substitute.html \
|
||||
doc/html/pcre2_substring_copy_byname.html \
|
||||
doc/html/pcre2_substring_copy_bynumber.html \
|
||||
doc/html/pcre2_substring_free.html \
|
||||
doc/html/pcre2_substring_get_byname.html \
|
||||
doc/html/pcre2_substring_get_bynumber.html \
|
||||
doc/html/pcre2_substring_length_byname.html \
|
||||
doc/html/pcre2_substring_length_bynumber.html \
|
||||
doc/html/pcre2_substring_list_free.html \
|
||||
doc/html/pcre2_substring_list_get.html \
|
||||
doc/html/pcre2_substring_nametable_scan.html \
|
||||
doc/html/pcre2_substring_number_from_name.html \
|
||||
doc/html/pcre2api.html \
|
||||
doc/html/pcre2build.html \
|
||||
doc/html/pcre2callout.html \
|
||||
doc/html/pcre2compat.html \
|
||||
doc/html/pcre2convert.html \
|
||||
doc/html/pcre2demo.html \
|
||||
doc/html/pcre2grep.html \
|
||||
doc/html/pcre2jit.html \
|
||||
doc/html/pcre2limits.html \
|
||||
doc/html/pcre2matching.html \
|
||||
doc/html/pcre2partial.html \
|
||||
doc/html/pcre2pattern.html \
|
||||
doc/html/pcre2perform.html \
|
||||
doc/html/pcre2posix.html \
|
||||
doc/html/pcre2sample.html \
|
||||
doc/html/pcre2serialize.html \
|
||||
doc/html/pcre2syntax.html \
|
||||
doc/html/pcre2test.html \
|
||||
doc/html/pcre2unicode.html
|
||||
|
||||
dist_man_MANS = \
|
||||
doc/pcre2-config.1 \
|
||||
doc/pcre2.3 \
|
||||
doc/pcre2_callout_enumerate.3 \
|
||||
doc/pcre2_code_copy.3 \
|
||||
doc/pcre2_code_copy_with_tables.3 \
|
||||
doc/pcre2_code_free.3 \
|
||||
doc/pcre2_compile.3 \
|
||||
doc/pcre2_compile_context_copy.3 \
|
||||
doc/pcre2_compile_context_create.3 \
|
||||
doc/pcre2_compile_context_free.3 \
|
||||
doc/pcre2_config.3 \
|
||||
doc/pcre2_convert_context_copy.3 \
|
||||
doc/pcre2_convert_context_create.3 \
|
||||
doc/pcre2_convert_context_free.3 \
|
||||
doc/pcre2_converted_pattern_free.3 \
|
||||
doc/pcre2_dfa_match.3 \
|
||||
doc/pcre2_general_context_copy.3 \
|
||||
doc/pcre2_general_context_create.3 \
|
||||
doc/pcre2_general_context_free.3 \
|
||||
doc/pcre2_get_error_message.3 \
|
||||
doc/pcre2_get_mark.3 \
|
||||
doc/pcre2_get_ovector_count.3 \
|
||||
doc/pcre2_get_ovector_pointer.3 \
|
||||
doc/pcre2_get_startchar.3 \
|
||||
doc/pcre2_jit_compile.3 \
|
||||
doc/pcre2_jit_free_unused_memory.3 \
|
||||
doc/pcre2_jit_match.3 \
|
||||
doc/pcre2_jit_stack_assign.3 \
|
||||
doc/pcre2_jit_stack_create.3 \
|
||||
doc/pcre2_jit_stack_free.3 \
|
||||
doc/pcre2_maketables.3 \
|
||||
doc/pcre2_match.3 \
|
||||
doc/pcre2_match_context_copy.3 \
|
||||
doc/pcre2_match_context_create.3 \
|
||||
doc/pcre2_match_context_free.3 \
|
||||
doc/pcre2_match_data_create.3 \
|
||||
doc/pcre2_match_data_create_from_pattern.3 \
|
||||
doc/pcre2_match_data_free.3 \
|
||||
doc/pcre2_pattern_convert.3 \
|
||||
doc/pcre2_pattern_info.3 \
|
||||
doc/pcre2_serialize_decode.3 \
|
||||
doc/pcre2_serialize_encode.3 \
|
||||
doc/pcre2_serialize_free.3 \
|
||||
doc/pcre2_serialize_get_number_of_codes.3 \
|
||||
doc/pcre2_set_bsr.3 \
|
||||
doc/pcre2_set_callout.3 \
|
||||
doc/pcre2_set_character_tables.3 \
|
||||
doc/pcre2_set_compile_extra_options.3 \
|
||||
doc/pcre2_set_compile_recursion_guard.3 \
|
||||
doc/pcre2_set_depth_limit.3 \
|
||||
doc/pcre2_set_glob_escape.3 \
|
||||
doc/pcre2_set_glob_separator.3 \
|
||||
doc/pcre2_set_heap_limit.3 \
|
||||
doc/pcre2_set_match_limit.3 \
|
||||
doc/pcre2_set_max_pattern_length.3 \
|
||||
doc/pcre2_set_offset_limit.3 \
|
||||
doc/pcre2_set_newline.3 \
|
||||
doc/pcre2_set_parens_nest_limit.3 \
|
||||
doc/pcre2_set_recursion_limit.3 \
|
||||
doc/pcre2_set_recursion_memory_management.3 \
|
||||
doc/pcre2_set_substitute_callout.3 \
|
||||
doc/pcre2_substitute.3 \
|
||||
doc/pcre2_substring_copy_byname.3 \
|
||||
doc/pcre2_substring_copy_bynumber.3 \
|
||||
doc/pcre2_substring_free.3 \
|
||||
doc/pcre2_substring_get_byname.3 \
|
||||
doc/pcre2_substring_get_bynumber.3 \
|
||||
doc/pcre2_substring_length_byname.3 \
|
||||
doc/pcre2_substring_length_bynumber.3 \
|
||||
doc/pcre2_substring_list_free.3 \
|
||||
doc/pcre2_substring_list_get.3 \
|
||||
doc/pcre2_substring_nametable_scan.3 \
|
||||
doc/pcre2_substring_number_from_name.3 \
|
||||
doc/pcre2api.3 \
|
||||
doc/pcre2build.3 \
|
||||
doc/pcre2callout.3 \
|
||||
doc/pcre2compat.3 \
|
||||
doc/pcre2convert.3 \
|
||||
doc/pcre2demo.3 \
|
||||
doc/pcre2grep.1 \
|
||||
doc/pcre2jit.3 \
|
||||
doc/pcre2limits.3 \
|
||||
doc/pcre2matching.3 \
|
||||
doc/pcre2partial.3 \
|
||||
doc/pcre2pattern.3 \
|
||||
doc/pcre2perform.3 \
|
||||
doc/pcre2posix.3 \
|
||||
doc/pcre2sample.3 \
|
||||
doc/pcre2serialize.3 \
|
||||
doc/pcre2syntax.3 \
|
||||
doc/pcre2test.1 \
|
||||
doc/pcre2unicode.3
|
||||
|
||||
# The Libtool libraries to install. We'll add to this later.
|
||||
|
||||
lib_LTLIBRARIES =
|
||||
|
||||
# Unit tests you want to run when people type 'make check'.
|
||||
# TESTS is for binary unit tests, check_SCRIPTS for script-based tests
|
||||
|
||||
TESTS =
|
||||
check_SCRIPTS =
|
||||
dist_noinst_SCRIPTS =
|
||||
|
||||
# Some of the binaries we make are to be installed, and others are
|
||||
# (non-user-visible) helper programs needed to build the libraries.
|
||||
|
||||
bin_PROGRAMS =
|
||||
noinst_PROGRAMS =
|
||||
|
||||
# Additional files to delete on 'make clean', 'make distclean',
|
||||
# and 'make maintainer-clean'.
|
||||
|
||||
CLEANFILES =
|
||||
DISTCLEANFILES = src/config.h.in~
|
||||
MAINTAINERCLEANFILES =
|
||||
|
||||
# Additional files to bundle with the distribution, over and above what
|
||||
# the Autotools include by default.
|
||||
|
||||
EXTRA_DIST =
|
||||
|
||||
# These files contain additional m4 macros that are used by autoconf.
|
||||
|
||||
EXTRA_DIST += \
|
||||
m4/ax_pthread.m4 m4/pcre2_visibility.m4
|
||||
|
||||
# These files contain maintenance information
|
||||
|
||||
EXTRA_DIST += \
|
||||
NON-AUTOTOOLS-BUILD \
|
||||
HACKING
|
||||
|
||||
# These files are used in the preparation of a release
|
||||
|
||||
EXTRA_DIST += \
|
||||
PrepareRelease \
|
||||
CheckMan \
|
||||
CleanTxt \
|
||||
Detrail \
|
||||
132html \
|
||||
doc/index.html.src
|
||||
|
||||
# These files are usable versions of pcre2.h and config.h that are distributed
|
||||
# for the benefit of people who are building PCRE2 manually, without the
|
||||
# Autotools support.
|
||||
|
||||
EXTRA_DIST += \
|
||||
src/pcre2.h.generic \
|
||||
src/config.h.generic
|
||||
|
||||
# The only difference between pcre2.h.in and pcre2.h is the setting of the PCRE
|
||||
# version number. Therefore, we can create the generic version just by copying.
|
||||
|
||||
src/pcre2.h.generic: src/pcre2.h.in configure.ac
|
||||
rm -f $@
|
||||
cp -p src/pcre2.h $@
|
||||
|
||||
# It is more complicated for config.h.generic. We need the version that results
|
||||
# from a default configuration so as to get all the default values for PCRE
|
||||
# configuration macros such as MATCH_LIMIT and NEWLINE. We can get this by
|
||||
# doing a configure in a temporary directory. However, some trickery is needed,
|
||||
# because the source directory may already be configured. If you just try
|
||||
# running configure in a new directory, it complains. For this reason, we move
|
||||
# config.status out of the way while doing the default configuration. The
|
||||
# resulting config.h is munged by perl to put #ifdefs round any #defines for
|
||||
# macros with values, and to #undef all boolean macros such as HAVE_xxx and
|
||||
# SUPPORT_xxx. We also get rid of any gcc-specific visibility settings. Make
|
||||
# sure that PCRE2_EXP_DEFN is unset (in case it has visibility settings).
|
||||
|
||||
src/config.h.generic: configure.ac
|
||||
rm -rf $@ _generic
|
||||
mkdir _generic
|
||||
cs=$(srcdir)/config.status; test ! -f $$cs || mv -f $$cs $$cs.aside
|
||||
cd _generic && $(abs_top_srcdir)/configure || :
|
||||
cs=$(srcdir)/config.status; test ! -f $$cs.aside || mv -f $$cs.aside $$cs
|
||||
test -f _generic/src/config.h
|
||||
perl -n \
|
||||
-e 'BEGIN{$$blank=0;}' \
|
||||
-e 'if(/PCRE2_EXP_DEFN/){print"/* #undef PCRE2_EXP_DEFN */\n";$$blank=0;next;}' \
|
||||
-e 'if(/to make a symbol visible/){next;}' \
|
||||
-e 'if(/__attribute__ \(\(visibility/){next;}' \
|
||||
-e 'if(/LT_OBJDIR/){print"/* This is ignored unless you are using libtool. */\n";}' \
|
||||
-e 'if(/^#define\s((?:HAVE|SUPPORT|STDC)_\w+)/){print"/* #undef $$1 */\n";$$blank=0;next;}' \
|
||||
-e 'if(/^#define\s(?!PACKAGE|VERSION)(\w+)/){print"#ifndef $$1\n$$_#endif\n";$$blank=0;next;}' \
|
||||
-e 'if(/^\s*$$/){print unless $$blank; $$blank=1;} else{print;$$blank=0;}' \
|
||||
_generic/src/config.h >$@
|
||||
rm -rf _generic
|
||||
|
||||
MAINTAINERCLEANFILES += src/pcre2.h.generic src/config.h.generic
|
||||
|
||||
# These are the header files we'll install. We do not distribute pcre2.h
|
||||
# because it is generated from pcre2.h.in.
|
||||
|
||||
nodist_include_HEADERS = src/pcre2.h
|
||||
include_HEADERS = src/pcre2posix.h
|
||||
|
||||
# This is the "config" script.
|
||||
|
||||
bin_SCRIPTS = pcre2-config
|
||||
|
||||
## ---------------------------------------------------------------
|
||||
## The dftables program is used to rebuild character tables before compiling
|
||||
## PCRE2, if --enable-rebuild-chartables is specified. It is not a user-visible
|
||||
## program. The default (when --enable-rebuild-chartables is not specified) is
|
||||
## to copy a distributed set of tables that are defined for ASCII code. In this
|
||||
## case, dftables is not needed.
|
||||
|
||||
if WITH_REBUILD_CHARTABLES
|
||||
noinst_PROGRAMS += dftables
|
||||
dftables_SOURCES = src/dftables.c
|
||||
src/pcre2_chartables.c: dftables$(EXEEXT)
|
||||
rm -f $@
|
||||
./dftables$(EXEEXT) $@
|
||||
else
|
||||
src/pcre2_chartables.c: $(srcdir)/src/pcre2_chartables.c.dist
|
||||
rm -f $@
|
||||
$(LN_S) $(abs_srcdir)/src/pcre2_chartables.c.dist $(abs_builddir)/src/pcre2_chartables.c
|
||||
endif # WITH_REBUILD_CHARTABLES
|
||||
|
||||
BUILT_SOURCES = src/pcre2_chartables.c
|
||||
NODIST_SOURCES = src/pcre2_chartables.c
|
||||
|
||||
## Define the list of common sources, then arrange to build whichever of the
|
||||
## 8-, 16-, or 32-bit libraries are configured.
|
||||
|
||||
COMMON_SOURCES = \
|
||||
src/pcre2_auto_possess.c \
|
||||
src/pcre2_compile.c \
|
||||
src/pcre2_config.c \
|
||||
src/pcre2_context.c \
|
||||
src/pcre2_convert.c \
|
||||
src/pcre2_dfa_match.c \
|
||||
src/pcre2_error.c \
|
||||
src/pcre2_extuni.c \
|
||||
src/pcre2_find_bracket.c \
|
||||
src/pcre2_internal.h \
|
||||
src/pcre2_intmodedep.h \
|
||||
src/pcre2_jit_compile.c \
|
||||
src/pcre2_maketables.c \
|
||||
src/pcre2_match.c \
|
||||
src/pcre2_match_data.c \
|
||||
src/pcre2_newline.c \
|
||||
src/pcre2_ord2utf.c \
|
||||
src/pcre2_pattern_info.c \
|
||||
src/pcre2_script_run.c \
|
||||
src/pcre2_serialize.c \
|
||||
src/pcre2_string_utils.c \
|
||||
src/pcre2_study.c \
|
||||
src/pcre2_substitute.c \
|
||||
src/pcre2_substring.c \
|
||||
src/pcre2_tables.c \
|
||||
src/pcre2_ucd.c \
|
||||
src/pcre2_ucp.h \
|
||||
src/pcre2_valid_utf.c \
|
||||
src/pcre2_xclass.c
|
||||
|
||||
if WITH_PCRE2_8
|
||||
lib_LTLIBRARIES += libpcre2-8.la
|
||||
libpcre2_8_la_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
nodist_libpcre2_8_la_SOURCES = \
|
||||
$(NODIST_SOURCES)
|
||||
libpcre2_8_la_CFLAGS = \
|
||||
-DPCRE2_CODE_UNIT_WIDTH=8 \
|
||||
$(VISIBILITY_CFLAGS) \
|
||||
$(AM_CFLAGS)
|
||||
libpcre2_8_la_LIBADD =
|
||||
endif # WITH_PCRE2_8
|
||||
|
||||
if WITH_PCRE2_16
|
||||
lib_LTLIBRARIES += libpcre2-16.la
|
||||
libpcre2_16_la_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
nodist_libpcre2_16_la_SOURCES = \
|
||||
$(NODIST_SOURCES)
|
||||
libpcre2_16_la_CFLAGS = \
|
||||
-DPCRE2_CODE_UNIT_WIDTH=16 \
|
||||
$(VISIBILITY_CFLAGS) \
|
||||
$(AM_CFLAGS)
|
||||
libpcre2_16_la_LIBADD =
|
||||
endif # WITH_PCRE2_16
|
||||
|
||||
if WITH_PCRE2_32
|
||||
lib_LTLIBRARIES += libpcre2-32.la
|
||||
libpcre2_32_la_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
nodist_libpcre2_32_la_SOURCES = \
|
||||
$(NODIST_SOURCES)
|
||||
libpcre2_32_la_CFLAGS = \
|
||||
-DPCRE2_CODE_UNIT_WIDTH=32 \
|
||||
$(VISIBILITY_CFLAGS) \
|
||||
$(AM_CFLAGS)
|
||||
libpcre2_32_la_LIBADD =
|
||||
endif # WITH_PCRE2_32
|
||||
|
||||
# The pcre2_chartables.c.dist file is the default version of
|
||||
# pcre2_chartables.c, used unless --enable-rebuild-chartables is specified.
|
||||
|
||||
EXTRA_DIST += src/pcre2_chartables.c.dist
|
||||
CLEANFILES += src/pcre2_chartables.c
|
||||
|
||||
# The JIT compiler lives in a separate directory, but its files are #included
|
||||
# when pcre2_jit_compile.c is processed, so they must be distributed.
|
||||
|
||||
EXTRA_DIST += \
|
||||
src/sljit/sljitConfig.h \
|
||||
src/sljit/sljitConfigInternal.h \
|
||||
src/sljit/sljitExecAllocator.c \
|
||||
src/sljit/sljitLir.c \
|
||||
src/sljit/sljitLir.h \
|
||||
src/sljit/sljitNativeARM_32.c \
|
||||
src/sljit/sljitNativeARM_64.c \
|
||||
src/sljit/sljitNativeARM_T2_32.c \
|
||||
src/sljit/sljitNativeMIPS_32.c \
|
||||
src/sljit/sljitNativeMIPS_64.c \
|
||||
src/sljit/sljitNativeMIPS_common.c \
|
||||
src/sljit/sljitNativePPC_32.c \
|
||||
src/sljit/sljitNativePPC_64.c \
|
||||
src/sljit/sljitNativePPC_common.c \
|
||||
src/sljit/sljitNativeSPARC_32.c \
|
||||
src/sljit/sljitNativeSPARC_common.c \
|
||||
src/sljit/sljitNativeTILEGX-encoder.c \
|
||||
src/sljit/sljitNativeTILEGX_64.c \
|
||||
src/sljit/sljitNativeX86_32.c \
|
||||
src/sljit/sljitNativeX86_64.c \
|
||||
src/sljit/sljitNativeX86_common.c \
|
||||
src/sljit/sljitProtExecAllocator.c \
|
||||
src/sljit/sljitUtils.c
|
||||
|
||||
# Some of the JIT sources are also in separate files that are #included.
|
||||
|
||||
EXTRA_DIST += \
|
||||
src/pcre2_jit_match.c \
|
||||
src/pcre2_jit_misc.c
|
||||
|
||||
if WITH_PCRE2_8
|
||||
libpcre2_8_la_LDFLAGS = $(EXTRA_LIBPCRE2_8_LDFLAGS)
|
||||
endif # WITH_PCRE2_8
|
||||
if WITH_PCRE2_16
|
||||
libpcre2_16_la_LDFLAGS = $(EXTRA_LIBPCRE2_16_LDFLAGS)
|
||||
endif # WITH_PCRE2_16
|
||||
if WITH_PCRE2_32
|
||||
libpcre2_32_la_LDFLAGS = $(EXTRA_LIBPCRE2_32_LDFLAGS)
|
||||
endif # WITH_PCRE2_32
|
||||
|
||||
if WITH_VALGRIND
|
||||
if WITH_PCRE2_8
|
||||
libpcre2_8_la_CFLAGS += $(VALGRIND_CFLAGS)
|
||||
endif # WITH_PCRE2_8
|
||||
if WITH_PCRE2_16
|
||||
libpcre2_16_la_CFLAGS += $(VALGRIND_CFLAGS)
|
||||
endif # WITH_PCRE2_16
|
||||
if WITH_PCRE2_32
|
||||
libpcre2_32_la_CFLAGS += $(VALGRIND_CFLAGS)
|
||||
endif # WITH_PCRE2_32
|
||||
endif # WITH_VALGRIND
|
||||
|
||||
if WITH_GCOV
|
||||
if WITH_PCRE2_8
|
||||
libpcre2_8_la_CFLAGS += $(GCOV_CFLAGS)
|
||||
endif # WITH_PCRE2_8
|
||||
if WITH_PCRE2_16
|
||||
libpcre2_16_la_CFLAGS += $(GCOV_CFLAGS)
|
||||
endif # WITH_PCRE2_16
|
||||
if WITH_PCRE2_32
|
||||
libpcre2_32_la_CFLAGS += $(GCOV_CFLAGS)
|
||||
endif # WITH_PCRE2_32
|
||||
endif # WITH_GCOV
|
||||
|
||||
## A version of the 8-bit library that has a POSIX API.
|
||||
|
||||
if WITH_PCRE2_8
|
||||
lib_LTLIBRARIES += libpcre2-posix.la
|
||||
libpcre2_posix_la_SOURCES = src/pcre2posix.c
|
||||
libpcre2_posix_la_CFLAGS = \
|
||||
-DPCRE2_CODE_UNIT_WIDTH=8 \
|
||||
$(VISIBILITY_CFLAGS) $(AM_CFLAGS)
|
||||
libpcre2_posix_la_LDFLAGS = $(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
|
||||
libpcre2_posix_la_LIBADD = libpcre2-8.la
|
||||
if WITH_GCOV
|
||||
libpcre2_posix_la_CFLAGS += $(GCOV_CFLAGS)
|
||||
endif # WITH_GCOV
|
||||
endif # WITH_PCRE2_8
|
||||
|
||||
## Build pcre2grep and optional fuzzer stuff if the 8-bit library is enabled
|
||||
|
||||
if WITH_PCRE2_8
|
||||
bin_PROGRAMS += pcre2grep
|
||||
pcre2grep_SOURCES = src/pcre2grep.c
|
||||
pcre2grep_CFLAGS = $(AM_CFLAGS)
|
||||
pcre2grep_LDADD = $(LIBZ) $(LIBBZ2)
|
||||
pcre2grep_LDADD += libpcre2-8.la
|
||||
if WITH_GCOV
|
||||
pcre2grep_CFLAGS += $(GCOV_CFLAGS)
|
||||
pcre2grep_LDADD += $(GCOV_LIBS)
|
||||
endif # WITH_GCOV
|
||||
|
||||
## If fuzzer support is enabled, build a non-distributed library containing the
|
||||
## fuzzing function. Also build the standalone checking binary from the same
|
||||
## source but using -DSTANDALONE.
|
||||
|
||||
if WITH_FUZZ_SUPPORT
|
||||
noinst_LIBRARIES = .libs/libpcre2-fuzzsupport.a
|
||||
_libs_libpcre2_fuzzsupport_a_SOURCES = src/pcre2_fuzzsupport.c
|
||||
_libs_libpcre2_fuzzsupport_a_CFLAGS = $(AM_CFLAGS)
|
||||
_libs_libpcre2_fuzzsupport_a_LIBADD =
|
||||
|
||||
noinst_PROGRAMS += pcre2fuzzcheck
|
||||
pcre2fuzzcheck_SOURCES = src/pcre2_fuzzsupport.c
|
||||
pcre2fuzzcheck_CFLAGS = -DSTANDALONE $(AM_CFLAGS)
|
||||
pcre2fuzzcheck_LDADD = libpcre2-8.la
|
||||
if WITH_GCOV
|
||||
pcre2fuzzcheck_CFLAGS += $(GCOV_CFLAGS)
|
||||
pcre2fuzzcheck_LDADD += $(GCOV_LIBS)
|
||||
endif # WITH_GCOV
|
||||
endif # WITH FUZZ_SUPPORT
|
||||
endif # WITH_PCRE2_8
|
||||
|
||||
## -------- Testing ----------
|
||||
|
||||
## If JIT support is enabled, arrange for the JIT test program to run.
|
||||
|
||||
if WITH_JIT
|
||||
TESTS += pcre2_jit_test
|
||||
noinst_PROGRAMS += pcre2_jit_test
|
||||
pcre2_jit_test_SOURCES = src/pcre2_jit_test.c
|
||||
pcre2_jit_test_CFLAGS = $(AM_CFLAGS)
|
||||
pcre2_jit_test_LDADD =
|
||||
if WITH_PCRE2_8
|
||||
pcre2_jit_test_LDADD += libpcre2-8.la
|
||||
endif # WITH_PCRE2_8
|
||||
if WITH_PCRE2_16
|
||||
pcre2_jit_test_LDADD += libpcre2-16.la
|
||||
endif # WITH_PCRE2_16
|
||||
if WITH_PCRE2_32
|
||||
pcre2_jit_test_LDADD += libpcre2-32.la
|
||||
endif # WITH_PCRE2_32
|
||||
if WITH_GCOV
|
||||
pcre2_jit_test_CFLAGS += $(GCOV_CFLAGS)
|
||||
pcre2_jit_test_LDADD += $(GCOV_LIBS)
|
||||
endif # WITH_GCOV
|
||||
endif # WITH_JIT
|
||||
|
||||
# Build the general pcre2test program. The file src/pcre2_printint.c is
|
||||
# #included by pcre2test as many times as needed, at different code unit
|
||||
# widths.
|
||||
|
||||
bin_PROGRAMS += pcre2test
|
||||
EXTRA_DIST += src/pcre2_printint.c
|
||||
pcre2test_SOURCES = src/pcre2test.c
|
||||
pcre2test_CFLAGS = $(AM_CFLAGS)
|
||||
pcre2test_LDADD = $(LIBREADLINE)
|
||||
|
||||
if WITH_PCRE2_8
|
||||
pcre2test_LDADD += libpcre2-8.la libpcre2-posix.la
|
||||
endif # WITH_PCRE2_8
|
||||
|
||||
if WITH_PCRE2_16
|
||||
pcre2test_LDADD += libpcre2-16.la
|
||||
endif # WITH_PCRE2_16
|
||||
|
||||
if WITH_PCRE2_32
|
||||
pcre2test_LDADD += libpcre2-32.la
|
||||
endif # WITH_PCRE2_32
|
||||
|
||||
if WITH_VALGRIND
|
||||
pcre2test_CFLAGS += $(VALGRIND_CFLAGS)
|
||||
endif # WITH_VALGRIND
|
||||
|
||||
if WITH_GCOV
|
||||
pcre2test_CFLAGS += $(GCOV_CFLAGS)
|
||||
pcre2test_LDADD += $(GCOV_LIBS)
|
||||
endif # WITH_GCOV
|
||||
|
||||
## The main library tests. Each test is a binary plus a script that runs that
|
||||
## binary in various ways. We install these test binaries in case folks find it
|
||||
## helpful. The two .bat files are for running the tests under Windows.
|
||||
|
||||
TESTS += RunTest
|
||||
EXTRA_DIST += RunTest.bat
|
||||
dist_noinst_SCRIPTS += RunTest
|
||||
|
||||
## When the 8-bit library is configured, pcre2grep will have been built.
|
||||
|
||||
if WITH_PCRE2_8
|
||||
TESTS += RunGrepTest
|
||||
EXTRA_DIST += RunGrepTest.bat
|
||||
dist_noinst_SCRIPTS += RunGrepTest
|
||||
endif # WITH_PCRE2_8
|
||||
|
||||
## Distribute all the test data files
|
||||
|
||||
EXTRA_DIST += \
|
||||
testdata/grepbinary \
|
||||
testdata/grepfilelist \
|
||||
testdata/grepinput \
|
||||
testdata/grepinput3 \
|
||||
testdata/grepinput8 \
|
||||
testdata/grepinputM \
|
||||
testdata/grepinputv \
|
||||
testdata/grepinputx \
|
||||
testdata/greplist \
|
||||
testdata/grepoutput \
|
||||
testdata/grepoutput8 \
|
||||
testdata/grepoutputC \
|
||||
testdata/grepoutputCN \
|
||||
testdata/grepoutputN \
|
||||
testdata/greppatN4 \
|
||||
testdata/testinput1 \
|
||||
testdata/testinput2 \
|
||||
testdata/testinput3 \
|
||||
testdata/testinput4 \
|
||||
testdata/testinput5 \
|
||||
testdata/testinput6 \
|
||||
testdata/testinput7 \
|
||||
testdata/testinput8 \
|
||||
testdata/testinput9 \
|
||||
testdata/testinput10 \
|
||||
testdata/testinput11 \
|
||||
testdata/testinput12 \
|
||||
testdata/testinput13 \
|
||||
testdata/testinput14 \
|
||||
testdata/testinput15 \
|
||||
testdata/testinput16 \
|
||||
testdata/testinput17 \
|
||||
testdata/testinput18 \
|
||||
testdata/testinput19 \
|
||||
testdata/testinput20 \
|
||||
testdata/testinput21 \
|
||||
testdata/testinput22 \
|
||||
testdata/testinput23 \
|
||||
testdata/testinput24 \
|
||||
testdata/testinput25 \
|
||||
testdata/testinputEBC \
|
||||
testdata/testoutput1 \
|
||||
testdata/testoutput2 \
|
||||
testdata/testoutput3 \
|
||||
testdata/testoutput3A \
|
||||
testdata/testoutput3B \
|
||||
testdata/testoutput4 \
|
||||
testdata/testoutput5 \
|
||||
testdata/testoutput6 \
|
||||
testdata/testoutput7 \
|
||||
testdata/testoutput8-16-2 \
|
||||
testdata/testoutput8-16-3 \
|
||||
testdata/testoutput8-16-4 \
|
||||
testdata/testoutput8-32-2 \
|
||||
testdata/testoutput8-32-3 \
|
||||
testdata/testoutput8-32-4 \
|
||||
testdata/testoutput8-8-2 \
|
||||
testdata/testoutput8-8-3 \
|
||||
testdata/testoutput8-8-4 \
|
||||
testdata/testoutput9 \
|
||||
testdata/testoutput10 \
|
||||
testdata/testoutput11-16 \
|
||||
testdata/testoutput11-32 \
|
||||
testdata/testoutput12-16 \
|
||||
testdata/testoutput12-32 \
|
||||
testdata/testoutput13 \
|
||||
testdata/testoutput14-16 \
|
||||
testdata/testoutput14-32 \
|
||||
testdata/testoutput14-8 \
|
||||
testdata/testoutput15 \
|
||||
testdata/testoutput16 \
|
||||
testdata/testoutput17 \
|
||||
testdata/testoutput18 \
|
||||
testdata/testoutput19 \
|
||||
testdata/testoutput20 \
|
||||
testdata/testoutput21 \
|
||||
testdata/testoutput22-16 \
|
||||
testdata/testoutput22-32 \
|
||||
testdata/testoutput22-8 \
|
||||
testdata/testoutput23 \
|
||||
testdata/testoutput24 \
|
||||
testdata/testoutput25 \
|
||||
testdata/testoutputEBC \
|
||||
testdata/valgrind-jit.supp \
|
||||
testdata/wintestinput3 \
|
||||
testdata/wintestoutput3 \
|
||||
perltest.sh
|
||||
|
||||
# RunTest and RunGrepTest should clean up after themselves, but just in case
|
||||
# they don't, add their working files to CLEANFILES.
|
||||
|
||||
CLEANFILES += \
|
||||
testSinput \
|
||||
test3input \
|
||||
test3output \
|
||||
test3outputA \
|
||||
test3outputB \
|
||||
testtry \
|
||||
teststdout \
|
||||
teststderr \
|
||||
teststderrgrep \
|
||||
testtemp1grep \
|
||||
testtemp2grep \
|
||||
testtrygrep \
|
||||
testNinputgrep
|
||||
|
||||
## ------------ End of testing -------------
|
||||
|
||||
|
||||
# PCRE2 demonstration program. Not built automatcally. The point is that the
|
||||
# users should build it themselves. So just distribute the source.
|
||||
|
||||
EXTRA_DIST += src/pcre2demo.c
|
||||
|
||||
|
||||
# We have .pc files for pkg-config users.
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA =
|
||||
|
||||
if WITH_PCRE2_8
|
||||
pkgconfig_DATA += libpcre2-8.pc libpcre2-posix.pc
|
||||
endif
|
||||
|
||||
if WITH_PCRE2_16
|
||||
pkgconfig_DATA += libpcre2-16.pc
|
||||
endif
|
||||
|
||||
if WITH_PCRE2_32
|
||||
pkgconfig_DATA += libpcre2-32.pc
|
||||
endif
|
||||
|
||||
|
||||
# gcov/lcov code coverage reporting
|
||||
#
|
||||
# Coverage reporting targets:
|
||||
#
|
||||
# coverage: Create a coverage report from 'make check'
|
||||
# coverage-baseline: Capture baseline coverage information
|
||||
# coverage-reset: This zeros the coverage counters only
|
||||
# coverage-report: This creates the coverage report only
|
||||
# coverage-clean-report: This removes the generated coverage report
|
||||
# without cleaning the coverage data itself
|
||||
# coverage-clean-data: This removes the captured coverage data without
|
||||
# removing the coverage files created at compile time (*.gcno)
|
||||
# coverage-clean: This cleans all coverage data including the generated
|
||||
# coverage report.
|
||||
|
||||
if WITH_GCOV
|
||||
COVERAGE_TEST_NAME = $(PACKAGE)
|
||||
COVERAGE_NAME = $(PACKAGE)-$(VERSION)
|
||||
COVERAGE_OUTPUT_FILE = $(COVERAGE_NAME)-coverage.info
|
||||
COVERAGE_OUTPUT_DIR = $(COVERAGE_NAME)-coverage
|
||||
COVERAGE_LCOV_EXTRA_FLAGS =
|
||||
COVERAGE_GENHTML_EXTRA_FLAGS =
|
||||
|
||||
coverage_quiet = $(coverage_quiet_$(V))
|
||||
coverage_quiet_ = $(coverage_quiet_$(AM_DEFAULT_VERBOSITY))
|
||||
coverage_quiet_0 = --quiet
|
||||
|
||||
coverage-check: all
|
||||
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
||||
|
||||
coverage-baseline:
|
||||
$(LCOV) $(coverage_quiet) \
|
||||
--directory $(top_builddir) \
|
||||
--output-file "$(COVERAGE_OUTPUT_FILE)" \
|
||||
--capture \
|
||||
--initial
|
||||
|
||||
coverage-report:
|
||||
$(LCOV) $(coverage_quiet) \
|
||||
--directory $(top_builddir) \
|
||||
--capture \
|
||||
--output-file "$(COVERAGE_OUTPUT_FILE).tmp" \
|
||||
--test-name "$(COVERAGE_TEST_NAME)" \
|
||||
--no-checksum \
|
||||
--compat-libtool \
|
||||
$(COVERAGE_LCOV_EXTRA_FLAGS)
|
||||
$(LCOV) $(coverage_quiet) \
|
||||
--directory $(top_builddir) \
|
||||
--output-file "$(COVERAGE_OUTPUT_FILE)" \
|
||||
--remove "$(COVERAGE_OUTPUT_FILE).tmp" \
|
||||
"/tmp/*" \
|
||||
"/usr/include/*" \
|
||||
"$(includedir)/*"
|
||||
-@rm -f "$(COVERAGE_OUTPUT_FILE).tmp"
|
||||
LANG=C $(GENHTML) $(coverage_quiet) \
|
||||
--prefix $(top_builddir) \
|
||||
--output-directory "$(COVERAGE_OUTPUT_DIR)" \
|
||||
--title "$(PACKAGE) $(VERSION) Code Coverage Report" \
|
||||
--show-details "$(COVERAGE_OUTPUT_FILE)" \
|
||||
--legend \
|
||||
$(COVERAGE_GENHTML_EXTRA_FLAGS)
|
||||
@echo "Code coverage report written to file://$(abs_builddir)/$(COVERAGE_OUTPUT_DIR)/index.html"
|
||||
|
||||
coverage-reset:
|
||||
-$(LCOV) $(coverage_quiet) --zerocounters --directory $(top_builddir)
|
||||
|
||||
coverage-clean-report:
|
||||
-rm -f "$(COVERAGE_OUTPUT_FILE)" "$(COVERAGE_OUTPUT_FILE).tmp"
|
||||
-rm -rf "$(COVERAGE_OUTPUT_DIR)"
|
||||
|
||||
coverage-clean-data:
|
||||
-find $(top_builddir) -name "*.gcda" -delete
|
||||
|
||||
coverage-clean: coverage-reset coverage-clean-report coverage-clean-data
|
||||
-find $(top_builddir) -name "*.gcno" -delete
|
||||
|
||||
coverage-distclean: coverage-clean
|
||||
|
||||
coverage: coverage-reset coverage-baseline coverage-check coverage-report
|
||||
clean-local: coverage-clean
|
||||
distclean-local: coverage-distclean
|
||||
|
||||
.PHONY: coverage coverage-baseline coverage-check coverage-report coverage-reset coverage-clean-report coverage-clean-data coverage-clean coverage-distclean
|
||||
|
||||
# Without coverage support, still arrange for 'make distclean' to get rid of
|
||||
# any coverage files that may have been left from a different configuration.
|
||||
|
||||
else
|
||||
|
||||
coverage:
|
||||
@echo "Configuring with --enable-coverage is required to generate code coverage report."
|
||||
|
||||
DISTCLEANFILES += src/*.gcda src/*.gcno
|
||||
|
||||
distclean-local:
|
||||
rm -rf $(PACKAGE)-$(VERSION)-coverage*
|
||||
|
||||
endif # WITH_GCOV
|
||||
|
||||
## CMake support
|
||||
|
||||
EXTRA_DIST += \
|
||||
cmake/COPYING-CMAKE-SCRIPTS \
|
||||
cmake/FindPackageHandleStandardArgs.cmake \
|
||||
cmake/FindReadline.cmake \
|
||||
cmake/FindEditline.cmake \
|
||||
CMakeLists.txt \
|
||||
config-cmake.h.in
|
||||
|
||||
## end Makefile.am
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,296 @@
|
|||
News about PCRE2 releases
|
||||
-------------------------
|
||||
|
||||
|
||||
Version 10.33-RC1 16-April-2019
|
||||
-------------------------------
|
||||
|
||||
Yet more bugfixes, tidies, and a few enhancements, summarized here (see
|
||||
ChangeLog for the full list):
|
||||
|
||||
1. Callouts from pcre2_substitute() are now available.
|
||||
|
||||
2. The POSIX functions are now all called pcre2_regcomp() etc., with wrapper
|
||||
functions that use the standard POSIX names. However, in pcre2posix.h the POSIX
|
||||
names are defined as macros. This should help avoid linking with the wrong
|
||||
library in some environments, while still exporting the POSIX names for
|
||||
pre-existing programs that use them.
|
||||
|
||||
3. Some new options:
|
||||
|
||||
(a) PCRE2_EXTRA_ESCAPED_CR_IS_LF makes \r behave as \n.
|
||||
|
||||
(b) PCRE2_EXTRA_ALT_BSUX enables support for ECMAScript 6's \u{hh...}
|
||||
construct.
|
||||
|
||||
(c) PCRE2_COPY_MATCHED_SUBJECT causes a copy of a matched subject to be
|
||||
made, instead of just remembering a pointer.
|
||||
|
||||
4. Some new Perl features:
|
||||
|
||||
(a) Perl 5.28's experimental alphabetic names for atomic groups and
|
||||
lookaround assertions, for example, (*pla:...) and (*atomic:...).
|
||||
|
||||
(b) The new Perl "script run" features (*script_run:...) and
|
||||
(*atomic_script_run:...) aka (*sr:...) and (*asr:...).
|
||||
|
||||
(c) When PCRE2_UTF is set, allow non-ASCII letters and decimal digits in
|
||||
capture group names.
|
||||
|
||||
5. --disable-percent-zt disables the use of %zu and %td in formatting strings
|
||||
in pcre2test. They were already automatically disabled for VC and older C
|
||||
compilers.
|
||||
|
||||
6. Some changes related to callouts in pcre2grep:
|
||||
|
||||
(a) Support for running an external program under VMS has been added, in
|
||||
addition to Windows and fork() support.
|
||||
|
||||
(b) --disable-pcre2grep-callout-fork restricts the callout support in
|
||||
to the inbuilt echo facility.
|
||||
|
||||
|
||||
Version 10.32 10-September-2018
|
||||
-------------------------------
|
||||
|
||||
This is another mainly bugfix and tidying release with a few minor
|
||||
enhancements. These are the main ones:
|
||||
|
||||
1. pcre2grep now supports the inclusion of binary zeros in patterns that are
|
||||
read from files via the -f option.
|
||||
|
||||
2. ./configure now supports --enable-jit=auto, which automatically enables JIT
|
||||
if the hardware supports it.
|
||||
|
||||
3. In pcre2_dfa_match(), internal recursive calls no longer use the stack for
|
||||
local workspace and local ovectors. Instead, an initial block of stack is
|
||||
reserved, but if this is insufficient, heap memory is used. The heap limit
|
||||
parameter now applies to pcre2_dfa_match().
|
||||
|
||||
4. Updated to Unicode version 11.0.0.
|
||||
|
||||
5. (*ACCEPT:ARG), (*FAIL:ARG), and (*COMMIT:ARG) are now supported.
|
||||
|
||||
6. Added support for \N{U+dddd}, but only in Unicode mode.
|
||||
|
||||
7. Added support for (?^) to unset all imnsx options.
|
||||
|
||||
|
||||
Version 10.31 12-February-2018
|
||||
------------------------------
|
||||
|
||||
This is mainly a bugfix and tidying release (see ChangeLog for full details).
|
||||
However, there are some minor enhancements.
|
||||
|
||||
1. New pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and
|
||||
PCRE2_CONFIG_COMPILED_WIDTHS.
|
||||
|
||||
2. New pcre2_pattern_info() option PCRE2_INFO_EXTRAOPTIONS to retrieve the
|
||||
extra compile time options.
|
||||
|
||||
3. There are now public names for all the pcre2_compile() error numbers.
|
||||
|
||||
4. Added PCRE2_CALLOUT_STARTMATCH and PCRE2_CALLOUT_BACKTRACK bits to a new
|
||||
field callout_flags in callout blocks.
|
||||
|
||||
|
||||
Version 10.30 14-August-2017
|
||||
----------------------------
|
||||
|
||||
The full list of changes that includes bugfixes and tidies is, as always, in
|
||||
ChangeLog. These are the most important new features:
|
||||
|
||||
1. The main interpreter, pcre2_match(), has been refactored into a new version
|
||||
that does not use recursive function calls (and therefore the system stack) for
|
||||
remembering backtracking positions. This makes --disable-stack-for-recursion a
|
||||
NOOP. The new implementation allows backtracking into recursive group calls in
|
||||
patterns, making it more compatible with Perl, and also fixes some other
|
||||
previously hard-to-do issues. For patterns that have a lot of backtracking, the
|
||||
heap is now used, and there is an explicit limit on the amount, settable by
|
||||
pcre2_set_heap_limit() or (*LIMIT_HEAP=xxx). The "recursion limit" is retained,
|
||||
but is renamed as "depth limit" (though the old names remain for
|
||||
compatibility).
|
||||
|
||||
There is also a change in the way callouts from pcre2_match() are handled. The
|
||||
offset_vector field in the callout block is no longer a pointer to the
|
||||
actual ovector that was passed to the matching function in the match data
|
||||
block. Instead it points to an internal ovector of a size large enough to hold
|
||||
all possible captured substrings in the pattern.
|
||||
|
||||
2. The new option PCRE2_ENDANCHORED insists that a pattern match must end at
|
||||
the end of the subject.
|
||||
|
||||
3. The new option PCRE2_EXTENDED_MORE implements Perl's /xx feature, and
|
||||
pcre2test is upgraded to support it. Setting within the pattern by (?xx) is
|
||||
also supported.
|
||||
|
||||
4. (?n) can be used to set PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
|
||||
|
||||
5. Additional compile options in the compile context are now available, and the
|
||||
first two are: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES and
|
||||
PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
|
||||
|
||||
6. The newline type PCRE2_NEWLINE_NUL is now available.
|
||||
|
||||
7. The match limit value now also applies to pcre2_dfa_match() as there are
|
||||
patterns that can use up a lot of resources without necessarily recursing very
|
||||
deeply.
|
||||
|
||||
8. The option REG_PEND (a GNU extension) is now available for the POSIX
|
||||
wrapper. Also there is a new option PCRE2_LITERAL which is used to support
|
||||
REG_NOSPEC.
|
||||
|
||||
9. PCRE2_EXTRA_MATCH_LINE and PCRE2_EXTRA_MATCH_WORD are implemented for the
|
||||
benefit of pcre2grep, and pcre2grep's -F, -w, and -x options are re-implemented
|
||||
using PCRE2_LITERAL, PCRE2_EXTRA_MATCH_WORD, and PCRE2_EXTRA_MATCH_LINE. This
|
||||
is tidier and also fixes some bugs.
|
||||
|
||||
10. The Unicode tables are upgraded from Unicode 8.0.0 to Unicode 10.0.0.
|
||||
|
||||
11. There are some experimental functions for converting foreign patterns
|
||||
(globs and POSIX patterns) into PCRE2 patterns.
|
||||
|
||||
|
||||
Version 10.23 14-February-2017
|
||||
------------------------------
|
||||
|
||||
1. ChangeLog has the details of a lot of bug fixes and tidies.
|
||||
|
||||
2. There has been a major re-factoring of the pcre2_compile.c file. Most syntax
|
||||
checking is now done in the pre-pass that identifies capturing groups. This has
|
||||
reduced the amount of duplication and made the code tidier. While doing this,
|
||||
some minor bugs and Perl incompatibilities were fixed (see ChangeLog for
|
||||
details.)
|
||||
|
||||
3. Back references are now permitted in lookbehind assertions when there are
|
||||
no duplicated group numbers (that is, (?| has not been used), and, if the
|
||||
reference is by name, there is only one group of that name. The referenced
|
||||
group must, of course be of fixed length.
|
||||
|
||||
4. \g{+<number>} (e.g. \g{+2} ) is now supported. It is a "forward back
|
||||
reference" and can be useful in repetitions (compare \g{-<number>} ). Perl does
|
||||
not recognize this syntax.
|
||||
|
||||
5. pcre2grep now automatically expands its buffer up to a maximum set by
|
||||
--max-buffer-size.
|
||||
|
||||
6. The -t option (grand total) has been added to pcre2grep.
|
||||
|
||||
7. A new function called pcre2_code_copy_with_tables() exists to copy a
|
||||
compiled pattern along with a private copy of the character tables that is
|
||||
uses.
|
||||
|
||||
8. A user supplied a number of patches to upgrade pcre2grep under Windows and
|
||||
tidy the code.
|
||||
|
||||
9. Several updates have been made to pcre2test and test scripts (see
|
||||
ChangeLog).
|
||||
|
||||
|
||||
Version 10.22 29-July-2016
|
||||
--------------------------
|
||||
|
||||
1. ChangeLog has the details of a number of bug fixes.
|
||||
|
||||
2. The POSIX wrapper function regcomp() did not used to support back references
|
||||
and subroutine calls if called with the REG_NOSUB option. It now does.
|
||||
|
||||
3. A new function, pcre2_code_copy(), is added, to make a copy of a compiled
|
||||
pattern.
|
||||
|
||||
4. Support for string callouts is added to pcre2grep.
|
||||
|
||||
5. Added the PCRE2_NO_JIT option to pcre2_match().
|
||||
|
||||
6. The pcre2_get_error_message() function now returns with a negative error
|
||||
code if the error number it is given is unknown.
|
||||
|
||||
7. Several updates have been made to pcre2test and test scripts (see
|
||||
ChangeLog).
|
||||
|
||||
|
||||
Version 10.21 12-January-2016
|
||||
-----------------------------
|
||||
|
||||
1. Many bugs have been fixed. A large number of them were provoked only by very
|
||||
strange pattern input, and were discovered by fuzzers. Some others were
|
||||
discovered by code auditing. See ChangeLog for details.
|
||||
|
||||
2. The Unicode tables have been updated to Unicode version 8.0.0.
|
||||
|
||||
3. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
|
||||
class, where both values are literal letters in the same case, omit the
|
||||
non-letter EBCDIC code points within the range.
|
||||
|
||||
4. There have been a number of enhancements to the pcre2_substitute() function,
|
||||
giving more flexibility to replacement facilities. It is now also possible to
|
||||
cause the function to return the needed buffer size if the one given is too
|
||||
small.
|
||||
|
||||
5. The PCRE2_ALT_VERBNAMES option causes the "name" parts of special verbs such
|
||||
as (*THEN:name) to be processed for backslashes and to take note of
|
||||
PCRE2_EXTENDED.
|
||||
|
||||
6. PCRE2_INFO_HASBACKSLASHC makes it possible for a client to find out if a
|
||||
pattern uses \C, and --never-backslash-C makes it possible to compile a version
|
||||
PCRE2 in which the use of \C is always forbidden.
|
||||
|
||||
7. A limit to the length of pattern that can be handled can now be set by
|
||||
calling pcre2_set_max_pattern_length().
|
||||
|
||||
8. When matching an unanchored pattern, a match can be required to begin within
|
||||
a given number of code units after the start of the subject by calling
|
||||
pcre2_set_offset_limit().
|
||||
|
||||
9. The pcre2test program has been extended to test new facilities, and it can
|
||||
now run the tests when LF on its own is not a valid newline sequence.
|
||||
|
||||
10. The RunTest script has also been updated to enable more tests to be run.
|
||||
|
||||
11. There have been some minor performance enhancements.
|
||||
|
||||
|
||||
Version 10.20 30-June-2015
|
||||
--------------------------
|
||||
|
||||
1. Callouts with string arguments and the pcre2_callout_enumerate() function
|
||||
have been implemented.
|
||||
|
||||
2. The PCRE2_NEVER_BACKSLASH_C option, which locks out the use of \C, is added.
|
||||
|
||||
3. The PCRE2_ALT_CIRCUMFLEX option lets ^ match after a newline at the end of a
|
||||
subject in multiline mode.
|
||||
|
||||
4. The way named subpatterns are handled has been refactored. The previous
|
||||
approach had several bugs.
|
||||
|
||||
5. The handling of \c in EBCDIC environments has been changed to conform to the
|
||||
perlebcdic document. This is an incompatible change.
|
||||
|
||||
6. Bugs have been mended, many of them discovered by fuzzers.
|
||||
|
||||
|
||||
Version 10.10 06-March-2015
|
||||
---------------------------
|
||||
|
||||
1. Serialization and de-serialization functions have been added to the API,
|
||||
making it possible to save and restore sets of compiled patterns, though
|
||||
restoration must be done in the same environment that was used for compilation.
|
||||
|
||||
2. The (*NO_JIT) feature has been added; this makes it possible for a pattern
|
||||
creator to specify that JIT is not to be used.
|
||||
|
||||
3. A number of bugs have been fixed. In particular, bugs that caused building
|
||||
on Windows using CMake to fail have been mended.
|
||||
|
||||
|
||||
Version 10.00 05-January-2015
|
||||
-----------------------------
|
||||
|
||||
Version 10.00 is the first release of PCRE2, a revised API for the PCRE
|
||||
library. Changes prior to 10.00 are logged in the ChangeLog file for the old
|
||||
API, up to item 20 for release 8.36. New programs are recommended to use the
|
||||
new library. Programs that use the original (PCRE1) API will need changing
|
||||
before linking with the new library.
|
||||
|
||||
****
|
|
@ -0,0 +1,406 @@
|
|||
Building PCRE2 without using autotools
|
||||
--------------------------------------
|
||||
|
||||
This document contains the following sections:
|
||||
|
||||
General
|
||||
Generic instructions for the PCRE2 C library
|
||||
Stack size in Windows environments
|
||||
Linking programs in Windows environments
|
||||
Calling conventions in Windows environments
|
||||
Comments about Win32 builds
|
||||
Building PCRE2 on Windows with CMake
|
||||
Building PCRE2 on Windows with Visual Studio
|
||||
Testing with RunTest.bat
|
||||
Building PCRE2 on native z/OS and z/VM
|
||||
|
||||
|
||||
GENERAL
|
||||
|
||||
The basic PCRE2 library consists entirely of code written in Standard C, and so
|
||||
should compile successfully on any system that has a Standard C compiler and
|
||||
library.
|
||||
|
||||
The PCRE2 distribution includes a "configure" file for use by the
|
||||
configure/make (autotools) build system, as found in many Unix-like
|
||||
environments. The README file contains information about the options for
|
||||
"configure".
|
||||
|
||||
There is also support for CMake, which some users prefer, especially in Windows
|
||||
environments, though it can also be run in Unix-like environments. See the
|
||||
section entitled "Building PCRE2 on Windows with CMake" below.
|
||||
|
||||
Versions of src/config.h and src/pcre2.h are distributed in the PCRE2 tarballs
|
||||
under the names src/config.h.generic and src/pcre2.h.generic. These are
|
||||
provided for those who build PCRE2 without using "configure" or CMake. If you
|
||||
use "configure" or CMake, the .generic versions are not used.
|
||||
|
||||
|
||||
GENERIC INSTRUCTIONS FOR THE PCRE2 C LIBRARY
|
||||
|
||||
The following are generic instructions for building the PCRE2 C library "by
|
||||
hand". If you are going to use CMake, this section does not apply to you; you
|
||||
can skip ahead to the CMake section.
|
||||
|
||||
(1) Copy or rename the file src/config.h.generic as src/config.h, and edit the
|
||||
macro settings that it contains to whatever is appropriate for your
|
||||
environment. In particular, you can alter the definition of the NEWLINE
|
||||
macro to specify what character(s) you want to be interpreted as line
|
||||
terminators by default.
|
||||
|
||||
When you subsequently compile any of the PCRE2 modules, you must specify
|
||||
-DHAVE_CONFIG_H to your compiler so that src/config.h is included in the
|
||||
sources.
|
||||
|
||||
An alternative approach is not to edit src/config.h, but to use -D on the
|
||||
compiler command line to make any changes that you need to the
|
||||
configuration options. In this case -DHAVE_CONFIG_H must not be set.
|
||||
|
||||
NOTE: There have been occasions when the way in which certain parameters
|
||||
in src/config.h are used has changed between releases. (In the
|
||||
configure/make world, this is handled automatically.) When upgrading to a
|
||||
new release, you are strongly advised to review src/config.h.generic
|
||||
before re-using what you had previously.
|
||||
|
||||
Note also that the src/config.h.generic file is created from a config.h
|
||||
that was generated by Autotools, which automatically includes settings of
|
||||
a number of macros that are not actually used by PCRE2 (for example,
|
||||
HAVE_MEMORY_H).
|
||||
|
||||
(2) Copy or rename the file src/pcre2.h.generic as src/pcre2.h.
|
||||
|
||||
(3) EITHER:
|
||||
Copy or rename file src/pcre2_chartables.c.dist as
|
||||
src/pcre2_chartables.c.
|
||||
|
||||
OR:
|
||||
Compile src/dftables.c as a stand-alone program (using -DHAVE_CONFIG_H
|
||||
if you have set up src/config.h), and then run it with the single
|
||||
argument "src/pcre2_chartables.c". This generates a set of standard
|
||||
character tables and writes them to that file. The tables are generated
|
||||
using the default C locale for your system. If you want to use a locale
|
||||
that is specified by LC_xxx environment variables, add the -L option to
|
||||
the dftables command. You must use this method if you are building on a
|
||||
system that uses EBCDIC code.
|
||||
|
||||
The tables in src/pcre2_chartables.c are defaults. The caller of PCRE2 can
|
||||
specify alternative tables at run time.
|
||||
|
||||
(4) For an 8-bit library, compile the following source files from the src
|
||||
directory, setting -DPCRE2_CODE_UNIT_WIDTH=8 as a compiler option. Also
|
||||
set -DHAVE_CONFIG_H if you have set up src/config.h with your
|
||||
configuration, or else use other -D settings to change the configuration
|
||||
as required.
|
||||
|
||||
pcre2_auto_possess.c
|
||||
pcre2_chartables.c
|
||||
pcre2_compile.c
|
||||
pcre2_config.c
|
||||
pcre2_context.c
|
||||
pcre2_convert.c
|
||||
pcre2_dfa_match.c
|
||||
pcre2_error.c
|
||||
pcre2_extuni.c
|
||||
pcre2_find_bracket.c
|
||||
pcre2_jit_compile.c
|
||||
pcre2_maketables.c
|
||||
pcre2_match.c
|
||||
pcre2_match_data.c
|
||||
pcre2_newline.c
|
||||
pcre2_ord2utf.c
|
||||
pcre2_pattern_info.c
|
||||
pcre2_script_run.c
|
||||
pcre2_serialize.c
|
||||
pcre2_string_utils.c
|
||||
pcre2_study.c
|
||||
pcre2_substitute.c
|
||||
pcre2_substring.c
|
||||
pcre2_tables.c
|
||||
pcre2_ucd.c
|
||||
pcre2_valid_utf.c
|
||||
pcre2_xclass.c
|
||||
|
||||
Make sure that you include -I. in the compiler command (or equivalent for
|
||||
an unusual compiler) so that all included PCRE2 header files are first
|
||||
sought in the src directory under the current directory. Otherwise you run
|
||||
the risk of picking up a previously-installed file from somewhere else.
|
||||
|
||||
Note that you must compile pcre2_jit_compile.c, even if you have not
|
||||
defined SUPPORT_JIT in src/config.h, because when JIT support is not
|
||||
configured, dummy functions are compiled. When JIT support IS configured,
|
||||
pcre2_jit_compile.c #includes other files from the sljit subdirectory,
|
||||
all of whose names begin with "sljit". It also #includes
|
||||
src/pcre2_jit_match.c and src/pcre2_jit_misc.c, so you should not compile
|
||||
these yourself.
|
||||
|
||||
Note also that the pcre2_fuzzsupport.c file contains special code that is
|
||||
useful to those who want to run fuzzing tests on the PCRE2 library. Unless
|
||||
you are doing that, you can ignore it.
|
||||
|
||||
(5) Now link all the compiled code into an object library in whichever form
|
||||
your system keeps such libraries. This is the basic PCRE2 C 8-bit library.
|
||||
If your system has static and shared libraries, you may have to do this
|
||||
once for each type.
|
||||
|
||||
(6) If you want to build a 16-bit library or 32-bit library (as well as, or
|
||||
instead of the 8-bit library) just supply 16 or 32 as the value of
|
||||
-DPCRE2_CODE_UNIT_WIDTH when you are compiling.
|
||||
|
||||
(7) If you want to build the POSIX wrapper functions (which apply only to the
|
||||
8-bit library), ensure that you have the src/pcre2posix.h file and then
|
||||
compile src/pcre2posix.c. Link the result (on its own) as the pcre2posix
|
||||
library.
|
||||
|
||||
(8) The pcre2test program can be linked with any combination of the 8-bit,
|
||||
16-bit and 32-bit libraries (depending on what you selected in
|
||||
src/config.h). Compile src/pcre2test.c; don't forget -DHAVE_CONFIG_H if
|
||||
necessary, but do NOT define PCRE2_CODE_UNIT_WIDTH. Then link with the
|
||||
appropriate library/ies. If you compiled an 8-bit library, pcre2test also
|
||||
needs the pcre2posix wrapper library.
|
||||
|
||||
(9) Run pcre2test on the testinput files in the testdata directory, and check
|
||||
that the output matches the corresponding testoutput files. There are
|
||||
comments about what each test does in the section entitled "Testing PCRE2"
|
||||
in the README file. If you compiled more than one of the 8-bit, 16-bit and
|
||||
32-bit libraries, you need to run pcre2test with the -16 option to do
|
||||
16-bit tests and with the -32 option to do 32-bit tests.
|
||||
|
||||
Some tests are relevant only when certain build-time options are selected.
|
||||
For example, test 4 is for Unicode support, and will not run if you have
|
||||
built PCRE2 without it. See the comments at the start of each testinput
|
||||
file. If you have a suitable Unix-like shell, the RunTest script will run
|
||||
the appropriate tests for you. The command "RunTest list" will output a
|
||||
list of all the tests.
|
||||
|
||||
Note that the supplied files are in Unix format, with just LF characters
|
||||
as line terminators. You may need to edit them to change this if your
|
||||
system uses a different convention.
|
||||
|
||||
(10) If you have built PCRE2 with SUPPORT_JIT, the JIT features can be tested
|
||||
by running pcre2test with the -jit option. This is done automatically by
|
||||
the RunTest script. You might also like to build and run the freestanding
|
||||
JIT test program, src/pcre2_jit_test.c.
|
||||
|
||||
(11) If you want to use the pcre2grep command, compile and link
|
||||
src/pcre2grep.c; it uses only the basic 8-bit PCRE2 library (it does not
|
||||
need the pcre2posix library). If you have built the PCRE2 library with JIT
|
||||
support by defining SUPPORT_JIT in src/config.h, you can also define
|
||||
SUPPORT_PCRE2GREP_JIT, which causes pcre2grep to make use of JIT (unless
|
||||
it is run with --no-jit). If you define SUPPORT_PCRE2GREP_JIT without
|
||||
defining SUPPORT_JIT, pcre2grep does not try to make use of JIT.
|
||||
|
||||
|
||||
STACK SIZE IN WINDOWS ENVIRONMENTS
|
||||
|
||||
Prior to release 10.30 the default system stack size of 1MiB in some Windows
|
||||
environments caused issues with some tests. This should no longer be the case
|
||||
for 10.30 and later releases.
|
||||
|
||||
|
||||
LINKING PROGRAMS IN WINDOWS ENVIRONMENTS
|
||||
|
||||
If you want to statically link a program against a PCRE2 library in the form of
|
||||
a non-dll .a file, you must define PCRE2_STATIC before including src/pcre2.h.
|
||||
|
||||
|
||||
CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
|
||||
|
||||
It is possible to compile programs to use different calling conventions using
|
||||
MSVC. Search the web for "calling conventions" for more information. To make it
|
||||
easier to change the calling convention for the exported functions in the
|
||||
PCRE2 library, the macro PCRE2_CALL_CONVENTION is present in all the external
|
||||
definitions. It can be set externally when compiling (e.g. in CFLAGS). If it is
|
||||
not set, it defaults to empty; the default calling convention is then used
|
||||
(which is what is wanted most of the time).
|
||||
|
||||
|
||||
COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE2 ON WINDOWS WITH CMAKE")
|
||||
|
||||
There are two ways of building PCRE2 using the "configure, make, make install"
|
||||
paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
|
||||
the same thing; they are completely different from each other. There is also
|
||||
support for building using CMake, which some users find a more straightforward
|
||||
way of building PCRE2 under Windows.
|
||||
|
||||
The MinGW home page (http://www.mingw.org/) says this:
|
||||
|
||||
MinGW: A collection of freely available and freely distributable Windows
|
||||
specific header files and import libraries combined with GNU toolsets that
|
||||
allow one to produce native Windows programs that do not rely on any
|
||||
3rd-party C runtime DLLs.
|
||||
|
||||
The Cygwin home page (http://www.cygwin.com/) says this:
|
||||
|
||||
Cygwin is a Linux-like environment for Windows. It consists of two parts:
|
||||
|
||||
. A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing
|
||||
substantial Linux API functionality
|
||||
|
||||
. A collection of tools which provide Linux look and feel.
|
||||
|
||||
On both MinGW and Cygwin, PCRE2 should build correctly using:
|
||||
|
||||
./configure && make && make install
|
||||
|
||||
This should create two libraries called libpcre2-8 and libpcre2-posix. These
|
||||
are independent libraries: when you link with libpcre2-posix you must also link
|
||||
with libpcre2-8, which contains the basic functions.
|
||||
|
||||
Using Cygwin's compiler generates libraries and executables that depend on
|
||||
cygwin1.dll. If a library that is generated this way is distributed,
|
||||
cygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL
|
||||
licence, this forces not only PCRE2 to be under the GPL, but also the entire
|
||||
application. A distributor who wants to keep their own code proprietary must
|
||||
purchase an appropriate Cygwin licence.
|
||||
|
||||
MinGW has no such restrictions. The MinGW compiler generates a library or
|
||||
executable that can run standalone on Windows without any third party dll or
|
||||
licensing issues.
|
||||
|
||||
But there is more complication:
|
||||
|
||||
If a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is
|
||||
to tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a
|
||||
front end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's
|
||||
gcc and MinGW's gcc). So, a user can:
|
||||
|
||||
. Build native binaries by using MinGW or by getting Cygwin and using
|
||||
-mno-cygwin.
|
||||
|
||||
. Build binaries that depend on cygwin1.dll by using Cygwin with the normal
|
||||
compiler flags.
|
||||
|
||||
The test files that are supplied with PCRE2 are in UNIX format, with LF
|
||||
characters as line terminators. Unless your PCRE2 library uses a default
|
||||
newline option that includes LF as a valid newline, it may be necessary to
|
||||
change the line terminators in the test files to get some of the tests to work.
|
||||
|
||||
|
||||
BUILDING PCRE2 ON WINDOWS WITH CMAKE
|
||||
|
||||
CMake is an alternative configuration facility that can be used instead of
|
||||
"configure". CMake creates project files (make files, solution files, etc.)
|
||||
tailored to numerous development environments, including Visual Studio,
|
||||
Borland, Msys, MinGW, NMake, and Unix. If possible, use short paths with no
|
||||
spaces in the names for your CMake installation and your PCRE2 source and build
|
||||
directories.
|
||||
|
||||
The following instructions were contributed by a PCRE1 user, but they should
|
||||
also work for PCRE2. If they are not followed exactly, errors may occur. In the
|
||||
event that errors do occur, it is recommended that you delete the CMake cache
|
||||
before attempting to repeat the CMake build process. In the CMake GUI, the
|
||||
cache can be deleted by selecting "File > Delete Cache".
|
||||
|
||||
1. Install the latest CMake version available from http://www.cmake.org/, and
|
||||
ensure that cmake\bin is on your path.
|
||||
|
||||
2. Unzip (retaining folder structure) the PCRE2 source tree into a source
|
||||
directory such as C:\pcre2. You should ensure your local date and time
|
||||
is not earlier than the file dates in your source dir if the release is
|
||||
very new.
|
||||
|
||||
3. Create a new, empty build directory, preferably a subdirectory of the
|
||||
source dir. For example, C:\pcre2\pcre2-xx\build.
|
||||
|
||||
4. Run cmake-gui from the Shell envirornment of your build tool, for example,
|
||||
Msys for Msys/MinGW or Visual Studio Command Prompt for VC/VC++. Do not try
|
||||
to start Cmake from the Windows Start menu, as this can lead to errors.
|
||||
|
||||
5. Enter C:\pcre2\pcre2-xx and C:\pcre2\pcre2-xx\build for the source and
|
||||
build directories, respectively.
|
||||
|
||||
6. Hit the "Configure" button.
|
||||
|
||||
7. Select the particular IDE / build tool that you are using (Visual
|
||||
Studio, MSYS makefiles, MinGW makefiles, etc.)
|
||||
|
||||
8. The GUI will then list several configuration options. This is where
|
||||
you can disable Unicode support or select other PCRE2 optional features.
|
||||
|
||||
9. Hit "Configure" again. The adjacent "Generate" button should now be
|
||||
active.
|
||||
|
||||
10. Hit "Generate".
|
||||
|
||||
11. The build directory should now contain a usable build system, be it a
|
||||
solution file for Visual Studio, makefiles for MinGW, etc. Exit from
|
||||
cmake-gui and use the generated build system with your compiler or IDE.
|
||||
E.g., for MinGW you can run "make", or for Visual Studio, open the PCRE2
|
||||
solution, select the desired configuration (Debug, or Release, etc.) and
|
||||
build the ALL_BUILD project.
|
||||
|
||||
12. If during configuration with cmake-gui you've elected to build the test
|
||||
programs, you can execute them by building the test project. E.g., for
|
||||
MinGW: "make test"; for Visual Studio build the RUN_TESTS project. The
|
||||
most recent build configuration is targeted by the tests. A summary of
|
||||
test results is presented. Complete test output is subsequently
|
||||
available for review in Testing\Temporary under your build dir.
|
||||
|
||||
|
||||
BUILDING PCRE2 ON WINDOWS WITH VISUAL STUDIO
|
||||
|
||||
The code currently cannot be compiled without a stdint.h header, which is
|
||||
available only in relatively recent versions of Visual Studio. However, this
|
||||
portable and permissively-licensed implementation of the header worked without
|
||||
issue:
|
||||
|
||||
http://www.azillionmonkeys.com/qed/pstdint.h
|
||||
|
||||
Just rename it and drop it into the top level of the build tree.
|
||||
|
||||
|
||||
TESTING WITH RUNTEST.BAT
|
||||
|
||||
If configured with CMake, building the test project ("make test" or building
|
||||
ALL_TESTS in Visual Studio) creates (and runs) pcre2_test.bat (and depending
|
||||
on your configuration options, possibly other test programs) in the build
|
||||
directory. The pcre2_test.bat script runs RunTest.bat with correct source and
|
||||
exe paths.
|
||||
|
||||
For manual testing with RunTest.bat, provided the build dir is a subdirectory
|
||||
of the source directory: Open command shell window. Chdir to the location
|
||||
of your pcre2test.exe and pcre2grep.exe programs. Call RunTest.bat with
|
||||
"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate.
|
||||
|
||||
To run only a particular test with RunTest.Bat provide a test number argument.
|
||||
|
||||
Otherwise:
|
||||
|
||||
1. Copy RunTest.bat into the directory where pcre2test.exe and pcre2grep.exe
|
||||
have been created.
|
||||
|
||||
2. Edit RunTest.bat to indentify the full or relative location of
|
||||
the pcre2 source (wherein which the testdata folder resides), e.g.:
|
||||
|
||||
set srcdir=C:\pcre2\pcre2-10.00
|
||||
|
||||
3. In a Windows command environment, chdir to the location of your bat and
|
||||
exe programs.
|
||||
|
||||
4. Run RunTest.bat. Test outputs will automatically be compared to expected
|
||||
results, and discrepancies will be identified in the console output.
|
||||
|
||||
To independently test the just-in-time compiler, run pcre2_jit_test.exe.
|
||||
|
||||
|
||||
BUILDING PCRE2 ON NATIVE Z/OS AND Z/VM
|
||||
|
||||
z/OS and z/VM are operating systems for mainframe computers, produced by IBM.
|
||||
The character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and
|
||||
applications can be supported through UNIX System Services, and in such an
|
||||
environment it should be possible to build PCRE2 in the same way as in other
|
||||
systems, with the EBCDIC related configuration settings, but it is not known if
|
||||
anybody has tried this.
|
||||
|
||||
In native z/OS (without UNIX System Services) and in z/VM, special ports are
|
||||
required. For details, please see file 939 on this web site:
|
||||
|
||||
http://www.cbttape.org
|
||||
|
||||
Everything in that location, source and executable, is in EBCDIC and native
|
||||
z/OS file formats. The port provides an API for LE languages such as COBOL and
|
||||
for the z/OS and z/VM versions of the Rexx languages.
|
||||
|
||||
==============================
|
||||
Last Updated: 14 November 2018
|
||||
==============================
|
|
@ -0,0 +1,236 @@
|
|||
#/bin/sh
|
||||
|
||||
# Script to prepare the files for building a PCRE2 release. It does some
|
||||
# processing of the documentation, detrails files, and creates pcre2.h.generic
|
||||
# and config.h.generic (for use by builders who can't run ./configure).
|
||||
|
||||
# You must run this script before runnning "make dist". If its first argument
|
||||
# is "doc", it stops after preparing the documentation. There are no other
|
||||
# arguments. The script makes use of the following files:
|
||||
|
||||
# 132html A Perl script that converts a .1 or .3 man page into HTML. It
|
||||
# "knows" the relevant troff constructs that are used in the PCRE2
|
||||
# man pages.
|
||||
|
||||
# CheckMan A Perl script that checks man pages for typos in the mark up.
|
||||
|
||||
# CleanTxt A Perl script that cleans up the output of "nroff -man" by
|
||||
# removing backspaces and other redundant text so as to produce
|
||||
# a readable .txt file.
|
||||
|
||||
# Detrail A Perl script that removes trailing spaces from files.
|
||||
|
||||
# doc/index.html.src
|
||||
# A file that is copied as index.html into the doc/html directory
|
||||
# when the HTML documentation is built. It works like this so that
|
||||
# doc/html can be deleted and re-created from scratch.
|
||||
|
||||
# README & NON-AUTOTOOLS-BUILD
|
||||
# These files are copied into the doc/html directory, with .txt
|
||||
# extensions so that they can by hyperlinked from the HTML
|
||||
# documentation, because some people just go to the HTML without
|
||||
# looking for text files.
|
||||
|
||||
|
||||
# First, sort out the documentation. Remove pcre2demo.3 first because it won't
|
||||
# pass the markup check (it is created below, using markup that none of the
|
||||
# other pages use).
|
||||
|
||||
cd doc
|
||||
echo Processing documentation
|
||||
|
||||
/bin/rm -f pcre2demo.3
|
||||
|
||||
# Check the remaining man pages
|
||||
|
||||
perl ../CheckMan *.1 *.3
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
|
||||
# Make Text form of the documentation. It needs some mangling to make it
|
||||
# tidy for online reading. Concatenate all the .3 stuff, but omit the
|
||||
# individual function pages.
|
||||
|
||||
cat <<End >pcre2.txt
|
||||
-----------------------------------------------------------------------------
|
||||
This file contains a concatenation of the PCRE2 man pages, converted to plain
|
||||
text format for ease of searching with a text editor, or for use on systems
|
||||
that do not have a man page processor. The small individual files that give
|
||||
synopses of each function in the library have not been included. Neither has
|
||||
the pcre2demo program. There are separate text files for the pcre2grep and
|
||||
pcre2test commands.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
End
|
||||
|
||||
echo "Making pcre2.txt"
|
||||
for file in pcre2 pcre2api pcre2build pcre2callout pcre2compat pcre2jit \
|
||||
pcre2limits pcre2matching pcre2partial pcre2pattern pcre2perform \
|
||||
pcre2posix pcre2sample pcre2serialize pcre2syntax \
|
||||
pcre2unicode ; do
|
||||
echo " Processing $file.3"
|
||||
nroff -c -man $file.3 >$file.rawtxt
|
||||
perl ../CleanTxt <$file.rawtxt >>pcre2.txt
|
||||
/bin/rm $file.rawtxt
|
||||
echo "------------------------------------------------------------------------------" >>pcre2.txt
|
||||
if [ "$file" != "pcre2sample" ] ; then
|
||||
echo " " >>pcre2.txt
|
||||
echo " " >>pcre2.txt
|
||||
fi
|
||||
done
|
||||
|
||||
# The three commands
|
||||
for file in pcre2test pcre2grep pcre2-config ; do
|
||||
echo Making $file.txt
|
||||
nroff -c -man $file.1 >$file.rawtxt
|
||||
perl ../CleanTxt <$file.rawtxt >$file.txt
|
||||
/bin/rm $file.rawtxt
|
||||
done
|
||||
|
||||
|
||||
# Make pcre2demo.3 from the pcre2demo.c source file
|
||||
|
||||
echo "Making pcre2demo.3"
|
||||
perl <<"END" >pcre2demo.3
|
||||
open(IN, "../src/pcre2demo.c") || die "Failed to open src/pcre2demo.c\n";
|
||||
open(OUT, ">pcre2demo.3") || die "Failed to open pcre2demo.3\n";
|
||||
print OUT ".\\\" Start example.\n" .
|
||||
".de EX\n" .
|
||||
". nr mE \\\\n(.f\n" .
|
||||
". nf\n" .
|
||||
". nh\n" .
|
||||
". ft CW\n" .
|
||||
"..\n" .
|
||||
".\n" .
|
||||
".\n" .
|
||||
".\\\" End example.\n" .
|
||||
".de EE\n" .
|
||||
". ft \\\\n(mE\n" .
|
||||
". fi\n" .
|
||||
". hy \\\\n(HY\n" .
|
||||
"..\n" .
|
||||
".\n" .
|
||||
".EX\n" ;
|
||||
while (<IN>)
|
||||
{
|
||||
s/\\/\\e/g;
|
||||
print OUT;
|
||||
}
|
||||
print OUT ".EE\n";
|
||||
close(IN);
|
||||
close(OUT);
|
||||
END
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
|
||||
|
||||
# Make HTML form of the documentation.
|
||||
|
||||
echo "Making HTML documentation"
|
||||
/bin/rm html/*
|
||||
cp index.html.src html/index.html
|
||||
cp ../README html/README.txt
|
||||
cp ../NON-AUTOTOOLS-BUILD html/NON-AUTOTOOLS-BUILD.txt
|
||||
|
||||
for file in *.1 ; do
|
||||
base=`basename $file .1`
|
||||
echo " Making $base.html"
|
||||
perl ../132html -toc $base <$file >html/$base.html
|
||||
done
|
||||
|
||||
# Exclude table of contents for function summaries. It seems that expr
|
||||
# forces an anchored regex. Also exclude them for small pages that have
|
||||
# only one section.
|
||||
|
||||
for file in *.3 ; do
|
||||
base=`basename $file .3`
|
||||
toc=-toc
|
||||
if [ `expr $base : '.*_'` -ne 0 ] ; then toc="" ; fi
|
||||
if [ "$base" = "pcre2sample" ] || \
|
||||
[ "$base" = "pcre2compat" ] || \
|
||||
[ "$base" = "pcre2limits" ] || \
|
||||
[ "$base" = "pcre2unicode" ] ; then
|
||||
toc=""
|
||||
fi
|
||||
echo " Making $base.html"
|
||||
perl ../132html $toc $base <$file >html/$base.html
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
done
|
||||
|
||||
# End of documentation processing; stop if only documentation required.
|
||||
|
||||
cd ..
|
||||
echo Documentation done
|
||||
if [ "$1" = "doc" ] ; then exit; fi
|
||||
|
||||
# These files are detrailed; do not detrail the test data because there may be
|
||||
# significant trailing spaces. Do not detrail RunTest.bat, because it has CRLF
|
||||
# line endings and the detrail script removes all trailing white space. The
|
||||
# configure files are also omitted from the detrailing.
|
||||
|
||||
files="\
|
||||
Makefile.am \
|
||||
configure.ac \
|
||||
README \
|
||||
LICENCE \
|
||||
COPYING \
|
||||
AUTHORS \
|
||||
NEWS \
|
||||
NON-AUTOTOOLS-BUILD \
|
||||
INSTALL \
|
||||
132html \
|
||||
CleanTxt \
|
||||
Detrail \
|
||||
ChangeLog \
|
||||
CMakeLists.txt \
|
||||
RunGrepTest \
|
||||
RunTest \
|
||||
pcre2-config.in \
|
||||
perltest.sh \
|
||||
libpcre2-8.pc.in \
|
||||
libpcre2-16.pc.in \
|
||||
libpcre2-32.pc.in \
|
||||
libpcre2-posix.pc.in \
|
||||
src/dftables.c \
|
||||
src/pcre2.h.in \
|
||||
src/pcre2_auto_possess.c \
|
||||
src/pcre2_compile.c \
|
||||
src/pcre2_config.c \
|
||||
src/pcre2_context.c \
|
||||
src/pcre2_convert.c \
|
||||
src/pcre2_dfa_match.c \
|
||||
src/pcre2_error.c \
|
||||
src/pcre2_extuni.c \
|
||||
src/pcre2_find_bracket.c \
|
||||
src/pcre2_internal.h \
|
||||
src/pcre2_intmodedep.h \
|
||||
src/pcre2_jit_compile.c \
|
||||
src/pcre2_jit_match.c \
|
||||
src/pcre2_jit_misc.c \
|
||||
src/pcre2_jit_test.c \
|
||||
src/pcre2_maketables.c \
|
||||
src/pcre2_match.c \
|
||||
src/pcre2_match_data.c \
|
||||
src/pcre2_newline.c \
|
||||
src/pcre2_ord2utf.c \
|
||||
src/pcre2_pattern_info.c \
|
||||
src/pcre2_printint.c \
|
||||
src/pcre2_string_utils.c \
|
||||
src/pcre2_study.c \
|
||||
src/pcre2_substring.c \
|
||||
src/pcre2_tables.c \
|
||||
src/pcre2_ucd.c \
|
||||
src/pcre2_ucp.h \
|
||||
src/pcre2_valid_utf.c \
|
||||
src/pcre2_xclass.c \
|
||||
src/pcre2demo.c \
|
||||
src/pcre2grep.c \
|
||||
src/pcre2posix.c \
|
||||
src/pcre2posix.h \
|
||||
src/pcre2test.c"
|
||||
|
||||
echo Detrailing
|
||||
perl ./Detrail $files doc/p* doc/html/*
|
||||
|
||||
echo Done
|
||||
|
||||
#End
|
|
@ -0,0 +1,895 @@
|
|||
README file for PCRE2 (Perl-compatible regular expression library)
|
||||
------------------------------------------------------------------
|
||||
|
||||
PCRE2 is a re-working of the original PCRE1 library to provide an entirely new
|
||||
API. Since its initial release in 2015, there has been further development of
|
||||
the code and it now differs from PCRE1 in more than just the API. There are new
|
||||
features and the internals have been improved. The latest release of PCRE2 is
|
||||
always available in three alternative formats from:
|
||||
|
||||
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-xxx.tar.gz
|
||||
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-xxx.tar.bz2
|
||||
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-xxx.zip
|
||||
|
||||
There is a mailing list for discussion about the development of PCRE (both the
|
||||
original and new APIs) at pcre-dev@exim.org. You can access the archives and
|
||||
subscribe or manage your subscription here:
|
||||
|
||||
https://lists.exim.org/mailman/listinfo/pcre-dev
|
||||
|
||||
Please read the NEWS file if you are upgrading from a previous release. The
|
||||
contents of this README file are:
|
||||
|
||||
The PCRE2 APIs
|
||||
Documentation for PCRE2
|
||||
Contributions by users of PCRE2
|
||||
Building PCRE2 on non-Unix-like systems
|
||||
Building PCRE2 without using autotools
|
||||
Building PCRE2 using autotools
|
||||
Retrieving configuration information
|
||||
Shared libraries
|
||||
Cross-compiling using autotools
|
||||
Making new tarballs
|
||||
Testing PCRE2
|
||||
Character tables
|
||||
File manifest
|
||||
|
||||
|
||||
The PCRE2 APIs
|
||||
--------------
|
||||
|
||||
PCRE2 is written in C, and it has its own API. There are three sets of
|
||||
functions, one for the 8-bit library, which processes strings of bytes, one for
|
||||
the 16-bit library, which processes strings of 16-bit values, and one for the
|
||||
32-bit library, which processes strings of 32-bit values. Unlike PCRE1, there
|
||||
are no C++ wrappers.
|
||||
|
||||
The distribution does contain a set of C wrapper functions for the 8-bit
|
||||
library that are based on the POSIX regular expression API (see the pcre2posix
|
||||
man page). These are built into a library called libpcre2-posix. Note that this
|
||||
just provides a POSIX calling interface to PCRE2; the regular expressions
|
||||
themselves still follow Perl syntax and semantics. The POSIX API is restricted,
|
||||
and does not give full access to all of PCRE2's facilities.
|
||||
|
||||
The header file for the POSIX-style functions is called pcre2posix.h. The
|
||||
official POSIX name is regex.h, but I did not want to risk possible problems
|
||||
with existing files of that name by distributing it that way. To use PCRE2 with
|
||||
an existing program that uses the POSIX API, pcre2posix.h will have to be
|
||||
renamed or pointed at by a link (or the program modified, of course). See the
|
||||
pcre2posix documentation for more details.
|
||||
|
||||
|
||||
Documentation for PCRE2
|
||||
-----------------------
|
||||
|
||||
If you install PCRE2 in the normal way on a Unix-like system, you will end up
|
||||
with a set of man pages whose names all start with "pcre2". The one that is
|
||||
just called "pcre2" lists all the others. In addition to these man pages, the
|
||||
PCRE2 documentation is supplied in two other forms:
|
||||
|
||||
1. There are files called doc/pcre2.txt, doc/pcre2grep.txt, and
|
||||
doc/pcre2test.txt in the source distribution. The first of these is a
|
||||
concatenation of the text forms of all the section 3 man pages except the
|
||||
listing of pcre2demo.c and those that summarize individual functions. The
|
||||
other two are the text forms of the section 1 man pages for the pcre2grep
|
||||
and pcre2test commands. These text forms are provided for ease of scanning
|
||||
with text editors or similar tools. They are installed in
|
||||
<prefix>/share/doc/pcre2, where <prefix> is the installation prefix
|
||||
(defaulting to /usr/local).
|
||||
|
||||
2. A set of files containing all the documentation in HTML form, hyperlinked
|
||||
in various ways, and rooted in a file called index.html, is distributed in
|
||||
doc/html and installed in <prefix>/share/doc/pcre2/html.
|
||||
|
||||
|
||||
Building PCRE2 on non-Unix-like systems
|
||||
---------------------------------------
|
||||
|
||||
For a non-Unix-like system, please read the file NON-AUTOTOOLS-BUILD, though if
|
||||
your system supports the use of "configure" and "make" you may be able to build
|
||||
PCRE2 using autotools in the same way as for many Unix-like systems.
|
||||
|
||||
PCRE2 can also be configured using CMake, which can be run in various ways
|
||||
(command line, GUI, etc). This creates Makefiles, solution files, etc. The file
|
||||
NON-AUTOTOOLS-BUILD has information about CMake.
|
||||
|
||||
PCRE2 has been compiled on many different operating systems. It should be
|
||||
straightforward to build PCRE2 on any system that has a Standard C compiler and
|
||||
library, because it uses only Standard C functions.
|
||||
|
||||
|
||||
Building PCRE2 without using autotools
|
||||
--------------------------------------
|
||||
|
||||
The use of autotools (in particular, libtool) is problematic in some
|
||||
environments, even some that are Unix or Unix-like. See the NON-AUTOTOOLS-BUILD
|
||||
file for ways of building PCRE2 without using autotools.
|
||||
|
||||
|
||||
Building PCRE2 using autotools
|
||||
------------------------------
|
||||
|
||||
The following instructions assume the use of the widely used "configure; make;
|
||||
make install" (autotools) process.
|
||||
|
||||
To build PCRE2 on system that supports autotools, first run the "configure"
|
||||
command from the PCRE2 distribution directory, with your current directory set
|
||||
to the directory where you want the files to be created. This command is a
|
||||
standard GNU "autoconf" configuration script, for which generic instructions
|
||||
are supplied in the file INSTALL.
|
||||
|
||||
Most commonly, people build PCRE2 within its own distribution directory, and in
|
||||
this case, on many systems, just running "./configure" is sufficient. However,
|
||||
the usual methods of changing standard defaults are available. For example:
|
||||
|
||||
CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
|
||||
|
||||
This command specifies that the C compiler should be run with the flags '-O2
|
||||
-Wall' instead of the default, and that "make install" should install PCRE2
|
||||
under /opt/local instead of the default /usr/local.
|
||||
|
||||
If you want to build in a different directory, just run "configure" with that
|
||||
directory as current. For example, suppose you have unpacked the PCRE2 source
|
||||
into /source/pcre2/pcre2-xxx, but you want to build it in
|
||||
/build/pcre2/pcre2-xxx:
|
||||
|
||||
cd /build/pcre2/pcre2-xxx
|
||||
/source/pcre2/pcre2-xxx/configure
|
||||
|
||||
PCRE2 is written in C and is normally compiled as a C library. However, it is
|
||||
possible to build it as a C++ library, though the provided building apparatus
|
||||
does not have any features to support this.
|
||||
|
||||
There are some optional features that can be included or omitted from the PCRE2
|
||||
library. They are also documented in the pcre2build man page.
|
||||
|
||||
. By default, both shared and static libraries are built. You can change this
|
||||
by adding one of these options to the "configure" command:
|
||||
|
||||
--disable-shared
|
||||
--disable-static
|
||||
|
||||
(See also "Shared libraries on Unix-like systems" below.)
|
||||
|
||||
. By default, only the 8-bit library is built. If you add --enable-pcre2-16 to
|
||||
the "configure" command, the 16-bit library is also built. If you add
|
||||
--enable-pcre2-32 to the "configure" command, the 32-bit library is also
|
||||
built. If you want only the 16-bit or 32-bit library, use --disable-pcre2-8
|
||||
to disable building the 8-bit library.
|
||||
|
||||
. If you want to include support for just-in-time (JIT) compiling, which can
|
||||
give large performance improvements on certain platforms, add --enable-jit to
|
||||
the "configure" command. This support is available only for certain hardware
|
||||
architectures. If you try to enable it on an unsupported architecture, there
|
||||
will be a compile time error. If in doubt, use --enable-jit=auto, which
|
||||
enables JIT only if the current hardware is supported.
|
||||
|
||||
. If you are enabling JIT under SELinux you may also want to add
|
||||
--enable-jit-sealloc, which enables the use of an execmem allocator in JIT
|
||||
that is compatible with SELinux. This has no effect if JIT is not enabled.
|
||||
|
||||
. If you do not want to make use of the default support for UTF-8 Unicode
|
||||
character strings in the 8-bit library, UTF-16 Unicode character strings in
|
||||
the 16-bit library, or UTF-32 Unicode character strings in the 32-bit
|
||||
library, you can add --disable-unicode to the "configure" command. This
|
||||
reduces the size of the libraries. It is not possible to configure one
|
||||
library with Unicode support, and another without, in the same configuration.
|
||||
It is also not possible to use --enable-ebcdic (see below) with Unicode
|
||||
support, so if this option is set, you must also use --disable-unicode.
|
||||
|
||||
When Unicode support is available, the use of a UTF encoding still has to be
|
||||
enabled by setting the PCRE2_UTF option at run time or starting a pattern
|
||||
with (*UTF). When PCRE2 is compiled with Unicode support, its input can only
|
||||
either be ASCII or UTF-8/16/32, even when running on EBCDIC platforms.
|
||||
|
||||
As well as supporting UTF strings, Unicode support includes support for the
|
||||
\P, \p, and \X sequences that recognize Unicode character properties.
|
||||
However, only the basic two-letter properties such as Lu are supported.
|
||||
Escape sequences such as \d and \w in patterns do not by default make use of
|
||||
Unicode properties, but can be made to do so by setting the PCRE2_UCP option
|
||||
or starting a pattern with (*UCP).
|
||||
|
||||
. You can build PCRE2 to recognize either CR or LF or the sequence CRLF, or any
|
||||
of the preceding, or any of the Unicode newline sequences, or the NUL (zero)
|
||||
character as indicating the end of a line. Whatever you specify at build time
|
||||
is the default; the caller of PCRE2 can change the selection at run time. The
|
||||
default newline indicator is a single LF character (the Unix standard). You
|
||||
can specify the default newline indicator by adding --enable-newline-is-cr,
|
||||
--enable-newline-is-lf, --enable-newline-is-crlf,
|
||||
--enable-newline-is-anycrlf, --enable-newline-is-any, or
|
||||
--enable-newline-is-nul to the "configure" command, respectively.
|
||||
|
||||
. By default, the sequence \R in a pattern matches any Unicode line ending
|
||||
sequence. This is independent of the option specifying what PCRE2 considers
|
||||
to be the end of a line (see above). However, the caller of PCRE2 can
|
||||
restrict \R to match only CR, LF, or CRLF. You can make this the default by
|
||||
adding --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
|
||||
|
||||
. In a pattern, the escape sequence \C matches a single code unit, even in a
|
||||
UTF mode. This can be dangerous because it breaks up multi-code-unit
|
||||
characters. You can build PCRE2 with the use of \C permanently locked out by
|
||||
adding --enable-never-backslash-C (note the upper case C) to the "configure"
|
||||
command. When \C is allowed by the library, individual applications can lock
|
||||
it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option.
|
||||
|
||||
. PCRE2 has a counter that limits the depth of nesting of parentheses in a
|
||||
pattern. This limits the amount of system stack that a pattern uses when it
|
||||
is compiled. The default is 250, but you can change it by setting, for
|
||||
example,
|
||||
|
||||
--with-parens-nest-limit=500
|
||||
|
||||
. PCRE2 has a counter that can be set to limit the amount of computing resource
|
||||
it uses when matching a pattern. If the limit is exceeded during a match, the
|
||||
match fails. The default is ten million. You can change the default by
|
||||
setting, for example,
|
||||
|
||||
--with-match-limit=500000
|
||||
|
||||
on the "configure" command. This is just the default; individual calls to
|
||||
pcre2_match() or pcre2_dfa_match() can supply their own value. There is more
|
||||
discussion in the pcre2api man page (search for pcre2_set_match_limit).
|
||||
|
||||
. There is a separate counter that limits the depth of nested backtracking
|
||||
(pcre2_match()) or nested function calls (pcre2_dfa_match()) during a
|
||||
matching process, which indirectly limits the amount of heap memory that is
|
||||
used, and in the case of pcre2_dfa_match() the amount of stack as well. This
|
||||
counter also has a default of ten million, which is essentially "unlimited".
|
||||
You can change the default by setting, for example,
|
||||
|
||||
--with-match-limit-depth=5000
|
||||
|
||||
There is more discussion in the pcre2api man page (search for
|
||||
pcre2_set_depth_limit).
|
||||
|
||||
. You can also set an explicit limit on the amount of heap memory used by
|
||||
the pcre2_match() and pcre2_dfa_match() interpreters:
|
||||
|
||||
--with-heap-limit=500
|
||||
|
||||
The units are kibibytes (units of 1024 bytes). This limit does not apply when
|
||||
the JIT optimization (which has its own memory control features) is used.
|
||||
There is more discussion on the pcre2api man page (search for
|
||||
pcre2_set_heap_limit).
|
||||
|
||||
. In the 8-bit library, the default maximum compiled pattern size is around
|
||||
64 kibibytes. You can increase this by adding --with-link-size=3 to the
|
||||
"configure" command. PCRE2 then uses three bytes instead of two for offsets
|
||||
to different parts of the compiled pattern. In the 16-bit library,
|
||||
--with-link-size=3 is the same as --with-link-size=4, which (in both
|
||||
libraries) uses four-byte offsets. Increasing the internal link size reduces
|
||||
performance in the 8-bit and 16-bit libraries. In the 32-bit library, the
|
||||
link size setting is ignored, as 4-byte offsets are always used.
|
||||
|
||||
. For speed, PCRE2 uses four tables for manipulating and identifying characters
|
||||
whose code point values are less than 256. By default, it uses a set of
|
||||
tables for ASCII encoding that is part of the distribution. If you specify
|
||||
|
||||
--enable-rebuild-chartables
|
||||
|
||||
a program called dftables is compiled and run in the default C locale when
|
||||
you obey "make". It builds a source file called pcre2_chartables.c. If you do
|
||||
not specify this option, pcre2_chartables.c is created as a copy of
|
||||
pcre2_chartables.c.dist. See "Character tables" below for further
|
||||
information.
|
||||
|
||||
. It is possible to compile PCRE2 for use on systems that use EBCDIC as their
|
||||
character code (as opposed to ASCII/Unicode) by specifying
|
||||
|
||||
--enable-ebcdic --disable-unicode
|
||||
|
||||
This automatically implies --enable-rebuild-chartables (see above). However,
|
||||
when PCRE2 is built this way, it always operates in EBCDIC. It cannot support
|
||||
both EBCDIC and UTF-8/16/32. There is a second option, --enable-ebcdic-nl25,
|
||||
which specifies that the code value for the EBCDIC NL character is 0x25
|
||||
instead of the default 0x15.
|
||||
|
||||
. If you specify --enable-debug, additional debugging code is included in the
|
||||
build. This option is intended for use by the PCRE2 maintainers.
|
||||
|
||||
. In environments where valgrind is installed, if you specify
|
||||
|
||||
--enable-valgrind
|
||||
|
||||
PCRE2 will use valgrind annotations to mark certain memory regions as
|
||||
unaddressable. This allows it to detect invalid memory accesses, and is
|
||||
mostly useful for debugging PCRE2 itself.
|
||||
|
||||
. In environments where the gcc compiler is used and lcov version 1.6 or above
|
||||
is installed, if you specify
|
||||
|
||||
--enable-coverage
|
||||
|
||||
the build process implements a code coverage report for the test suite. The
|
||||
report is generated by running "make coverage". If ccache is installed on
|
||||
your system, it must be disabled when building PCRE2 for coverage reporting.
|
||||
You can do this by setting the environment variable CCACHE_DISABLE=1 before
|
||||
running "make" to build PCRE2. There is more information about coverage
|
||||
reporting in the "pcre2build" documentation.
|
||||
|
||||
. When JIT support is enabled, pcre2grep automatically makes use of it, unless
|
||||
you add --disable-pcre2grep-jit to the "configure" command.
|
||||
|
||||
. There is support for calling external programs during matching in the
|
||||
pcre2grep command, using PCRE2's callout facility with string arguments. This
|
||||
support can be disabled by adding --disable-pcre2grep-callout to the
|
||||
"configure" command. There are two kinds of callout: one that generates
|
||||
output from inbuilt code, and another that calls an external program. The
|
||||
latter has special support for Windows and VMS; otherwise it assumes the
|
||||
existence of the fork() function. This facility can be disabled by adding
|
||||
--disable-pcre2grep-callout-fork to the "configure" command.
|
||||
|
||||
. The pcre2grep program currently supports only 8-bit data files, and so
|
||||
requires the 8-bit PCRE2 library. It is possible to compile pcre2grep to use
|
||||
libz and/or libbz2, in order to read .gz and .bz2 files (respectively), by
|
||||
specifying one or both of
|
||||
|
||||
--enable-pcre2grep-libz
|
||||
--enable-pcre2grep-libbz2
|
||||
|
||||
Of course, the relevant libraries must be installed on your system.
|
||||
|
||||
. The default starting size (in bytes) of the internal buffer used by pcre2grep
|
||||
can be set by, for example:
|
||||
|
||||
--with-pcre2grep-bufsize=51200
|
||||
|
||||
The value must be a plain integer. The default is 20480. The amount of memory
|
||||
used by pcre2grep is actually three times this number, to allow for "before"
|
||||
and "after" lines. If very long lines are encountered, the buffer is
|
||||
automatically enlarged, up to a fixed maximum size.
|
||||
|
||||
. The default maximum size of pcre2grep's internal buffer can be set by, for
|
||||
example:
|
||||
|
||||
--with-pcre2grep-max-bufsize=2097152
|
||||
|
||||
The default is either 1048576 or the value of --with-pcre2grep-bufsize,
|
||||
whichever is the larger.
|
||||
|
||||
. It is possible to compile pcre2test so that it links with the libreadline
|
||||
or libedit libraries, by specifying, respectively,
|
||||
|
||||
--enable-pcre2test-libreadline or --enable-pcre2test-libedit
|
||||
|
||||
If this is done, when pcre2test's input is from a terminal, it reads it using
|
||||
the readline() function. This provides line-editing and history facilities.
|
||||
Note that libreadline is GPL-licenced, so if you distribute a binary of
|
||||
pcre2test linked in this way, there may be licensing issues. These can be
|
||||
avoided by linking with libedit (which has a BSD licence) instead.
|
||||
|
||||
Enabling libreadline causes the -lreadline option to be added to the
|
||||
pcre2test build. In many operating environments with a sytem-installed
|
||||
readline library this is sufficient. However, in some environments (e.g. if
|
||||
an unmodified distribution version of readline is in use), it may be
|
||||
necessary to specify something like LIBS="-lncurses" as well. This is
|
||||
because, to quote the readline INSTALL, "Readline uses the termcap functions,
|
||||
but does not link with the termcap or curses library itself, allowing
|
||||
applications which link with readline the to choose an appropriate library."
|
||||
If you get error messages about missing functions tgetstr, tgetent, tputs,
|
||||
tgetflag, or tgoto, this is the problem, and linking with the ncurses library
|
||||
should fix it.
|
||||
|
||||
. The C99 standard defines formatting modifiers z and t for size_t and
|
||||
ptrdiff_t values, respectively. By default, PCRE2 uses these modifiers in
|
||||
environments other than Microsoft Visual Studio when __STDC_VERSION__ is
|
||||
defined and has a value greater than or equal to 199901L (indicating C99).
|
||||
However, there is at least one environment that claims to be C99 but does not
|
||||
support these modifiers. If --disable-percent-zt is specified, no use is made
|
||||
of the z or t modifiers. Instead or %td or %zu, %lu is used, with a cast for
|
||||
size_t values.
|
||||
|
||||
. There is a special option called --enable-fuzz-support for use by people who
|
||||
want to run fuzzing tests on PCRE2. At present this applies only to the 8-bit
|
||||
library. If set, it causes an extra library called libpcre2-fuzzsupport.a to
|
||||
be built, but not installed. This contains a single function called
|
||||
LLVMFuzzerTestOneInput() whose arguments are a pointer to a string and the
|
||||
length of the string. When called, this function tries to compile the string
|
||||
as a pattern, and if that succeeds, to match it. This is done both with no
|
||||
options and with some random options bits that are generated from the string.
|
||||
Setting --enable-fuzz-support also causes a binary called pcre2fuzzcheck to
|
||||
be created. This is normally run under valgrind or used when PCRE2 is
|
||||
compiled with address sanitizing enabled. It calls the fuzzing function and
|
||||
outputs information about it is doing. The input strings are specified by
|
||||
arguments: if an argument starts with "=" the rest of it is a literal input
|
||||
string. Otherwise, it is assumed to be a file name, and the contents of the
|
||||
file are the test string.
|
||||
|
||||
. Releases before 10.30 could be compiled with --disable-stack-for-recursion,
|
||||
which caused pcre2_match() to use individual blocks on the heap for
|
||||
backtracking instead of recursive function calls (which use the stack). This
|
||||
is now obsolete since pcre2_match() was refactored always to use the heap (in
|
||||
a much more efficient way than before). This option is retained for backwards
|
||||
compatibility, but has no effect other than to output a warning.
|
||||
|
||||
The "configure" script builds the following files for the basic C library:
|
||||
|
||||
. Makefile the makefile that builds the library
|
||||
. src/config.h build-time configuration options for the library
|
||||
. src/pcre2.h the public PCRE2 header file
|
||||
. pcre2-config script that shows the building settings such as CFLAGS
|
||||
that were set for "configure"
|
||||
. libpcre2-8.pc )
|
||||
. libpcre2-16.pc ) data for the pkg-config command
|
||||
. libpcre2-32.pc )
|
||||
. libpcre2-posix.pc )
|
||||
. libtool script that builds shared and/or static libraries
|
||||
|
||||
Versions of config.h and pcre2.h are distributed in the src directory of PCRE2
|
||||
tarballs under the names config.h.generic and pcre2.h.generic. These are
|
||||
provided for those who have to build PCRE2 without using "configure" or CMake.
|
||||
If you use "configure" or CMake, the .generic versions are not used.
|
||||
|
||||
The "configure" script also creates config.status, which is an executable
|
||||
script that can be run to recreate the configuration, and config.log, which
|
||||
contains compiler output from tests that "configure" runs.
|
||||
|
||||
Once "configure" has run, you can run "make". This builds whichever of the
|
||||
libraries libpcre2-8, libpcre2-16 and libpcre2-32 are configured, and a test
|
||||
program called pcre2test. If you enabled JIT support with --enable-jit, another
|
||||
test program called pcre2_jit_test is built as well. If the 8-bit library is
|
||||
built, libpcre2-posix and the pcre2grep command are also built. Running
|
||||
"make" with the -j option may speed up compilation on multiprocessor systems.
|
||||
|
||||
The command "make check" runs all the appropriate tests. Details of the PCRE2
|
||||
tests are given below in a separate section of this document. The -j option of
|
||||
"make" can also be used when running the tests.
|
||||
|
||||
You can use "make install" to install PCRE2 into live directories on your
|
||||
system. The following are installed (file names are all relative to the
|
||||
<prefix> that is set when "configure" is run):
|
||||
|
||||
Commands (bin):
|
||||
pcre2test
|
||||
pcre2grep (if 8-bit support is enabled)
|
||||
pcre2-config
|
||||
|
||||
Libraries (lib):
|
||||
libpcre2-8 (if 8-bit support is enabled)
|
||||
libpcre2-16 (if 16-bit support is enabled)
|
||||
libpcre2-32 (if 32-bit support is enabled)
|
||||
libpcre2-posix (if 8-bit support is enabled)
|
||||
|
||||
Configuration information (lib/pkgconfig):
|
||||
libpcre2-8.pc
|
||||
libpcre2-16.pc
|
||||
libpcre2-32.pc
|
||||
libpcre2-posix.pc
|
||||
|
||||
Header files (include):
|
||||
pcre2.h
|
||||
pcre2posix.h
|
||||
|
||||
Man pages (share/man/man{1,3}):
|
||||
pcre2grep.1
|
||||
pcre2test.1
|
||||
pcre2-config.1
|
||||
pcre2.3
|
||||
pcre2*.3 (lots more pages, all starting "pcre2")
|
||||
|
||||
HTML documentation (share/doc/pcre2/html):
|
||||
index.html
|
||||
*.html (lots more pages, hyperlinked from index.html)
|
||||
|
||||
Text file documentation (share/doc/pcre2):
|
||||
AUTHORS
|
||||
COPYING
|
||||
ChangeLog
|
||||
LICENCE
|
||||
NEWS
|
||||
README
|
||||
pcre2.txt (a concatenation of the man(3) pages)
|
||||
pcre2test.txt the pcre2test man page
|
||||
pcre2grep.txt the pcre2grep man page
|
||||
pcre2-config.txt the pcre2-config man page
|
||||
|
||||
If you want to remove PCRE2 from your system, you can run "make uninstall".
|
||||
This removes all the files that "make install" installed. However, it does not
|
||||
remove any directories, because these are often shared with other programs.
|
||||
|
||||
|
||||
Retrieving configuration information
|
||||
------------------------------------
|
||||
|
||||
Running "make install" installs the command pcre2-config, which can be used to
|
||||
recall information about the PCRE2 configuration and installation. For example:
|
||||
|
||||
pcre2-config --version
|
||||
|
||||
prints the version number, and
|
||||
|
||||
pcre2-config --libs8
|
||||
|
||||
outputs information about where the 8-bit library is installed. This command
|
||||
can be included in makefiles for programs that use PCRE2, saving the programmer
|
||||
from having to remember too many details. Run pcre2-config with no arguments to
|
||||
obtain a list of possible arguments.
|
||||
|
||||
The pkg-config command is another system for saving and retrieving information
|
||||
about installed libraries. Instead of separate commands for each library, a
|
||||
single command is used. For example:
|
||||
|
||||
pkg-config --libs libpcre2-16
|
||||
|
||||
The data is held in *.pc files that are installed in a directory called
|
||||
<prefix>/lib/pkgconfig.
|
||||
|
||||
|
||||
Shared libraries
|
||||
----------------
|
||||
|
||||
The default distribution builds PCRE2 as shared libraries and static libraries,
|
||||
as long as the operating system supports shared libraries. Shared library
|
||||
support relies on the "libtool" script which is built as part of the
|
||||
"configure" process.
|
||||
|
||||
The libtool script is used to compile and link both shared and static
|
||||
libraries. They are placed in a subdirectory called .libs when they are newly
|
||||
built. The programs pcre2test and pcre2grep are built to use these uninstalled
|
||||
libraries (by means of wrapper scripts in the case of shared libraries). When
|
||||
you use "make install" to install shared libraries, pcre2grep and pcre2test are
|
||||
automatically re-built to use the newly installed shared libraries before being
|
||||
installed themselves. However, the versions left in the build directory still
|
||||
use the uninstalled libraries.
|
||||
|
||||
To build PCRE2 using static libraries only you must use --disable-shared when
|
||||
configuring it. For example:
|
||||
|
||||
./configure --prefix=/usr/gnu --disable-shared
|
||||
|
||||
Then run "make" in the usual way. Similarly, you can use --disable-static to
|
||||
build only shared libraries.
|
||||
|
||||
|
||||
Cross-compiling using autotools
|
||||
-------------------------------
|
||||
|
||||
You can specify CC and CFLAGS in the normal way to the "configure" command, in
|
||||
order to cross-compile PCRE2 for some other host. However, you should NOT
|
||||
specify --enable-rebuild-chartables, because if you do, the dftables.c source
|
||||
file is compiled and run on the local host, in order to generate the inbuilt
|
||||
character tables (the pcre2_chartables.c file). This will probably not work,
|
||||
because dftables.c needs to be compiled with the local compiler, not the cross
|
||||
compiler.
|
||||
|
||||
When --enable-rebuild-chartables is not specified, pcre2_chartables.c is
|
||||
created by making a copy of pcre2_chartables.c.dist, which is a default set of
|
||||
tables that assumes ASCII code. Cross-compiling with the default tables should
|
||||
not be a problem.
|
||||
|
||||
If you need to modify the character tables when cross-compiling, you should
|
||||
move pcre2_chartables.c.dist out of the way, then compile dftables.c by hand
|
||||
and run it on the local host to make a new version of pcre2_chartables.c.dist.
|
||||
Then when you cross-compile PCRE2 this new version of the tables will be used.
|
||||
|
||||
|
||||
Making new tarballs
|
||||
-------------------
|
||||
|
||||
The command "make dist" creates three PCRE2 tarballs, in tar.gz, tar.bz2, and
|
||||
zip formats. The command "make distcheck" does the same, but then does a trial
|
||||
build of the new distribution to ensure that it works.
|
||||
|
||||
If you have modified any of the man page sources in the doc directory, you
|
||||
should first run the PrepareRelease script before making a distribution. This
|
||||
script creates the .txt and HTML forms of the documentation from the man pages.
|
||||
|
||||
|
||||
Testing PCRE2
|
||||
-------------
|
||||
|
||||
To test the basic PCRE2 library on a Unix-like system, run the RunTest script.
|
||||
There is another script called RunGrepTest that tests the pcre2grep command.
|
||||
When JIT support is enabled, a third test program called pcre2_jit_test is
|
||||
built. Both the scripts and all the program tests are run if you obey "make
|
||||
check". For other environments, see the instructions in NON-AUTOTOOLS-BUILD.
|
||||
|
||||
The RunTest script runs the pcre2test test program (which is documented in its
|
||||
own man page) on each of the relevant testinput files in the testdata
|
||||
directory, and compares the output with the contents of the corresponding
|
||||
testoutput files. RunTest uses a file called testtry to hold the main output
|
||||
from pcre2test. Other files whose names begin with "test" are used as working
|
||||
files in some tests.
|
||||
|
||||
Some tests are relevant only when certain build-time options were selected. For
|
||||
example, the tests for UTF-8/16/32 features are run only when Unicode support
|
||||
is available. RunTest outputs a comment when it skips a test.
|
||||
|
||||
Many (but not all) of the tests that are not skipped are run twice if JIT
|
||||
support is available. On the second run, JIT compilation is forced. This
|
||||
testing can be suppressed by putting "nojit" on the RunTest command line.
|
||||
|
||||
The entire set of tests is run once for each of the 8-bit, 16-bit and 32-bit
|
||||
libraries that are enabled. If you want to run just one set of tests, call
|
||||
RunTest with either the -8, -16 or -32 option.
|
||||
|
||||
If valgrind is installed, you can run the tests under it by putting "valgrind"
|
||||
on the RunTest command line. To run pcre2test on just one or more specific test
|
||||
files, give their numbers as arguments to RunTest, for example:
|
||||
|
||||
RunTest 2 7 11
|
||||
|
||||
You can also specify ranges of tests such as 3-6 or 3- (meaning 3 to the
|
||||
end), or a number preceded by ~ to exclude a test. For example:
|
||||
|
||||
Runtest 3-15 ~10
|
||||
|
||||
This runs tests 3 to 15, excluding test 10, and just ~13 runs all the tests
|
||||
except test 13. Whatever order the arguments are in, the tests are always run
|
||||
in numerical order.
|
||||
|
||||
You can also call RunTest with the single argument "list" to cause it to output
|
||||
a list of tests.
|
||||
|
||||
The test sequence starts with "test 0", which is a special test that has no
|
||||
input file, and whose output is not checked. This is because it will be
|
||||
different on different hardware and with different configurations. The test
|
||||
exists in order to exercise some of pcre2test's code that would not otherwise
|
||||
be run.
|
||||
|
||||
Tests 1 and 2 can always be run, as they expect only plain text strings (not
|
||||
UTF) and make no use of Unicode properties. The first test file can be fed
|
||||
directly into the perltest.sh script to check that Perl gives the same results.
|
||||
The only difference you should see is in the first few lines, where the Perl
|
||||
version is given instead of the PCRE2 version. The second set of tests check
|
||||
auxiliary functions, error detection, and run-time flags that are specific to
|
||||
PCRE2. It also uses the debugging flags to check some of the internals of
|
||||
pcre2_compile().
|
||||
|
||||
If you build PCRE2 with a locale setting that is not the standard C locale, the
|
||||
character tables may be different (see next paragraph). In some cases, this may
|
||||
cause failures in the second set of tests. For example, in a locale where the
|
||||
isprint() function yields TRUE for characters in the range 128-255, the use of
|
||||
[:isascii:] inside a character class defines a different set of characters, and
|
||||
this shows up in this test as a difference in the compiled code, which is being
|
||||
listed for checking. For example, where the comparison test output contains
|
||||
[\x00-\x7f] the test might contain [\x00-\xff], and similarly in some other
|
||||
cases. This is not a bug in PCRE2.
|
||||
|
||||
Test 3 checks pcre2_maketables(), the facility for building a set of character
|
||||
tables for a specific locale and using them instead of the default tables. The
|
||||
script uses the "locale" command to check for the availability of the "fr_FR",
|
||||
"french", or "fr" locale, and uses the first one that it finds. If the "locale"
|
||||
command fails, or if its output doesn't include "fr_FR", "french", or "fr" in
|
||||
the list of available locales, the third test cannot be run, and a comment is
|
||||
output to say why. If running this test produces an error like this:
|
||||
|
||||
** Failed to set locale "fr_FR"
|
||||
|
||||
it means that the given locale is not available on your system, despite being
|
||||
listed by "locale". This does not mean that PCRE2 is broken. There are three
|
||||
alternative output files for the third test, because three different versions
|
||||
of the French locale have been encountered. The test passes if its output
|
||||
matches any one of them.
|
||||
|
||||
Tests 4 and 5 check UTF and Unicode property support, test 4 being compatible
|
||||
with the perltest.sh script, and test 5 checking PCRE2-specific things.
|
||||
|
||||
Tests 6 and 7 check the pcre2_dfa_match() alternative matching function, in
|
||||
non-UTF mode and UTF-mode with Unicode property support, respectively.
|
||||
|
||||
Test 8 checks some internal offsets and code size features, but it is run only
|
||||
when Unicode support is enabled. The output is different in 8-bit, 16-bit, and
|
||||
32-bit modes and for different link sizes, so there are different output files
|
||||
for each mode and link size.
|
||||
|
||||
Tests 9 and 10 are run only in 8-bit mode, and tests 11 and 12 are run only in
|
||||
16-bit and 32-bit modes. These are tests that generate different output in
|
||||
8-bit mode. Each pair are for general cases and Unicode support, respectively.
|
||||
|
||||
Test 13 checks the handling of non-UTF characters greater than 255 by
|
||||
pcre2_dfa_match() in 16-bit and 32-bit modes.
|
||||
|
||||
Test 14 contains some special UTF and UCP tests that give different output for
|
||||
different code unit widths.
|
||||
|
||||
Test 15 contains a number of tests that must not be run with JIT. They check,
|
||||
among other non-JIT things, the match-limiting features of the intepretive
|
||||
matcher.
|
||||
|
||||
Test 16 is run only when JIT support is not available. It checks that an
|
||||
attempt to use JIT has the expected behaviour.
|
||||
|
||||
Test 17 is run only when JIT support is available. It checks JIT complete and
|
||||
partial modes, match-limiting under JIT, and other JIT-specific features.
|
||||
|
||||
Tests 18 and 19 are run only in 8-bit mode. They check the POSIX interface to
|
||||
the 8-bit library, without and with Unicode support, respectively.
|
||||
|
||||
Test 20 checks the serialization functions by writing a set of compiled
|
||||
patterns to a file, and then reloading and checking them.
|
||||
|
||||
Tests 21 and 22 test \C support when the use of \C is not locked out, without
|
||||
and with UTF support, respectively. Test 23 tests \C when it is locked out.
|
||||
|
||||
Tests 24 and 25 test the experimental pattern conversion functions, without and
|
||||
with UTF support, respectively.
|
||||
|
||||
|
||||
Character tables
|
||||
----------------
|
||||
|
||||
For speed, PCRE2 uses four tables for manipulating and identifying characters
|
||||
whose code point values are less than 256. By default, a set of tables that is
|
||||
built into the library is used. The pcre2_maketables() function can be called
|
||||
by an application to create a new set of tables in the current locale. This are
|
||||
passed to PCRE2 by calling pcre2_set_character_tables() to put a pointer into a
|
||||
compile context.
|
||||
|
||||
The source file called pcre2_chartables.c contains the default set of tables.
|
||||
By default, this is created as a copy of pcre2_chartables.c.dist, which
|
||||
contains tables for ASCII coding. However, if --enable-rebuild-chartables is
|
||||
specified for ./configure, a different version of pcre2_chartables.c is built
|
||||
by the program dftables (compiled from dftables.c), which uses the ANSI C
|
||||
character handling functions such as isalnum(), isalpha(), isupper(),
|
||||
islower(), etc. to build the table sources. This means that the default C
|
||||
locale that is set for your system will control the contents of these default
|
||||
tables. You can change the default tables by editing pcre2_chartables.c and
|
||||
then re-building PCRE2. If you do this, you should take care to ensure that the
|
||||
file does not get automatically re-generated. The best way to do this is to
|
||||
move pcre2_chartables.c.dist out of the way and replace it with your customized
|
||||
tables.
|
||||
|
||||
When the dftables program is run as a result of --enable-rebuild-chartables,
|
||||
it uses the default C locale that is set on your system. It does not pay
|
||||
attention to the LC_xxx environment variables. In other words, it uses the
|
||||
system's default locale rather than whatever the compiling user happens to have
|
||||
set. If you really do want to build a source set of character tables in a
|
||||
locale that is specified by the LC_xxx variables, you can run the dftables
|
||||
program by hand with the -L option. For example:
|
||||
|
||||
./dftables -L pcre2_chartables.c.special
|
||||
|
||||
The first two 256-byte tables provide lower casing and case flipping functions,
|
||||
respectively. The next table consists of three 32-byte bit maps which identify
|
||||
digits, "word" characters, and white space, respectively. These are used when
|
||||
building 32-byte bit maps that represent character classes for code points less
|
||||
than 256. The final 256-byte table has bits indicating various character types,
|
||||
as follows:
|
||||
|
||||
1 white space character
|
||||
2 letter
|
||||
4 decimal digit
|
||||
8 hexadecimal digit
|
||||
16 alphanumeric or '_'
|
||||
128 regular expression metacharacter or binary zero
|
||||
|
||||
You should not alter the set of characters that contain the 128 bit, as that
|
||||
will cause PCRE2 to malfunction.
|
||||
|
||||
|
||||
File manifest
|
||||
-------------
|
||||
|
||||
The distribution should contain the files listed below.
|
||||
|
||||
(A) Source files for the PCRE2 library functions and their headers are found in
|
||||
the src directory:
|
||||
|
||||
src/dftables.c auxiliary program for building pcre2_chartables.c
|
||||
when --enable-rebuild-chartables is specified
|
||||
|
||||
src/pcre2_chartables.c.dist a default set of character tables that assume
|
||||
ASCII coding; unless --enable-rebuild-chartables is
|
||||
specified, used by copying to pcre2_chartables.c
|
||||
|
||||
src/pcre2posix.c )
|
||||
src/pcre2_auto_possess.c )
|
||||
src/pcre2_compile.c )
|
||||
src/pcre2_config.c )
|
||||
src/pcre2_context.c )
|
||||
src/pcre2_convert.c )
|
||||
src/pcre2_dfa_match.c )
|
||||
src/pcre2_error.c )
|
||||
src/pcre2_extuni.c )
|
||||
src/pcre2_find_bracket.c )
|
||||
src/pcre2_jit_compile.c )
|
||||
src/pcre2_jit_match.c ) sources for the functions in the library,
|
||||
src/pcre2_jit_misc.c ) and some internal functions that they use
|
||||
src/pcre2_maketables.c )
|
||||
src/pcre2_match.c )
|
||||
src/pcre2_match_data.c )
|
||||
src/pcre2_newline.c )
|
||||
src/pcre2_ord2utf.c )
|
||||
src/pcre2_pattern_info.c )
|
||||
src/pcre2_script_run.c )
|
||||
src/pcre2_serialize.c )
|
||||
src/pcre2_string_utils.c )
|
||||
src/pcre2_study.c )
|
||||
src/pcre2_substitute.c )
|
||||
src/pcre2_substring.c )
|
||||
src/pcre2_tables.c )
|
||||
src/pcre2_ucd.c )
|
||||
src/pcre2_valid_utf.c )
|
||||
src/pcre2_xclass.c )
|
||||
|
||||
src/pcre2_printint.c debugging function that is used by pcre2test,
|
||||
src/pcre2_fuzzsupport.c function for (optional) fuzzing support
|
||||
|
||||
src/config.h.in template for config.h, when built by "configure"
|
||||
src/pcre2.h.in template for pcre2.h when built by "configure"
|
||||
src/pcre2posix.h header for the external POSIX wrapper API
|
||||
src/pcre2_internal.h header for internal use
|
||||
src/pcre2_intmodedep.h a mode-specific internal header
|
||||
src/pcre2_ucp.h header for Unicode property handling
|
||||
|
||||
sljit/* source files for the JIT compiler
|
||||
|
||||
(B) Source files for programs that use PCRE2:
|
||||
|
||||
src/pcre2demo.c simple demonstration of coding calls to PCRE2
|
||||
src/pcre2grep.c source of a grep utility that uses PCRE2
|
||||
src/pcre2test.c comprehensive test program
|
||||
src/pcre2_jit_test.c JIT test program
|
||||
|
||||
(C) Auxiliary files:
|
||||
|
||||
132html script to turn "man" pages into HTML
|
||||
AUTHORS information about the author of PCRE2
|
||||
ChangeLog log of changes to the code
|
||||
CleanTxt script to clean nroff output for txt man pages
|
||||
Detrail script to remove trailing spaces
|
||||
HACKING some notes about the internals of PCRE2
|
||||
INSTALL generic installation instructions
|
||||
LICENCE conditions for the use of PCRE2
|
||||
COPYING the same, using GNU's standard name
|
||||
Makefile.in ) template for Unix Makefile, which is built by
|
||||
) "configure"
|
||||
Makefile.am ) the automake input that was used to create
|
||||
) Makefile.in
|
||||
NEWS important changes in this release
|
||||
NON-AUTOTOOLS-BUILD notes on building PCRE2 without using autotools
|
||||
PrepareRelease script to make preparations for "make dist"
|
||||
README this file
|
||||
RunTest a Unix shell script for running tests
|
||||
RunGrepTest a Unix shell script for pcre2grep tests
|
||||
aclocal.m4 m4 macros (generated by "aclocal")
|
||||
config.guess ) files used by libtool,
|
||||
config.sub ) used only when building a shared library
|
||||
configure a configuring shell script (built by autoconf)
|
||||
configure.ac ) the autoconf input that was used to build
|
||||
) "configure" and config.h
|
||||
depcomp ) script to find program dependencies, generated by
|
||||
) automake
|
||||
doc/*.3 man page sources for PCRE2
|
||||
doc/*.1 man page sources for pcre2grep and pcre2test
|
||||
doc/index.html.src the base HTML page
|
||||
doc/html/* HTML documentation
|
||||
doc/pcre2.txt plain text version of the man pages
|
||||
doc/pcre2test.txt plain text documentation of test program
|
||||
install-sh a shell script for installing files
|
||||
libpcre2-8.pc.in template for libpcre2-8.pc for pkg-config
|
||||
libpcre2-16.pc.in template for libpcre2-16.pc for pkg-config
|
||||
libpcre2-32.pc.in template for libpcre2-32.pc for pkg-config
|
||||
libpcre2-posix.pc.in template for libpcre2-posix.pc for pkg-config
|
||||
ltmain.sh file used to build a libtool script
|
||||
missing ) common stub for a few missing GNU programs while
|
||||
) installing, generated by automake
|
||||
mkinstalldirs script for making install directories
|
||||
perltest.sh Script for running a Perl test program
|
||||
pcre2-config.in source of script which retains PCRE2 information
|
||||
testdata/testinput* test data for main library tests
|
||||
testdata/testoutput* expected test results
|
||||
testdata/grep* input and output for pcre2grep tests
|
||||
testdata/* other supporting test files
|
||||
|
||||
(D) Auxiliary files for cmake support
|
||||
|
||||
cmake/COPYING-CMAKE-SCRIPTS
|
||||
cmake/FindPackageHandleStandardArgs.cmake
|
||||
cmake/FindEditline.cmake
|
||||
cmake/FindReadline.cmake
|
||||
CMakeLists.txt
|
||||
config-cmake.h.in
|
||||
|
||||
(E) Auxiliary files for building PCRE2 "by hand"
|
||||
|
||||
src/pcre2.h.generic ) a version of the public PCRE2 header file
|
||||
) for use in non-"configure" environments
|
||||
src/config.h.generic ) a version of config.h for use in non-"configure"
|
||||
) environments
|
||||
|
||||
Philip Hazel
|
||||
Email local part: ph10
|
||||
Email domain: cam.ac.uk
|
||||
Last updated: 16 April 2019
|
|
@ -0,0 +1,777 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Run pcre2grep tests. The assumption is that the PCRE2 tests check the library
|
||||
# itself. What we are checking here is the file handling and options that are
|
||||
# supported by pcre2grep. This script must be run in the build directory.
|
||||
|
||||
# CODING CONVENTIONS:
|
||||
# * Put printf arguments in single, not double quotes to avoid unwanted
|
||||
# escaping.
|
||||
# * Use \0 for binary zero in printf, not \x0, for the benefit of older
|
||||
# versions.
|
||||
|
||||
# Set the C locale, so that sort(1) behaves predictably.
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Remove any non-default colouring and aliases that the caller may have set.
|
||||
|
||||
unset PCRE2GREP_COLOUR PCRE2GREP_COLOR PCREGREP_COLOUR PCREGREP_COLOR
|
||||
unset GREP_COLOR GREP_COLORS
|
||||
unset cp ls mv rm
|
||||
|
||||
# Remember the current (build) directory, set the program to be tested, and
|
||||
# valgrind settings when requested.
|
||||
|
||||
builddir=`pwd`
|
||||
pcre2grep=$builddir/pcre2grep
|
||||
pcre2test=$builddir/pcre2test
|
||||
|
||||
if [ ! -x $pcre2grep ] ; then
|
||||
echo "** $pcre2grep does not exist or is not executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x $pcre2test ] ; then
|
||||
echo "** $pcre2test does not exist or is not executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
valgrind=
|
||||
while [ $# -gt 0 ] ; do
|
||||
case $1 in
|
||||
valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all-non-file";;
|
||||
*) echo "RunGrepTest: Unknown argument $1"; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
vjs=
|
||||
pcre2grep_version=`$pcre2grep -V`
|
||||
if [ "$valgrind" = "" ] ; then
|
||||
echo "Testing $pcre2grep_version"
|
||||
else
|
||||
echo "Testing $pcre2grep_version using valgrind"
|
||||
$pcre2test -C jit >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
vjs="--suppressions=./testdata/valgrind-jit.supp"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set up a suitable "diff" command for comparison. Some systems have a diff
|
||||
# that lacks a -u option. Try to deal with this; better do the test for the -b
|
||||
# option as well.
|
||||
|
||||
cf="diff"
|
||||
diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b"
|
||||
diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
|
||||
diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub"
|
||||
|
||||
# If this test is being run from "make check", $srcdir will be set. If not, set
|
||||
# it to the current or parent directory, whichever one contains the test data.
|
||||
# Subsequently, we run most of the pcre2grep tests in the source directory so
|
||||
# that the file names in the output are always the same.
|
||||
|
||||
if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
|
||||
if [ -d "./testdata" ] ; then
|
||||
srcdir=.
|
||||
elif [ -d "../testdata" ] ; then
|
||||
srcdir=..
|
||||
else
|
||||
echo "Cannot find the testdata directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for the availability of UTF-8 support
|
||||
|
||||
$pcre2test -C unicode >/dev/null
|
||||
utf8=$?
|
||||
|
||||
# Check default newline convention. If it does not include LF, force LF.
|
||||
|
||||
nl=`$pcre2test -C newline`
|
||||
if [ "$nl" != "LF" -a "$nl" != "ANY" -a "$nl" != "ANYCRLF" ]; then
|
||||
pcre2grep="$pcre2grep -N LF"
|
||||
echo "Default newline setting forced to LF"
|
||||
fi
|
||||
|
||||
# ------ Function to run and check a special pcre2grep arguments test -------
|
||||
|
||||
checkspecial()
|
||||
{
|
||||
$valgrind $pcre2grep $1 >>testtrygrep 2>&1
|
||||
if [ $? -ne $2 ] ; then
|
||||
echo "** pcre2grep $1 failed - check testtrygrep"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ------ Normal tests ------
|
||||
|
||||
echo "Testing pcre2grep main features"
|
||||
|
||||
echo "---------------------------- Test 1 ------------------------------" >testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 2 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep '^PATTERN' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 3 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 4 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -ic PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 5 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 6 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 7 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 8 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 9 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 10 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 11 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -vn pattern ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 12 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -ix pattern ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 13 -----------------------------" >>testtrygrep
|
||||
echo seventeen >testtemp1grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist -f $builddir/testtemp1grep ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 14 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 15 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep 'abc^*' ./testdata/grepinput) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 16 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep abc ./testdata/grepinput ./testdata/nonexistfile) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 17 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -M 'the\noutput' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 18 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 19 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 20 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 21 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -nA3 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 22 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -nB3 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 23 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -C3 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 24 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -A9 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 25 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -nB9 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 26 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 27 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -A10 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 28 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -nB10 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 29 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 30 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 31 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 32 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 33 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 34 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 35 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 36 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude 'grepinput$' --exclude=grepinput8 --exclude=grepinputM --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 37 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
echo "======== STDERR ========" >>testtrygrep
|
||||
cat teststderrgrep >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 38 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep '>\x00<' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 39 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 40 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 41 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 42 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 43 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 44 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 45 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 46 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -eabc -e '(unclosed' ./testdata/grepinput) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 47 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Fx "AB.VE
|
||||
elephant" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 48 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -F "AB.VE
|
||||
elephant" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 49 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -F -e DATA -e "AB.VE
|
||||
elephant" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 50 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 51 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 52 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always jumps ./testdata/grepinputv) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 53 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 54 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 55 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 56 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -c lazy ./testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 57 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -c -l lazy ./testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 58 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --regex=PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 59 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --regexp=PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 60 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --regex PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 61 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --regexp PATTERN ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 62 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $pcre2grep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 63 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $pcre2grep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 64 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 65 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 66 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 67 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 68 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 69 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 70 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -M -n "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 71 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 72 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 73 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 74 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 75 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 76 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 77 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 78 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 79 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 80 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 81 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 82 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 83 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 84 -----------------------------" >>testtrygrep
|
||||
echo testdata/grepinput3 >testtemp1grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1grep "fox|complete|t7") >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 85 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 86 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 87 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 88 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 89 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 90 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 91 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 92 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 93 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 94 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 95 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 96 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinputM 'fox' ./test* | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 97 -----------------------------" >>testtrygrep
|
||||
echo "grepinput$" >testtemp1grep
|
||||
echo "grepinput8" >>testtemp1grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude=grepinputM --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 98 -----------------------------" >>testtrygrep
|
||||
echo "grepinput$" >testtemp1grep
|
||||
echo "grepinput8" >>testtemp1grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --exclude=grepinput3 --exclude=grepinputM --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 99 -----------------------------" >>testtrygrep
|
||||
echo "grepinput$" >testtemp1grep
|
||||
echo "grepinput8" >testtemp2grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include grepinput --exclude=grepinputM --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 100 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 101 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 102 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 103 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 104 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 105 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 106 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; echo "a" | $valgrind $vjs $pcre2grep -M "|a" ) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 107 -----------------------------" >>testtrygrep
|
||||
echo "a" >testtemp1grep
|
||||
echo "aaaaa" >>testtemp1grep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 108 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 109 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -cq lazy ./testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 110 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --om-separator / -Mo0 -o1 -o2 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 111 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 112 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --file-offsets -M 'match (\d+):\n (.)\n' testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 113 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --total-count 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 114 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -tc 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 115 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -tlc 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 116 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --exclude=grepinputM -th 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 117 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -tch 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 118 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -tL 'the' testdata/grepinput*) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 119 -----------------------------" >>testtrygrep
|
||||
printf '123\n456\n789\n---abc\ndef\nxyz\n---\n' >testNinputgrep
|
||||
$valgrind $vjs $pcre2grep -Mo '(\n|[^-])*---' testNinputgrep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 120 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -HO '$0:$2$1$3' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 121 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -F '\E and (regex)' testdata/grepinputv) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 122 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -w 'cat|dog' testdata/grepinputv) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 123 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -w 'dog|cat' testdata/grepinputv) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 124 -----------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always 'start[\s]+end' testdata/grepinputM) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mn --colour=always -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mn 'start[\s]+end' testdata/grepinputM) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -Mn -A2 'start[\s]+end' testdata/grepinputM) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 125 -----------------------------" >>testtrygrep
|
||||
printf 'abcd\n' >testNinputgrep
|
||||
$valgrind $vjs $pcre2grep --colour=always '(?<=\K.)' testNinputgrep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep --colour=always '(?=.\K)' testNinputgrep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep --colour=always '(?<=\K[ac])' testNinputgrep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep --colour=always '(?=[ac]\K)' testNinputgrep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test 126 -----------------------------" >>testtrygrep
|
||||
printf 'Next line pattern has binary zero\nABC\0XYZ\n' >testtemp1grep
|
||||
printf 'ABC\0XYZ\nABCDEF\nDEFABC\n' >testtemp2grep
|
||||
$valgrind $vjs $pcre2grep -a -f testtemp1grep testtemp2grep >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
|
||||
# Now compare the results.
|
||||
|
||||
$cf $srcdir/testdata/grepoutput testtrygrep
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
|
||||
|
||||
# These tests require UTF-8 support
|
||||
|
||||
if [ $utf8 -ne 0 ] ; then
|
||||
echo "Testing pcre2grep UTF-8 features"
|
||||
|
||||
echo "---------------------------- Test U1 ------------------------------" >testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test U2 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
echo "---------------------------- Test U3 ------------------------------" >>testtrygrep
|
||||
(cd $srcdir; $valgrind $vjs $pcre2grep --line-offsets -u --newline=any '(?<=\K\x{17f})' ./testdata/grepinput8) >>testtrygrep
|
||||
echo "RC=$?" >>testtrygrep
|
||||
|
||||
$cf $srcdir/testdata/grepoutput8 testtrygrep
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
|
||||
else
|
||||
echo "Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library"
|
||||
fi
|
||||
|
||||
|
||||
# We go to some contortions to try to ensure that the tests for the various
|
||||
# newline settings will work in environments where the normal newline sequence
|
||||
# is not \n. Do not use exported files, whose line endings might be changed.
|
||||
# Instead, create an input file using printf so that its contents are exactly
|
||||
# what we want. Note the messy fudge to get printf to write a string that
|
||||
# starts with a hyphen. These tests are run in the build directory.
|
||||
|
||||
echo "Testing pcre2grep newline settings"
|
||||
printf 'abc\rdef\r\nghi\njkl' >testNinputgrep
|
||||
|
||||
printf '%c--------------------------- Test N1 ------------------------------\r\n' - >testtrygrep
|
||||
$valgrind $vjs $pcre2grep -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
printf '%c--------------------------- Test N2 ------------------------------\r\n' - >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
printf '%c--------------------------- Test N3 ------------------------------\r\n' - >>testtrygrep
|
||||
pattern=`printf 'def\rjkl'`
|
||||
$valgrind $vjs $pcre2grep -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep
|
||||
|
||||
printf '%c--------------------------- Test N4 ------------------------------\r\n' - >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinputgrep >>testtrygrep
|
||||
|
||||
printf '%c--------------------------- Test N5 ------------------------------\r\n' - >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
printf '%c--------------------------- Test N6 ------------------------------\r\n' - >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
# It seems impossible to handle NUL characters easily in many operating
|
||||
# systems, including Solaris (aka SunOS), where the version of sed explicitly
|
||||
# doesn't like them, and also MacOS (Darwin), OpenBSD, FreeBSD, and NetBSD. So
|
||||
# now we run this test only on OS that are known to work. For the rest, we
|
||||
# fudge the output so that the comparison works.
|
||||
|
||||
printf '%c--------------------------- Test N7 ------------------------------\r\n' - >>testtrygrep
|
||||
uname=`uname`
|
||||
case $uname in
|
||||
Linux)
|
||||
printf 'abc\0def' >testNinputgrep
|
||||
$valgrind $vjs $pcre2grep -na --newline=nul "^(abc|def)" testNinputgrep | sed 's/\x00/ZERO/' >>testtrygrep
|
||||
echo "" >>testtrygrep
|
||||
;;
|
||||
*)
|
||||
echo '1:abcZERO2:def' >>testtrygrep
|
||||
;;
|
||||
esac
|
||||
|
||||
$cf $srcdir/testdata/grepoutputN testtrygrep
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
|
||||
# If pcre2grep supports script callouts, run some tests on them. It is possible
|
||||
# to restrict these callouts to the non-fork case, either for security, or for
|
||||
# environments that do not support fork(). This is handled by comparing to a
|
||||
# different output.
|
||||
|
||||
if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scripts in patterns are supported'; then
|
||||
echo "Testing pcre2grep script callouts"
|
||||
$valgrind $vjs $pcre2grep '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' $srcdir/testdata/grepinputv >testtrygrep
|
||||
$valgrind $vjs $pcre2grep '(T)(..(.))()()()()()()()(..)(?C"/bin/echo|Arg1: [$11] [${11}]")' $srcdir/testdata/grepinputv >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep '(T)(?C"|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep
|
||||
$valgrind $vjs $pcre2grep '(T)(?C"|$1$n")(*F)' $srcdir/testdata/grepinputv >>testtrygrep
|
||||
|
||||
if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'Non-fork callout scripts in patterns are supported'; then
|
||||
$cf $srcdir/testdata/grepoutputCN testtrygrep
|
||||
else
|
||||
$cf $srcdir/testdata/grepoutputC testtrygrep
|
||||
fi
|
||||
|
||||
if [ $? != 0 ] ; then exit 1; fi
|
||||
else
|
||||
echo "Script callouts are not supported"
|
||||
fi
|
||||
|
||||
# Finally, some tests to exercise code that is not tested above, just to be
|
||||
# sure that it runs OK. Doing this improves the coverage statistics. The output
|
||||
# is not checked.
|
||||
|
||||
echo "Testing miscellaneous pcre2grep arguments (unchecked)"
|
||||
echo '' >testtrygrep
|
||||
checkspecial '-xxxxx' 2
|
||||
checkspecial '--help' 0
|
||||
checkspecial '--line-buffered --colour=auto abc /dev/null' 1
|
||||
|
||||
# Clean up local working files
|
||||
rm -f testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep
|
||||
|
||||
exit 0
|
||||
|
||||
# End
|
|
@ -0,0 +1,699 @@
|
|||
@echo off
|
||||
|
||||
:: Run pcre2grep tests. The assumption is that the PCRE2 tests check the library
|
||||
:: itself. What we are checking here is the file handling and options that are
|
||||
:: supported by pcre2grep. This script must be run in the build directory.
|
||||
:: (jmh: I've only tested in the main directory, using my own builds.)
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Remove any non-default colouring that the caller may have set.
|
||||
|
||||
set PCRE2GREP_COLOUR=
|
||||
set PCRE2GREP_COLOR=
|
||||
set PCREGREP_COLOUR=
|
||||
set PCREGREP_COLOR=
|
||||
set GREP_COLORS=
|
||||
set GREP_COLOR=
|
||||
|
||||
:: Remember the current (build) directory and set the program to be tested.
|
||||
|
||||
set builddir="%CD%"
|
||||
set pcre2grep=%builddir%\pcre2grep.exe
|
||||
set pcre2test=%builddir%\pcre2test.exe
|
||||
|
||||
if NOT exist %pcre2grep% (
|
||||
echo ** %pcre2grep% does not exist.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if NOT exist %pcre2test% (
|
||||
echo ** %pcre2test% does not exist.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for /f "delims=" %%a in ('"%pcre2grep%" -V') do set pcre2grep_version=%%a
|
||||
echo Testing %pcre2grep_version%
|
||||
|
||||
:: Set up a suitable "diff" command for comparison. Some systems have a diff
|
||||
:: that lacks a -u option. Try to deal with this; better do the test for the -b
|
||||
:: option as well. Use FC if there's no diff, taking care to ignore equality.
|
||||
|
||||
set cf=
|
||||
set cfout=
|
||||
diff -b nul nul 2>nul && set cf=diff -b
|
||||
diff -u nul nul 2>nul && set cf=diff -u
|
||||
diff -ub nul nul 2>nul && set cf=diff -ub
|
||||
if NOT defined cf (
|
||||
set cf=fc /n
|
||||
set "cfout=>testcf || (type testcf & cmd /c exit /b 1)"
|
||||
)
|
||||
|
||||
:: Set srcdir to the current or parent directory, whichever one contains the
|
||||
:: test data. Subsequently, we run most of the pcre2grep tests in the source
|
||||
:: directory so that the file names in the output are always the same.
|
||||
|
||||
if NOT defined srcdir set srcdir=.
|
||||
if NOT exist %srcdir%\testdata\ (
|
||||
if exist testdata\ (
|
||||
set srcdir=.
|
||||
) else if exist ..\testdata\ (
|
||||
set srcdir=..
|
||||
) else if exist ..\..\testdata\ (
|
||||
set srcdir=..\..
|
||||
) else (
|
||||
echo Cannot find the testdata directory
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
:: Check for the availability of UTF-8 support
|
||||
|
||||
%pcre2test% -C unicode >nul
|
||||
set utf8=%ERRORLEVEL%
|
||||
|
||||
:: Check default newline convention. If it does not include LF, force LF.
|
||||
|
||||
for /f %%a in ('"%pcre2test%" -C newline') do set nl=%%a
|
||||
if NOT "%nl%" == "LF" if NOT "%nl%" == "ANY" if NOT "%nl%" == "ANYCRLF" (
|
||||
set pcre2grep=%pcre2grep% -N LF
|
||||
echo Default newline setting forced to LF
|
||||
)
|
||||
|
||||
:: Create a simple printf via cscript/JScript (an actual printf may translate
|
||||
:: LF to CRLF, which this one does not).
|
||||
|
||||
echo WScript.StdOut.Write(WScript.Arguments(0).replace(/\\r/g, "\r").replace(/\\n/g, "\n")) >printf.js
|
||||
set printf=cscript //nologo printf.js
|
||||
|
||||
:: ------ Normal tests ------
|
||||
|
||||
echo Testing pcre2grep main features
|
||||
|
||||
echo ---------------------------- Test 1 ------------------------------>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 2 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "^PATTERN" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 3 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -in PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 4 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -ic PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 5 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -in PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 6 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -inh PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 7 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -il PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 8 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -l PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 9 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -q PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 10 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 11 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -vn pattern ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 12 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -ix pattern ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 13 ----------------------------->>testtrygrep
|
||||
echo seventeen >testtemp1grep
|
||||
(pushd %srcdir% & %pcre2grep% -f./testdata/greplist -f %builddir%\testtemp1grep ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 14 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -w pat ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 15 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "abc^*" ./testdata/grepinput & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 16 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% abc ./testdata/grepinput ./testdata/nonexistfile & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 17 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -M "the\noutput" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 18 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Mn "(the\noutput|dog\.\n--)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 19 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Mix "Pattern" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 20 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Mixn "complete pair\nof lines" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 21 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -nA3 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 22 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -nB3 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 23 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -C3 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 24 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -A9 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 25 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -nB9 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 26 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -A9 -B9 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 27 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -A10 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 28 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -nB10 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 29 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -C12 -B10 "four" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 30 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -inB3 "pattern" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 31 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -inA3 "pattern" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 32 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -L "fox" ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 33 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "fox" ./testdata/grepnonexist & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 34 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -s "fox" ./testdata/grepnonexist & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 35 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include=grepinputx --include grepinput8 --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 36 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include=grepinput --exclude "grepinput$" --exclude=grepinput8 --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 37 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "^(a+)*\d" ./testdata/grepinput & popd) >>testtrygrep 2>teststderrgrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
echo ======== STDERR ========>>testtrygrep
|
||||
type teststderrgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 38 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% ">\x00<" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 39 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -A1 "before the binary zero" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 40 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -B1 "after the binary zero" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 41 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -B1 -o "\w+ the binary zero" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 42 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -B1 -onH "\w+ the binary zero" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 43 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -on "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 44 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -on -e before -ezero -e after ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 45 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -on -f ./testdata/greplist -e binary ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 46 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -eabc -e "(unclosed" ./testdata/grepinput & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 47 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Fx AB.VE^
|
||||
|
||||
elephant ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 48 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -F AB.VE^
|
||||
|
||||
elephant ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 49 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -F -e DATA -e AB.VE^
|
||||
|
||||
elephant ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 50 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "^(abc|def|ghi|jkl)" ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 51 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Mv "brown\sfox" ./testdata/grepinputv & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 52 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --colour=always jumps ./testdata/grepinputv & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 53 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --file-offsets "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 54 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --line-offsets "before|zero|after" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 55 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -f./testdata/greplist --color=always ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 56 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -c lazy ./testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 57 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -c -l lazy ./testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 58 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --regex=PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 59 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --regexp=PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 60 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --regex PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 61 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --regexp PATTERN ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 62 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --match-limit=1000 --no-jit -M "This is a file(.|\R)*file." ./testdata/grepinput & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 63 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --recursion-limit=1000 --no-jit -M "This is a file(.|\R)*file." ./testdata/grepinput & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 64 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o1 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 65 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o2 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 66 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o3 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 67 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o12 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 68 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --only-matching=2 "(?<=PAT)TERN (ap(pear)s)" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 69 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -vn --colour=always pattern ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 70 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3 & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 71 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 72 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --color=always "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 73 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|^02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 74 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 75 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --color=always "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 76 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|02|^03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 77 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 78 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --color=always "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 79 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o --colour=always "^01|^02|03" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 80 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 81 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --color=always "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 82 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o --colour=always "\b01|\b02" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 83 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --buffer-size=10 --max-buffer-size=100 "^a" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 84 ----------------------------->>testtrygrep
|
||||
echo testdata/grepinput3 >testtemp1grep
|
||||
(pushd %srcdir% & %pcre2grep% --file-list ./testdata/grepfilelist --file-list %builddir%\testtemp1grep "fox|complete|t7" & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 85 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 86 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 87 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% "cat" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 88 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -v "cat" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 89 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -I "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 90 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --binary-files=without-match "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 91 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -a "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 92 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --binary-files=text "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 93 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --text "dog" ./testdata/grepbinary & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 94 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include=grepinputx --include grepinput8 "fox" ./testdata/grepinput* | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 95 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete" & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 96 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include-dir=testdata --exclude "^^(?^!grepinput)" "fox" ./test* | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 97 ----------------------------->>testtrygrep
|
||||
echo grepinput$>testtemp1grep
|
||||
echo grepinput8>>testtemp1grep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include=grepinput --exclude-from %builddir%\testtemp1grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 98 ----------------------------->>testtrygrep
|
||||
echo grepinput$>testtemp1grep
|
||||
echo grepinput8>>testtemp1grep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --exclude=grepinput3 --include=grepinput --exclude-from %builddir%\testtemp1grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 99 ----------------------------->>testtrygrep
|
||||
echo grepinput$>testtemp1grep
|
||||
echo grepinput8>testtemp2grep
|
||||
(pushd %srcdir% & %pcre2grep% -L -r --include grepinput --exclude-from %builddir%\testtemp1grep --exclude-from=%builddir%\testtemp2grep --exclude-dir="^\." "fox" ./testdata | sort & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 100 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -Ho2 --only-matching=1 -o3 "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 101 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator="|" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 102 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -n "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 103 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --only-matching "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 104 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -n --only-matching "^$" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 105 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --colour=always "ipsum|" ./testdata/grepinput3 & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 106 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & echo a| %pcre2grep% -M "|a" & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 107 ----------------------------->>testtrygrep
|
||||
echo a>testtemp1grep
|
||||
echo aaaaa>>testtemp1grep
|
||||
(pushd %srcdir% & %pcre2grep% --line-offsets "(?<=\Ka)" %builddir%\testtemp1grep & popd) >>testtrygrep 2>&1
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 108 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -lq PATTERN ./testdata/grepinput ./testdata/grepinputx & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 109 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -cq lazy ./testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 110 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --om-separator / -Mo0 -o1 -o2 "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 111 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --line-offsets -M "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 112 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --file-offsets -M "match (\d+):\n (.)\n" testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 113 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --total-count "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 114 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -tc "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 115 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -tlc "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 116 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -th "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 117 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -tch "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 118 ----------------------------->>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -tL "the" testdata/grepinput* & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 119 ----------------------------->>testtrygrep
|
||||
%printf% "123\n456\n789\n---abc\ndef\nxyz\n---\n" >testNinputgrep
|
||||
%pcre2grep% -Mo "(\n|[^-])*---" testNinputgrep >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test 120 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -HO "$0:$2$1$3" "(\w+) binary (\w+)(\.)?" ./testdata/grepinput & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
:: Now compare the results.
|
||||
|
||||
%cf% %srcdir%\testdata\grepoutput testtrygrep %cfout%
|
||||
if ERRORLEVEL 1 exit /b 1
|
||||
|
||||
|
||||
:: These tests require UTF-8 support
|
||||
|
||||
if %utf8% neq 0 (
|
||||
echo Testing pcre2grep UTF-8 features
|
||||
|
||||
echo ---------------------------- Test U1 ------------------------------>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -n -u --newline=any "^X" ./testdata/grepinput8 & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test U2 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% -n -u -C 3 --newline=any "Match" ./testdata/grepinput8 & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
echo ---------------------------- Test U3 ------------------------------>>testtrygrep
|
||||
(pushd %srcdir% & %pcre2grep% --line-offsets -u --newline=any "(?<=\K\x{17f})" ./testdata/grepinput8 & popd) >>testtrygrep
|
||||
echo RC=^%ERRORLEVEL%>>testtrygrep
|
||||
|
||||
%cf% %srcdir%\testdata\grepoutput8 testtrygrep %cfout%
|
||||
if ERRORLEVEL 1 exit /b 1
|
||||
|
||||
) else (
|
||||
echo Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library
|
||||
)
|
||||
|
||||
|
||||
:: We go to some contortions to try to ensure that the tests for the various
|
||||
:: newline settings will work in environments where the normal newline sequence
|
||||
:: is not \n. Do not use exported files, whose line endings might be changed.
|
||||
:: Instead, create an input file so that its contents are exactly what we want.
|
||||
:: These tests are run in the build directory.
|
||||
|
||||
echo Testing pcre2grep newline settings
|
||||
%printf% "abc\rdef\r\nghi\njkl" >testNinputgrep
|
||||
|
||||
echo ---------------------------- Test N1 ------------------------------>testtrygrep
|
||||
%pcre2grep% -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test N2 ------------------------------>>testtrygrep
|
||||
%pcre2grep% -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test N3 ------------------------------>>testtrygrep
|
||||
for /f %%a in ('%printf% "def\rjkl"') do set pattern=%%a
|
||||
%pcre2grep% -n --newline=cr -F "!pattern!" testNinputgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test N4 ------------------------------>>testtrygrep
|
||||
%pcre2grep% -n --newline=crlf -F -f %srcdir%/testdata/greppatN4 testNinputgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test N5 ------------------------------>>testtrygrep
|
||||
%pcre2grep% -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
echo ---------------------------- Test N6 ------------------------------>>testtrygrep
|
||||
%pcre2grep% -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
||||
|
||||
%cf% %srcdir%\testdata\grepoutputN testtrygrep %cfout%
|
||||
if ERRORLEVEL 1 exit /b 1
|
||||
|
||||
:: If pcre2grep supports script callouts, run some tests on them.
|
||||
|
||||
%pcre2grep% --help | %pcre2grep% -q "callout scripts in patterns are supported"
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo Testing pcre2grep script callouts
|
||||
%pcre2grep% "(T)(..(.))(?C'cmd|/c echo|Arg1: [$1] [$2] [$3]|Arg2: ^$|${1}^$| ($4) ($14) ($0)')()" %srcdir%/testdata/grepinputv >testtrygrep
|
||||
%pcre2grep% "(T)(..(.))()()()()()()()(..)(?C'cmd|/c echo|Arg1: [$11] [${11}]')" %srcdir%/testdata/grepinputv >>testtrygrep
|
||||
%pcre2grep% "(T)(?C'|$0:$1$n')" %srcdir%/testdata/grepinputv >>testtrygrep
|
||||
%pcre2grep% "(T)(?C'|$1$n')(*F)" %srcdir%/testdata/grepinputv >>testtrygrep
|
||||
%pcre2grep% --help | %pcre2grep% -q "Non-script callout scripts in patterns are supported"
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
%cf% %srcdir%\testdata\grepoutputCN testtrygrep %cfout%
|
||||
) else (
|
||||
%cf% %srcdir%\testdata\grepoutputC testtrygrep %cfout%
|
||||
)
|
||||
if ERRORLEVEL 1 exit /b 1
|
||||
) else (
|
||||
echo Script callouts are not supported
|
||||
)
|
||||
|
||||
:: Finally, some tests to exercise code that is not tested above, just to be
|
||||
:: sure that it runs OK. Doing this improves the coverage statistics. The output
|
||||
:: is not checked.
|
||||
|
||||
echo Testing miscellaneous pcre2grep arguments (unchecked)
|
||||
%printf% "" >testtrygrep
|
||||
call :checkspecial "-xxxxx" 2 || exit /b 1
|
||||
call :checkspecial "--help" 0 || exit /b 1
|
||||
call :checkspecial "--line-buffered --colour=auto abc nul" 1 || exit /b 1
|
||||
|
||||
:: Clean up local working files
|
||||
del testcf printf.js testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep
|
||||
|
||||
exit /b 0
|
||||
|
||||
:: ------ Function to run and check a special pcre2grep arguments test -------
|
||||
|
||||
:checkspecial
|
||||
%pcre2grep% %~1 >>testtrygrep 2>&1
|
||||
if %ERRORLEVEL% neq %2 (
|
||||
echo ** pcre2grep %~1 failed - check testtrygrep
|
||||
exit /b 1
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
:: End
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue