82 static int SCLogAddFGFilter(
const char *file,
const char *
function,
83 int line,
int listtype)
97 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
98 "first before using the debug API\n");
102 if (file == NULL &&
function == NULL && line < 0) {
103 printf(
"Error: Invalid arguments supplied to SCLogAddFGFilter\n");
107 SCMutex *
m = &sc_log_fg_filters_m[listtype];
113 prev_fgf_file = fgf_file;
114 while (fgf_file != NULL) {
115 prev_fgf_file = fgf_file;
116 if (file == NULL && fgf_file->
file == NULL)
118 else if (file != NULL && fgf_file->
file != NULL)
119 found = (strcmp(file, fgf_file->
file) == 0);
126 fgf_file = fgf_file->
next;
135 fgf_func = fgf_file->
func;
136 prev_fgf_func = fgf_func;
137 while (fgf_func != NULL) {
138 prev_fgf_func = fgf_func;
139 if (
function == NULL && fgf_func->
func == NULL)
141 else if (
function != NULL && fgf_func->
func != NULL)
142 found = (strcmp(
function, fgf_func->
func) == 0);
149 fgf_func = fgf_func->
next;
158 fgf_line = fgf_func->
line;
159 prev_fgf_line = fgf_line;
160 while(fgf_line != NULL) {
161 prev_fgf_line = fgf_line;
162 if (line == fgf_line->
line) {
167 fgf_line = fgf_line->
next;
198 static int SCLogMatchFGFilter(
const char *file,
const char *
function,
int line,
207 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
208 "first before using the debug API\n");
216 if (fgf_file == NULL) {
221 while(fgf_file != NULL) {
224 match &= (fgf_file->
file != NULL)? !strcmp(file, fgf_file->
file): 1;
227 fgf_file = fgf_file->
next;
231 fgf_func = fgf_file->
func;
232 while (fgf_func != NULL) {
235 match &= (fgf_func->
func != NULL)? !strcmp(
function, fgf_func->
func): 1;
238 fgf_func = fgf_func->
next;
242 fgf_line = fgf_func->
line;
243 while (fgf_line != NULL) {
246 match &= (fgf_line->
line != -1)? (line == fgf_line->
line): 1;
251 fgf_line = fgf_line->
next;
257 fgf_func = fgf_func->
next;
268 fgf_file = fgf_file->
next;
371 while (fgf_file != NULL) {
373 fgf_func = fgf_file->
func;
374 while (fgf_func != NULL) {
376 fgf_line = fgf_func->
line;
377 while(fgf_line != NULL) {
379 fgf_line = fgf_line->
next;
383 if (fgf_func->
func != NULL)
386 fgf_func = fgf_func->
next;
390 if (fgf_file->
file != NULL)
393 fgf_file = fgf_file->
next;
419 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
420 "first before using the debug API\n");
425 printf(
"Fine grained filters:\n");
432 while (fgf_file != NULL) {
434 fgf_func = fgf_file->
func;
435 while (fgf_func != NULL) {
437 fgf_line = fgf_func->
line;
438 while(fgf_line != NULL) {
440 printf(
"%s - ", fgf_file->
file);
441 printf(
"%s - ", fgf_func->
func);
442 printf(
"%d\n", fgf_line->
line);
447 fgf_line = fgf_line->
next;
450 fgf_func = fgf_func->
next;
453 fgf_file = fgf_file->
next;
484 pthread_t
self = pthread_self();
487 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
488 "first before using the debug API\n");
494 if (sc_log_fd_filters_tl == NULL) {
496 if (sc_log_fd_filters != NULL)
501 thread_list = sc_log_fd_filters_tl;
502 while (thread_list != NULL) {
503 if (pthread_equal(
self, thread_list->
t)) {
504 if (thread_list->
entered > 0) {
512 thread_list = thread_list->
next;
538 pthread_t
self = pthread_self();
541 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
542 "first before using the debug API\n");
548 curr = sc_log_fd_filters;
550 while (curr != NULL) {
551 if (strcmp(
function, curr->
func) == 0)
566 thread_list = sc_log_fd_filters_tl;
567 while (thread_list != NULL) {
568 if (pthread_equal(
self, thread_list->
t))
571 thread_list = thread_list->
next;
574 if (thread_list != NULL) {
586 thread_list_temp->
t =
self;
589 sc_log_fd_filters_tl = thread_list_temp;
611 pthread_t
self = pthread_self();
614 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
615 "first before using the debug API\n");
621 curr = sc_log_fd_filters;
623 while (curr != NULL) {
624 if (strcmp(
function, curr->
func) == 0)
639 thread_list = sc_log_fd_filters_tl;
640 while (thread_list != NULL) {
641 if (pthread_equal(
self, thread_list->
t))
644 thread_list = thread_list->
next;
649 if (thread_list != NULL)
670 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
671 "first before using the debug API\n");
675 if (
function == NULL) {
676 printf(
"Invalid argument supplied to SCLogAddFDFilter\n");
682 curr = sc_log_fd_filters;
683 while (curr != NULL) {
686 if (strcmp(
function, curr->
func) == 0) {
696 printf(
"Error Allocating memory (SCMalloc)\n");
702 printf(
"Error Allocating memory (SCStrdup)\n");
706 if (sc_log_fd_filters == NULL)
707 sc_log_fd_filters = temp;
711 else if (prev != NULL)
730 fdf = sc_log_fd_filters;
731 while (fdf != NULL) {
737 sc_log_fd_filters = NULL;
758 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
759 "first before using the debug API\n");
763 if (
function == NULL) {
764 printf(
"Invalid argument(s) supplied to SCLogRemoveFDFilter\n");
770 if (sc_log_fd_filters == NULL) {
775 curr = sc_log_fd_filters;
777 while (curr != NULL) {
778 if (strcmp(
function, curr->
func) == 0)
792 if (sc_log_fd_filters == curr)
793 sc_log_fd_filters = curr->
next;
801 if (sc_log_fd_filters == NULL)
818 printf(
"Logging module not initialized. Call SCLogInitLogModule() "
819 "first before using the debug API\n");
824 printf(
"FD filters:\n");
829 fdf = sc_log_fd_filters;
830 while (fdf != NULL) {
832 printf(
"%s \n", fdf->
func);
858 const char *
function,
int line,
867 "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
871 if ( file != NULL && (fgf_file_temp->
file =
SCStrdup(file)) == NULL) {
872 printf(
"Error Allocating memory\n");
878 "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
882 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
883 printf(
"Error Allocating memory\n");
889 "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
893 fgf_line_temp->
line = line;
896 fgf_func_temp->
line = fgf_line_temp;
898 fgf_file_temp->
func = fgf_func_temp;
900 if (fgf_file == NULL)
903 fgf_file->
next = fgf_file_temp;
924 const char *
function,
int line)
931 "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
935 if (
function != NULL && (fgf_func_temp->
func =
SCStrdup(
function)) == NULL) {
936 printf(
"Error Allocating memory\n");
942 "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
946 fgf_line_temp->
line = line;
949 fgf_func_temp->
line = fgf_line_temp;
951 if (fgf_func == NULL)
952 fgf_file->
func = fgf_func_temp;
954 fgf_func->
next = fgf_func_temp;
980 "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
984 fgf_line_temp->
line = line;
987 if (fgf_line == NULL)
988 fgf_func->
line = fgf_line_temp;
990 fgf_line->
next = fgf_line_temp;
1003 if (fdf->
func != NULL)