LCOV - code coverage report
Current view: top level - src - cmd.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 73 73 100.0 %
Date: 2022-08-30 22:36:43 Functions: 9 9 100.0 %

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

Generated by: LCOV version 1.13