LCOV - code coverage report
Current view: top level - src/client - monitor.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 32 0.0 %
Date: 2016-05-01 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             :         struct iobuf wbuf;
      12           0 :         iobuf_set(&wbuf, CMD_GEN, in->rbuf->buf, in->rbuf->len);
      13           0 :         return out->write(out, &wbuf);
      14             : }
      15             : 
      16           0 : static int main_loop(struct async *as, struct conf **confs)
      17             : {
      18             :         struct asfd *asfd;
      19           0 :         struct asfd *sfd; // Server fd.
      20           0 :         struct asfd *sin;
      21             :         struct asfd *sout;
      22             : 
      23           0 :         sfd=as->asfd;
      24           0 :         sin=sfd->next;
      25           0 :         sout=sin->next;
      26             : 
      27             :         while(1)
      28             :         {
      29           0 :                 if(as->read_write(as))
      30             :                 {
      31           0 :                         logp("Exiting main loop\n");
      32             :                         break;
      33             :                 }
      34             : 
      35           0 :                 for(asfd=as->asfd; asfd; asfd=asfd->next)
      36           0 :                         while(asfd->rbuf->buf)
      37             :                 {
      38           0 :                         if(asfd==sfd)
      39             :                         {
      40           0 :                                 if(copy_input_to_output(sfd, sout))
      41             :                                         goto error;
      42             :                         }
      43           0 :                         else if(asfd==sin)
      44             :                         {
      45           0 :                                 if(copy_input_to_output(sin, sfd))
      46             :                                         goto error;
      47             :                         }
      48           0 :                         iobuf_free_content(asfd->rbuf);
      49           0 :                         if(asfd->parse_readbuf(asfd))
      50             :                                 goto error;
      51             :                 }
      52             : 
      53             :                 //if(sel) logp("sel: %s\n", sel->name);
      54             :         }
      55             : 
      56             : error:
      57             :         // FIX THIS: should probably be freeing a bunch of stuff here.
      58           0 :         return -1;
      59             : }
      60             : 
      61           0 : int do_monitor_client(struct asfd *asfd, struct conf **confs)
      62             : {
      63           0 :         int ret=-1;
      64           0 :         struct async *as=asfd->as;
      65           0 :         int stdinfd=fileno(stdin);
      66           0 :         int stdoutfd=fileno(stdout);
      67           0 : logp("in monitor\n");
      68             :         // I tried to just printf to stdout, but the strings to print would be
      69             :         // so long that I would start to get printf errors.
      70             :         // Using the asfd stuff works well though.
      71           0 :         if(!setup_asfd(as, "stdin", &stdinfd, NULL, ASFD_STREAM_LINEBUF,
      72           0 :                 ASFD_FD_CLIENT_MONITOR_READ, -1, confs)
      73           0 :           || !setup_asfd(as, "stdout", &stdoutfd, NULL, ASFD_STREAM_LINEBUF,
      74           0 :                 ASFD_FD_CLIENT_MONITOR_WRITE, -1, confs))
      75             :                 goto end;
      76           0 :         ret=main_loop(as, confs);
      77             : end:
      78           0 :         return ret;
      79             : }

Generated by: LCOV version 1.10