Diff

Differences From Artifact [72840611b5]:

To Artifact [f25bb5c801]:


    10     10   #include <errno.h>
    11     11   #include <fcntl.h>
    12     12   #include <stdio.h>
    13     13   #include <fuse.h>
    14     14   #include <pwd.h>
    15     15   #include <tcl.h>
    16     16   
           17  +/* From sha1.c */
           18  +int Sha1_Init(Tcl_Interp *interp);
           19  +
    17     20   #ifndef APPFS_CACHEDIR
    18     21   #define APPFS_CACHEDIR "/var/cache/appfs"
    19     22   #endif
    20     23   
    21     24   #ifdef DEBUG
    22     25   #define APPFS_DEBUG(x...) { fprintf(stderr, "[debug] %s:%i:%s: ", __FILE__, __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); }
    23     26   #else
................................................................................
    91     94   
    92     95   		return(NULL);
    93     96   	}
    94     97   
    95     98   	tcl_ret = Tcl_Init(interp);
    96     99   	if (tcl_ret != TCL_OK) {
    97    100   		fprintf(stderr, "Unable to initialize Tcl.  Aborting.\n");
          101  +		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
          102  +
          103  +		Tcl_DeleteInterp(interp);
          104  +
          105  +		return(NULL);
          106  +	}
          107  +
          108  +	tcl_ret = Tcl_Eval(interp, "package ifneeded sha1 1.0 [list load {} sha1]");
          109  +	if (tcl_ret != TCL_OK) {
          110  +		fprintf(stderr, "Unable to initialize Tcl SHA1.  Aborting.\n");
          111  +		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
    98    112   
    99    113   		Tcl_DeleteInterp(interp);
   100    114   
   101    115   		return(NULL);
   102    116   	}
   103    117   
   104    118   	tcl_ret = Tcl_Eval(interp, ""
................................................................................
  1106   1120   	char dbfilename[1024];
  1107   1121   	int pthread_ret, snprintf_ret, sqlite_ret;
  1108   1122   
  1109   1123   	globalThread.cachedir = cachedir;
  1110   1124   	globalThread.boottime = time(NULL);
  1111   1125   	globalThread.platform = "linux-x86_64";
  1112   1126   	globalThread.options.writable = 1;
         1127  +
         1128  +	Tcl_StaticPackage(NULL, "sha1", Sha1_Init, NULL);
  1113   1129   
  1114   1130   	pthread_ret = pthread_key_create(&interpKey, NULL);
  1115   1131   	if (pthread_ret != 0) {
  1116   1132   		fprintf(stderr, "Unable to create TSD key for Tcl.  Aborting.\n");
  1117   1133   
  1118   1134   		return(1);
  1119   1135   	}