mirror of
https://github.com/openappsec/openappsec.git
synced 2025-10-01 20:17:43 +03:00
First release of open-appsec source code
This commit is contained in:
63
components/utils/pm/debugpm.cc
Executable file
63
components/utils/pm/debugpm.cc
Executable file
@@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "debug.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "sasal.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
USE_DEBUG_FLAG(D_PM);
|
||||
|
||||
SASAL_START // Multiple Pattern Matcher
|
||||
// Helper class for printing C format string
|
||||
class CFmtPrinter
|
||||
{
|
||||
public:
|
||||
char buf[500]; // Length limit.
|
||||
explicit CFmtPrinter(const char *fmt, va_list va)
|
||||
{
|
||||
vsnprintf(buf, sizeof(buf), fmt, va);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
}
|
||||
};
|
||||
|
||||
static ostream &
|
||||
operator<<(ostream &os, const CFmtPrinter &p)
|
||||
{
|
||||
return os << p.buf;
|
||||
}
|
||||
|
||||
void
|
||||
panicCFmt(const string &func, uint line, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
Debug("PM", func, line).getStreamAggr() << CFmtPrinter(fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void
|
||||
debugPrtCFmt(const char *func, uint line, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
Debug("PM", func, line, Debug::DebugLevel::TRACE, D_PM).getStreamAggr() << CFmtPrinter(fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
SASAL_END
|
Reference in New Issue
Block a user