LCOV - code coverage report
Current view: top level - src/client - monitor.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 34 0.0 %
Date: 2015-11-30 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #include "../burp.h"
       2             : #include "../asfd.h"
       3             : #include "../async.h"
       4             : #include "../conf.h"
       5             : #include "../cmd.h"
       6             : #include "../iobuf.h"
       7             : #include "../log.h"
       8             : 
       9           0 : static int copy_input_to_output(struct asfd *in, struct asfd *out)
      10             : {
      11           0 :         return out->write_strn(out, CMD_GEN, in->rbuf->buf, in->rbuf->len);
      12             : }
      13             : 
      14           0 : static int main_loop(struct async *as, struct conf **confs)
      15             : {
      16             :         struct asfd *asfd;
      17             :         struct asfd *sfd; // Server fd.
      18             :         struct asfd *sin;
      19             :         struct asfd *sout;
      20             : 
      21           0 :         sfd=as->asfd;
      22           0 :         sin=sfd->next;
      23           0 :         sout=sin->next;
      24             : 
      25             :         while(1)
      26             :         {
      27           0 :                 if(as->read_write(as))
      28             :                 {
      29           0 :                         logp("Exiting main loop\n");
      30           0 :                         break;
      31             :                 }
      32             : 
      33           0 :                 for(asfd=as->asfd; asfd; asfd=asfd->next)
      34           0 :                         while(asfd->rbuf->buf)
      35             :                 {
      36           0 :                         if(asfd==sfd)
      37             :                         {
      38           0 :                                 if(copy_input_to_output(sfd, sout))
      39           0 :                                         goto error;
      40             :                         }
      41           0 :                         else if(asfd==sin)
      42             :                         {
      43           0 :                                 if(copy_input_to_output(sin, sfd))
      44           0 :                                         goto error;
      45             :                         }
      46           0 :                         iobuf_free_content(asfd->rbuf);
      47           0 :                         if(asfd->parse_readbuf(asfd))
      48           0 :                                 goto error;
      49             :                 }
      50             : 
      51             :                 //if(sel) logp("sel: %s\n", sel->name);
      52             :         }
      53             : 
      54             : error:
      55             :         // FIX THIS: should probably be freeing a bunch of stuff here.
      56           0 :         return -1;
      57             : }
      58             : 
      59           0 : int do_monitor_client(struct asfd *asfd, struct conf **confs)
      60             : {
      61           0 :         int ret=-1;
      62           0 :         struct async *as=asfd->as;
      63           0 :         int stdinfd=fileno(stdin);
      64           0 :         int stdoutfd=fileno(stdout);
      65           0 : logp("in monitor\n");
      66             :         // I tried to just printf to stdout, but the strings to print would be
      67             :         // so long that I would start to get printf errors.
      68             :         // Using the asfd stuff works well though.
      69           0 :         if(!setup_asfd(as, "stdin", &stdinfd, NULL, ASFD_STREAM_LINEBUF,
      70           0 :                 ASFD_FD_CLIENT_MONITOR_READ, -1, confs)
      71           0 :           || !setup_asfd(as, "stdout", &stdoutfd, NULL, ASFD_STREAM_LINEBUF,
      72           0 :                 ASFD_FD_CLIENT_MONITOR_WRITE, -1, confs))
      73           0 :                 goto end;
      74           0 :         ret=main_loop(as, confs);
      75             : end:
      76           0 :         return ret;
      77             : }

Generated by: LCOV version 1.10