LCOV - code coverage report
Current view: top level - src - cmd.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 38 38 100.0 %
Date: 2017-07-01 Functions: 9 9 100.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "cmd.h"
       3             : 
       4          52 : static char *cmd_to_text(enum cmd cmd)
       5             : {
       6             :         static char buf[256];
       7          52 :         size_t len=sizeof(buf);
       8          52 :         *buf='\0';
       9          52 :         switch(cmd)
      10             :         {
      11             :                 case CMD_ATTRIBS:
      12             :                         snprintf(buf, len, "File attribute information"); break;
      13             :                 case CMD_ATTRIBS_SIGS:
      14             :                         snprintf(buf, len, "File attribute information preceding block signatures"); break;
      15             :                 case CMD_SIG:
      16             :                         snprintf(buf, len, "Block signature"); break;
      17             :                 case CMD_DATA_REQ:
      18             :                         snprintf(buf, len, "Request for block of data"); break;
      19             :                 case CMD_DATA:
      20             :                         snprintf(buf, len, "Block data"); break;
      21             :                 case CMD_WRAP_UP:
      22             :                         snprintf(buf, len, "Control packet"); break;
      23             :                 case CMD_FILE:
      24             :                         snprintf(buf, len, "Plain file"); break;
      25             :                 case CMD_ENC_FILE:
      26             :                         snprintf(buf, len, "Encrypted file"); break;
      27             :                 case CMD_DIRECTORY:
      28             :                         snprintf(buf, len, "Directory"); break;
      29             :                 case CMD_SOFT_LINK:
      30             :                         snprintf(buf, len, "Soft link"); break;
      31             :                 case CMD_HARD_LINK:
      32             :                         snprintf(buf, len, "Hard link"); break;
      33             :                 case CMD_SPECIAL:
      34             :                         snprintf(buf, len, "Special file - fifo, socket, device node"); break;
      35             :                 case CMD_METADATA:
      36             :                         snprintf(buf, len, "Extra meta data"); break;
      37             :                 case CMD_GEN:
      38             :                         snprintf(buf, len, "Generic command"); break;
      39             :                 case CMD_ERROR:
      40             :                         snprintf(buf, len, "Error message"); break;
      41             :                 case CMD_APPEND:
      42             :                         snprintf(buf, len, "Append to a file"); break;
      43             :                 case CMD_INTERRUPT:
      44             :                         snprintf(buf, len, "Interrupt"); break;
      45             :                 case CMD_MESSAGE:
      46             :                         snprintf(buf, len, "Message"); break;
      47             :                 case CMD_WARNING:
      48             :                         snprintf(buf, len, "Warning"); break;
      49             :                 case CMD_END_FILE:
      50             :                         snprintf(buf, len, "End of file transmission"); break;
      51             :                 case CMD_ENC_METADATA:
      52             :                         snprintf(buf, len, "Encrypted meta data"); break;
      53             :                 case CMD_EFS_FILE:
      54             :                         snprintf(buf, len, "Windows EFS file"); break;
      55             :                 case CMD_FILE_CHANGED:
      56             :                         snprintf(buf, len, "Plain file changed"); break;
      57             :                 case CMD_TIMESTAMP:
      58             :                         snprintf(buf, len, "Backup timestamp"); break;
      59             :                 case CMD_TIMESTAMP_END:
      60             :                         snprintf(buf, len, "Timestamp now/end"); break;
      61             :                 case CMD_MANIFEST:
      62             :                         snprintf(buf, len, "Path to a manifest"); break;
      63             :                 case CMD_FINGERPRINT:
      64             :                         snprintf(buf, len, "Fingerprint part of a signature"); break;
      65             :                 case CMD_SAVE_PATH:
      66             :                         snprintf(buf, len, "Save path part of a signature"); break;
      67             : 
      68             :                 // For the status server/client */
      69             : 
      70             :                 case CMD_TOTAL:
      71             :                         snprintf(buf, len, "Total counter"); break;
      72             :                 case CMD_GRAND_TOTAL:
      73             :                         snprintf(buf, len, "Grand total counter"); break;
      74             :                 case CMD_BYTES_ESTIMATED:
      75             :                         snprintf(buf, len, "Bytes estimated"); break;
      76             :                 case CMD_BYTES:
      77             :                         snprintf(buf, len, "Bytes"); break;
      78             :                 case CMD_BYTES_RECV:
      79             :                         snprintf(buf, len, "Bytes received"); break;
      80             :                 case CMD_BYTES_SENT:
      81             :                         snprintf(buf, len, "Bytes sent"); break;
      82             : 
      83             :                 // Protocol1 only.
      84             :                 case CMD_DATAPTH:
      85             :                         snprintf(buf, len, "Path to data on the server"); break;
      86             :                 case CMD_VSS:
      87             :                         snprintf(buf, len, "Windows VSS header"); break;
      88             :                 case CMD_ENC_VSS:
      89             :                         snprintf(buf, len, "Encrypted windows VSS header"); break;
      90             :                 case CMD_VSS_T:
      91             :                         snprintf(buf, len, "Windows VSS footer"); break;
      92             :                 case CMD_ENC_VSS_T:
      93             :                         snprintf(buf, len, "Encrypted windows VSS footer"); break;
      94             : 
      95             :                 // No default so that we get compiler warnings when we forget
      96             :                 // to add new ones here.
      97             :         }
      98          52 :         if(!*buf) snprintf(buf, len, "----------------");
      99          52 :         return buf;
     100             : }
     101             : 
     102           1 : void cmd_print_all(void)
     103             : {
     104           1 :         int i=0;
     105           1 :         char cmds[256]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     106             :         printf("\nIndex of symbols\n\n");
     107          53 :         for(i=0; cmds[i]; i++)
     108          52 :                 printf("  %c: %s\n", cmds[i], cmd_to_text((enum cmd)cmds[i]));
     109             :         printf("\n");
     110           1 : }
     111             : 
     112      261498 : int cmd_is_filedata(enum cmd cmd)
     113             : {
     114      522996 :         return     cmd==CMD_FILE
     115      261498 :                 || cmd==CMD_ENC_FILE
     116             :                 || cmd==CMD_METADATA
     117      111888 :                 || cmd==CMD_ENC_METADATA
     118      373018 :                 || cmd==CMD_EFS_FILE;
     119             : }
     120             : 
     121       11044 : int cmd_is_vssdata(enum cmd cmd)
     122             : {
     123       22459 :         return     cmd==CMD_VSS
     124       11415 :                 || cmd==CMD_ENC_VSS
     125       10985 :                 || cmd==CMD_VSS_T
     126       22400 :                 || cmd==CMD_ENC_VSS_T;
     127             : }
     128             : 
     129       70224 : int cmd_is_link(enum cmd cmd)
     130             : {
     131       70224 :         return cmd==CMD_SOFT_LINK || cmd==CMD_HARD_LINK;
     132             : }
     133             : 
     134         256 : int cmd_is_endfile(enum cmd cmd)
     135             : {
     136         256 :         return cmd==CMD_END_FILE;
     137             : }
     138             : 
     139       85505 : int cmd_is_encrypted(enum cmd cmd)
     140             : {
     141      171010 :         return     cmd==CMD_ENC_FILE
     142       85505 :                 || cmd==CMD_ENC_METADATA
     143             :                 || cmd==CMD_ENC_VSS
     144       85485 :                 || cmd==CMD_ENC_VSS_T
     145      170988 :                 || cmd==CMD_EFS_FILE;
     146             : }
     147             : 
     148         371 : int cmd_is_metadata(enum cmd cmd)
     149             : {
     150         371 :         return cmd_is_vssdata(cmd)
     151             :                 || cmd==CMD_METADATA
     152         371 :                 || cmd==CMD_ENC_METADATA;
     153             : }
     154             : 
     155         256 : int cmd_is_estimatable(enum cmd cmd)
     156             : {
     157         512 :         return     cmd==CMD_FILE
     158         256 :                 || cmd==CMD_ENC_FILE
     159         256 :                 || cmd==CMD_EFS_FILE;
     160             : }

Generated by: LCOV version 1.10