## modules/up/src/util/trace.cc

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. Tracer
2. enable
3. disable
4. enabledp
5. tindex
6. enable
7. disable
8. enabledp

       1 //  $Id: trace.cc,v 1.2 2001/02/21 11:08:52 engin Exp $
       2 //
       3 //  Copyright (c) 1994 by the University of Southern California
       4 //  All rights reserved.
       5 //
       6 //  Permission to use, copy, modify, and distribute this software and its
       7 //  documentation in source and binary forms for lawful non-commercial
       8 //  purposes and without fee is hereby granted, provided that the above
       9 //  copyright notice appear in all copies and that both the copyright
      10 //  notice and this permission notice appear in supporting documentation,
      11 //  and that any documentation, advertising materials, and other materials
      12 //  related to such distribution and use acknowledge that the software was
      13 //  developed by the University of Southern California, Information
      14 //  Sciences Institute. The name of the USC may not be used to endorse or
      15 //  promote products derived from this software without specific prior
      16 //  written permission.
      17 //
      18 //  THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY
      19 //  REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
      20 //  PURPOSE.  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      21 //  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      22 //  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
      23 //  TITLE, AND NON-INFRINGEMENT.
      24 //
      25 //  IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
      26 //  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT,
      27 //  OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE
      28 //  OR PERFORMANCE OF THIS SOFTWARE.
      29 //
      30 //  Questions concerning this software should be directed to
      31 //  ratoolset@isi.edu.
      32 //
      33 //  Author(s): Cengiz Alaettinoglu <cengiz@ISI.EDU>
      34
      35 #include "config.h"
      36 #include <cstring>
      37
      38 #include "trace.hh"
      39
      40 Tracer trace;
      41
      42 char *Tracer::tracenames[TR_MAX] = { "all",
      43                                      "whois_query",
      44                                      "whois_response",
      45                                      "input",
      46                                      0 };
      47
      48 Tracer::Tracer() {
         /* [<][>][^][v][top][bottom][index][help] */
      49    enabled=0;
      50 }
      51
      52 void Tracer::enable(int level) {
         /* [<][>][^][v][top][bottom][index][help] */
      53    if (level)
      54       enabled |= (1 << level);
      55    else // trace all
      56       enabled = ~0;
      57 }
      58 void Tracer::disable(int level) {
         /* [<][>][^][v][top][bottom][index][help] */
      59    enabled &= ~(1 << level);
      60 }
      61 int Tracer::enabledp(int level) {
         /* [<][>][^][v][top][bottom][index][help] */
      62    return (enabled & (1 << level));
      63 }
      64
      65 inline int Tracer::tindex(char *tracename) {
         /* [<][>][^][v][top][bottom][index][help] */
      66    for (int i = 0; i < TR_MAX && tracenames[i]; i++)
      67       if (strcmp(tracename, tracenames[i]) == 0)
      68          return i;
      69
      70    return -1;
      71 }
      72
      73 void Tracer::enable(char *tracename) {
         /* [<][>][^][v][top][bottom][index][help] */
      74    int i = tindex(tracename);
      75    if (i >= 0)
      76       enable(i);
      77 }
      78
      79 void Tracer::disable(char *tracename) {
         /* [<][>][^][v][top][bottom][index][help] */
      80    int i = tindex(tracename);
      81    if (i >= 0)
      82       disable(i);
      83 }
      84
      85 int Tracer::enabledp(char *tracename) {
         /* [<][>][^][v][top][bottom][index][help] */
      86    int i = tindex(tracename);
      87    if (i >= 0)
      88       return enabledp(i);
      89    else
      90       return 0;
      91 }

/* [<][>][^][v][top][bottom][index][help] */