Back to index

nagios-plugins  1.4.16
Functions | Variables
attrprint.c File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <stdio.h>
#include <netdb.h>
#include <pwd.h>
#include <time.h>
#include <ctype.h>
#include "radiusd.h"

Go to the source code of this file.

Functions

void debug_pair (FILE *fd, VALUE_PAIR *pair)
void fprint_attr_list (FILE *fd, VALUE_PAIR *pair)
void fprint_attr_val (FILE *fd, VALUE_PAIR *pair)

Variables

char attrprint_sccsid [] = " 2.1 Copyright 1998 Cistron Internet Services B.V."

Function Documentation

void debug_pair ( FILE *  fd,
VALUE_PAIR pair 
)

Definition at line 50 of file attrprint.c.

{
       if(debug_flag) {
              fputs("    ", fd);
              fprint_attr_val(fd, pair);
              fputs("\n", fd);
       }
}

Here is the call graph for this function:

void fprint_attr_list ( FILE *  fd,
VALUE_PAIR pair 
)

Definition at line 63 of file attrprint.c.

{
       while(pair) {
              fprintf(fd, "    ");
              fprint_attr_val(fd, pair);
              fprintf(fd, "\n");
              pair = pair->next;
       }
}

Here is the call graph for this function:

void fprint_attr_val ( FILE *  fd,
VALUE_PAIR pair 
)

Definition at line 78 of file attrprint.c.

{
       DICT_VALUE    *dict_valget();
       DICT_VALUE    *dval;
       char          buffer[32];
       u_char        *ptr;
       UINT4         vendor;
       int           i, left;

       switch(pair->type) {

       case PW_TYPE_STRING:
              fprintf(fd, "%s = \"", pair->name);
              ptr = (u_char *)pair->strvalue;
              if (pair->attribute != PW_VENDOR_SPECIFIC) {
                     left = pair->length;
                     while(left-- > 0) {
                            /*
                             *     Ugh! Ascend gear sends "foo"
                             *     as "foo\0", length 4.
                             *     Suppress trailing zeros.
                             */
                            if (left == 0 && *ptr == 0)
                                   break;
                            if(!(isprint(*ptr)))
                                   fprintf(fd, "\\%03o", *ptr);
                            else
                                   fputc(*ptr, fd);
                            ptr++;
                     }
                     fputc('"', fd);
                     break;
              }
              /*
               *     Special format, print out as much
               *     info as we can.
               */
              if (pair->length < 6) {
                     fprintf(fd, "(invalid length: %d)\"", pair->length);
                     break;
              }
              memcpy(&vendor, ptr, 4);
              ptr += 4;
              fprintf(fd, "V%d", (int)ntohl(vendor));
              left = pair->length - 4;
              while (left >= 2) {
                     fprintf(fd, ":T%d:L%d:", ptr[0], ptr[1]);
                     left -= 2;
                     ptr += 2;
                     i = ptr[1] - 2;
                     while (i > 0 && left > 0) {
                            if(!(isprint(*ptr)))
                                   fprintf(fd, "\\%03o", *ptr);
                            else
                                   fputc(*ptr, fd);
                            ptr++;
                            i--;
                            left--;
                     }
              }
              fputc('"', fd);
              break;

       case PW_TYPE_INTEGER:
              dval = dict_valget(pair->lvalue, pair->name);
              if(dval != (DICT_VALUE *)NULL) {
                     fprintf(fd, "%s = %s", pair->name, dval->name);
              }
              else {
                     fprintf(fd, "%s = %ld", pair->name, (long)pair->lvalue);
              }
              break;

       case PW_TYPE_IPADDR:
              ipaddr2str(buffer, pair->lvalue);
              fprintf(fd, "%s = %s", pair->name, buffer);
              break;

       case PW_TYPE_DATE:
              strftime(buffer, sizeof(buffer), "%b %e %Y",
                                   localtime((time_t *)&pair->lvalue));
              fprintf(fd, "%s = \"%s\"", pair->name, buffer);
              break;

       default:
              fprintf(fd, "Unknown type %d", pair->type);
              break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char attrprint_sccsid[] = " 2.1 Copyright 1998 Cistron Internet Services B.V."

Definition at line 28 of file attrprint.c.