LCOV - code coverage report
Current view: top level - src - incexc_recv.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 25 0.0 %
Date: 2016-05-01 Functions: 0 6 0.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "alloc.h"
       3             : #include "asfd.h"
       4             : #include "async.h"
       5             : #include "cmd.h"
       6             : #include "iobuf.h"
       7             : #include "prepend.h"
       8             : 
       9             : static const char *endreqstrf;
      10             : static const char *endrepstrf;
      11             : 
      12           0 : static int add_to_incexc(char **incexc, const char *src, size_t len, const char *sep)
      13             : {
      14             :         char *tmp;
      15           0 :         if(!(tmp=prepend_n(*incexc?:"", src, len, *incexc?"\n":""))) return -1;
      16           0 :         free_w(incexc);
      17           0 :         *incexc=tmp;
      18             :         return 0;
      19             : }
      20             : 
      21           0 : static enum asl_ret incexc_recv_func(struct asfd *asfd,
      22             :         struct conf **confs, void *param)
      23             : {
      24           0 :         char **incexc=(char **)param;
      25           0 :         if(!strcmp(asfd->rbuf->buf, endreqstrf))
      26             :         {
      27           0 :                 if(asfd->write_str(asfd, CMD_GEN, endrepstrf))
      28             :                         return ASL_END_ERROR;
      29           0 :                 return ASL_END_OK;
      30             :         }
      31           0 :         if(add_to_incexc(incexc,
      32           0 :                 asfd->rbuf->buf, asfd->rbuf->len, *incexc?"\n":""))
      33             :                         return ASL_END_ERROR;
      34           0 :         return ASL_CONTINUE;
      35             : }
      36             : 
      37             : 
      38           0 : static int incexc_recv(struct asfd *asfd, char **incexc,
      39             :         const char *reqstr, const char *repstr,
      40             :         const char *endreqstr, const char *endrepstr, struct conf **confs)
      41             : {
      42           0 :         free_w(incexc);
      43           0 :         if(asfd->write_str(asfd, CMD_GEN, repstr)) return -1;
      44             : 
      45           0 :         endreqstrf=endreqstr;
      46           0 :         endrepstrf=endrepstr;
      47           0 :         if(asfd->simple_loop(asfd, confs, incexc, __func__, incexc_recv_func))
      48             :                 return -1;
      49             : 
      50             :         // Need to put another new line at the end.
      51           0 :         return add_to_incexc(incexc, "\n", 1, "");
      52             : }
      53             : 
      54           0 : int incexc_recv_client(struct asfd *asfd,
      55             :         char **incexc, struct conf **confs)
      56             : {
      57             :         return incexc_recv(asfd, incexc,
      58             :                 "sincexc", "sincexc ok",
      59             :                 "sincexc end", "sincexc end ok",
      60           0 :                 confs);
      61             : }
      62             : 
      63           0 : int incexc_recv_client_restore(struct asfd *asfd,
      64             :         char **incexc, struct conf **confs)
      65             : {
      66             :         return incexc_recv(asfd, incexc,
      67             :                 "srestore", "srestore ok",
      68             :                 "srestore end", "srestore end ok",
      69           0 :                 confs);
      70             : }
      71             : 
      72           0 : int incexc_recv_server(struct asfd *asfd,
      73             :         char **incexc, struct conf **confs)
      74             : {
      75             :         return incexc_recv(asfd, incexc,
      76             :                 "incexc", "incexc ok",
      77             :                 "incexc end", "incexc end ok",
      78           0 :                 confs);
      79             : }

Generated by: LCOV version 1.10