X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_regex%2Fexamples%2Fregex_str.c;h=8def8acfe2d2b0325db7a17e66e8e4c1c4b9bc9c;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=c28346fcd1a2f26f1ca3b154f9d582bc0d14d1a3;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/os_regex/examples/regex_str.c b/src/os_regex/examples/regex_str.c old mode 100755 new mode 100644 index c28346f..8def8ac --- a/src/os_regex/examples/regex_str.c +++ b/src/os_regex/examples/regex_str.c @@ -2,74 +2,67 @@ * Under the public domain. It is just an example. * Some examples of usage for the os_regex library. */ - + #include #include #include - -/* Must be included */ + #include "os_regex.h" -int main(int argc,char **argv) + +int main(int argc, char **argv) { int r_code = 0; - char **ret; /* OSRegex structure */ OSRegex reg; - - /* checking for arguments */ - if(argc != 3) - { - printf("%s regex string\n",argv[0]); + + /* Check for arguments */ + if (argc != 3) { + printf("%s regex string\n", argv[0]); exit(1); } - /* If the compilation failed, we don't need to free anything. - * We are passing the OS_RETURN_SUBSTRING because we wan't the + * We are passing the OS_RETURN_SUBSTRING because we want the * substrings back. */ - if(OSRegex_Compile(argv[1], ®, OS_RETURN_SUBSTRING)) - { - char *retv; - /* If the execution succeeds, the substrings will be + if (OSRegex_Compile(argv[1], ®, OS_RETURN_SUBSTRING)) { + const char *retv; + /* If the execution succeeds, the substrings will be * at reg.sub_strings */ - if((retv = OSRegex_Execute(argv[2], ®))) - { + if ((retv = OSRegex_Execute(argv[2], ®))) { int sub_size = 0; + char **ret; r_code = 1; - /* next pt */ + /* Next pt */ printf("next pt: '%s'\n", retv); - /* Assigning reg.sub_strings to ret */ + /* Assign reg.sub_strings to ret */ ret = reg.sub_strings; - + printf("substrings:\n"); - while(*ret) - { + while (*ret) { printf(" %d: !%s!\n", sub_size, *ret); - sub_size++; ret++; + sub_size++; + ret++; } /* We must free the substrings */ OSRegex_FreeSubStrings(®); - } - else - { + } else { printf("Error: Didn't match.\n"); } OSRegex_FreePattern(®); } - + /* Compilation error */ - else - { + else { printf("Error: Regex Compile Error: %d\n", reg.error); } - - return(r_code); + + return (r_code); } -/* EOF */ +