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;
400 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
401 "first before using the debug API\n");
406 printf(
"Fine grained filters:\n");
413 while (fgf_file != NULL) {
415 fgf_func = fgf_file->
func;
416 while (fgf_func != NULL) {
418 fgf_line = fgf_func->
line;
419 while(fgf_line != NULL) {
421 printf(
"%s - ", fgf_file->
file);
422 printf(
"%s - ", fgf_func->
func);
423 printf(
"%d\n", fgf_line->
line);
428 fgf_line = fgf_line->
next;
431 fgf_func = fgf_func->
next;
434 fgf_file = fgf_file->
next;
465 pthread_t
self = pthread_self();
468 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
469 "first before using the debug API\n");
475 if (sc_log_fd_filters_tl == NULL) {
477 if (sc_log_fd_filters != NULL)
482 thread_list = sc_log_fd_filters_tl;
483 while (thread_list != NULL) {
484 if (pthread_equal(
self, thread_list->
t)) {
485 if (thread_list->
entered > 0) {
493 thread_list = thread_list->
next;
519 pthread_t
self = pthread_self();
522 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
523 "first before using the debug API\n");
529 curr = sc_log_fd_filters;
531 while (curr != NULL) {
532 if (strcmp(
function, curr->
func) == 0)
547 thread_list = sc_log_fd_filters_tl;
548 while (thread_list != NULL) {
549 if (pthread_equal(
self, thread_list->
t))
552 thread_list = thread_list->
next;
555 if (thread_list != NULL) {
566 thread_list_temp->
t =
self;
569 sc_log_fd_filters_tl = thread_list_temp;
591 pthread_t
self = pthread_self();
594 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
595 "first before using the debug API\n");
601 curr = sc_log_fd_filters;
603 while (curr != NULL) {
604 if (strcmp(
function, curr->
func) == 0)
619 thread_list = sc_log_fd_filters_tl;
620 while (thread_list != NULL) {
621 if (pthread_equal(
self, thread_list->
t))
624 thread_list = thread_list->
next;
629 if (thread_list != NULL)
650 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
651 "first before using the debug API\n");
655 if (
function == NULL) {
656 printf(
"Invalid argument supplied to SCLogAddFDFilter\n");
662 curr = sc_log_fd_filters;
663 while (curr != NULL) {
666 if (strcmp(
function, curr->
func) == 0) {
676 printf(
"Error Allocating memory (SCCalloc)\n");
681 printf(
"Error Allocating memory (SCStrdup)\n");
685 if (sc_log_fd_filters == NULL)
686 sc_log_fd_filters = temp;
690 else if (prev != NULL)
709 fdf = sc_log_fd_filters;
710 while (fdf != NULL) {
716 sc_log_fd_filters = NULL;
737 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
738 "first before using the debug API\n");
742 if (
function == NULL) {
743 printf(
"Invalid argument(s) supplied to SCLogRemoveFDFilter\n");
749 if (sc_log_fd_filters == NULL) {
754 curr = sc_log_fd_filters;
756 while (curr != NULL) {
757 if (strcmp(
function, curr->
func) == 0)
771 if (sc_log_fd_filters == curr)
772 sc_log_fd_filters = curr->
next;
780 if (sc_log_fd_filters == NULL)
797 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
798 "first before using the debug API\n");
803 printf(
"FD filters:\n");
808 fdf = sc_log_fd_filters;
809 while (fdf != NULL) {
811 printf(
"%s \n", fdf->
func);
837 const char *
function,
int line,
845 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
848 if ( file != NULL && (fgf_file_temp->
file =
SCStrdup(file)) == NULL) {
849 printf(
"Error Allocating memory\n");
854 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
857 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
858 printf(
"Error Allocating memory\n");
863 FatalError(
"Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
866 fgf_line_temp->
line = line;
869 fgf_func_temp->
line = fgf_line_temp;
871 fgf_file_temp->
func = fgf_func_temp;
873 if (fgf_file == NULL)
876 fgf_file->
next = fgf_file_temp;
897 const char *
function,
int line)
903 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
906 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
907 printf(
"Error Allocating memory\n");
912 FatalError(
"Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
915 fgf_line_temp->
line = line;
918 fgf_func_temp->
line = fgf_line_temp;
920 if (fgf_func == NULL)
921 fgf_file->
func = fgf_func_temp;
923 fgf_func->
next = fgf_func_temp;
948 FatalError(
"Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
951 fgf_line_temp->
line = line;
954 if (fgf_line == NULL)
955 fgf_func->
line = fgf_line_temp;
957 fgf_line->
next = fgf_line_temp;
970 if (fdf->
func != NULL)