LCOV - code coverage report
Current view: top level - src/server/protocol2 - bsigs.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 42 0.0 %
Date: 2015-10-31 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #include "../../burp.h"
       2             : #include "../../fzp.h"
       3             : #include "../../handy.h"
       4             : #include "../../hexmap.h"
       5             : #include "../../iobuf.h"
       6             : #include "../../log.h"
       7             : #include "../../protocol2/blk.h"
       8             : 
       9             : static const char *path=NULL;
      10             : 
      11           0 : static int usage(void)
      12             : {
      13           0 :         printf("\nUsage: %s [filename]\n\n", prog);
      14           0 :         return 1;
      15             : }
      16             : 
      17           0 : static int parse_cmd(struct iobuf *rbuf, struct blk *blk)
      18             : {
      19           0 :         int ret=-1;
      20             : 
      21           0 :         printf("%c%04X", rbuf->cmd, (unsigned int)rbuf->len);
      22           0 :         switch(rbuf->cmd)
      23             :         {
      24             :                 case CMD_SIG:
      25           0 :                         if(blk_set_from_iobuf_sig_and_savepath(blk, rbuf))
      26           0 :                                 goto end;
      27             :                         printf("%016"PRIX64"%s%s\n",
      28             :                                 blk->fingerprint,
      29             :                                 bytes_to_md5str(blk->md5sum),
      30           0 :                                 uint64_to_savepathstr_with_sig(blk->savepath));
      31           0 :                         break;
      32             :                 case CMD_FINGERPRINT:
      33           0 :                         if(blk_set_from_iobuf_fingerprint(blk, rbuf))
      34           0 :                                 goto end;
      35           0 :                         printf("%016"PRIX64"\n", blk->fingerprint);
      36           0 :                         break;
      37             :                 case CMD_SAVE_PATH:
      38           0 :                         if(blk_set_from_iobuf_savepath(blk, rbuf))
      39           0 :                                 goto end;
      40           0 :                         printf("%s\n", uint64_to_savepathstr(blk->savepath));
      41           0 :                         break;
      42             :                 case CMD_DATA:
      43           0 :                         logp("\n%s looks like a data file\n", path);
      44           0 :                         goto end;
      45             :                 default:
      46           0 :                         printf("%s\n", rbuf->buf);
      47           0 :                         break;
      48             :         }
      49           0 :         ret=0;
      50             : end:
      51           0 :         return ret;;
      52             : }
      53             : 
      54           0 : int run_bsigs(int argc, char *argv[])
      55             : {
      56           0 :         int ret=1;
      57           0 :         fzp *fzp=NULL;
      58             :         struct iobuf rbuf;
      59             :         struct blk blk;
      60           0 :         memset(&rbuf, 0, sizeof(struct iobuf));
      61             : 
      62           0 :         if(argc!=2)
      63           0 :                 return usage();
      64           0 :         path=argv[1];
      65             : 
      66           0 :         if(!(fzp=fzp_gzopen(path, "rb")))
      67           0 :                 goto end;
      68             :         while(1)
      69             :         {
      70           0 :                 iobuf_free_content(&rbuf);
      71           0 :                 switch(iobuf_fill_from_fzp(&rbuf, fzp))
      72             :                 {
      73           0 :                         case 1: ret=0; // Finished OK.
      74           0 :                         case -1: goto end; // Error.
      75             :                 }
      76             : 
      77           0 :                 if(parse_cmd(&rbuf, &blk)) goto end;
      78             :         }
      79             : 
      80             : end:
      81           0 :         iobuf_free_content(&rbuf);
      82           0 :         fzp_close(&fzp);
      83           0 :         return ret;
      84             : }

Generated by: LCOV version 1.10