From 7b90c51b8fc8a6b74ae9e7c8fa4566ae5a6db419 Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 29 Sep 2005 15:59:52 +0000 Subject: - added support of vfs.file.regmatch and vfs.file.regexp[] (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@2085 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/libs/zbxsysinfo/Makefile.am | 10 +------- src/libs/zbxsysinfo/linux/file.c | 52 -------------------------------------- src/libs/zbxsysinfo/linux/param.c | 5 +++- src/libs/zbxsysinfo/linux/regexp.c | 42 +----------------------------- 4 files changed, 6 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/libs/zbxsysinfo/Makefile.am b/src/libs/zbxsysinfo/Makefile.am index 7b30ba79..c9a5e01b 100644 --- a/src/libs/zbxsysinfo/Makefile.am +++ b/src/libs/zbxsysinfo/Makefile.am @@ -1,14 +1,6 @@ SUBDIRS= -if CONFIG_HOST_LINUX - libzbxsysinfo_a_SOURCES=linux/cpu.c linux/diskio.c linux/diskspace.c linux/file.c linux/inodes.c linux/memory.c linux -/sensors.c linux/swap.c linux/uptime.c sysinfo.c linux/system.c linux/regexp.c linux/param.c -endif - -if CONFIG_HOST_SOLARIS - libzbxsysinfo_a_SOURCES=solaris/cpu.c solaris/diskio.c solaris/diskspace.c solaris/file.c solaris/inodes.c solaris/me -mory.c solaris/sensors.c solaris/swap.c solaris/uptime.c sysinfo.c solaris/system.c -endif +libzbxsysinfo_a_SOURCES=linux/cpu.c linux/diskio.c linux/diskspace.c linux/file.c linux/inodes.c linux/memory.c linux/sensors.c linux/swap.c linux/uptime.c sysinfo.c linux/system.c linux/regexp.c linux/param.c lib_LIBRARIES=libzbxsysinfo.a libzbxsysinfo_a_LIBADD = ../zbxcrypto/libzbxcrypto.a diff --git a/src/libs/zbxsysinfo/linux/file.c b/src/libs/zbxsysinfo/linux/file.c index c040c141..6c1c715d 100644 --- a/src/libs/zbxsysinfo/linux/file.c +++ b/src/libs/zbxsysinfo/linux/file.c @@ -231,55 +231,3 @@ int VFS_FILE_REGEXP(const char *cmd, const char *param, char **value) return ret; } - -char *zbx_regexp_match(const char *string, char *pattern, int *len) -{ - int status; - char *c; - - regex_t re; - regmatch_t match; - - char c[1024]; - - *len=0; - - if (regcomp(&re, pattern, REG_EXTENDED | REG_ICASE | REG_NEWLINE) != 0) - { - return(NULL); - } - - status = regexec(&re, string, (size_t) 1, &match, 0); - - /* Not matched */ - if (status != 0) - { - return(NULL); - } - - c=string+match.rm_so; - *len=match.rm_eo - match.rm_so; - - regfree(&re); - - return c; -} - - - - - - - - - - - - - - return ret; -} - -int VFS_FILE_REGMATCH(const char *cmd, const char *filename,double *value) -{ -} diff --git a/src/libs/zbxsysinfo/linux/param.c b/src/libs/zbxsysinfo/linux/param.c index cb2803d5..ed470d9d 100644 --- a/src/libs/zbxsysinfo/linux/param.c +++ b/src/libs/zbxsysinfo/linux/param.c @@ -17,9 +17,12 @@ ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ +#include "common.h" #include "config.h" -int get_param(char *param, int num, char *buf, int maxlen) +#include + +int get_param(const char *param, int num, char *buf, int maxlen) { char tmp[MAX_STRING_LEN]; char *s; diff --git a/src/libs/zbxsysinfo/linux/regexp.c b/src/libs/zbxsysinfo/linux/regexp.c index 1f8661bf..a25e5b1f 100644 --- a/src/libs/zbxsysinfo/linux/regexp.c +++ b/src/libs/zbxsysinfo/linux/regexp.c @@ -10,45 +10,7 @@ #define MAX_FILE_LEN 1024*1024 -int main (int argc, char *argv[]){ - - int x; - FILE *f; - char *buf; - - f=fopen(argv[1],"r"); - if(f==NULL) - { - printf("Error fopen(%s)\n", strerror(errno)); - return 0; - } - - buf=(char *)malloc((size_t)100); - - memset(buf,0,100); - - x=fread(buf, 1, 100, f); - - if(x==0) - { - printf("Error fread(%s)\n", strerror(errno)); - } - - printf("Read [%d] bytes\n", x); - - - - x = match(buf, argv[2]); - - if ( x == 1 ){ - - printf("\n\n Match \n\n"); - } - - return(0); -} - -char *zbx_regexp_match(const char *string, char *pattern, int *len) +char *zbx_regexp_match(const char *string, const char *pattern, int *len) { int status; char *c; @@ -56,8 +18,6 @@ char *zbx_regexp_match(const char *string, char *pattern, int *len) regex_t re; regmatch_t match; - char c[1024]; - *len=0; if (regcomp(&re, pattern, REG_EXTENDED | REG_ICASE | REG_NEWLINE) != 0) -- cgit