mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
format and push pkgs, fix SOFT_IIC
This commit is contained in:
parent
84ba0114f0
commit
0adbb62369
@ -43,7 +43,7 @@ char* PikaStdDevice_CAN_read(PikaObj* self, int length) {
|
||||
return obj_getStr(self, "readData");
|
||||
}
|
||||
|
||||
Arg* PikaStdDevice_CAN_readBytes(PikaObj *self, int length){
|
||||
Arg* PikaStdDevice_CAN_readBytes(PikaObj* self, int length) {
|
||||
obj_setInt(self, "length", length);
|
||||
obj_runNativeMethod(self, "platformReadBytes", NULL);
|
||||
return arg_copy(obj_getArg(self, "readData"));
|
||||
@ -54,7 +54,7 @@ void PikaStdDevice_CAN_write(PikaObj* self, char* data) {
|
||||
obj_runNativeMethod(self, "platformWrite", NULL);
|
||||
}
|
||||
|
||||
void PikaStdDevice_CAN_writeBytes(PikaObj *self, uint8_t* data, int length){
|
||||
void PikaStdDevice_CAN_writeBytes(PikaObj* self, uint8_t* data, int length) {
|
||||
obj_setBytes(self, "writeData", data, length);
|
||||
obj_runNativeMethod(self, "platformWriteBytes", NULL);
|
||||
}
|
||||
@ -75,10 +75,10 @@ void PikaStdDevice_CAN_platformWrite(PikaObj* self) {
|
||||
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
||||
}
|
||||
|
||||
void PikaStdDevice_CAN_platformReadBytes(PikaObj *self){
|
||||
void PikaStdDevice_CAN_platformReadBytes(PikaObj* self) {
|
||||
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
||||
}
|
||||
|
||||
void PikaStdDevice_CAN_platformWriteBytes(PikaObj *self){
|
||||
void PikaStdDevice_CAN_platformWriteBytes(PikaObj* self) {
|
||||
ABSTRACT_METHOD_NEED_OVERRIDE_ERROR();
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void PikaStdDevice_GPIO_setCallBack(PikaObj* self,
|
||||
#endif
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_close(PikaObj *self){
|
||||
void PikaStdDevice_GPIO_close(PikaObj* self) {
|
||||
pika_dev* dev = _get_dev(self);
|
||||
pika_hal_close(dev);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
extern PikaEventListener* g_pika_device_event_listener;
|
||||
void _PikaStdDevice_event_handler(pika_dev* dev, int signal) {
|
||||
pika_eventListener_sendSignal(g_pika_device_event_listener, (uintptr_t)dev,
|
||||
signal);
|
||||
signal);
|
||||
}
|
||||
|
||||
void _PikaStdDevice_setCallBack(PikaObj* self,
|
||||
@ -21,7 +21,7 @@ void _PikaStdDevice_setCallBack(PikaObj* self,
|
||||
extern volatile PikaObj* __pikaMain;
|
||||
PikaObj* PikaStdDevice_Time(PikaObj* self) {
|
||||
PikaObj* time = obj_getPtr((PikaObj*)__pikaMain, "time");
|
||||
if(NULL == time){
|
||||
if (NULL == time) {
|
||||
obj_setErrorCode(self, -1);
|
||||
obj_setSysOut(self, "Error: please install and import 'time' module");
|
||||
return NULL;
|
||||
|
@ -55,7 +55,7 @@ __exit:
|
||||
}
|
||||
/* error */
|
||||
__platform_printf("Error: dev_open failed.\r\n");
|
||||
if (dev->ioctl_config) {
|
||||
if (dev && dev->ioctl_config) {
|
||||
pikaFree(dev->ioctl_config, _pika_hal_dev_config_size(dev_type));
|
||||
dev->ioctl_config = NULL;
|
||||
}
|
||||
@ -76,7 +76,7 @@ int pika_hal_close(pika_dev* dev) {
|
||||
}
|
||||
ret = impl->close(dev);
|
||||
__exit:
|
||||
if (NULL != dev->ioctl_config) {
|
||||
if (NULL != dev && NULL != dev->ioctl_config) {
|
||||
pikaFree(dev->ioctl_config, _pika_hal_dev_config_size(dev->type));
|
||||
dev->ioctl_config = NULL;
|
||||
}
|
||||
|
@ -1,4 +1,17 @@
|
||||
#include "../PikaStdDevice/pika_hal.h"
|
||||
#include "pika_hal.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static void _IIC_SDA_input(pika_hal_SOFT_IIC_config* iic_cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_IN;
|
||||
pika_hal_ioctl(iic_cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static void _IIC_SDA_output(pika_hal_SOFT_IIC_config* iic_cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_OUT;
|
||||
pika_hal_ioctl(iic_cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static int _GPIO_write(pika_dev* dev, uint32_t val) {
|
||||
return pika_hal_write(dev, &val, sizeof(val));
|
||||
@ -11,11 +24,12 @@ static uint32_t _GPIO_read(pika_dev* dev) {
|
||||
}
|
||||
|
||||
static void _IIC_Delay(void) {
|
||||
// Delay implementation, can be modified based on hardware platform.
|
||||
// You may need to adjust the delay time to match your hardware.
|
||||
pika_sleep_ms(3);
|
||||
}
|
||||
|
||||
static void _IIC_Start(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_debug("iic start");
|
||||
_IIC_SDA_output(cfg);
|
||||
_GPIO_write(cfg->SDA, 1);
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -25,6 +39,8 @@ static void _IIC_Start(pika_hal_SOFT_IIC_config* cfg) {
|
||||
}
|
||||
|
||||
static void _IIC_Stop(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_debug("iic stop");
|
||||
_IIC_SDA_output(cfg);
|
||||
_GPIO_write(cfg->SDA, 0);
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -32,7 +48,9 @@ static void _IIC_Stop(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_IIC_Delay();
|
||||
}
|
||||
|
||||
static void _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
pika_debug(" - iic write: 0x%02X", byte);
|
||||
_IIC_SDA_output(cfg);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
@ -46,11 +64,52 @@ static void _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
_IIC_Delay();
|
||||
byte <<= 1;
|
||||
}
|
||||
|
||||
// 在发送完字节后检查ACK信号
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
_IIC_SDA_input(cfg); // 设置SDA为输入
|
||||
_GPIO_write(cfg->SCL, 1); // 将SCL线设置为高,让从设备发送ACK信号
|
||||
|
||||
int timeout = 1000;
|
||||
uint32_t ack = 0;
|
||||
do {
|
||||
_IIC_Delay();
|
||||
ack = !_GPIO_read(cfg->SDA); // 如果从设备发送了ACK信号,SDA线会被拉低
|
||||
} while (ack == 0 && timeout-- > 0);
|
||||
|
||||
// pika_debug("ack timeout:%d", timeout);
|
||||
if (timeout <= 0) {
|
||||
pika_platform_printf("Error: IIC write byte timeout\r\n");
|
||||
}
|
||||
|
||||
_GPIO_write(cfg->SCL, 0); // 将SCL线设置为低,完成一个I2C周期
|
||||
return ack;
|
||||
}
|
||||
|
||||
static void _IIC_Ack(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
_IIC_SDA_output(cfg); // 设置SDA为输出
|
||||
_GPIO_write(cfg->SDA, 0); // 拉低数据线
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 1); // 产生时钟
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
}
|
||||
|
||||
static void _IIC_NAck(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
_IIC_SDA_output(cfg); // 设置SDA为输出
|
||||
_GPIO_write(cfg->SDA, 1); // 数据线拉高
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 1); // 产生时钟
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
}
|
||||
|
||||
static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
|
||||
uint8_t byte = 0;
|
||||
_IIC_SDA_input(cfg);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -61,77 +120,75 @@ static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
}
|
||||
// 在读取完一个字节后发送ACK信号
|
||||
if (ack) {
|
||||
_IIC_SendByte(cfg, 0xFF);
|
||||
_IIC_Ack(cfg); // 如果ack为真,发送ACK信号
|
||||
} else {
|
||||
_IIC_SendByte(cfg, 0x00);
|
||||
_IIC_NAck(cfg); // 如果ack为假,发送NACK信号
|
||||
}
|
||||
pika_debug(" - iic read: 0x%02X", byte);
|
||||
return byte;
|
||||
}
|
||||
|
||||
static void set_SDA_input(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_IN;
|
||||
pika_hal_ioctl(cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static void set_SDA_output(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_OUT;
|
||||
pika_hal_ioctl(cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
int pika_hal_platform_SOFT_IIC_write(pika_dev* dev, void* buf, size_t count) {
|
||||
pika_hal_SOFT_IIC_config* cfg =
|
||||
pika_hal_SOFT_IIC_config* iic_cfg =
|
||||
(pika_hal_SOFT_IIC_config*)dev->ioctl_config;
|
||||
uint8_t* data = (uint8_t*)buf;
|
||||
set_SDA_output(cfg);
|
||||
_IIC_Start(cfg);
|
||||
|
||||
_IIC_Start(iic_cfg);
|
||||
uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写
|
||||
// pika_debug("iic addr_write: 0x%02X", addr_write);
|
||||
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写
|
||||
|
||||
// 如果启用了mem_addr_ena,将设备地址和内存地址发送到I2C总线
|
||||
if (cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
_IIC_SendByte(cfg, cfg->slave_addr);
|
||||
if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
} else if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(cfg, (cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
} else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(iic_cfg, (iic_cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
_IIC_SendByte(cfg, data[i]);
|
||||
_IIC_SendByte(iic_cfg, data[i]);
|
||||
}
|
||||
_IIC_Stop(cfg);
|
||||
_IIC_Stop(iic_cfg);
|
||||
return count;
|
||||
}
|
||||
|
||||
int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
|
||||
pika_hal_SOFT_IIC_config* cfg =
|
||||
pika_hal_SOFT_IIC_config* iic_cfg =
|
||||
(pika_hal_SOFT_IIC_config*)dev->ioctl_config;
|
||||
uint8_t* data = (uint8_t*)buf;
|
||||
|
||||
_IIC_Start(iic_cfg);
|
||||
|
||||
// 如果启用了mem_addr_ena,先写设备地址和内存地址
|
||||
if (cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
set_SDA_output(cfg);
|
||||
_IIC_Start(cfg);
|
||||
_IIC_SendByte(cfg, cfg->slave_addr);
|
||||
if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
} else if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(cfg, (cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
uint8_t addr_write =
|
||||
(iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写
|
||||
// pika_debug("iic addr_write: 0x%02X", addr_write);
|
||||
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写
|
||||
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
} else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(iic_cfg, (iic_cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
}
|
||||
_IIC_Stop(cfg);
|
||||
_IIC_Start(iic_cfg);
|
||||
}
|
||||
|
||||
set_SDA_input(cfg);
|
||||
_IIC_Start(cfg);
|
||||
uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01; // 方向位为1代表读
|
||||
// pika_debug("iic addr_read: 0x%02X", addr_read);
|
||||
_IIC_SendByte(iic_cfg, addr_read); // 方向位为1代表读
|
||||
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
data[i] = _IIC_ReadByte(cfg, 1);
|
||||
// data[i] = _IIC_ReadByte(iic_cfg, 1);
|
||||
data[i] = _IIC_ReadByte(iic_cfg, 1);
|
||||
}
|
||||
data[count - 1] = _IIC_ReadByte(cfg, 0);
|
||||
_IIC_Stop(cfg);
|
||||
data[count - 1] = _IIC_ReadByte(iic_cfg, 0);
|
||||
_IIC_Stop(iic_cfg);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../PikaStdDevice/pika_hal.h"
|
||||
#include "pika_hal.h"
|
||||
|
||||
static int _GPIO_write(pika_dev* dev, uint32_t val) {
|
||||
return pika_hal_write(dev, &val, sizeof(val));
|
||||
|
1133
package/re/cre.c
1133
package/re/cre.c
File diff suppressed because it is too large
Load Diff
@ -4,47 +4,93 @@
|
||||
#include "pcre.h"
|
||||
#define GetGroupLen(vc, n) (vc[(n)*2 + 1] - vc[(n)*2])
|
||||
|
||||
int *_re_get_vec_table(pcre *re, int *out_groups_number);
|
||||
int* _re_get_vec_table(pcre* re, int* out_groups_number);
|
||||
|
||||
int *pcre_match(const char *_pat, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* pcre_match(const char* _pat,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
int *re_match2(pcre *re, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* re_match2(pcre* re, const char* s, int len, int* out_vec_number, int opt);
|
||||
|
||||
int *pcre_fullmatch(const char *_pat, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* pcre_fullmatch(const char* _pat,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
int *re_fullmatch2(pcre *re, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* re_fullmatch2(pcre* re,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
pcre *re_get_match_re(const char *_pat, int opt);
|
||||
pcre* re_get_match_re(const char* _pat, int opt);
|
||||
|
||||
pcre *re_get_fullmatch_re(const char *_pat, int opt);
|
||||
pcre* re_get_fullmatch_re(const char* _pat, int opt);
|
||||
|
||||
int *pcre_search(const char *pat, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* pcre_search(const char* pat,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
int *re_search2(pcre *re, const char *s, int len, int *out_vec_number, int opt);
|
||||
int* re_search2(pcre* re, const char* s, int len, int* out_vec_number, int opt);
|
||||
|
||||
int **re_searchall(const char *pat, const char *s, int len, int *out_number, int *out_vec_number, int opt);
|
||||
int** re_searchall(const char* pat,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_number,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
int **re_searchall2(pcre *re, const char *s, int len, int *out_number, int *out_vec_number, int opt);
|
||||
int** re_searchall2(pcre* re,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_number,
|
||||
int* out_vec_number,
|
||||
int opt);
|
||||
|
||||
void re_free_searchall(int **vecs, int n);
|
||||
void re_free_searchall(int** vecs, int n);
|
||||
|
||||
char **_re_extract_substring(const char *s, int **vecs, int n);
|
||||
char** _re_extract_substring(const char* s, int** vecs, int n);
|
||||
|
||||
char *re_find(const char *pat, const char *s, int len, int opt);
|
||||
char* re_find(const char* pat, const char* s, int len, int opt);
|
||||
|
||||
char *re_find2(pcre *re, const char *s, int len, int opt);
|
||||
char* re_find2(pcre* re, const char* s, int len, int opt);
|
||||
|
||||
char **pcre_findall(const char *pat, const char *s, int len, int *out_number, int opt);
|
||||
char** pcre_findall(const char* pat,
|
||||
const char* s,
|
||||
int len,
|
||||
int* out_number,
|
||||
int opt);
|
||||
|
||||
char **re_findall2(pcre *re, const char *s, int len, int *out_number, int opt);
|
||||
char** re_findall2(pcre* re, const char* s, int len, int* out_number, int opt);
|
||||
|
||||
void re_free_findall(char **ss, int n);
|
||||
void re_free_findall(char** ss, int n);
|
||||
|
||||
char *pcre_sub(const char *pat, const char *to, const char *s, int len, int opt);
|
||||
char* pcre_sub(const char* pat,
|
||||
const char* to,
|
||||
const char* s,
|
||||
int len,
|
||||
int opt);
|
||||
|
||||
char *pcre_subn(const char *pat, const char *to, const char *s, int len, int n, int opt, int *out_repl_times);
|
||||
char* pcre_subn(const char* pat,
|
||||
const char* to,
|
||||
const char* s,
|
||||
int len,
|
||||
int n,
|
||||
int opt,
|
||||
int* out_repl_times);
|
||||
|
||||
char *re_subn2(pcre *re, const char *to, const char *s, int len, int n, int opt, int *out_repl_times);
|
||||
char* re_subn2(pcre* re,
|
||||
const char* to,
|
||||
const char* s,
|
||||
int len,
|
||||
int n,
|
||||
int opt,
|
||||
int* out_repl_times);
|
||||
|
||||
char *re_sub2(pcre *re, const char *to, const char *s, int len, int opt);
|
||||
char* re_sub2(pcre* re, const char* to, const char* s, int len, int opt);
|
||||
#endif
|
@ -8,36 +8,36 @@ export setting is defined in pcre_internal.h, which includes this file. So we
|
||||
don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
|
||||
|
||||
#if defined(_WIN32) && !defined(PCRE_STATIC)
|
||||
# ifndef PCRE_EXP_DECL
|
||||
# define PCRE_EXP_DECL extern __declspec(dllimport)
|
||||
# endif
|
||||
# ifdef __cplusplus
|
||||
# ifndef PCRECPP_EXP_DECL
|
||||
# define PCRECPP_EXP_DECL extern __declspec(dllimport)
|
||||
# endif
|
||||
# ifndef PCRECPP_EXP_DEFN
|
||||
# define PCRECPP_EXP_DEFN __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#ifndef PCRE_EXP_DECL
|
||||
#define PCRE_EXP_DECL extern __declspec(dllimport)
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#ifndef PCRECPP_EXP_DECL
|
||||
#define PCRECPP_EXP_DECL extern __declspec(dllimport)
|
||||
#endif
|
||||
#ifndef PCRECPP_EXP_DEFN
|
||||
#define PCRECPP_EXP_DEFN __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* By default, we use the standard "extern" declarations. */
|
||||
|
||||
#ifndef PCRE_EXP_DECL
|
||||
# ifdef __cplusplus
|
||||
# define PCRE_EXP_DECL extern "C"
|
||||
# else
|
||||
# define PCRE_EXP_DECL extern
|
||||
# endif
|
||||
#ifdef __cplusplus
|
||||
#define PCRE_EXP_DECL extern "C"
|
||||
#else
|
||||
#define PCRE_EXP_DECL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# ifndef PCRECPP_EXP_DECL
|
||||
# define PCRECPP_EXP_DECL extern
|
||||
# endif
|
||||
# ifndef PCRECPP_EXP_DEFN
|
||||
# define PCRECPP_EXP_DEFN
|
||||
# endif
|
||||
#ifndef PCRECPP_EXP_DECL
|
||||
#define PCRECPP_EXP_DECL extern
|
||||
#endif
|
||||
#ifndef PCRECPP_EXP_DEFN
|
||||
#define PCRECPP_EXP_DEFN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Have to include stdlib.h in order to ensure that size_t is defined;
|
||||
@ -45,161 +45,158 @@ it is needed here for malloc. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PCRE_CASELESS 0x00000001
|
||||
#define PCRE_MULTILINE 0x00000002
|
||||
#define PCRE_DOTALL 0x00000004
|
||||
#define PCRE_EXTENDED 0x00000008
|
||||
#define PCRE_ANCHORED 0x00000010
|
||||
#define PCRE_DOLLAR_ENDONLY 0x00000020
|
||||
#define PCRE_EXTRA 0x00000040
|
||||
#define PCRE_NOTBOL 0x00000080
|
||||
#define PCRE_NOTEOL 0x00000100
|
||||
#define PCRE_UNGREEDY 0x00000200
|
||||
#define PCRE_NOTEMPTY 0x00000400
|
||||
#define PCRE_UTF8 0x00000800
|
||||
#define PCRE_NO_AUTO_CAPTURE 0x00001000
|
||||
#define PCRE_NO_UTF8_CHECK 0x00002000
|
||||
#define PCRE_AUTO_CALLOUT 0x00004000
|
||||
#define PCRE_PARTIAL 0x00008000
|
||||
#define PCRE_DFA_SHORTEST 0x00010000
|
||||
#define PCRE_DFA_RESTART 0x00020000
|
||||
#define PCRE_FIRSTLINE 0x00040000
|
||||
#define PCRE_DUPNAMES 0x00080000
|
||||
#define PCRE_NEWLINE_CR 0x00100000
|
||||
#define PCRE_NEWLINE_LF 0x00200000
|
||||
#define PCRE_NEWLINE_CRLF 0x00300000
|
||||
#define PCRE_NEWLINE_ANY 0x00400000
|
||||
#define PCRE_NEWLINE_ANYCRLF 0x00500000
|
||||
#define PCRE_BSR_ANYCRLF 0x00800000
|
||||
#define PCRE_BSR_UNICODE 0x01000000
|
||||
#define PCRE_ONLY_ASCII 0x02000000
|
||||
|
||||
#define PCRE_CASELESS 0x00000001
|
||||
#define PCRE_MULTILINE 0x00000002
|
||||
#define PCRE_DOTALL 0x00000004
|
||||
#define PCRE_EXTENDED 0x00000008
|
||||
#define PCRE_ANCHORED 0x00000010
|
||||
#define PCRE_DOLLAR_ENDONLY 0x00000020
|
||||
#define PCRE_EXTRA 0x00000040
|
||||
#define PCRE_NOTBOL 0x00000080
|
||||
#define PCRE_NOTEOL 0x00000100
|
||||
#define PCRE_UNGREEDY 0x00000200
|
||||
#define PCRE_NOTEMPTY 0x00000400
|
||||
#define PCRE_UTF8 0x00000800
|
||||
#define PCRE_NO_AUTO_CAPTURE 0x00001000
|
||||
#define PCRE_NO_UTF8_CHECK 0x00002000
|
||||
#define PCRE_AUTO_CALLOUT 0x00004000
|
||||
#define PCRE_PARTIAL 0x00008000
|
||||
#define PCRE_DFA_SHORTEST 0x00010000
|
||||
#define PCRE_DFA_RESTART 0x00020000
|
||||
#define PCRE_FIRSTLINE 0x00040000
|
||||
#define PCRE_DUPNAMES 0x00080000
|
||||
#define PCRE_NEWLINE_CR 0x00100000
|
||||
#define PCRE_NEWLINE_LF 0x00200000
|
||||
#define PCRE_NEWLINE_CRLF 0x00300000
|
||||
#define PCRE_NEWLINE_ANY 0x00400000
|
||||
#define PCRE_NEWLINE_ANYCRLF 0x00500000
|
||||
#define PCRE_BSR_ANYCRLF 0x00800000
|
||||
#define PCRE_BSR_UNICODE 0x01000000
|
||||
#define PCRE_ONLY_ASCII 0x02000000
|
||||
|
||||
|
||||
#define PCRE_ERROR_NOMATCH (-1)
|
||||
#define PCRE_ERROR_NULL (-2)
|
||||
#define PCRE_ERROR_BADOPTION (-3)
|
||||
#define PCRE_ERROR_BADMAGIC (-4)
|
||||
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
|
||||
#define PCRE_ERROR_UNKNOWN_NODE (-5)
|
||||
#define PCRE_ERROR_NOMEMORY (-6)
|
||||
#define PCRE_ERROR_NOSUBSTRING (-7)
|
||||
#define PCRE_ERROR_MATCHLIMIT (-8)
|
||||
#define PCRE_ERROR_CALLOUT (-9)
|
||||
#define PCRE_ERROR_BADUTF8 (-10)
|
||||
#define PCRE_ERROR_NOMATCH (-1)
|
||||
#define PCRE_ERROR_NULL (-2)
|
||||
#define PCRE_ERROR_BADOPTION (-3)
|
||||
#define PCRE_ERROR_BADMAGIC (-4)
|
||||
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
|
||||
#define PCRE_ERROR_UNKNOWN_NODE (-5)
|
||||
#define PCRE_ERROR_NOMEMORY (-6)
|
||||
#define PCRE_ERROR_NOSUBSTRING (-7)
|
||||
#define PCRE_ERROR_MATCHLIMIT (-8)
|
||||
#define PCRE_ERROR_CALLOUT (-9)
|
||||
#define PCRE_ERROR_BADUTF8 (-10)
|
||||
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
|
||||
#define PCRE_ERROR_PARTIAL (-12)
|
||||
#define PCRE_ERROR_BADPARTIAL (-13)
|
||||
#define PCRE_ERROR_INTERNAL (-14)
|
||||
#define PCRE_ERROR_BADCOUNT (-15)
|
||||
#define PCRE_ERROR_DFA_UITEM (-16)
|
||||
#define PCRE_ERROR_DFA_UCOND (-17)
|
||||
#define PCRE_ERROR_DFA_UMLIMIT (-18)
|
||||
#define PCRE_ERROR_DFA_WSSIZE (-19)
|
||||
#define PCRE_ERROR_DFA_RECURSE (-20)
|
||||
#define PCRE_ERROR_PARTIAL (-12)
|
||||
#define PCRE_ERROR_BADPARTIAL (-13)
|
||||
#define PCRE_ERROR_INTERNAL (-14)
|
||||
#define PCRE_ERROR_BADCOUNT (-15)
|
||||
#define PCRE_ERROR_DFA_UITEM (-16)
|
||||
#define PCRE_ERROR_DFA_UCOND (-17)
|
||||
#define PCRE_ERROR_DFA_UMLIMIT (-18)
|
||||
#define PCRE_ERROR_DFA_WSSIZE (-19)
|
||||
#define PCRE_ERROR_DFA_RECURSE (-20)
|
||||
#define PCRE_ERROR_RECURSIONLIMIT (-21)
|
||||
#define PCRE_ERROR_NULLWSLIMIT (-22)
|
||||
#define PCRE_ERROR_BADNEWLINE (-23)
|
||||
#define PCRE_ERROR_NULLWSLIMIT (-22)
|
||||
#define PCRE_ERROR_BADNEWLINE (-23)
|
||||
|
||||
#define PCRE_INFO_OPTIONS 0
|
||||
#define PCRE_INFO_SIZE 1
|
||||
#define PCRE_INFO_CAPTURECOUNT 2
|
||||
#define PCRE_INFO_BACKREFMAX 3
|
||||
#define PCRE_INFO_FIRSTBYTE 4
|
||||
#define PCRE_INFO_FIRSTCHAR 4
|
||||
#define PCRE_INFO_FIRSTTABLE 5
|
||||
#define PCRE_INFO_LASTLITERAL 6
|
||||
#define PCRE_INFO_NAMEENTRYSIZE 7
|
||||
#define PCRE_INFO_NAMECOUNT 8
|
||||
#define PCRE_INFO_NAMETABLE 9
|
||||
#define PCRE_INFO_STUDYSIZE 10
|
||||
#define PCRE_INFO_DEFAULT_TABLES 11
|
||||
#define PCRE_INFO_OKPARTIAL 12
|
||||
#define PCRE_INFO_JCHANGED 13
|
||||
#define PCRE_INFO_HASCRORLF 14
|
||||
|
||||
#define PCRE_INFO_OPTIONS 0
|
||||
#define PCRE_INFO_SIZE 1
|
||||
#define PCRE_INFO_CAPTURECOUNT 2
|
||||
#define PCRE_INFO_BACKREFMAX 3
|
||||
#define PCRE_INFO_FIRSTBYTE 4
|
||||
#define PCRE_INFO_FIRSTCHAR 4
|
||||
#define PCRE_INFO_FIRSTTABLE 5
|
||||
#define PCRE_INFO_LASTLITERAL 6
|
||||
#define PCRE_INFO_NAMEENTRYSIZE 7
|
||||
#define PCRE_INFO_NAMECOUNT 8
|
||||
#define PCRE_INFO_NAMETABLE 9
|
||||
#define PCRE_INFO_STUDYSIZE 10
|
||||
#define PCRE_INFO_DEFAULT_TABLES 11
|
||||
#define PCRE_INFO_OKPARTIAL 12
|
||||
#define PCRE_INFO_JCHANGED 13
|
||||
#define PCRE_INFO_HASCRORLF 14
|
||||
#define PCRE_CONFIG_UTF8 0
|
||||
#define PCRE_CONFIG_NEWLINE 1
|
||||
#define PCRE_CONFIG_LINK_SIZE 2
|
||||
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
|
||||
#define PCRE_CONFIG_MATCH_LIMIT 4
|
||||
#define PCRE_CONFIG_STACKRECURSE 5
|
||||
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
|
||||
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
|
||||
#define PCRE_CONFIG_BSR 8
|
||||
|
||||
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
||||
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
|
||||
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
||||
#define PCRE_EXTRA_TABLES 0x0008
|
||||
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
|
||||
|
||||
#define PCRE_CONFIG_UTF8 0
|
||||
#define PCRE_CONFIG_NEWLINE 1
|
||||
#define PCRE_CONFIG_LINK_SIZE 2
|
||||
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
|
||||
#define PCRE_CONFIG_MATCH_LIMIT 4
|
||||
#define PCRE_CONFIG_STACKRECURSE 5
|
||||
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
|
||||
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
|
||||
#define PCRE_CONFIG_BSR 8
|
||||
|
||||
|
||||
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
||||
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
|
||||
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
||||
#define PCRE_EXTRA_TABLES 0x0008
|
||||
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
|
||||
|
||||
|
||||
struct real_pcre; /* declaration; the definition is private */
|
||||
struct real_pcre; /* declaration; the definition is private */
|
||||
typedef struct real_pcre pcre;
|
||||
|
||||
|
||||
#ifndef PCRE_SPTR
|
||||
#define PCRE_SPTR const char *
|
||||
#define PCRE_SPTR const char*
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct pcre_extra {
|
||||
unsigned long int flags;
|
||||
void *study_data;
|
||||
unsigned long int match_limit;
|
||||
void *callout_data;
|
||||
const unsigned char *tables;
|
||||
unsigned long int match_limit_recursion;
|
||||
unsigned long int flags;
|
||||
void* study_data;
|
||||
unsigned long int match_limit;
|
||||
void* callout_data;
|
||||
const unsigned char* tables;
|
||||
unsigned long int match_limit_recursion;
|
||||
} pcre_extra;
|
||||
|
||||
|
||||
typedef struct pcre_callout_block {
|
||||
int version;
|
||||
int callout_number;
|
||||
int *offset_vector;
|
||||
PCRE_SPTR subject;
|
||||
int subject_length;
|
||||
int start_match;
|
||||
int current_position;
|
||||
int capture_top;
|
||||
int capture_last;
|
||||
void *callout_data;
|
||||
int pattern_position;
|
||||
int next_item_length;
|
||||
int version;
|
||||
int callout_number;
|
||||
int* offset_vector;
|
||||
PCRE_SPTR subject;
|
||||
int subject_length;
|
||||
int start_match;
|
||||
int current_position;
|
||||
int capture_top;
|
||||
int capture_last;
|
||||
void* callout_data;
|
||||
int pattern_position;
|
||||
int next_item_length;
|
||||
} pcre_callout_block;
|
||||
|
||||
|
||||
#ifndef VPCOMPAT
|
||||
PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
|
||||
PCRE_EXP_DECL void (*pcre_free)(void *);
|
||||
PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
|
||||
PCRE_EXP_DECL void (*pcre_stack_free)(void *);
|
||||
PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
|
||||
PCRE_EXP_DECL void* (*pcre_malloc)(size_t);
|
||||
PCRE_EXP_DECL void (*pcre_free)(void*);
|
||||
PCRE_EXP_DECL void* (*pcre_stack_malloc)(size_t);
|
||||
PCRE_EXP_DECL void (*pcre_stack_free)(void*);
|
||||
PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block*);
|
||||
#else
|
||||
PCRE_EXP_DECL void *pcre_malloc(size_t);
|
||||
PCRE_EXP_DECL void pcre_free(void *);
|
||||
PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
|
||||
PCRE_EXP_DECL void pcre_stack_free(void *);
|
||||
PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
|
||||
PCRE_EXP_DECL void* pcre_malloc(size_t);
|
||||
PCRE_EXP_DECL void pcre_free(void*);
|
||||
PCRE_EXP_DECL void* pcre_stack_malloc(size_t);
|
||||
PCRE_EXP_DECL void pcre_stack_free(void*);
|
||||
PCRE_EXP_DECL int pcre_callout(pcre_callout_block*);
|
||||
#endif
|
||||
|
||||
pcre *pcre_compile(const char *, int, const char **, int *,
|
||||
const unsigned char *);
|
||||
pcre *pcre_compile2(const char *, int, int *, const char **,
|
||||
int *, const unsigned char *);
|
||||
int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
|
||||
int, int, int, int *, int);
|
||||
int pcre_fullinfo(const pcre *, const pcre_extra *, int,
|
||||
void *);
|
||||
pcre* pcre_compile(const char*, int, const char**, int*, const unsigned char*);
|
||||
pcre* pcre_compile2(const char*,
|
||||
int,
|
||||
int*,
|
||||
const char**,
|
||||
int*,
|
||||
const unsigned char*);
|
||||
int pcre_exec(const pcre*,
|
||||
const pcre_extra*,
|
||||
PCRE_SPTR,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
int*,
|
||||
int);
|
||||
int pcre_fullinfo(const pcre*, const pcre_extra*, int, void*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -3,171 +3,130 @@
|
||||
|
||||
const unsigned char _pcre_default_tables[] = {
|
||||
|
||||
/* This table is a lower casing table. */
|
||||
/* This table is a lower casing table. */
|
||||
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51, 52, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61, 62, 63,
|
||||
64, 97, 98, 99,100,101,102,103,
|
||||
104,105,106,107,108,109,110,111,
|
||||
112,113,114,115,116,117,118,119,
|
||||
120,121,122, 91, 92, 93, 94, 95,
|
||||
96, 97, 98, 99,100,101,102,103,
|
||||
104,105,106,107,108,109,110,111,
|
||||
112,113,114,115,116,117,118,119,
|
||||
120,121,122,123,124,125,126,127,
|
||||
128,129,130,131,132,133,134,135,
|
||||
136,137,138,139,140,141,142,143,
|
||||
144,145,146,147,148,149,150,151,
|
||||
152,153,154,155,156,157,158,159,
|
||||
160,161,162,163,164,165,166,167,
|
||||
168,169,170,171,172,173,174,175,
|
||||
176,177,178,179,180,181,182,183,
|
||||
184,185,186,187,188,189,190,191,
|
||||
192,193,194,195,196,197,198,199,
|
||||
200,201,202,203,204,205,206,207,
|
||||
208,209,210,211,212,213,214,215,
|
||||
216,217,218,219,220,221,222,223,
|
||||
224,225,226,227,228,229,230,231,
|
||||
232,233,234,235,236,237,238,239,
|
||||
240,241,242,243,244,245,246,247,
|
||||
248,249,250,251,252,253,254,255,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
|
||||
59, 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
|
||||
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
|
||||
91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
|
||||
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
|
||||
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
|
||||
138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
|
||||
153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
|
||||
168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
|
||||
183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
|
||||
198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
|
||||
213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
|
||||
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
|
||||
243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
|
||||
|
||||
/* This table is a case flipping table. */
|
||||
/* This table is a case flipping table. */
|
||||
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51, 52, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61, 62, 63,
|
||||
64, 97, 98, 99,100,101,102,103,
|
||||
104,105,106,107,108,109,110,111,
|
||||
112,113,114,115,116,117,118,119,
|
||||
120,121,122, 91, 92, 93, 94, 95,
|
||||
96, 65, 66, 67, 68, 69, 70, 71,
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83, 84, 85, 86, 87,
|
||||
88, 89, 90,123,124,125,126,127,
|
||||
128,129,130,131,132,133,134,135,
|
||||
136,137,138,139,140,141,142,143,
|
||||
144,145,146,147,148,149,150,151,
|
||||
152,153,154,155,156,157,158,159,
|
||||
160,161,162,163,164,165,166,167,
|
||||
168,169,170,171,172,173,174,175,
|
||||
176,177,178,179,180,181,182,183,
|
||||
184,185,186,187,188,189,190,191,
|
||||
192,193,194,195,196,197,198,199,
|
||||
200,201,202,203,204,205,206,207,
|
||||
208,209,210,211,212,213,214,215,
|
||||
216,217,218,219,220,221,222,223,
|
||||
224,225,226,227,228,229,230,231,
|
||||
232,233,234,235,236,237,238,239,
|
||||
240,241,242,243,244,245,246,247,
|
||||
248,249,250,251,252,253,254,255,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
|
||||
59, 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
|
||||
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
|
||||
91, 92, 93, 94, 95, 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
|
||||
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127,
|
||||
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
|
||||
143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
|
||||
158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
|
||||
173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
|
||||
188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
|
||||
203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
|
||||
218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
|
||||
233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
|
||||
248, 249, 250, 251, 252, 253, 254, 255,
|
||||
|
||||
/* This table contains bit maps for various character classes. Each map is 32
|
||||
bytes long and the bits run from the least significant end of each byte. The
|
||||
classes that have their own maps are: space, xdigit, digit, upper, lower, word,
|
||||
graph, print, punct, and cntrl. Other classes are built from combinations. */
|
||||
/* This table contains bit maps for various character classes. Each map is
|
||||
32 bytes long and the bits run from the least significant end of each byte.
|
||||
The classes that have their own maps are: space, xdigit, digit, upper,
|
||||
lower, word, graph, print, punct, and cntrl. Other classes are built from
|
||||
combinations. */
|
||||
|
||||
0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
|
||||
0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
|
||||
0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0xfe, 0xff, 0xff, 0x87,
|
||||
0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
|
||||
0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, 0xfc, 0x01, 0x00, 0x00, 0xf8,
|
||||
0x01, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
/* This table identifies various classes of character by individual bits:
|
||||
0x01 white space character
|
||||
0x02 letter
|
||||
0x04 decimal digit
|
||||
0x08 hexadecimal digit
|
||||
0x10 alphanumeric or '_'
|
||||
0x80 regular expression metacharacter or binary zero
|
||||
*/
|
||||
/* This table identifies various classes of character by individual bits:
|
||||
0x01 white space character
|
||||
0x02 letter
|
||||
0x04 decimal digit
|
||||
0x08 hexadecimal digit
|
||||
0x10 alphanumeric or '_'
|
||||
0x80 regular expression metacharacter or binary zero
|
||||
*/
|
||||
|
||||
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
|
||||
0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /* 8- 15 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
|
||||
0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */
|
||||
0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */
|
||||
0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
|
||||
0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */
|
||||
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */
|
||||
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */
|
||||
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */
|
||||
0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /* X - _ */
|
||||
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */
|
||||
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */
|
||||
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */
|
||||
0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
|
||||
0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
|
||||
0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, /* - ' */
|
||||
0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, /* ( - / */
|
||||
0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, /* 0 - 7 */
|
||||
0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 8 - ? */
|
||||
0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* @ - G */
|
||||
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* H - O */
|
||||
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* P - W */
|
||||
0x12, 0x12, 0x12, 0x80, 0x80, 0x00, 0x80, 0x10, /* X - _ */
|
||||
0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* ` - g */
|
||||
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* h - o */
|
||||
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* p - w */
|
||||
0x12, 0x12, 0x12, 0x80, 0x80, 0x00, 0x00, 0x00, /* x -127 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 136-143 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144-151 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 152-159 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160-167 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 168-175 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 176-183 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 192-199 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200-207 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 208-215 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 216-223 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 224-231 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 232-239 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240-247 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* 248-255 */
|
||||
|
||||
/* End of pcre_chartables.c */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,14 +2,12 @@
|
||||
/* This module contains the external function pcre_fullinfo(), which returns
|
||||
information about a compiled pattern. */
|
||||
|
||||
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Return info about compiled pattern *
|
||||
*************************************************/
|
||||
* Return info about compiled pattern *
|
||||
*************************************************/
|
||||
|
||||
/* This is a newer "info" function which has an extensible interface so
|
||||
that additional items can be added compatibly.
|
||||
@ -23,101 +21,107 @@ Arguments:
|
||||
Returns: 0 if data returned, negative on error
|
||||
*/
|
||||
|
||||
int
|
||||
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
|
||||
void *where)
|
||||
{
|
||||
real_pcre internal_re;
|
||||
pcre_study_data internal_study;
|
||||
const real_pcre *re = (const real_pcre *)argument_re;
|
||||
const pcre_study_data *study = NULL;
|
||||
int pcre_fullinfo(const pcre* argument_re,
|
||||
const pcre_extra* extra_data,
|
||||
int what,
|
||||
void* where) {
|
||||
real_pcre internal_re;
|
||||
pcre_study_data internal_study;
|
||||
const real_pcre* re = (const real_pcre*)argument_re;
|
||||
const pcre_study_data* study = NULL;
|
||||
|
||||
if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
|
||||
if (re == NULL || where == NULL)
|
||||
return PCRE_ERROR_NULL;
|
||||
|
||||
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
|
||||
study = (const pcre_study_data *)extra_data->study_data;
|
||||
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
|
||||
study = (const pcre_study_data*)extra_data->study_data;
|
||||
|
||||
if (re->magic_number != MAGIC_NUMBER)
|
||||
{
|
||||
re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
|
||||
if (re == NULL) return PCRE_ERROR_BADMAGIC;
|
||||
if (study != NULL) study = &internal_study;
|
||||
}
|
||||
if (re->magic_number != MAGIC_NUMBER) {
|
||||
re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
|
||||
if (re == NULL)
|
||||
return PCRE_ERROR_BADMAGIC;
|
||||
if (study != NULL)
|
||||
study = &internal_study;
|
||||
}
|
||||
|
||||
switch (what)
|
||||
{
|
||||
case PCRE_INFO_OPTIONS:
|
||||
*((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;
|
||||
break;
|
||||
switch (what) {
|
||||
case PCRE_INFO_OPTIONS:
|
||||
*((unsigned long int*)where) = re->options & PUBLIC_OPTIONS;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_SIZE:
|
||||
*((size_t *)where) = re->size;
|
||||
break;
|
||||
case PCRE_INFO_SIZE:
|
||||
*((size_t*)where) = re->size;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_STUDYSIZE:
|
||||
*((size_t *)where) = (study == NULL)? 0 : study->size;
|
||||
break;
|
||||
case PCRE_INFO_STUDYSIZE:
|
||||
*((size_t*)where) = (study == NULL) ? 0 : study->size;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_CAPTURECOUNT:
|
||||
*((int *)where) = re->top_bracket;
|
||||
break;
|
||||
case PCRE_INFO_CAPTURECOUNT:
|
||||
*((int*)where) = re->top_bracket;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_BACKREFMAX:
|
||||
*((int *)where) = re->top_backref;
|
||||
break;
|
||||
case PCRE_INFO_BACKREFMAX:
|
||||
*((int*)where) = re->top_backref;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_FIRSTBYTE:
|
||||
*((int *)where) =
|
||||
((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
|
||||
((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
|
||||
break;
|
||||
case PCRE_INFO_FIRSTBYTE:
|
||||
*((int*)where) = ((re->flags & PCRE_FIRSTSET) != 0) ? re->first_byte
|
||||
: ((re->flags & PCRE_STARTLINE) != 0) ? -1
|
||||
: -2;
|
||||
break;
|
||||
|
||||
/* Make sure we pass back the pointer to the bit vector in the external
|
||||
block, not the internal copy (with flipped integer fields). */
|
||||
/* Make sure we pass back the pointer to the bit vector in the
|
||||
external block, not the internal copy (with flipped integer fields).
|
||||
*/
|
||||
|
||||
case PCRE_INFO_FIRSTTABLE:
|
||||
*((const uschar **)where) =
|
||||
(study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?
|
||||
((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
|
||||
break;
|
||||
case PCRE_INFO_FIRSTTABLE:
|
||||
*((const uschar**)where) =
|
||||
(study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)
|
||||
? ((const pcre_study_data*)extra_data->study_data)
|
||||
->start_bits
|
||||
: NULL;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_LASTLITERAL:
|
||||
*((int *)where) =
|
||||
((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
|
||||
break;
|
||||
case PCRE_INFO_LASTLITERAL:
|
||||
*((int*)where) =
|
||||
((re->flags & PCRE_REQCHSET) != 0) ? re->req_byte : -1;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_NAMEENTRYSIZE:
|
||||
*((int *)where) = re->name_entry_size;
|
||||
break;
|
||||
case PCRE_INFO_NAMEENTRYSIZE:
|
||||
*((int*)where) = re->name_entry_size;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_NAMECOUNT:
|
||||
*((int *)where) = re->name_count;
|
||||
break;
|
||||
case PCRE_INFO_NAMECOUNT:
|
||||
*((int*)where) = re->name_count;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_NAMETABLE:
|
||||
*((const uschar **)where) = (const uschar *)re + re->name_table_offset;
|
||||
break;
|
||||
case PCRE_INFO_NAMETABLE:
|
||||
*((const uschar**)where) =
|
||||
(const uschar*)re + re->name_table_offset;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_DEFAULT_TABLES:
|
||||
*((const uschar **)where) = (const uschar *)(_pcre_default_tables);
|
||||
break;
|
||||
case PCRE_INFO_DEFAULT_TABLES:
|
||||
*((const uschar**)where) = (const uschar*)(_pcre_default_tables);
|
||||
break;
|
||||
|
||||
case PCRE_INFO_OKPARTIAL:
|
||||
*((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
|
||||
break;
|
||||
case PCRE_INFO_OKPARTIAL:
|
||||
*((int*)where) = (re->flags & PCRE_NOPARTIAL) == 0;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_JCHANGED:
|
||||
*((int *)where) = (re->flags & PCRE_JCHANGED) != 0;
|
||||
break;
|
||||
case PCRE_INFO_JCHANGED:
|
||||
*((int*)where) = (re->flags & PCRE_JCHANGED) != 0;
|
||||
break;
|
||||
|
||||
case PCRE_INFO_HASCRORLF:
|
||||
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
|
||||
break;
|
||||
case PCRE_INFO_HASCRORLF:
|
||||
*((int*)where) = (re->flags & PCRE_HASCRORLF) != 0;
|
||||
break;
|
||||
|
||||
default: return PCRE_ERROR_BADOPTION;
|
||||
}
|
||||
default:
|
||||
return PCRE_ERROR_BADOPTION;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* End of pcre_fullinfo.c */
|
||||
|
@ -11,11 +11,11 @@ differently, and global variables are not used (see pcre.in). */
|
||||
#include "pcre_internal.h"
|
||||
|
||||
#ifndef VPCOMPAT
|
||||
void *(*pcre_malloc)(size_t) = malloc;
|
||||
void (*pcre_free)(void *) = free;
|
||||
void *(*pcre_stack_malloc)(size_t) = malloc;
|
||||
void (*pcre_stack_free)(void *) = free;
|
||||
int (*pcre_callout)(pcre_callout_block *) = NULL;
|
||||
void* (*pcre_malloc)(size_t) = malloc;
|
||||
void (*pcre_free)(void*) = free;
|
||||
void* (*pcre_stack_malloc)(size_t) = malloc;
|
||||
void (*pcre_stack_free)(void*) = free;
|
||||
int (*pcre_callout)(pcre_callout_block*) = NULL;
|
||||
#endif
|
||||
|
||||
/* End of pcre_globals.c */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,9 @@
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Check for newline at given position *
|
||||
*************************************************/
|
||||
* Check for newline at given position *
|
||||
*************************************************/
|
||||
|
||||
/* It is guaranteed that the initial value of ptr is less than the end of the
|
||||
string that is being processed.
|
||||
@ -20,42 +18,56 @@ Arguments:
|
||||
Returns: TRUE or FALSE
|
||||
*/
|
||||
|
||||
BOOL
|
||||
_pcre_is_newline(const uschar *ptr, int type, const uschar *endptr,
|
||||
int *lenptr, BOOL utf8)
|
||||
{
|
||||
int c;
|
||||
if (utf8) { GETCHAR(c, ptr); } else c = *ptr;
|
||||
BOOL _pcre_is_newline(const uschar* ptr,
|
||||
int type,
|
||||
const uschar* endptr,
|
||||
int* lenptr,
|
||||
BOOL utf8) {
|
||||
int c;
|
||||
if (utf8) {
|
||||
GETCHAR(c, ptr);
|
||||
} else
|
||||
c = *ptr;
|
||||
|
||||
if (type == NLTYPE_ANYCRLF) switch(c)
|
||||
{
|
||||
case 0x000a: *lenptr = 1; return TRUE; /* LF */
|
||||
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
|
||||
return TRUE; /* CR */
|
||||
default: return FALSE;
|
||||
}
|
||||
if (type == NLTYPE_ANYCRLF)
|
||||
switch (c) {
|
||||
case 0x000a:
|
||||
*lenptr = 1;
|
||||
return TRUE; /* LF */
|
||||
case 0x000d:
|
||||
*lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a) ? 2 : 1;
|
||||
return TRUE; /* CR */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* NLTYPE_ANY */
|
||||
/* NLTYPE_ANY */
|
||||
|
||||
else switch(c)
|
||||
{
|
||||
case 0x000a: /* LF */
|
||||
case 0x000b: /* VT */
|
||||
case 0x000c: *lenptr = 1; return TRUE; /* FF */
|
||||
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
|
||||
return TRUE; /* CR */
|
||||
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */
|
||||
case 0x2028: /* LS */
|
||||
case 0x2029: *lenptr = 3; return TRUE; /* PS */
|
||||
default: return FALSE;
|
||||
}
|
||||
else
|
||||
switch (c) {
|
||||
case 0x000a: /* LF */
|
||||
case 0x000b: /* VT */
|
||||
case 0x000c:
|
||||
*lenptr = 1;
|
||||
return TRUE; /* FF */
|
||||
case 0x000d:
|
||||
*lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a) ? 2 : 1;
|
||||
return TRUE; /* CR */
|
||||
case 0x0085:
|
||||
*lenptr = utf8 ? 2 : 1;
|
||||
return TRUE; /* NEL */
|
||||
case 0x2028: /* LS */
|
||||
case 0x2029:
|
||||
*lenptr = 3;
|
||||
return TRUE; /* PS */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Check for newline at previous position *
|
||||
*************************************************/
|
||||
* Check for newline at previous position *
|
||||
*************************************************/
|
||||
|
||||
/* It is guaranteed that the initial value of ptr is greater than the start of
|
||||
the string that is being processed.
|
||||
@ -70,43 +82,55 @@ Arguments:
|
||||
Returns: TRUE or FALSE
|
||||
*/
|
||||
|
||||
BOOL
|
||||
_pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
|
||||
int *lenptr, BOOL utf8)
|
||||
{
|
||||
int c;
|
||||
ptr--;
|
||||
BOOL _pcre_was_newline(const uschar* ptr,
|
||||
int type,
|
||||
const uschar* startptr,
|
||||
int* lenptr,
|
||||
BOOL utf8) {
|
||||
int c;
|
||||
ptr--;
|
||||
#ifdef SUPPORT_UTF8
|
||||
if (utf8)
|
||||
{
|
||||
BACKCHAR(ptr);
|
||||
GETCHAR(c, ptr);
|
||||
}
|
||||
else c = *ptr;
|
||||
#else /* no UTF-8 support */
|
||||
c = *ptr;
|
||||
#endif /* SUPPORT_UTF8 */
|
||||
if (utf8) {
|
||||
BACKCHAR(ptr);
|
||||
GETCHAR(c, ptr);
|
||||
} else
|
||||
c = *ptr;
|
||||
#else /* no UTF-8 support */
|
||||
c = *ptr;
|
||||
#endif /* SUPPORT_UTF8 */
|
||||
|
||||
if (type == NLTYPE_ANYCRLF) switch(c)
|
||||
{
|
||||
case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
|
||||
return TRUE; /* LF */
|
||||
case 0x000d: *lenptr = 1; return TRUE; /* CR */
|
||||
default: return FALSE;
|
||||
}
|
||||
if (type == NLTYPE_ANYCRLF)
|
||||
switch (c) {
|
||||
case 0x000a:
|
||||
*lenptr = (ptr > startptr && ptr[-1] == 0x0d) ? 2 : 1;
|
||||
return TRUE; /* LF */
|
||||
case 0x000d:
|
||||
*lenptr = 1;
|
||||
return TRUE; /* CR */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
else switch(c)
|
||||
{
|
||||
case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
|
||||
return TRUE; /* LF */
|
||||
case 0x000b: /* VT */
|
||||
case 0x000c: /* FF */
|
||||
case 0x000d: *lenptr = 1; return TRUE; /* CR */
|
||||
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */
|
||||
case 0x2028: /* LS */
|
||||
case 0x2029: *lenptr = 3; return TRUE; /* PS */
|
||||
default: return FALSE;
|
||||
}
|
||||
else
|
||||
switch (c) {
|
||||
case 0x000a:
|
||||
*lenptr = (ptr > startptr && ptr[-1] == 0x0d) ? 2 : 1;
|
||||
return TRUE; /* LF */
|
||||
case 0x000b: /* VT */
|
||||
case 0x000c: /* FF */
|
||||
case 0x000d:
|
||||
*lenptr = 1;
|
||||
return TRUE; /* CR */
|
||||
case 0x0085:
|
||||
*lenptr = utf8 ? 2 : 1;
|
||||
return TRUE; /* NEL */
|
||||
case 0x2028: /* LS */
|
||||
case 0x2029:
|
||||
*lenptr = 3;
|
||||
return TRUE; /* PS */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of pcre_newline.c */
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Convert character value to UTF-8 *
|
||||
*************************************************/
|
||||
* Convert character value to UTF-8 *
|
||||
*************************************************/
|
||||
|
||||
/* This function takes an integer value in the range 0 - 0x7fffffff
|
||||
and encodes it as a UTF-8 character in 0 to 6 bytes.
|
||||
@ -16,24 +15,22 @@ Arguments:
|
||||
Returns: number of characters placed in the buffer
|
||||
*/
|
||||
|
||||
int
|
||||
_pcre_ord2utf8(int cvalue, uschar *buffer)
|
||||
{
|
||||
int _pcre_ord2utf8(int cvalue, uschar* buffer) {
|
||||
#ifdef SUPPORT_UTF8
|
||||
register int i, j;
|
||||
for (i = 0; i < _pcre_utf8_table1_size; i++)
|
||||
if (cvalue <= _pcre_utf8_table1[i]) break;
|
||||
buffer += i;
|
||||
for (j = i; j > 0; j--)
|
||||
{
|
||||
*buffer-- = 0x80 | (cvalue & 0x3f);
|
||||
cvalue >>= 6;
|
||||
}
|
||||
*buffer = _pcre_utf8_table2[i] | cvalue;
|
||||
return i + 1;
|
||||
register int i, j;
|
||||
for (i = 0; i < _pcre_utf8_table1_size; i++)
|
||||
if (cvalue <= _pcre_utf8_table1[i])
|
||||
break;
|
||||
buffer += i;
|
||||
for (j = i; j > 0; j--) {
|
||||
*buffer-- = 0x80 | (cvalue & 0x3f);
|
||||
cvalue >>= 6;
|
||||
}
|
||||
*buffer = _pcre_utf8_table2[i] | cvalue;
|
||||
return i + 1;
|
||||
#else
|
||||
return 0; /* Keep compiler happy; this function won't ever be */
|
||||
#endif /* called when SUPPORT_UTF8 is not defined. */
|
||||
return 0; /* Keep compiler happy; this function won't ever be */
|
||||
#endif /* called when SUPPORT_UTF8 is not defined. */
|
||||
}
|
||||
|
||||
/* End of pcre_ord2utf8.c */
|
||||
|
@ -2,40 +2,36 @@
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
|
||||
the definition is next to the definition of the opcodes in pcre_internal.h. */
|
||||
|
||||
const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
|
||||
|
||||
|
||||
const uschar _pcre_OP_lengths[] = {OP_LENGTHS};
|
||||
|
||||
/*************************************************
|
||||
* Tables for UTF-8 support *
|
||||
*************************************************/
|
||||
* Tables for UTF-8 support *
|
||||
*************************************************/
|
||||
|
||||
/* These are the breakpoints for different numbers of bytes in a UTF-8
|
||||
character. */
|
||||
|
||||
#ifdef SUPPORT_UTF8
|
||||
|
||||
const int _pcre_utf8_table1[] =
|
||||
{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
|
||||
const int _pcre_utf8_table1[] = {0x7f, 0x7ff, 0xffff,
|
||||
0x1fffff, 0x3ffffff, 0x7fffffff};
|
||||
|
||||
const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1)/sizeof(int);
|
||||
const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1) / sizeof(int);
|
||||
|
||||
/* These are the indicator bits and the mask for the data bits to set in the
|
||||
first byte of a character, indexed by the number of additional bytes. */
|
||||
|
||||
const int _pcre_utf8_table2[] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
|
||||
const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
const int _pcre_utf8_table2[] = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
|
||||
const int _pcre_utf8_table3[] = {0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
|
||||
/* Table of the number of extra bytes, indexed by the first byte masked with
|
||||
0x3f. The highest number for a valid UTF-8 first byte is in fact 0x3d. */
|
||||
|
||||
const uschar _pcre_utf8_table4[] = {
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};
|
||||
#endif
|
||||
|
@ -2,10 +2,9 @@
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Flip bytes in an integer *
|
||||
*************************************************/
|
||||
* Flip bytes in an integer *
|
||||
*************************************************/
|
||||
|
||||
/* This function is called when the magic number in a regex doesn't match, in
|
||||
order to flip its bytes to see if we are dealing with a pattern that was
|
||||
@ -19,21 +18,16 @@ Arguments:
|
||||
Returns: the flipped value
|
||||
*/
|
||||
|
||||
static unsigned long int
|
||||
byteflip(unsigned long int value, int n)
|
||||
{
|
||||
if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
|
||||
return ((value & 0x000000ff) << 24) |
|
||||
((value & 0x0000ff00) << 8) |
|
||||
((value & 0x00ff0000) >> 8) |
|
||||
((value & 0xff000000) >> 24);
|
||||
static unsigned long int byteflip(unsigned long int value, int n) {
|
||||
if (n == 2)
|
||||
return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
|
||||
return ((value & 0x000000ff) << 24) | ((value & 0x0000ff00) << 8) |
|
||||
((value & 0x00ff0000) >> 8) | ((value & 0xff000000) >> 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Test for a byte-flipped compiled regex *
|
||||
*************************************************/
|
||||
* Test for a byte-flipped compiled regex *
|
||||
*************************************************/
|
||||
|
||||
/* This function is called from pcre_exec(), pcre_dfa_exec(), and also from
|
||||
pcre_fullinfo(). Its job is to test whether the regex is byte-flipped - that
|
||||
@ -51,40 +45,40 @@ Returns: the new block if is is indeed a byte-flipped regex
|
||||
NULL if it is not
|
||||
*/
|
||||
|
||||
real_pcre *
|
||||
_pcre_try_flipped(const real_pcre *re, real_pcre *internal_re,
|
||||
const pcre_study_data *study, pcre_study_data *internal_study)
|
||||
{
|
||||
if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
|
||||
return NULL;
|
||||
real_pcre* _pcre_try_flipped(const real_pcre* re,
|
||||
real_pcre* internal_re,
|
||||
const pcre_study_data* study,
|
||||
pcre_study_data* internal_study) {
|
||||
if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
|
||||
return NULL;
|
||||
|
||||
*internal_re = *re; /* To copy other fields */
|
||||
internal_re->size = byteflip(re->size, sizeof(re->size));
|
||||
internal_re->options = byteflip(re->options, sizeof(re->options));
|
||||
internal_re->flags = (pcre_uint16)byteflip(re->flags, sizeof(re->flags));
|
||||
internal_re->top_bracket =
|
||||
(pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));
|
||||
internal_re->top_backref =
|
||||
(pcre_uint16)byteflip(re->top_backref, sizeof(re->top_backref));
|
||||
internal_re->first_byte =
|
||||
(pcre_uint16)byteflip(re->first_byte, sizeof(re->first_byte));
|
||||
internal_re->req_byte =
|
||||
(pcre_uint16)byteflip(re->req_byte, sizeof(re->req_byte));
|
||||
internal_re->name_table_offset =
|
||||
(pcre_uint16)byteflip(re->name_table_offset, sizeof(re->name_table_offset));
|
||||
internal_re->name_entry_size =
|
||||
(pcre_uint16)byteflip(re->name_entry_size, sizeof(re->name_entry_size));
|
||||
internal_re->name_count =
|
||||
(pcre_uint16)byteflip(re->name_count, sizeof(re->name_count));
|
||||
*internal_re = *re; /* To copy other fields */
|
||||
internal_re->size = byteflip(re->size, sizeof(re->size));
|
||||
internal_re->options = byteflip(re->options, sizeof(re->options));
|
||||
internal_re->flags = (pcre_uint16)byteflip(re->flags, sizeof(re->flags));
|
||||
internal_re->top_bracket =
|
||||
(pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));
|
||||
internal_re->top_backref =
|
||||
(pcre_uint16)byteflip(re->top_backref, sizeof(re->top_backref));
|
||||
internal_re->first_byte =
|
||||
(pcre_uint16)byteflip(re->first_byte, sizeof(re->first_byte));
|
||||
internal_re->req_byte =
|
||||
(pcre_uint16)byteflip(re->req_byte, sizeof(re->req_byte));
|
||||
internal_re->name_table_offset = (pcre_uint16)byteflip(
|
||||
re->name_table_offset, sizeof(re->name_table_offset));
|
||||
internal_re->name_entry_size =
|
||||
(pcre_uint16)byteflip(re->name_entry_size, sizeof(re->name_entry_size));
|
||||
internal_re->name_count =
|
||||
(pcre_uint16)byteflip(re->name_count, sizeof(re->name_count));
|
||||
|
||||
if (study != NULL)
|
||||
{
|
||||
*internal_study = *study; /* To copy other fields */
|
||||
internal_study->size = byteflip(study->size, sizeof(study->size));
|
||||
internal_study->options = byteflip(study->options, sizeof(study->options));
|
||||
}
|
||||
if (study != NULL) {
|
||||
*internal_study = *study; /* To copy other fields */
|
||||
internal_study->size = byteflip(study->size, sizeof(study->size));
|
||||
internal_study->options =
|
||||
byteflip(study->options, sizeof(study->options));
|
||||
}
|
||||
|
||||
return internal_re;
|
||||
return internal_re;
|
||||
}
|
||||
|
||||
/* End of pcre_tryflipped.c */
|
||||
|
@ -2,10 +2,9 @@
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Validate a UTF-8 string *
|
||||
*************************************************/
|
||||
* Validate a UTF-8 string *
|
||||
*************************************************/
|
||||
|
||||
/* This function is called (optionally) at the start of compile or match, to
|
||||
validate that a supposed UTF-8 string is actually valid. The early check means
|
||||
@ -28,60 +27,60 @@ Returns: < 0 if the string is a valid UTF-8 string
|
||||
>= 0 otherwise; the value is the offset of the bad byte
|
||||
*/
|
||||
|
||||
int
|
||||
_pcre_valid_utf8(const uschar *string, int length)
|
||||
{
|
||||
int _pcre_valid_utf8(const uschar* string, int length) {
|
||||
#ifdef SUPPORT_UTF8
|
||||
register const uschar *p;
|
||||
register const uschar* p;
|
||||
|
||||
if (length < 0)
|
||||
{
|
||||
for (p = string; *p != 0; p++);
|
||||
length = (uintptr_t)p - (uintptr_t)string;
|
||||
}
|
||||
if (length < 0) {
|
||||
for (p = string; *p != 0; p++)
|
||||
;
|
||||
length = (uintptr_t)p - (uintptr_t)string;
|
||||
}
|
||||
|
||||
for (p = string; length-- > 0; p++)
|
||||
{
|
||||
register int ab;
|
||||
register int c = *p;
|
||||
if (c < 128) continue;
|
||||
if (c < 0xc0) return (uintptr_t)p - (uintptr_t)string;
|
||||
ab = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
|
||||
if (length < ab || ab > 3) return (uintptr_t)p - (uintptr_t)string;
|
||||
length -= ab;
|
||||
for (p = string; length-- > 0; p++) {
|
||||
register int ab;
|
||||
register int c = *p;
|
||||
if (c < 128)
|
||||
continue;
|
||||
if (c < 0xc0)
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
ab = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
|
||||
if (length < ab || ab > 3)
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
length -= ab;
|
||||
|
||||
/* Check top bits in the second byte */
|
||||
if ((*(++p) & 0xc0) != 0x80) return (uintptr_t)p - (uintptr_t)string;
|
||||
/* Check top bits in the second byte */
|
||||
if ((*(++p) & 0xc0) != 0x80)
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
|
||||
/* Check for overlong sequences for each different length, and for the
|
||||
excluded range 0xd000 to 0xdfff. */
|
||||
/* Check for overlong sequences for each different length, and for the
|
||||
excluded range 0xd000 to 0xdfff. */
|
||||
|
||||
switch (ab)
|
||||
{
|
||||
/* Check for xx00 000x (overlong sequence) */
|
||||
switch (ab) {
|
||||
/* Check for xx00 000x (overlong sequence) */
|
||||
|
||||
case 1:
|
||||
if ((c & 0x3e) == 0) return (uintptr_t)p - (uintptr_t)string;
|
||||
continue; /* We know there aren't any more bytes to check */
|
||||
case 1:
|
||||
if ((c & 0x3e) == 0)
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
continue; /* We know there aren't any more bytes to check */
|
||||
|
||||
/* Check for 1110 0000, xx0x xxxx (overlong sequence) or
|
||||
1110 1101, 1010 xxxx (0xd000 - 0xdfff) */
|
||||
/* Check for 1110 0000, xx0x xxxx (overlong sequence) or
|
||||
1110 1101, 1010 xxxx (0xd000 - 0xdfff) */
|
||||
|
||||
case 2:
|
||||
if ((c == 0xe0 && (*p & 0x20) == 0) ||
|
||||
(c == 0xed && *p >= 0xa0))
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
break;
|
||||
case 2:
|
||||
if ((c == 0xe0 && (*p & 0x20) == 0) ||
|
||||
(c == 0xed && *p >= 0xa0))
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
break;
|
||||
|
||||
/* Check for 1111 0000, xx00 xxxx (overlong sequence) or
|
||||
greater than 0x0010ffff (f4 8f bf bf) */
|
||||
/* Check for 1111 0000, xx00 xxxx (overlong sequence) or
|
||||
greater than 0x0010ffff (f4 8f bf bf) */
|
||||
|
||||
case 3:
|
||||
if ((c == 0xf0 && (*p & 0x30) == 0) ||
|
||||
(c > 0xf4 ) ||
|
||||
(c == 0xf4 && *p > 0x8f))
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
break;
|
||||
case 3:
|
||||
if ((c == 0xf0 && (*p & 0x30) == 0) || (c > 0xf4) ||
|
||||
(c == 0xf4 && *p > 0x8f))
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
/* These cases can no longer occur, as we restrict to a maximum of four
|
||||
@ -99,18 +98,17 @@ for (p = string; length-- > 0; p++)
|
||||
(c == 0xfc && (*p & 0x3c) == 0)) return (uintptr_t)p - (uintptr_t)string;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check for valid bytes after the 2nd, if any; all must start 10 */
|
||||
while (--ab > 0) {
|
||||
if ((*(++p) & 0xc0) != 0x80)
|
||||
return (uintptr_t)p - (uintptr_t)string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for valid bytes after the 2nd, if any; all must start 10 */
|
||||
while (--ab > 0)
|
||||
{
|
||||
if ((*(++p) & 0xc0) != 0x80) return (uintptr_t)p - (uintptr_t)string;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* End of pcre_valid_utf8.c */
|
||||
|
@ -1,11 +1,9 @@
|
||||
|
||||
#include "re_config.h"
|
||||
#include "pcre_internal.h"
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Match character against an XCLASS *
|
||||
*************************************************/
|
||||
* Match character against an XCLASS *
|
||||
*************************************************/
|
||||
|
||||
/* This function is called to match a character against an extended class that
|
||||
might contain values > 255.
|
||||
@ -17,85 +15,84 @@ Arguments:
|
||||
Returns: TRUE if character matches, else FALSE
|
||||
*/
|
||||
|
||||
BOOL
|
||||
_pcre_xclass(int c, const uschar *data)
|
||||
{
|
||||
int t;
|
||||
BOOL negated = (*data & XCL_NOT) != 0;
|
||||
BOOL _pcre_xclass(int c, const uschar* data) {
|
||||
int t;
|
||||
BOOL negated = (*data & XCL_NOT) != 0;
|
||||
|
||||
/* Character values < 256 are matched against a bitmap, if one is present. If
|
||||
not, we still carry on, because there may be ranges that start below 256 in the
|
||||
additional data. */
|
||||
/* Character values < 256 are matched against a bitmap, if one is present.
|
||||
If not, we still carry on, because there may be ranges that start below 256
|
||||
in the additional data. */
|
||||
|
||||
if (c < 256)
|
||||
{
|
||||
if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)
|
||||
return !negated; /* char found */
|
||||
}
|
||||
|
||||
/* First skip the bit map if present. Then match against the list of Unicode
|
||||
properties or large chars or ranges that end with a large char. We won't ever
|
||||
encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
|
||||
|
||||
if ((*data++ & XCL_MAP) != 0) data += 32;
|
||||
|
||||
while ((t = *data++) != XCL_END)
|
||||
{
|
||||
int x, y;
|
||||
if (t == XCL_SINGLE)
|
||||
{
|
||||
GETCHARINC(x, data);
|
||||
if (c == x) return !negated;
|
||||
}
|
||||
else if (t == XCL_RANGE)
|
||||
{
|
||||
GETCHARINC(x, data);
|
||||
GETCHARINC(y, data);
|
||||
if (c >= x && c <= y) return !negated;
|
||||
if (c < 256) {
|
||||
if ((*data & XCL_MAP) != 0 && (data[1 + c / 8] & (1 << (c & 7))) != 0)
|
||||
return !negated; /* char found */
|
||||
}
|
||||
|
||||
/* First skip the bit map if present. Then match against the list of Unicode
|
||||
properties or large chars or ranges that end with a large char. We won't
|
||||
ever encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
|
||||
|
||||
if ((*data++ & XCL_MAP) != 0)
|
||||
data += 32;
|
||||
|
||||
while ((t = *data++) != XCL_END) {
|
||||
int x, y;
|
||||
if (t == XCL_SINGLE) {
|
||||
GETCHARINC(x, data);
|
||||
if (c == x)
|
||||
return !negated;
|
||||
} else if (t == XCL_RANGE) {
|
||||
GETCHARINC(x, data);
|
||||
GETCHARINC(y, data);
|
||||
if (c >= x && c <= y)
|
||||
return !negated;
|
||||
}
|
||||
#ifdef SUPPORT_UCP
|
||||
else /* XCL_PROP & XCL_NOTPROP */
|
||||
{
|
||||
int chartype, script;
|
||||
int category = _pcre_ucp_findprop(c, &chartype, &script);
|
||||
else /* XCL_PROP & XCL_NOTPROP */
|
||||
{
|
||||
int chartype, script;
|
||||
int category = _pcre_ucp_findprop(c, &chartype, &script);
|
||||
|
||||
switch(*data)
|
||||
{
|
||||
case PT_ANY:
|
||||
if (t == XCL_PROP) return !negated;
|
||||
break;
|
||||
switch (*data) {
|
||||
case PT_ANY:
|
||||
if (t == XCL_PROP)
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
case PT_LAMP:
|
||||
if ((chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt) ==
|
||||
(t == XCL_PROP)) return !negated;
|
||||
break;
|
||||
case PT_LAMP:
|
||||
if ((chartype == ucp_Lu || chartype == ucp_Ll ||
|
||||
chartype == ucp_Lt) == (t == XCL_PROP))
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
case PT_GC:
|
||||
if ((data[1] == category) == (t == XCL_PROP)) return !negated;
|
||||
break;
|
||||
case PT_GC:
|
||||
if ((data[1] == category) == (t == XCL_PROP))
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
case PT_PC:
|
||||
if ((data[1] == chartype) == (t == XCL_PROP)) return !negated;
|
||||
break;
|
||||
case PT_PC:
|
||||
if ((data[1] == chartype) == (t == XCL_PROP))
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
case PT_SC:
|
||||
if ((data[1] == script) == (t == XCL_PROP)) return !negated;
|
||||
break;
|
||||
case PT_SC:
|
||||
if ((data[1] == script) == (t == XCL_PROP))
|
||||
return !negated;
|
||||
break;
|
||||
|
||||
/* This should never occur, but compilers may mutter if there is no
|
||||
default. */
|
||||
/* This should never occur, but compilers may mutter if
|
||||
there is no default. */
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
data += 2;
|
||||
data += 2;
|
||||
}
|
||||
#endif /* SUPPORT_UCP */
|
||||
}
|
||||
#endif /* SUPPORT_UCP */
|
||||
}
|
||||
|
||||
return negated; /* char did not match */
|
||||
return negated; /* char did not match */
|
||||
}
|
||||
|
||||
/* End of pcre_xclass.c */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -143,59 +143,60 @@
|
||||
#endif
|
||||
|
||||
/* The value of MATCH_LIMIT determines the default number of times the
|
||||
internal match() function can be called during a single execution of
|
||||
pcre_exec(). There is a runtime interface for setting a different limit.
|
||||
The limit exists in order to catch runaway regular expressions that take
|
||||
for ever to determine that they do not match. The default is set very large
|
||||
so that it does not accidentally catch legitimate cases. On systems that
|
||||
support it, "configure" can be used to override this default default. */
|
||||
internal match() function can be called during a single execution of
|
||||
pcre_exec(). There is a runtime interface for setting a different
|
||||
limit. The limit exists in order to catch runaway regular expressions that
|
||||
take for ever to determine that they do not match. The default is set very
|
||||
large so that it does not accidentally catch legitimate cases. On systems
|
||||
that support it, "configure" can be used to override this default default. */
|
||||
#ifndef MATCH_LIMIT
|
||||
#define MATCH_LIMIT 10000000
|
||||
#endif
|
||||
|
||||
/* The above limit applies to all calls of match(), whether or not they
|
||||
increase the recursion depth. In some environments it is desirable to limit
|
||||
the depth of recursive calls of match() more strictly, in order to restrict
|
||||
the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
|
||||
used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
|
||||
match(). To have any useful effect, it must be less than the value of
|
||||
MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
|
||||
a runtime method for setting a different limit. On systems that support it,
|
||||
"configure" can be used to override the default. */
|
||||
increase the recursion depth. In some environments it is
|
||||
desirable to limit the depth of recursive calls of match() more strictly, in
|
||||
order to restrict the maximum amount of stack (or heap, if NO_RECURSE is
|
||||
defined) that is used. The value of MATCH_LIMIT_RECURSION applies only to
|
||||
recursive calls of match(). To have any useful effect, it must be less than
|
||||
the value of MATCH_LIMIT. The default is to use the same value as
|
||||
MATCH_LIMIT. There is a runtime method for setting a different limit. On
|
||||
systems that support it, "configure" can be used to override the default. */
|
||||
#ifndef MATCH_LIMIT_RECURSION
|
||||
#define MATCH_LIMIT_RECURSION MATCH_LIMIT
|
||||
#endif
|
||||
|
||||
/* This limit is parameterized just in case anybody ever wants to change it.
|
||||
Care must be taken if it is increased, because it guards against integer
|
||||
overflow caused by enormously large patterns. */
|
||||
Care must be taken if it is increased, because it guards
|
||||
against integer overflow caused by enormously large patterns. */
|
||||
#ifndef MAX_NAME_COUNT
|
||||
#define MAX_NAME_COUNT 10000
|
||||
#endif
|
||||
|
||||
/* This limit is parameterized just in case anybody ever wants to change it.
|
||||
Care must be taken if it is increased, because it guards against integer
|
||||
overflow caused by enormously large patterns. */
|
||||
Care must be taken if it is increased, because it
|
||||
guards against integer overflow caused by enormously large patterns. */
|
||||
#ifndef MAX_NAME_SIZE
|
||||
#define MAX_NAME_SIZE 32
|
||||
#endif
|
||||
|
||||
/* The value of NEWLINE determines the newline character sequence. On systems
|
||||
that support it, "configure" can be used to override the default, which is
|
||||
10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
|
||||
(ANYCRLF). */
|
||||
that support it, "configure" can be used to
|
||||
override the default, which is
|
||||
10. The possible values are 10 (LF), 13 (CR),
|
||||
3338 (CRLF), -1 (ANY), or -2 (ANYCRLF). */
|
||||
#ifndef NEWLINE
|
||||
#define NEWLINE 10
|
||||
#endif
|
||||
|
||||
/* When calling PCRE via the POSIX interface, additional working storage is
|
||||
required for holding the pointers to capturing substrings because PCRE
|
||||
requires three integers per substring, whereas the POSIX interface provides
|
||||
only two. If the number of expected substrings is small, the wrapper
|
||||
function uses space on the stack, because this is faster than using
|
||||
malloc() for each call. The threshold above which the stack is no longer
|
||||
used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
|
||||
"configure" can be used to override this default. */
|
||||
required for holding the pointers to capturing substrings because PCRE
|
||||
requires three integers per substring, whereas the POSIX interface
|
||||
provides only two. If the number of expected substrings is small, the wrapper
|
||||
function uses space on the stack, because this is faster than using
|
||||
malloc() for each call. The threshold above which the stack is no
|
||||
longer used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
|
||||
"configure" can be used to override this default. */
|
||||
#ifndef POSIX_MALLOC_THRESHOLD
|
||||
#define POSIX_MALLOC_THRESHOLD 10
|
||||
#endif
|
||||
@ -209,6 +210,5 @@
|
||||
/* #undef SUPPORT_UTF8 */
|
||||
#define SUPPORT_UTF8
|
||||
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
@ -1,4 +1,17 @@
|
||||
#include "../PikaStdDevice/pika_hal.h"
|
||||
#include "pika_hal.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static void _IIC_SDA_input(pika_hal_SOFT_IIC_config* iic_cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_IN;
|
||||
pika_hal_ioctl(iic_cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static void _IIC_SDA_output(pika_hal_SOFT_IIC_config* iic_cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_OUT;
|
||||
pika_hal_ioctl(iic_cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static int _GPIO_write(pika_dev* dev, uint32_t val) {
|
||||
return pika_hal_write(dev, &val, sizeof(val));
|
||||
@ -11,11 +24,12 @@ static uint32_t _GPIO_read(pika_dev* dev) {
|
||||
}
|
||||
|
||||
static void _IIC_Delay(void) {
|
||||
// Delay implementation, can be modified based on hardware platform.
|
||||
// You may need to adjust the delay time to match your hardware.
|
||||
pika_sleep_ms(3);
|
||||
}
|
||||
|
||||
static void _IIC_Start(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_debug("iic start");
|
||||
_IIC_SDA_output(cfg);
|
||||
_GPIO_write(cfg->SDA, 1);
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -25,6 +39,8 @@ static void _IIC_Start(pika_hal_SOFT_IIC_config* cfg) {
|
||||
}
|
||||
|
||||
static void _IIC_Stop(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_debug("iic stop");
|
||||
_IIC_SDA_output(cfg);
|
||||
_GPIO_write(cfg->SDA, 0);
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -32,7 +48,9 @@ static void _IIC_Stop(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_IIC_Delay();
|
||||
}
|
||||
|
||||
static void _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
pika_debug(" - iic write: 0x%02X", byte);
|
||||
_IIC_SDA_output(cfg);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
@ -46,11 +64,52 @@ static void _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
|
||||
_IIC_Delay();
|
||||
byte <<= 1;
|
||||
}
|
||||
|
||||
// 在发送完字节后检查ACK信号
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
_IIC_SDA_input(cfg); // 设置SDA为输入
|
||||
_GPIO_write(cfg->SCL, 1); // 将SCL线设置为高,让从设备发送ACK信号
|
||||
|
||||
int timeout = 1000;
|
||||
uint32_t ack = 0;
|
||||
do {
|
||||
_IIC_Delay();
|
||||
ack = !_GPIO_read(cfg->SDA); // 如果从设备发送了ACK信号,SDA线会被拉低
|
||||
} while (ack == 0 && timeout-- > 0);
|
||||
|
||||
// pika_debug("ack timeout:%d", timeout);
|
||||
if (timeout <= 0) {
|
||||
pika_platform_printf("Error: IIC write byte timeout\r\n");
|
||||
}
|
||||
|
||||
_GPIO_write(cfg->SCL, 0); // 将SCL线设置为低,完成一个I2C周期
|
||||
return ack;
|
||||
}
|
||||
|
||||
static void _IIC_Ack(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
_IIC_SDA_output(cfg); // 设置SDA为输出
|
||||
_GPIO_write(cfg->SDA, 0); // 拉低数据线
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 1); // 产生时钟
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
}
|
||||
|
||||
static void _IIC_NAck(pika_hal_SOFT_IIC_config* cfg) {
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
_IIC_SDA_output(cfg); // 设置SDA为输出
|
||||
_GPIO_write(cfg->SDA, 1); // 数据线拉高
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 1); // 产生时钟
|
||||
_IIC_Delay();
|
||||
_GPIO_write(cfg->SCL, 0); // 拉低时钟线
|
||||
}
|
||||
|
||||
static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
|
||||
uint8_t byte = 0;
|
||||
_IIC_SDA_input(cfg);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
_GPIO_write(cfg->SCL, 1);
|
||||
_IIC_Delay();
|
||||
@ -61,77 +120,75 @@ static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
|
||||
_GPIO_write(cfg->SCL, 0);
|
||||
_IIC_Delay();
|
||||
}
|
||||
// 在读取完一个字节后发送ACK信号
|
||||
if (ack) {
|
||||
_IIC_SendByte(cfg, 0xFF);
|
||||
_IIC_Ack(cfg); // 如果ack为真,发送ACK信号
|
||||
} else {
|
||||
_IIC_SendByte(cfg, 0x00);
|
||||
_IIC_NAck(cfg); // 如果ack为假,发送NACK信号
|
||||
}
|
||||
pika_debug(" - iic read: 0x%02X", byte);
|
||||
return byte;
|
||||
}
|
||||
|
||||
static void set_SDA_input(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_IN;
|
||||
pika_hal_ioctl(cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
static void set_SDA_output(pika_hal_SOFT_IIC_config* cfg) {
|
||||
pika_hal_GPIO_config cfg_SDA = {0};
|
||||
cfg_SDA.dir = PIKA_HAL_GPIO_DIR_OUT;
|
||||
pika_hal_ioctl(cfg->SDA, PIKA_HAL_IOCTL_CONFIG, &cfg_SDA);
|
||||
}
|
||||
|
||||
int pika_hal_platform_SOFT_IIC_write(pika_dev* dev, void* buf, size_t count) {
|
||||
pika_hal_SOFT_IIC_config* cfg =
|
||||
pika_hal_SOFT_IIC_config* iic_cfg =
|
||||
(pika_hal_SOFT_IIC_config*)dev->ioctl_config;
|
||||
uint8_t* data = (uint8_t*)buf;
|
||||
set_SDA_output(cfg);
|
||||
_IIC_Start(cfg);
|
||||
|
||||
_IIC_Start(iic_cfg);
|
||||
uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写
|
||||
// pika_debug("iic addr_write: 0x%02X", addr_write);
|
||||
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写
|
||||
|
||||
// 如果启用了mem_addr_ena,将设备地址和内存地址发送到I2C总线
|
||||
if (cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
_IIC_SendByte(cfg, cfg->slave_addr);
|
||||
if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
} else if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(cfg, (cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
} else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(iic_cfg, (iic_cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
_IIC_SendByte(cfg, data[i]);
|
||||
_IIC_SendByte(iic_cfg, data[i]);
|
||||
}
|
||||
_IIC_Stop(cfg);
|
||||
_IIC_Stop(iic_cfg);
|
||||
return count;
|
||||
}
|
||||
|
||||
int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
|
||||
pika_hal_SOFT_IIC_config* cfg =
|
||||
pika_hal_SOFT_IIC_config* iic_cfg =
|
||||
(pika_hal_SOFT_IIC_config*)dev->ioctl_config;
|
||||
uint8_t* data = (uint8_t*)buf;
|
||||
|
||||
_IIC_Start(iic_cfg);
|
||||
|
||||
// 如果启用了mem_addr_ena,先写设备地址和内存地址
|
||||
if (cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
set_SDA_output(cfg);
|
||||
_IIC_Start(cfg);
|
||||
_IIC_SendByte(cfg, cfg->slave_addr);
|
||||
if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
} else if (cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(cfg, (cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(cfg, cfg->mem_addr & 0xFF);
|
||||
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
|
||||
uint8_t addr_write =
|
||||
(iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写
|
||||
// pika_debug("iic addr_write: 0x%02X", addr_write);
|
||||
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写
|
||||
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
} else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
|
||||
_IIC_SendByte(iic_cfg, (iic_cfg->mem_addr >> 8) & 0xFF);
|
||||
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
|
||||
}
|
||||
_IIC_Stop(cfg);
|
||||
_IIC_Start(iic_cfg);
|
||||
}
|
||||
|
||||
set_SDA_input(cfg);
|
||||
_IIC_Start(cfg);
|
||||
uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01; // 方向位为1代表读
|
||||
// pika_debug("iic addr_read: 0x%02X", addr_read);
|
||||
_IIC_SendByte(iic_cfg, addr_read); // 方向位为1代表读
|
||||
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
data[i] = _IIC_ReadByte(cfg, 1);
|
||||
// data[i] = _IIC_ReadByte(iic_cfg, 1);
|
||||
data[i] = _IIC_ReadByte(iic_cfg, 1);
|
||||
}
|
||||
data[count - 1] = _IIC_ReadByte(cfg, 0);
|
||||
_IIC_Stop(cfg);
|
||||
data[count - 1] = _IIC_ReadByte(iic_cfg, 0);
|
||||
_IIC_Stop(iic_cfg);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -4524,9 +4524,11 @@ HEAP_RETURN:
|
||||
LBL(7)
|
||||
LBL(8)
|
||||
LBL(9)
|
||||
LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) LBL(19) LBL(24)
|
||||
LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33) LBL(35) LBL(43)
|
||||
LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52) LBL(53) LBL(54)
|
||||
LBL(10)
|
||||
LBL(11)
|
||||
LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) LBL(19) LBL(24) LBL(25) LBL(26)
|
||||
LBL(27) LBL(29) LBL(31) LBL(33) LBL(35) LBL(43) LBL(47) LBL(48)
|
||||
LBL(49) LBL(50) LBL(51) LBL(52) LBL(53) LBL(54)
|
||||
#ifdef SUPPORT_UTF8
|
||||
LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28)
|
||||
LBL(30) LBL(32) LBL(34) LBL(42) LBL(46)
|
||||
|
@ -2,7 +2,7 @@ import requests
|
||||
|
||||
b = "kkk"
|
||||
|
||||
a = requests.request("GET", "http://pikascript.com/package", params = {"name":"get-test"})
|
||||
a = requests.request("GET", "http://pikapython.com/packages", params = {"name":"get-test"})
|
||||
|
||||
print(a.headers)
|
||||
print(a.content_length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user