mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-03-20 23:02:08 -04:00
Removed as renamed or reincoporated.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@416 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
150
src/jmemdst.c
150
src/jmemdst.c
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* ZoneMinder JPEG memory encoding, $Date$, $Revision$
|
||||
* Copyright (C) 2003 Philip Coombes
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jerror.h"
|
||||
|
||||
/* Expanded data destination object for memory */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_destination_mgr pub; /* public fields */
|
||||
|
||||
JOCTET *outbuffer; /* target buffer */
|
||||
int *outbuffer_size;
|
||||
JOCTET *buffer; /* start of buffer */
|
||||
} mem_destination_mgr;
|
||||
|
||||
typedef mem_destination_mgr * mem_dest_ptr;
|
||||
|
||||
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
||||
|
||||
|
||||
/*
|
||||
* Initialize destination --- called by jpeg_start_compress
|
||||
* before any data is actually written.
|
||||
*/
|
||||
|
||||
static void
|
||||
init_destination (j_compress_ptr cinfo)
|
||||
{
|
||||
mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
|
||||
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
|
||||
*(dest->outbuffer_size) = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Empty the output buffer --- called whenever buffer fills up.
|
||||
*
|
||||
* In typical applications, this should write the entire output buffer
|
||||
* (ignoring the current state of next_output_byte & free_in_buffer),
|
||||
* reset the pointer & count to the start of the buffer, and return TRUE
|
||||
* indicating that the buffer has been dumped.
|
||||
*
|
||||
* In applications that need to be able to suspend compression due to output
|
||||
* overrun, a FALSE return indicates that the buffer cannot be emptied now.
|
||||
* In this situation, the compressor will return to its caller (possibly with
|
||||
* an indication that it has not accepted all the supplied scanlines). The
|
||||
* application should resume compression after it has made more room in the
|
||||
* output buffer. Note that there are substantial restrictions on the use of
|
||||
* suspension --- see the documentation.
|
||||
*
|
||||
* When suspending, the compressor will back up to a convenient restart point
|
||||
* (typically the start of the current MCU). next_output_byte & free_in_buffer
|
||||
* indicate where the restart point will be if the current call returns FALSE.
|
||||
* Data beyond this point will be regenerated after resumption, so do not
|
||||
* write it out when emptying the buffer externally.
|
||||
*/
|
||||
|
||||
static boolean
|
||||
empty_output_buffer (j_compress_ptr cinfo)
|
||||
{
|
||||
mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
|
||||
|
||||
memcpy( dest->outbuffer+*(dest->outbuffer_size), dest->buffer, OUTPUT_BUF_SIZE );
|
||||
*(dest->outbuffer_size) += OUTPUT_BUF_SIZE;
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Terminate destination --- called by jpeg_finish_compress
|
||||
* after all data has been written. Usually needs to flush buffer.
|
||||
*
|
||||
* NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
|
||||
* application must deal with any cleanup that should happen even
|
||||
* for error exit.
|
||||
*/
|
||||
|
||||
static void
|
||||
term_destination (j_compress_ptr cinfo)
|
||||
{
|
||||
mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
|
||||
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
||||
|
||||
if (datacount > 0) {
|
||||
memcpy( dest->outbuffer+*(dest->outbuffer_size), dest->buffer, datacount );
|
||||
*(dest->outbuffer_size) += datacount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Prepare for output to a stdio stream.
|
||||
* The caller must have already opened the stream, and is responsible
|
||||
* for closing it after finishing compression.
|
||||
*/
|
||||
|
||||
void
|
||||
jpeg_mem_dest (j_compress_ptr cinfo, JOCTET *outbuffer, int *outbuffer_size )
|
||||
{
|
||||
mem_dest_ptr dest;
|
||||
|
||||
/* The destination object is made permanent so that multiple JPEG images
|
||||
* can be written to the same file without re-executing jpeg_stdio_dest.
|
||||
* This makes it dangerous to use this manager and a different destination
|
||||
* manager serially with the same JPEG object, because their private object
|
||||
* sizes may be different. Caveat programmer.
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(mem_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (mem_dest_ptr) cinfo->dest;
|
||||
dest->pub.init_destination = init_destination;
|
||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||
dest->pub.term_destination = term_destination;
|
||||
dest->outbuffer = outbuffer;
|
||||
dest->outbuffer_size = outbuffer_size;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// ZoneMinder Configuration, $Date$, $Revision$
|
||||
// Copyright (C) 2003 Philip Coombes
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define ZM_DB_SERVER "<from zmconfig>" // Machine on which the database server is running (from zmconfig)
|
||||
#define ZM_DB_NAME "<from zmconfig>" // Database containing the tables (from zmconfig)
|
||||
#define ZM_DB_USERA "<from zmconfig>" // Privileged DB user name, needs at least select, insert, update and delete privileges (from zmconfig)
|
||||
#define ZM_DB_PASSA "<from zmconfig>" // Privileged DB user password (from zmconfig)
|
||||
#define ZM_DB_USERB "<from zmconfig>" // Unprivileged DB user name, need just select privilege. (from zmconfig)
|
||||
#define ZM_DB_PASSB "<from zmconfig>" // Unprivileged DB user password (from zmconfig)
|
||||
|
||||
#define ZM_SHM_KEY <from zmconfig> // Shared memory key to use, only change if it clashes with another application (from zmconfig)
|
||||
|
||||
#define ZM_DIR_EVENTS "<from zmconfig>" // Local path to where events directory lives (from zmconfig)
|
||||
|
||||
#define ZM_FORCED_ALARM_SCORE <from zmconfig> // Score to give X10 forced alarms (from zmconfig)
|
||||
|
||||
#define ZM_RECORD_EVENT_STATS <from zmconfig> // Whether to record event statistical information, change to no if too slow (from zmconfig)
|
||||
|
||||
#define ZM_STRICT_VIDEO_CONFIG <from zmconfig> // Whether to allow errors in setting video config to be fatal
|
||||
370
src/zmdbg.c
370
src/zmdbg.c
@@ -1,370 +0,0 @@
|
||||
//
|
||||
// ZoneMinder Debug Implementation, $Date$, $Revision$
|
||||
// Copyright (C) 2003 Philip Coombes
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <syslog.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "zmdbg.h"
|
||||
|
||||
#define PRESERVE_ATTEMPTS 3
|
||||
|
||||
static char string[4096];
|
||||
static char dbg_string[4096+512];
|
||||
static const char *dbg_file;
|
||||
static int dbg_line;
|
||||
static int dbg_code;
|
||||
static char dbg_class[4];
|
||||
const char *dbg_name = "";
|
||||
int dbg_pid = -1;
|
||||
static int dbg_switched_on = FALSE;
|
||||
|
||||
int dbg_level = 0;
|
||||
char dbg_log[128] = "";
|
||||
FILE *dbg_log_fd = (FILE *)NULL;
|
||||
int dbg_print = FALSE;
|
||||
int dbg_flush = FALSE;
|
||||
int dbg_runtime = FALSE;
|
||||
int dbg_add_log_id = FALSE;
|
||||
struct timeval dbg_start;
|
||||
|
||||
static int dbg_running = FALSE;
|
||||
|
||||
void UsrHandler( int sig )
|
||||
{
|
||||
if( sig == SIGUSR1)
|
||||
{
|
||||
dbg_switched_on = TRUE;
|
||||
if ( dbg_level < 9 )
|
||||
{
|
||||
dbg_level++;
|
||||
}
|
||||
}
|
||||
else if ( sig == SIGUSR2 )
|
||||
{
|
||||
if( dbg_level > -3 )
|
||||
{
|
||||
dbg_level--;
|
||||
}
|
||||
}
|
||||
Info(( "Debug Level Changed to %d", dbg_level ));
|
||||
}
|
||||
|
||||
int GetDebugEnv( const char * const command )
|
||||
{
|
||||
char buffer[128];
|
||||
char *env_ptr;
|
||||
|
||||
/* dbg_level = 0; */
|
||||
/* dbg_log[0] = '\0'; */
|
||||
|
||||
env_ptr = getenv( "DBG_PRINT" );
|
||||
if ( env_ptr == (char *)NULL )
|
||||
{
|
||||
dbg_print = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_print = atoi( env_ptr );
|
||||
}
|
||||
|
||||
env_ptr = getenv( "DBG_FLUSH" );
|
||||
if ( env_ptr == (char *)NULL )
|
||||
{
|
||||
dbg_flush = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_flush = atoi( env_ptr );
|
||||
}
|
||||
|
||||
env_ptr = getenv( "DBG_RUNTIME" );
|
||||
if ( env_ptr == (char *)NULL )
|
||||
{
|
||||
dbg_runtime = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_runtime = atoi( env_ptr );
|
||||
}
|
||||
|
||||
sprintf(buffer,"DLVL_%s",command);
|
||||
env_ptr = getenv(buffer);
|
||||
if( env_ptr != (char *)NULL )
|
||||
{
|
||||
dbg_level = atoi(env_ptr);
|
||||
}
|
||||
sprintf( buffer, "DLOG_%s", command );
|
||||
env_ptr = getenv( buffer );
|
||||
if ( env_ptr != (char *)NULL )
|
||||
{
|
||||
/* If we do not want to add a pid to the debug logs
|
||||
* which is the default, and original method
|
||||
*/
|
||||
if ( env_ptr[strlen(env_ptr)-1] == '+' )
|
||||
{
|
||||
/* remove the + character from the string */
|
||||
env_ptr[strlen(env_ptr)-1] = '\0';
|
||||
dbg_add_log_id = TRUE;
|
||||
}
|
||||
if ( dbg_add_log_id == FALSE )
|
||||
{
|
||||
strcpy( dbg_log, env_ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( dbg_log, "%s.%05d", env_ptr, getpid() );
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int InitialiseDebug()
|
||||
{
|
||||
char *prev_file = (char*)NULL;
|
||||
|
||||
FILE *tmp_fp;
|
||||
|
||||
int status;
|
||||
|
||||
struct timezone tzp;
|
||||
|
||||
gettimeofday( &dbg_start, &tzp );
|
||||
|
||||
Debug(1,("Initialising Debug"));
|
||||
|
||||
/* Now set up the syslog stuff */
|
||||
(void) openlog( dbg_name, LOG_PID|LOG_NDELAY, LOG_LOCAL1 );
|
||||
|
||||
string[0] = '\0';
|
||||
dbg_class[0] = '\0';
|
||||
|
||||
dbg_pid = getpid();
|
||||
dbg_log_fd = (FILE *)NULL;
|
||||
if( (status = GetDebugEnv(dbg_name) ) < 0)
|
||||
{
|
||||
Error(("Debug Environment Error, status = %d",status));
|
||||
return(DBG_ERROR);
|
||||
}
|
||||
|
||||
if ( ( dbg_add_log_id == FALSE && dbg_log[0] ) && ( dbg_log[strlen(dbg_log)-1] == '~' ) )
|
||||
{
|
||||
dbg_log[strlen(dbg_log)-1] = '\0';
|
||||
|
||||
if ( (tmp_fp = fopen(dbg_log, "r")) != NULL )
|
||||
{
|
||||
char old_pth[256];
|
||||
|
||||
sprintf(old_pth, "%s.old", dbg_log);
|
||||
rename(dbg_log, old_pth);
|
||||
fclose(tmp_fp); /* should maybe fclose() before rename() ? */
|
||||
}
|
||||
}
|
||||
|
||||
if( dbg_log[0] && (dbg_log_fd = fopen(dbg_log,"w")) == (FILE *)NULL )
|
||||
{
|
||||
Error(("fopen() for %s, error = %s",dbg_log,strerror(errno)));
|
||||
return(DBG_ERROR);
|
||||
}
|
||||
Info(("Debug Level = %d, Debug Log = %s",dbg_level,dbg_log));
|
||||
|
||||
{
|
||||
struct sigaction action, old_action;
|
||||
action.sa_handler = UsrHandler;
|
||||
action.sa_flags = SA_RESTART;
|
||||
|
||||
if ( sigaction( SIGUSR1, &action, &old_action ) < 0 )
|
||||
{
|
||||
Error(("%s(), error = %s",sigaction,strerror(errno)));
|
||||
return(DBG_ERROR);
|
||||
}
|
||||
if ( sigaction( SIGUSR2, &action, &old_action ) < 0)
|
||||
{
|
||||
Error(("%s(), error = %s",sigaction,strerror(errno)));
|
||||
return(DBG_ERROR);
|
||||
}
|
||||
}
|
||||
dbg_running = TRUE;
|
||||
return(DBG_OK);
|
||||
}
|
||||
|
||||
int DbgInit()
|
||||
{
|
||||
return((InitialiseDebug() == DBG_OK ? 0 : 1));
|
||||
}
|
||||
|
||||
int TerminateDebug()
|
||||
{
|
||||
Debug(1,("Terminating Debug"));
|
||||
fflush(dbg_log_fd);
|
||||
if((fclose(dbg_log_fd)) == -1)
|
||||
{
|
||||
Error(("fclose(), error = %s",strerror(errno)));
|
||||
return(DBG_ERROR);
|
||||
}
|
||||
dbg_log_fd = (FILE *)NULL;
|
||||
(void) closelog();
|
||||
|
||||
dbg_running = FALSE;
|
||||
return(DBG_OK);
|
||||
}
|
||||
|
||||
int DbgTerm()
|
||||
{
|
||||
return((TerminateDebug() == DBG_OK ? 0 : 1));
|
||||
}
|
||||
|
||||
void DbgSubtractTime( struct timeval * const tp1, struct timeval * const tp2 )
|
||||
{
|
||||
tp1->tv_sec -= tp2->tv_sec;
|
||||
if ( tp1->tv_usec <= tp2->tv_usec )
|
||||
{
|
||||
tp1->tv_sec--;
|
||||
tp1->tv_usec = 1000000 - (tp2->tv_usec - tp1->tv_usec);
|
||||
}
|
||||
else
|
||||
{
|
||||
tp1->tv_usec = tp1->tv_usec - tp2->tv_usec;
|
||||
}
|
||||
}
|
||||
|
||||
int DbgPrepare( const char * const file, const int line, const int code )
|
||||
{
|
||||
dbg_file = file;
|
||||
dbg_line = line;
|
||||
dbg_code = code;
|
||||
switch(code)
|
||||
{
|
||||
case DBG_INF:
|
||||
strcpy(dbg_class,"INF");
|
||||
break;
|
||||
case DBG_WAR:
|
||||
strcpy(dbg_class,"WAR");
|
||||
break;
|
||||
case DBG_ERR:
|
||||
strcpy(dbg_class,"ERR");
|
||||
break;
|
||||
case DBG_FAT:
|
||||
strcpy(dbg_class,"FAT");
|
||||
break;
|
||||
default:
|
||||
if(code > 0 && code <= 9)
|
||||
{
|
||||
sprintf(dbg_class,"DB%d",code);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(("Unknown Error Code %d",code));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(code);
|
||||
}
|
||||
|
||||
int DbgOutput( const char *fstring, ... )
|
||||
{
|
||||
char time_string[64];
|
||||
va_list arg_ptr;
|
||||
int log_code;
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int count = 0;
|
||||
|
||||
string[0] = '\0';
|
||||
va_start(arg_ptr,fstring);
|
||||
vsprintf(string,fstring,arg_ptr);
|
||||
|
||||
gettimeofday( &tp, &tzp );
|
||||
|
||||
if ( dbg_runtime )
|
||||
{
|
||||
DbgSubtractTime( &tp, &dbg_start );
|
||||
|
||||
sprintf( time_string, "%d.%03ld", tp.tv_sec, tp.tv_usec/1000 );
|
||||
}
|
||||
else
|
||||
{
|
||||
time_t the_time;
|
||||
|
||||
the_time = tp.tv_sec;
|
||||
|
||||
strftime(time_string,63,"%x %H:%M:%S",localtime(&the_time));
|
||||
sprintf(&(time_string[strlen(time_string)]), ".%06ld", tp.tv_usec);
|
||||
|
||||
}
|
||||
sprintf(dbg_string,"%s %s[%d].%s-%s/%d [%s]\n",
|
||||
time_string,dbg_name,dbg_pid,
|
||||
dbg_class,dbg_file,dbg_line,string);
|
||||
if ( dbg_print )
|
||||
{
|
||||
printf("%s", dbg_string);
|
||||
fflush(stdout);
|
||||
}
|
||||
if ( dbg_log_fd != (FILE *)NULL )
|
||||
{
|
||||
fprintf( dbg_log_fd, "%s", dbg_string );
|
||||
|
||||
if ( dbg_flush )
|
||||
{
|
||||
fflush(dbg_log_fd);
|
||||
}
|
||||
}
|
||||
/* For Info, Warning, Errors etc we want to log them */
|
||||
if ( dbg_code <= DBG_INF )
|
||||
{
|
||||
if ( !dbg_flush )
|
||||
{
|
||||
fflush(dbg_log_fd);
|
||||
}
|
||||
switch(dbg_code)
|
||||
{
|
||||
case DBG_INF:
|
||||
log_code = LOG_INFO;
|
||||
break;
|
||||
case DBG_WAR:
|
||||
log_code = LOG_WARNING;
|
||||
break;
|
||||
case DBG_ERR:
|
||||
log_code = LOG_ERR;
|
||||
break;
|
||||
case DBG_FAT:
|
||||
log_code = LOG_CRIT;
|
||||
break;
|
||||
default:
|
||||
log_code = LOG_CRIT;
|
||||
break;
|
||||
}
|
||||
log_code |= LOG_LOCAL1;
|
||||
syslog( log_code, "%s [%s]", dbg_class, string );
|
||||
}
|
||||
va_end(arg_ptr);
|
||||
if ( dbg_code == DBG_FAT )
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
return( strlen( string ) );
|
||||
}
|
||||
143
src/zmdbg.h
143
src/zmdbg.h
@@ -1,143 +0,0 @@
|
||||
//
|
||||
// ZoneMinder Debug Interface, $Date$, $Revision$
|
||||
// Copyright (C) 2003 Philip Coombes
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/* Leve 0 and below */
|
||||
#define DBG_OK 0
|
||||
#define DBG_SUCCESS 0
|
||||
#define DBG_INFO 1
|
||||
#define DBG_WARNING -1
|
||||
#define DBG_ERROR -2
|
||||
#define DBG_FATAL -3
|
||||
|
||||
#define DBG_INF 0
|
||||
#define DBG_WAR -1
|
||||
#define DBG_ERR -2
|
||||
#define DBG_FAT -3
|
||||
|
||||
#ifndef DEBUG_OFF
|
||||
|
||||
#define DbgPrintf(code,params) {\
|
||||
if (code <= dbg_level)\
|
||||
{\
|
||||
(void) DbgPrepare(__FILE__,__LINE__,code);\
|
||||
(void) DbgOutput params;\
|
||||
}\
|
||||
}
|
||||
|
||||
#define Null(params)
|
||||
#define Debug(level,params) DbgPrintf(level,params)
|
||||
#define Info(params) DbgPrintf(0, params)
|
||||
#define Warning(params) DbgPrintf(DBG_WAR,params)
|
||||
#define Error(params) DbgPrintf(DBG_ERR,params)
|
||||
#define Fatal(params) DbgPrintf(DBG_FAT,params)
|
||||
#define Entrypoint(params) DbgPrintf(9,params);
|
||||
#define Exitpoint(params) DbgPrintf(9,params);
|
||||
#define Mark() Info(("Mark/%s/%d", __FILE__, __LINE__ ))
|
||||
#define Log() Info(("Log"))
|
||||
#ifdef __GNUC__
|
||||
#define Enter(level) DbgPrintf(level,("Entering %s",__PRETTY_FUNCTION__))
|
||||
#define Exit(level) DbgPrintf(level,("Exiting %s",__PRETTY_FUNCTION__))
|
||||
#else
|
||||
#if 0
|
||||
#define Enter(level) DbgPrintf(level,("Entering <unknown>"))
|
||||
#define Exit(level) DbgPrintf(level,("Exiting <unknown>"))
|
||||
#endif
|
||||
#define Enter(level)
|
||||
#define Exit(level)
|
||||
#endif
|
||||
|
||||
#define HexDump(t,n) {if(dbg_level == 9) \
|
||||
{ \
|
||||
int _i; \
|
||||
int _len; \
|
||||
char *_s; \
|
||||
_s = (t); \
|
||||
_len = (n); \
|
||||
for(_i = 0; _i < _len; _i++,_s++) \
|
||||
{ \
|
||||
if(!(_i % 16)) \
|
||||
{ \
|
||||
fprintf(dbg_log_fd,"\n"); \
|
||||
} \
|
||||
fprintf(dbg_log_fd,"0x%02x ", \
|
||||
((int)*_s)&0xff); \
|
||||
} \
|
||||
fprintf(dbg_log_fd,"\n"); \
|
||||
}}
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
int DbgInit(void);
|
||||
int DbgTerm(void);
|
||||
int DbgPrepare(const char * const file,const int line, const int code);
|
||||
int DbgOutput(const char *fstring, ... ) __attribute__ ((format(printf, 1, 2)));
|
||||
#else
|
||||
int DbgInit();
|
||||
int DbgTerm();
|
||||
int DbgPrepare();
|
||||
int DbgOutput();
|
||||
#endif
|
||||
|
||||
extern int dbg_level;
|
||||
extern int dbg_pid;
|
||||
extern char dbg_log[];
|
||||
#ifndef _STDIO_INCLUDED
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
extern FILE *dbg_log_fd;
|
||||
extern const char *dbg_name;
|
||||
extern int dbg_print;
|
||||
extern int dbg_flush;
|
||||
extern int dbg_add_log_id;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} //extern "C"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define InitialiseDebug(params) DBG_OK
|
||||
#define TerminateDebug(params) DBG_OK
|
||||
|
||||
#define Debug(lvl,params)
|
||||
#define Info(params)
|
||||
#define Warning(params)
|
||||
#define Error(params)
|
||||
#define Fatal(params)
|
||||
#define Mark()
|
||||
#define Log()
|
||||
#define Enter()
|
||||
#define Exit()
|
||||
|
||||
#define DbgInit()
|
||||
#define DbgTerm()
|
||||
|
||||
#endif /* DEBUG_ON */
|
||||
Reference in New Issue
Block a user