LCOV - code coverage report
Current view: top level - src/client/protocol2 - rabin_read.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 19 21 90.5 %
Date: 2016-02-29 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "../../burp.h"
       2             : #include "../../attribs.h"
       3             : #include "../../bfile.h"
       4             : #include "../../cntr.h"
       5             : #include "../../log.h"
       6             : #include "../../sbuf.h"
       7             : 
       8             : // Return -1 for error, 0 for could not open file, 1 for success.
       9          22 : int rabin_open_file(struct sbuf *sb, struct asfd *asfd, struct cntr *cntr,
      10             :         struct conf **confs)
      11             : {
      12          22 :         BFILE *bfd=&sb->protocol2->bfd;
      13             : #ifdef HAVE_WIN32
      14             :         if(win32_lstat(sb->path.buf, &sb->statp, &sb->winattr))
      15             : #else
      16          44 :         if(lstat(sb->path.buf, &sb->statp))
      17             : #endif
      18             :         {
      19             :                 // This file is no longer available.
      20           3 :                 logw(asfd, cntr, "%s has vanished\n", sb->path.buf);
      21           3 :                 return 0;
      22             :         }
      23          19 :         if(sbuf_is_metadata(sb))
      24             :         {
      25             :                 // Implement this.
      26             :                 // Load all of the metadata into a buffer.
      27             :                 return -1;
      28             :         }
      29          19 :         sb->compression=get_int(confs[OPT_COMPRESSION]);
      30             :         // Encryption not yet implemented in protocol2.
      31             :         //sb->protocol2->encryption=conf->protocol2->encryption_password?1:0;
      32          19 :         if(attribs_encode(sb)) return -1;
      33             : 
      34          19 :         if(bfd->open_for_send(bfd, asfd,
      35             :                 sb->path.buf, sb->winattr,
      36          19 :                 get_int(confs[OPT_ATIME]), cntr, PROTO_2))
      37             :         {
      38             :                 logw(asfd, get_cntr(confs),
      39           0 :                         "Could not open %s\n", sb->path.buf);
      40           0 :                 return 0;
      41             :         }
      42             :         return 1;
      43             : }
      44             : 
      45          19 : void rabin_close_file(struct sbuf *sb, struct asfd *asfd)
      46             : {
      47             :         BFILE *bfd;
      48          19 :         if(sbuf_is_metadata(sb))
      49             :         {
      50             :                 // Implement this.
      51             :                 // Free the buffer.
      52          19 :                 return;
      53             :         }
      54          19 :         bfd=&sb->protocol2->bfd;
      55          19 :         bfd->close(bfd, asfd);
      56             : }
      57             : 
      58          38 : ssize_t rabin_read(struct sbuf *sb, char *buf, size_t bufsize)
      59             : {
      60             :         BFILE *bfd;
      61          38 :         if(sbuf_is_metadata(sb))
      62             :         {
      63             :                 // Implement this.
      64             :                 // Place bufsize of the metadata buffer contents into buf.
      65             :                 return 0;
      66             :         }
      67          38 :         bfd=&sb->protocol2->bfd;
      68          38 :         return (ssize_t)bfd->read(bfd, buf, bufsize);
      69             : }

Generated by: LCOV version 1.10