Changeset 798


Ignore:
Timestamp:
Aug 20, 2006, 6:15:25 PM (15 years ago)
Author:
joshe
Message:

Allow frontend to change message output level.
Rename tr_setErrorFunction() to tr_setMessageFunction()

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/transmission.h

    r788 r798  
    6262
    6363/***********************************************************************
    64  * tr_setErrorFunction
    65  ***********************************************************************
    66  * Sets the function used to display libtransmission errors.  A NULL
    67  * function means to use the default, which simple prints the message
    68  * to stderr.  The function's prototype should look like this:
    69  * void myErrFunc( const char * errstr );
    70  **********************************************************************/
    71 void tr_setErrorFunction( void (*func)( const char * ) );
     64 * tr_setMessageFunction
     65 ***********************************************************************
     66 * Sets the function used to display libtransmission messages.  This
     67 * function must be reentrant, it may be called from different threads.
     68 * A NULL argument means to print messages to stderr.  The function's
     69 * prototype should look like this: void myErrFunc( const char * );
     70 **********************************************************************/
     71void tr_setMessageFunction( void (*func)( const char * ) );
     72
     73/***********************************************************************
     74 * tr_setMessageLevel
     75 ***********************************************************************
     76 * Set the level of messages to be output
     77 **********************************************************************/
     78#define TR_MSG_ERR 1
     79#define TR_MSG_INF 2
     80#define TR_MSG_DBG 4
     81void tr_setMessageLevel( int );
     82int tr_getMessageLevel( void );
    7283
    7384/***********************************************************************
     
    8293 * tr_setBindPort
    8394 ***********************************************************************
    84  * Sets a "start" port: everytime we start a torrent, we try to bind
    85  * this port, then the next one and so on until we are successful.
     95 * Sets the port to listen for incoming peer connections
    8696 **********************************************************************/
    8797void tr_setBindPort( tr_handle_t *, int );
  • trunk/libtransmission/utils.c

    r626 r798  
    2525#include "transmission.h"
    2626
    27 static void (*errorFunc)( const char * );
     27static void (*messageFunc)( const char * );
    2828
    29 void tr_setErrorFunction( void (*func)( const char * ) )
     29static int verboseLevel = 0;
     30
     31void tr_setMessageFunction( void (*func)( const char * ) )
    3032{
    31     errorFunc = func;
     33    messageFunc = func;
     34}
     35
     36void tr_setMessageLevel( int level )
     37{
     38    verboseLevel = level;
     39}
     40
     41int tr_getMessageLevel( void )
     42{
     43    return verboseLevel;
    3244}
    3345
     
    3648    char         string[256];
    3749    va_list      args;
    38     static int   verboseLevel = 0;
    3950
    4051    if( !verboseLevel )
     
    5970    va_end( args );
    6071
    61     if( NULL == errorFunc )
     72    if( NULL == messageFunc )
    6273    {
    6374        fprintf( stderr, "%s\n", string );
     
    6576    else
    6677    {
    67         errorFunc( string );
     78        messageFunc( string );
    6879    }
    6980}
  • trunk/libtransmission/utils.h

    r310 r798  
    2626#define TR_UTILS_H 1
    2727
    28 #define TR_MSG_ERR 1
    29 #define TR_MSG_INF 2
    30 #define TR_MSG_DBG 4
    3128#define tr_err( a... ) tr_msg( TR_MSG_ERR, ## a )
    3229#define tr_inf( a... ) tr_msg( TR_MSG_INF, ## a )
Note: See TracChangeset for help on using the changeset viewer.