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;
373 while (fgf_file != NULL) {
375 fgf_func = fgf_file->
func;
376 while (fgf_func != NULL) {
378 fgf_line = fgf_func->
line;
379 while(fgf_line != NULL) {
381 fgf_line = fgf_line->
next;
385 if (fgf_func->
func != NULL)
388 fgf_func = fgf_func->
next;
392 if (fgf_file->
file != NULL)
395 fgf_file = fgf_file->
next;
421 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
422 "first before using the debug API\n");
427 printf(
"Fine grained filters:\n");
434 while (fgf_file != NULL) {
436 fgf_func = fgf_file->
func;
437 while (fgf_func != NULL) {
439 fgf_line = fgf_func->
line;
440 while(fgf_line != NULL) {
442 printf(
"%s - ", fgf_file->
file);
443 printf(
"%s - ", fgf_func->
func);
444 printf(
"%d\n", fgf_line->
line);
449 fgf_line = fgf_line->
next;
452 fgf_func = fgf_func->
next;
455 fgf_file = fgf_file->
next;
486 pthread_t
self = pthread_self();
489 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
490 "first before using the debug API\n");
496 if (sc_log_fd_filters_tl == NULL) {
498 if (sc_log_fd_filters != NULL)
503 thread_list = sc_log_fd_filters_tl;
504 while (thread_list != NULL) {
505 if (pthread_equal(
self, thread_list->
t)) {
506 if (thread_list->
entered > 0) {
514 thread_list = thread_list->
next;
540 pthread_t
self = pthread_self();
543 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
544 "first before using the debug API\n");
550 curr = sc_log_fd_filters;
552 while (curr != NULL) {
553 if (strcmp(
function, curr->
func) == 0)
568 thread_list = sc_log_fd_filters_tl;
569 while (thread_list != NULL) {
570 if (pthread_equal(
self, thread_list->
t))
573 thread_list = thread_list->
next;
576 if (thread_list != NULL) {
588 thread_list_temp->
t =
self;
591 sc_log_fd_filters_tl = thread_list_temp;
613 pthread_t
self = pthread_self();
616 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
617 "first before using the debug API\n");
623 curr = sc_log_fd_filters;
625 while (curr != NULL) {
626 if (strcmp(
function, curr->
func) == 0)
641 thread_list = sc_log_fd_filters_tl;
642 while (thread_list != NULL) {
643 if (pthread_equal(
self, thread_list->
t))
646 thread_list = thread_list->
next;
651 if (thread_list != NULL)
672 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
673 "first before using the debug API\n");
677 if (
function == NULL) {
678 printf(
"Invalid argument supplied to SCLogAddFDFilter\n");
684 curr = sc_log_fd_filters;
685 while (curr != NULL) {
688 if (strcmp(
function, curr->
func) == 0) {
698 printf(
"Error Allocating memory (SCMalloc)\n");
704 printf(
"Error Allocating memory (SCStrdup)\n");
708 if (sc_log_fd_filters == NULL)
709 sc_log_fd_filters = temp;
713 else if (prev != NULL)
732 fdf = sc_log_fd_filters;
733 while (fdf != NULL) {
739 sc_log_fd_filters = NULL;
760 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
761 "first before using the debug API\n");
765 if (
function == NULL) {
766 printf(
"Invalid argument(s) supplied to SCLogRemoveFDFilter\n");
772 if (sc_log_fd_filters == NULL) {
777 curr = sc_log_fd_filters;
779 while (curr != NULL) {
780 if (strcmp(
function, curr->
func) == 0)
794 if (sc_log_fd_filters == curr)
795 sc_log_fd_filters = curr->
next;
803 if (sc_log_fd_filters == NULL)
820 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
821 "first before using the debug API\n");
826 printf(
"FD filters:\n");
831 fdf = sc_log_fd_filters;
832 while (fdf != NULL) {
834 printf(
"%s \n", fdf->
func);
860 const char *
function,
int line,
868 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
872 if ( file != NULL && (fgf_file_temp->
file =
SCStrdup(file)) == NULL) {
873 printf(
"Error Allocating memory\n");
878 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
882 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
883 printf(
"Error Allocating memory\n");
888 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
892 fgf_line_temp->
line = line;
895 fgf_func_temp->
line = fgf_line_temp;
897 fgf_file_temp->
func = fgf_func_temp;
899 if (fgf_file == NULL)
902 fgf_file->
next = fgf_file_temp;
923 const char *
function,
int line)
929 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
933 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
934 printf(
"Error Allocating memory\n");
939 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
943 fgf_line_temp->
line = line;
946 fgf_func_temp->
line = fgf_line_temp;
948 if (fgf_func == NULL)
949 fgf_file->
func = fgf_func_temp;
951 fgf_func->
next = fgf_func_temp;
976 FatalError(
"Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
980 fgf_line_temp->
line = line;
983 if (fgf_line == NULL)
984 fgf_func->
line = fgf_line_temp;
986 fgf_line->
next = fgf_line_temp;
999 if (fdf->
func != NULL)