Overview
Comment: | Working on creating an SQLite interface |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 676f99c72e881fdf4d897dae482b156eb96dff24 |
User & Date: | rkeene on 2014-09-08 04:25:02 |
Other Links: | manifest | tags |
Context
2014-09-08
| ||
04:34 | More work towards SQLite3 integration check-in: 76ac4557f6 user: rkeene tags: trunk | |
04:25 | Working on creating an SQLite interface check-in: 676f99c72e user: rkeene tags: trunk | |
03:18 | More rework check-in: ebf9995a42 user: rkeene tags: trunk | |
Changes
Modified appfs.c from [4ce583b799] to [8a456b75d5].
1 1 #define FUSE_USE_VERSION 26 2 2 3 +#include <sqlite3.h> 3 4 #include <string.h> 4 5 #include <stdarg.h> 5 6 #include <errno.h> 6 7 #include <fcntl.h> 7 8 #include <stdio.h> 8 9 #include <fuse.h> 9 10 #include <tcl.h> 10 11 11 12 #define APPFS_CACHEDIR "/tmp/appfs-cache" 12 13 13 14 #define APPFS_DEBUG(x...) { fprintf(stderr, "%i:%s: ", __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); } 14 15 15 -Tcl_Interp *interp; 16 +struct appfs_thread_data { 17 + Tcl_Interp *interp; 18 + sqlite3 *db; 19 +}; 20 + 21 +struct appfs_thread_data globalThread; 16 22 17 23 typedef enum { 18 24 APPFS_OS_UNKNOWN, 19 25 APPFS_OS_ALL, 20 26 APPFS_OS_LINUX, 21 27 APPFS_OS_MACOSX, 22 28 APPFS_OS_FREEBSD, ................................................................................ 145 151 static struct appfs_package *appfs_getindex(const char *hostname, int *package_count_p) { 146 152 int tcl_ret; 147 153 148 154 if (package_count_p == NULL) { 149 155 return(NULL); 150 156 } 151 157 152 - tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getindex", hostname); 158 + tcl_ret = appfs_Tcl_Eval(globalThread.interp, 2, "::appfs::getindex", hostname); 153 159 if (tcl_ret != TCL_OK) { 154 - APPFS_DEBUG("Call to ::appfs::getindex failed: %s", Tcl_GetStringResult(interp)); 160 + APPFS_DEBUG("Call to ::appfs::getindex failed: %s", Tcl_GetStringResult(globalThread.interp)); 155 161 156 162 return(NULL); 157 163 } 158 164 159 165 return(NULL); 160 166 } 161 167 ................................................................................ 218 224 .read = appfs_fuse_read 219 225 }; 220 226 221 227 int main(int argc, char **argv) { 222 228 const char *cachedir = APPFS_CACHEDIR; 223 229 int tcl_ret; 224 230 225 - interp = Tcl_CreateInterp(); 226 - if (interp == NULL) { 231 + globalThread.interp = Tcl_CreateInterp(); 232 + if (globalThread.interp == NULL) { 227 233 fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n"); 228 234 229 235 return(1); 230 236 } 231 237 232 - tcl_ret = Tcl_Init(interp); 238 + tcl_ret = Tcl_Init(globalThread.interp); 233 239 if (tcl_ret != TCL_OK) { 234 240 fprintf(stderr, "Unable to initialize Tcl. Aborting.\n"); 235 241 236 242 return(1); 237 243 } 238 244 239 - tcl_ret = Tcl_Eval(interp, "" 245 + tcl_ret = Tcl_Eval(globalThread.interp, "" 240 246 #include "appfs.tcl.h" 241 247 ""); 242 248 if (tcl_ret != TCL_OK) { 243 249 fprintf(stderr, "Unable to initialize Tcl AppFS script. Aborting.\n"); 244 - fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); 250 + fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(globalThread.interp)); 245 251 246 252 return(1); 247 253 } 248 254 249 - if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) { 255 + if (Tcl_SetVar(globalThread.interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) { 250 256 fprintf(stderr, "Unable to set cache directory. This should never fail.\n"); 251 257 252 258 return(1); 253 259 } 254 260 255 - tcl_ret = appfs_Tcl_Eval(interp, 1, "::appfs::init"); 261 + tcl_ret = appfs_Tcl_Eval(globalThread.interp, 1, "::appfs::init"); 256 262 if (tcl_ret != TCL_OK) { 257 263 fprintf(stderr, "Unable to initialize Tcl AppFS script (::appfs::init). Aborting.\n"); 258 - fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); 264 + fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(globalThread.interp)); 259 265 260 266 return(1); 261 267 } 262 268 263 269 #ifdef APPFS_TEST_DRIVER 264 270 return(appfs_test_driver()); 265 271 #else 266 272 return(fuse_main(argc, argv, &appfs_oper, NULL)); 267 273 #endif 268 274 } 269 275