Diff for /embedaddon/quagga/lib/log.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2013/07/21 23:54:39 version 1.1.1.4, 2016/11/02 10:09:11
Line 51  const char *zlog_proto_names[] =  Line 51  const char *zlog_proto_names[] = 
   "BABEL",    "BABEL",
   "OSPF6",    "OSPF6",
   "ISIS",    "ISIS",
     "PIM",
   "MASC",    "MASC",
   NULL,    NULL,
 };  };
Line 69  const char *zlog_priority[] = Line 70  const char *zlog_priority[] =
 };  };
       
   
 /* For time string format. */  /* For time string format. */
   
 size_t  size_t
Line 145  time_print(FILE *fp, struct timestamp_control *ctl) Line 146  time_print(FILE *fp, struct timestamp_control *ctl)
   fprintf(fp, "%s ", ctl->buf);    fprintf(fp, "%s ", ctl->buf);
 }  }
       
 /* va_list version of zlog. */  /* va_list version of zlog. */
 static void  static void
 vzlog (struct zlog *zl, int priority, const char *format, va_list args)  vzlog (struct zlog *zl, int priority, const char *format, va_list args)
 {  {
     int original_errno = errno;
   struct timestamp_control tsctl;    struct timestamp_control tsctl;
   tsctl.already_rendered = 0;    tsctl.already_rendered = 0;
   
Line 168  vzlog (struct zlog *zl, int priority, const char *form Line 170  vzlog (struct zlog *zl, int priority, const char *form
       fflush (stderr);        fflush (stderr);
   
       /* In this case we return at here. */        /* In this case we return at here. */
         errno = original_errno;
       return;        return;
     }      }
   tsctl.precision = zl->timestamp_precision;    tsctl.precision = zl->timestamp_precision;
Line 215  vzlog (struct zlog *zl, int priority, const char *form Line 218  vzlog (struct zlog *zl, int priority, const char *form
   if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])    if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
     vty_log ((zl->record_priority ? zlog_priority[priority] : NULL),      vty_log ((zl->record_priority ? zlog_priority[priority] : NULL),
              zlog_proto_names[zl->protocol], format, &tsctl, args);               zlog_proto_names[zl->protocol], format, &tsctl, args);
   
     errno = original_errno;
 }  }
   
 static char *  static char *
Line 425  zlog_signal(int signo, const char *action Line 430  zlog_signal(int signo, const char *action
                          NULL                           NULL
 #endif  #endif
                         );                          );
   
     s = buf;
     if (!thread_current)
       s = str_append (LOC, "no thread information available\n");
     else
       {
         s = str_append (LOC, "in thread ");
         s = str_append (LOC, thread_current->funcname);
         s = str_append (LOC, " scheduled from ");
         s = str_append (LOC, thread_current->schedfrom);
         s = str_append (LOC, ":");
         s = num_append (LOC, thread_current->schedfrom_line);
         s = str_append (LOC, "\n");
       }
   
   #define DUMP(FD) write(FD, buf, s-buf);
     /* If no file logging configured, try to write to fallback log file. */
     if (logfile_fd >= 0)
       DUMP(logfile_fd)
     if (!zlog_default)
       DUMP(STDERR_FILENO)
     else
       {
         if (PRI <= zlog_default->maxlvl[ZLOG_DEST_STDOUT])
           DUMP(STDOUT_FILENO)
         /* Remove trailing '\n' for monitor and syslog */
         *--s = '\0';
         if (PRI <= zlog_default->maxlvl[ZLOG_DEST_MONITOR])
           vty_log_fixed(buf,s-buf);
         if (PRI <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG])
           syslog_sigsafe(PRI|zlog_default->facility,msgstart,s-msgstart);
       }
   #undef DUMP
   
 #undef PRI  #undef PRI
 #undef LOC  #undef LOC
 }  }
Line 443  zlog_backtrace_sigsafe(int priority, void *program_cou Line 482  zlog_backtrace_sigsafe(int priority, void *program_cou
 #define LOC s,buf+sizeof(buf)-s  #define LOC s,buf+sizeof(buf)-s
   
 #ifdef HAVE_GLIBC_BACKTRACE  #ifdef HAVE_GLIBC_BACKTRACE
  if (((size = backtrace(array,array_size(array)) <= 0) ||  size = backtrace(array, array_size(array));
      ((size_t)size > array_size(array))))  if (size <= 0 || (size_t)size > array_size(array))
     return;      return;
   
 #define DUMP(FD) { \  #define DUMP(FD) { \
Line 526  zlog_backtrace(int priority) Line 565  zlog_backtrace(int priority)
   int size, i;    int size, i;
   char **strings;    char **strings;
   
  if (((size = backtrace(array,array_size(array))) <= 0) ||  size = backtrace(array, array_size(array));
      ((size_t)size > array_size(array)))  if (size <= 0 || (size_t)size > array_size(array))
     {      {
       zlog_err("Cannot get backtrace, returned invalid # of frames %d "        zlog_err("Cannot get backtrace, returned invalid # of frames %d "
                "(valid range is between 1 and %lu)",                 "(valid range is between 1 and %lu)",
Line 604  PLOG_FUNC(plog_debug, LOG_DEBUG) Line 643  PLOG_FUNC(plog_debug, LOG_DEBUG)
   
 #undef PLOG_FUNC  #undef PLOG_FUNC
   
   void zlog_thread_info (int log_level)
   {
     if (thread_current)
       zlog(NULL, log_level, "Current thread function %s, scheduled from "
            "file %s, line %u", thread_current->funcname,
            thread_current->schedfrom, thread_current->schedfrom_line);
     else
       zlog(NULL, log_level, "Current thread not known/applicable");
   }
   
 void  void
 _zlog_assert_failed (const char *assertion, const char *file,  _zlog_assert_failed (const char *assertion, const char *file,
                      unsigned int line, const char *function)                       unsigned int line, const char *function)
Line 616  _zlog_assert_failed (const char *assertion, const char Line 665  _zlog_assert_failed (const char *assertion, const char
   zlog(NULL, LOG_CRIT, "Assertion `%s' failed in file %s, line %u, function %s",    zlog(NULL, LOG_CRIT, "Assertion `%s' failed in file %s, line %u, function %s",
        assertion,file,line,(function ? function : "?"));         assertion,file,line,(function ? function : "?"));
   zlog_backtrace(LOG_CRIT);    zlog_backtrace(LOG_CRIT);
     zlog_thread_info(LOG_CRIT);
   abort();    abort();
 }  }
   
 /* Open log stream */  /* Open log stream */
 struct zlog *  struct zlog *
 openzlog (const char *progname, zlog_proto_t protocol,  openzlog (const char *progname, zlog_proto_t protocol,
Line 756  zlog_rotate (struct zlog *zl) Line 806  zlog_rotate (struct zlog *zl)
   
   return 1;    return 1;
 }  }
 /* Message lookup function. */  /* Message lookup function. */
 const char *  const char *
 lookup (const struct message *mes, int key)  lookup (const struct message *mes, int key)
Line 954  proto_redistnum(int afi, const char *s) Line 1004  proto_redistnum(int afi, const char *s)
         return ZEBRA_ROUTE_BABEL;          return ZEBRA_ROUTE_BABEL;
     }      }
   return -1;    return -1;
   }
   
   void
   zlog_hexdump (void *mem, unsigned int len) {
     unsigned long i = 0;
     unsigned int j = 0;
     unsigned int columns = 8;
     char buf[(len * 4) + ((len/4) * 20) + 30];
     char *s = buf;
   
     for (i = 0; i < len + ((len % columns) ? (columns - len % columns) : 0); i++)
       {
         /* print offset */
         if (i % columns == 0)
           s += sprintf(s, "0x%016lx: ", (unsigned long)mem + i);
   
         /* print hex data */
         if (i < len)
           s += sprintf(s, "%02x ", 0xFF & ((char*)mem)[i]);
   
         /* end of block, just aligning for ASCII dump */
         else
           s += sprintf(s, "   ");
   
         /* print ASCII dump */
         if (i % columns == (columns - 1))
           {
             for (j = i - (columns - 1); j <= i; j++)
               {
                 if (j >= len) /* end of block, not really printing */
                   s += sprintf(s, " ");
   
                 else if(isprint((int)((char*)mem)[j])) /* printable char */
                   s += sprintf(s, "%c", 0xFF & ((char*)mem)[j]);
   
                 else /* other char */
                   s += sprintf(s, ".");
               }
             s += sprintf(s, "\n");
           }
       }
       zlog_debug("\n%s", buf);
 }  }

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>