84 static int SCLogAddFGFilter(
const char *file,
const char *
function,
85 int line,
int listtype)
99 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
100 "first before using the debug API\n");
104 if (file == NULL &&
function == NULL && line < 0) {
105 printf(
"Error: Invalid arguments supplied to SCLogAddFGFilter\n");
109 SCMutex *
m = &sc_log_fg_filters_m[listtype];
115 prev_fgf_file = fgf_file;
116 while (fgf_file != NULL) {
117 prev_fgf_file = fgf_file;
118 if (file == NULL && fgf_file->
file == NULL)
120 else if (file != NULL && fgf_file->
file != NULL)
121 found = (strcmp(file, fgf_file->
file) == 0);
128 fgf_file = fgf_file->
next;
137 fgf_func = fgf_file->
func;
138 prev_fgf_func = fgf_func;
139 while (fgf_func != NULL) {
140 prev_fgf_func = fgf_func;
141 if (
function == NULL && fgf_func->
func == NULL)
143 else if (
function != NULL && fgf_func->
func != NULL)
144 found = (strcmp(
function, fgf_func->
func) == 0);
151 fgf_func = fgf_func->
next;
160 fgf_line = fgf_func->
line;
161 prev_fgf_line = fgf_line;
162 while(fgf_line != NULL) {
163 prev_fgf_line = fgf_line;
164 if (line == fgf_line->
line) {
169 fgf_line = fgf_line->
next;
200 static int SCLogMatchFGFilter(
const char *file,
const char *
function,
int line,
209 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
210 "first before using the debug API\n");
218 if (fgf_file == NULL) {
223 while(fgf_file != NULL) {
226 match &= (fgf_file->
file != NULL)? !strcmp(file, fgf_file->
file): 1;
229 fgf_file = fgf_file->
next;
233 fgf_func = fgf_file->
func;
234 while (fgf_func != NULL) {
237 match &= (fgf_func->
func != NULL)? !strcmp(
function, fgf_func->
func): 1;
240 fgf_func = fgf_func->
next;
244 fgf_line = fgf_func->
line;
245 while (fgf_line != NULL) {
248 match &= (fgf_line->
line != -1)? (line == fgf_line->
line): 1;
253 fgf_line = fgf_line->
next;
259 fgf_func = fgf_func->
next;
270 fgf_file = fgf_file->
next;
352 while (fgf_file != NULL) {
354 fgf_func = fgf_file->
func;
355 while (fgf_func != NULL) {
357 fgf_line = fgf_func->
line;
358 while(fgf_line != NULL) {
360 fgf_line = fgf_line->
next;
364 if (fgf_func->
func != NULL)
367 fgf_func = fgf_func->
next;
371 if (fgf_file->
file != NULL)
374 fgf_file = fgf_file->
next;
398 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
399 "first before using the debug API\n");
404 printf(
"Fine grained filters:\n");
411 while (fgf_file != NULL) {
413 fgf_func = fgf_file->
func;
414 while (fgf_func != NULL) {
416 fgf_line = fgf_func->
line;
417 while(fgf_line != NULL) {
419 printf(
"%s - ", fgf_file->
file);
420 printf(
"%s - ", fgf_func->
func);
421 printf(
"%d\n", fgf_line->
line);
426 fgf_line = fgf_line->
next;
429 fgf_func = fgf_func->
next;
432 fgf_file = fgf_file->
next;
463 pthread_t
self = pthread_self();
466 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
467 "first before using the debug API\n");
473 if (sc_log_fd_filters_tl == NULL) {
475 if (sc_log_fd_filters != NULL)
480 thread_list = sc_log_fd_filters_tl;
481 while (thread_list != NULL) {
482 if (pthread_equal(
self, thread_list->
t)) {
483 if (thread_list->
entered > 0) {
491 thread_list = thread_list->
next;
517 pthread_t
self = pthread_self();
520 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
521 "first before using the debug API\n");
527 curr = sc_log_fd_filters;
529 while (curr != NULL) {
530 if (strcmp(
function, curr->
func) == 0)
545 thread_list = sc_log_fd_filters_tl;
546 while (thread_list != NULL) {
547 if (pthread_equal(
self, thread_list->
t))
550 thread_list = thread_list->
next;
553 if (thread_list != NULL) {
564 thread_list_temp->
t =
self;
567 sc_log_fd_filters_tl = thread_list_temp;
589 pthread_t
self = pthread_self();
592 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
593 "first before using the debug API\n");
599 curr = sc_log_fd_filters;
601 while (curr != NULL) {
602 if (strcmp(
function, curr->
func) == 0)
617 thread_list = sc_log_fd_filters_tl;
618 while (thread_list != NULL) {
619 if (pthread_equal(
self, thread_list->
t))
622 thread_list = thread_list->
next;
627 if (thread_list != NULL)
646 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
647 "first before using the debug API\n");
651 if (
function == NULL) {
652 printf(
"Invalid argument supplied to SCLogAddFDFilter\n");
658 curr = sc_log_fd_filters;
659 while (curr != NULL) {
662 if (strcmp(
function, curr->
func) == 0) {
672 printf(
"Error Allocating memory (SCCalloc)\n");
677 printf(
"Error Allocating memory (SCStrdup)\n");
681 if (sc_log_fd_filters == NULL)
682 sc_log_fd_filters = temp;
686 else if (prev != NULL)
705 fdf = sc_log_fd_filters;
706 while (fdf != NULL) {
712 sc_log_fd_filters = NULL;
731 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
732 "first before using the debug API\n");
736 if (
function == NULL) {
737 printf(
"Invalid argument(s) supplied to SCLogRemoveFDFilter\n");
743 if (sc_log_fd_filters == NULL) {
748 curr = sc_log_fd_filters;
750 while (curr != NULL) {
751 if (strcmp(
function, curr->
func) == 0)
765 if (sc_log_fd_filters == curr)
766 sc_log_fd_filters = curr->
next;
774 if (sc_log_fd_filters == NULL)
791 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
792 "first before using the debug API\n");
797 printf(
"FD filters:\n");
802 fdf = sc_log_fd_filters;
803 while (fdf != NULL) {
805 printf(
"%s \n", fdf->
func);
831 const char *
function,
int line,
839 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
842 if ( file != NULL && (fgf_file_temp->
file =
SCStrdup(file)) == NULL) {
843 printf(
"Error Allocating memory\n");
848 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
851 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
852 printf(
"Error Allocating memory\n");
857 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
860 fgf_line_temp->
line = line;
863 fgf_func_temp->
line = fgf_line_temp;
865 fgf_file_temp->
func = fgf_func_temp;
867 if (fgf_file == NULL)
870 fgf_file->
next = fgf_file_temp;
889 const char *
function,
int line)
895 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
898 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
899 printf(
"Error Allocating memory\n");
904 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
907 fgf_line_temp->
line = line;
910 fgf_func_temp->
line = fgf_line_temp;
912 if (fgf_func == NULL)
913 fgf_file->
func = fgf_func_temp;
915 fgf_func->
next = fgf_func_temp;
938 FatalError(
"Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
941 fgf_line_temp->
line = line;
944 if (fgf_line == NULL)
945 fgf_func->
line = fgf_line_temp;
947 fgf_line->
next = fgf_line_temp;
958 if (fdf->
func != NULL)