LCOV - code coverage report
Current view: top level - src - Base64.h (source / functions) Hit Total Coverage
Test: app.info Lines: 0 6 0.0 %
Date: 2010-12-13 Functions: 0 2 0.0 %
Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : // $Id: Base64.h 3526 2006-09-12 07:32:21Z vern $
       2                 :            : 
       3                 :            : #ifndef base64_h
       4                 :            : #define base64_h
       5                 :            : 
       6                 :            : #include <assert.h>
       7                 :            : #include <stdio.h>
       8                 :            : #include <string.h>
       9                 :            : 
      10                 :            : #include "util.h"
      11                 :            : #include "BroString.h"
      12                 :            : #include "Analyzer.h"
      13                 :            : 
      14                 :            : // Maybe we should have a base class for generic decoders?
      15                 :            : 
      16                 :            : class Base64Decoder {
      17                 :            : public:
      18                 :            :         // <analyzer> is used for error reporting, and it should be zero
      19                 :            :         // when the decoder is called by the built-in function
      20                 :            :         // decode_base64().
      21                 :            :         Base64Decoder(Analyzer* analyzer);
      22                 :          0 :         ~Base64Decoder()        { }
      23                 :            : 
      24                 :            :         // A note on Decode():
      25                 :            :         //
      26                 :            :         // The input is specified by <len> and <data> and the output
      27                 :            :         // buffer by <blen> and <buf>.  If *buf is nil, a buffer of
      28                 :            :         // an appropriate size will be new'd and *buf will point
      29                 :            :         // to the buffer on return. *blen holds the length of
      30                 :            :         // decoded data on return.  The function returns the number of
      31                 :            :         // input bytes processed, since the decoding will stop when there
      32                 :            :         // is not enough output buffer space.
      33                 :            : 
      34                 :            :         int Decode(int len, const char* data, int* blen, char** buf);
      35                 :            : 
      36                 :            :         int Done(int* pblen, char** pbuf);
      37                 :            :         int HasData() const { return base64_group_next != 0; }
      38                 :            : 
      39                 :            :         // True if an error has occurred.
      40                 :            :         int Errored() const     { return errored; }
      41                 :            : 
      42                 :            :         const char* ErrorMsg() const    { return error_msg; }
      43                 :          0 :         void IllegalEncoding(const char* msg)
      44                 :            :                 { 
      45                 :            :                 // strncpy(error_msg, msg, sizeof(error_msg));
      46         [ #  # ]:          0 :                 if ( analyzer )
      47                 :          0 :                         analyzer->Weird("base64_illegal_encoding", msg);
      48                 :            :                 else
      49                 :          0 :                         run_time(msg);
      50                 :          0 :                 }
      51                 :            : 
      52                 :            : protected:
      53                 :            :         char error_msg[256];
      54                 :            : 
      55                 :            : protected:
      56                 :            :         char base64_group[4];
      57                 :            :         int base64_group_next;
      58                 :            :         int base64_padding;
      59                 :            :         int base64_after_padding;
      60                 :            :         int errored;    // if true, we encountered an error - skip further processing
      61                 :            :         Analyzer* analyzer;
      62                 :            : };
      63                 :            : 
      64                 :            : BroString* decode_base64(const BroString* s);
      65                 :            : 
      66                 :            : #endif /* base64_h */

Generated by: LCOV version 1.8