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-12-03 01:09:05 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             :                 case CMD_DATAPTH:
      72           1 :                         snprintf(buf, len, "Path to data on the server"); break;
      73             :                 case CMD_VSS:
      74           1 :                         snprintf(buf, len, "Windows VSS header"); break;
      75             :                 case CMD_ENC_VSS:
      76           1 :                         snprintf(buf, len, "Encrypted windows VSS header"); break;
      77             :                 case CMD_VSS_T:
      78           1 :                         snprintf(buf, len, "Windows VSS footer"); break;
      79             :                 case CMD_ENC_VSS_T:
      80           1 :                         snprintf(buf, len, "Encrypted windows VSS footer"); break;
      81             : 
      82             :                 // No default so that we get compiler warnings when we forget
      83             :                 // to add new ones here.
      84             :         }
      85          52 :         if(!*buf) snprintf(buf, len, "----------------");
      86          52 :         return buf;
      87             : }
      88             : 
      89           1 : void cmd_print_all(void)
      90             : {
      91           1 :         int i=0;
      92           1 :         char cmds[256]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
      93           1 :         printf("\nIndex of symbols\n\n");
      94          53 :         for(i=0; cmds[i]; i++)
      95          52 :                 printf("  %c: %s\n", cmds[i], cmd_to_text((enum cmd)cmds[i]));
      96           1 :         printf("\n");
      97           1 : }
      98             : 
      99       33017 : int cmd_is_filedata(enum cmd cmd)
     100             : {
     101       33017 :         return     cmd==CMD_FILE
     102       33017 :                 || cmd==CMD_ENC_FILE
     103             :                 || cmd==CMD_METADATA
     104        6005 :                 || cmd==CMD_ENC_METADATA
     105       38816 :                 || cmd==CMD_EFS_FILE;
     106             : }
     107             : 
     108        5415 : int cmd_is_vssdata(enum cmd cmd)
     109             : {
     110        5671 :         return     cmd==CMD_VSS
     111        5671 :                 || cmd==CMD_ENC_VSS
     112        5403 :                 || cmd==CMD_VSS_T
     113       11074 :                 || cmd==CMD_ENC_VSS_T;
     114             : }
     115             : 
     116       15348 : int cmd_is_link(enum cmd cmd)
     117             : {
     118       15348 :         return cmd==CMD_SOFT_LINK || cmd==CMD_HARD_LINK;
     119             : }
     120             : 
     121         256 : int cmd_is_endfile(enum cmd cmd)
     122             : {
     123         256 :         return cmd==CMD_END_FILE;
     124             : }
     125             : 
     126         294 : int cmd_is_encrypted(enum cmd cmd)
     127             : {
     128         294 :         return     cmd==CMD_ENC_FILE
     129         294 :                 || cmd==CMD_ENC_METADATA
     130             :                 || cmd==CMD_ENC_VSS
     131         274 :                 || cmd==CMD_ENC_VSS_T
     132         566 :                 || cmd==CMD_EFS_FILE;
     133             : }
     134             : 
     135         256 : int cmd_is_metadata(enum cmd cmd)
     136             : {
     137         256 :         return cmd_is_vssdata(cmd)
     138             :                 || cmd==CMD_METADATA
     139         256 :                 || cmd==CMD_ENC_METADATA;
     140             : }
     141             : 
     142         256 : int cmd_is_estimatable(enum cmd cmd)
     143             : {
     144         256 :         return     cmd==CMD_FILE
     145         256 :                 || cmd==CMD_ENC_FILE
     146         256 :                 || cmd==CMD_EFS_FILE;
     147             : }

Generated by: LCOV version 1.13