Browse code

general code clean-up and adjustments

Kevin Lin authored on 2014/09/24 02:43:55
Showing 4 changed files
... ...
@@ -1359,9 +1359,9 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
1359 1359
 				    if(res) {
1360 1360
 					newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result));
1361 1361
 					if(!newres) {
1362
-                        cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result));
1362
+					    cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", (unsigned long)sizeof(struct cli_ac_result));
1363 1363
 					    return CL_EMEM;
1364
-                    }
1364
+					}
1365 1365
 					newres->virname = pt->virname;
1366 1366
 					newres->customdata = pt->customdata;
1367 1367
 					newres->next = *res;
... ...
@@ -1412,9 +1412,9 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
1412 1412
 				if(res) {
1413 1413
 				    newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result));
1414 1414
 				    if(!newres) {
1415
-                        cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result));
1416
-                        return CL_EMEM;
1417
-                    }
1415
+					cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", (unsigned long)sizeof(struct cli_ac_result));
1416
+					return CL_EMEM;
1417
+				    }
1418 1418
 				    newres->virname = pt->virname;
1419 1419
 				    newres->customdata = pt->customdata;
1420 1420
 				    newres->offset = realoff;
... ...
@@ -336,7 +336,7 @@ int cli_pcre_addpatt(struct cli_matcher *root, const char *trigger, const char *
336 336
     return CL_SUCCESS;
337 337
 }
338 338
 
339
- int cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf)
339
+int cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf)
340 340
 {
341 341
     unsigned int i;
342 342
     int ret;
... ...
@@ -45,24 +45,6 @@ int cli_pcre_init()
45 45
     return CL_SUCCESS;
46 46
 }
47 47
 
48
-/* TODO: function is kinda pointless, remove or rework? */
49
-int cli_pcre_parse(struct cli_pcre_data *pd, const char *pattern)
50
-{
51
-    if (!pd || !pattern) {
52
-        cli_errmsg("cli_pcre_parse: NULL pd or NULL pattern\n");
53
-        return CL_ENULLARG;
54
-    }
55
-
56
-    /* copy expression to struct cli_pcre_data */
57
-    pd->expression = cli_strdup(pattern);
58
-    if (!(pd->expression)) {
59
-        cli_errmsg("cli_pcre_parse: Unable to allocate memory\n");
60
-        return CL_EMEM;
61
-    }
62
-
63
-    return CL_SUCCESS;
64
-}
65
-
66 48
 int cli_pcre_addoptions(struct cli_pcre_data *pd, const char **opt, int errout)
67 49
 {
68 50
     if (!pd || !opt || !(*opt))
... ...
@@ -48,7 +48,7 @@ struct cli_pcre_data {
48 48
     uint32_t search_offset; /* start offset to search at for pcre_exec */
49 49
 };
50 50
 
51
-int cli_pcre_parse(struct cli_pcre_data *pd, const char *pattern);
51
+int cli_pcre_init();
52 52
 int cli_pcre_addoptions(struct cli_pcre_data *pd, const char **opt, int errout);
53 53
 int cli_pcre_compile(struct cli_pcre_data *pd, long long unsigned match_limit, long long unsigned match_limit_recursion, unsigned int options, int opt_override);
54 54
 int cli_pcre_match(struct cli_pcre_data *pd, const unsigned char *buffer, uint32_t buflen, int override_offset, int options, int *ovector, size_t ovlen);