Diff

Differences From Artifact [c7558f05e3]:

To Artifact [981ef56829]:


     2      2   
     3      3   #ifdef HAVE_STDLIB_H
     4      4   #  include <stdlib.h>
     5      5   #endif
     6      6   
     7      7   typedef struct cvfs_data *(cmd_getData_t)(const char *, unsigned long);
     8      8   typedef unsigned long (cmd_getChildren_t)(const char *, unsigned long *, unsigned long);
            9  +typedef void (cmd_decryptFile_t)(const char *, struct cvfs_data *); 
     9     10   
    10     11   /* Your implementation must provide these */
    11     12   static cmd_getData_t *getCmdData(const char *hashkey);
    12     13   static cmd_getChildren_t *getCmdChildren(const char *hashkey);
           14  +static cmd_decryptFile_t *getCmdDecryptFile(const char *hashkey);
    13     15   
    14     16   /* Tcl Commands */
    15     17   static int getMetadata(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
    16     18   	cmd_getData_t *cmd_getData;
    17     19   	cmd_getChildren_t *cmd_getChildren;
    18     20   	struct cvfs_data *finfo = NULL;
    19     21   	Tcl_Obj *ret_list, *ret_list_items[20];
................................................................................
   105    107   
   106    108   	return(TCL_OK);
   107    109   }
   108    110   
   109    111   static int getData(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   110    112   	struct cvfs_data *finfo = NULL;
   111    113   	cmd_getData_t *cmd_getData;
          114  +	cmd_decryptFile_t *cmd_decryptFile;
   112    115   	const char *hashkey;
   113    116   	const char *file;
   114    117   	const char *end_str;
   115    118   	Tcl_Obj *ret_str;
   116    119   	long start = 0;
   117    120   	long end = -1;
   118    121   	int tclGetLFO_ret;
................................................................................
   158    161   	finfo = cmd_getData(file, 0);
   159    162   
   160    163   	if (finfo == NULL) {
   161    164   		Tcl_SetResult(interp, "No such file or directory", TCL_STATIC);
   162    165   
   163    166   		return(TCL_ERROR);
   164    167   	}
          168  +
          169  +	if (finfo->type == CVFS_FILETYPE_OBSFUCATED_FILE || finfo->type == CVFS_FILETYPE_ENCRYPTED_FILE) {
          170  +		cmd_decryptFile = getCmdDecryptFile(hashkey);
          171  +
          172  +		if (cmd_decryptFile != NULL) {
          173  +			cmd_decryptFile(file, finfo);
          174  +		}
          175  +	}
   165    176   
   166    177   	if (finfo->type != CVFS_FILETYPE_FILE) {
   167    178   		Tcl_SetResult(interp, "Not a file", TCL_STATIC);
   168    179   
   169    180   		return(TCL_ERROR);
   170    181   	}
   171    182