Diff

Differences From Artifact [4d722642c3]:

To Artifact [0c5019ef32]:


34
35
36
37
38
39
40






41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58





















59
60
61
62
63
64
65
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92







+
+
+
+
+
+




-
+













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	APPFS_CPU_UNKNOWN,
	APPFS_CPU_ALL,
	APPFS_CPU_AMD64,
	APPFS_CPU_I386,
	APPFS_CPU_ARM
} appfs_cpuArch_t;

typedef enum {
	APPFS_PATHTYPE_FILE,
	APPFS_PATHTYPE_DIRECTORY,
	APPFS_PATHTYPE_SYMLINK
} appfs_pathtype_t;

struct appfs_package {
	struct appfs_package *_next;
	int counter;

	char name[128];
	char name[256];
	char version[64];
	char sha1[41];
	appfs_os_t os;
	appfs_cpuArch_t cpuArch;
	int isLatest;
};

struct appfs_site {
	struct appfs_site *_next;
	int counter;

	char name[256];
};

struct appfs_children {
	struct appfs_children *_next;
	int counter;

	char name[256];
};

struct appfs_pathinfo {
	appfs_pathtype_t type;
	time_t time;
	union {
		struct {
			int childcount;
		} dir;
		struct {
			int executable;
			off_t size;
		} file;
	} typeinfo;
};

static appfs_os_t appfs_convert_os_fromString(const char *os) {
	if (strcasecmp(os, "Linux") == 0) {
		return(APPFS_OS_LINUX);
	}

	if (strcasecmp(os, "Darwin") == 0 || strcasecmp(os, "Mac OS") == 0 || strcasecmp(os, "Mac OS X") == 0) {
140
141
142
143
144
145
146

147
148
149
150
151

152
153
154
155




156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
212







+





+




+
+
+
+
















-
+







	const char *arg;
	va_list argp;
	int retval;
	int i;

	objv = (void *) ckalloc(sizeof(*objv) * objc);
	objv[0] = Tcl_NewStringObj(cmd, -1);
	Tcl_IncrRefCount(objv[0]);

	va_start(argp, cmd);
	for (i = 1; i < objc; i++) {
		arg = va_arg(argp, const char *);
		objv[i] = Tcl_NewStringObj(arg, -1);
		Tcl_IncrRefCount(objv[i]);
	}
	va_end(argp);

	retval = Tcl_EvalObjv(interp, objc, objv, 0);

	for (i = 0; i < objc; i++) {
		Tcl_DecrRefCount(objv[i]);
	}

	ckfree((void *) objv);

	return(retval);
}

#define appfs_free_list_type(id, type) static void appfs_free_list_ ## id(type *head) { \
	type *obj, *next; \
	for (obj = head; obj; obj = next) { \
		next = obj->_next; \
		ckfree((void *) obj); \
	} \
}

appfs_free_list_type(site, struct appfs_site)
appfs_free_list_type(package, struct appfs_package)

appfs_free_list_type(children, struct appfs_children)

static int appfs_getsites_cb(void *_head, int columns, char **values, char **names) {
	struct appfs_site **head_p, *obj;

	head_p = _head;

	obj = (void *) ckalloc(sizeof(*obj));
286
287
288
289
290
291
292
293
294
295






296
297
298
299
300
301
302
303
304
305
306















307
308
309
310
311
312
313
314
315
316
317
318
319




320
321
322
323
324
325
326

327
328
329
330
331
332





333
334





335
336












337
338
339
340
341
342
343
319
320
321
322
323
324
325



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366




367
368
369
370



371

372
373
374
375
376
377
378


379
380
381
382
383
384
385
386
387
388
389
390


391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409







-
-
-
+
+
+
+
+
+











+
+
+
+
+
+
+
+
+
+
+
+
+
+
+









-
-
-
-
+
+
+
+
-
-
-

-


+




-
-
+
+
+
+
+


+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+







	return(0);
}

static int appfs_getmanifest(const char *hostname, const char *sha1) {
	return(0);
}

#if 0
static int appfs_parse_path(const char *_path, struct appfs_path *pathinfo) {
	char *path;
/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *_path, struct appfs_pathinfo *pathinfo, struct appfs_children **children) {
	struct appfs_site *sites, *site;
	struct appfs_children *node;
	int sites_count;
	char *path, *hostname, *package;

	if (_path == NULL) {
		return(-ENOENT);
	}

	if (_path[0] != '/') {
		return(-ENOENT);
	}

	if (_path[1] == '\0') {
		/* Request for the root directory */
		pathinfo->type = APPFS_PATHTYPE_DIRECTORY;
		sites = appfs_getsites(&sites_count);
		pathinfo->typeinfo.dir.childcount = sites_count;

		if (children) {
			for (site = sites; site; site = site->_next) {
				node = (void *) ckalloc(sizeof(*node));
				node->_next = *children;
				*children = node;
			}
		}

		appfs_free_list_site(sites);

		return(0);
	}

	path = strdup(_path);

	hostname = path + 1;
	package = strchr(hostname, '/');

	if (package == NULL) {
		/* Request for a single hostname */
	}


}
	} else {
		*package = '\0';
		package++;
	}
#else
static int appfs_parse_path(const char *_path) {
	return(0);
}
#endif

static int appfs_fuse_getattr(const char *path, struct stat *stbuf) {
	struct appfs_pathinfo pathinfo;
	int res = 0;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

	res = appfs_parse_path(path);

	res = appfs_get_path_info(path, &pathinfo, NULL);
	if (res != 0) {
		return(res);
	}

	memset(stbuf, 0, sizeof(struct stat));

	stbuf->st_mtime = pathinfo.time;
	stbuf->st_ctime = pathinfo.time;
	stbuf->st_atime = pathinfo.time;

	if (pathinfo.type == APPFS_PATHTYPE_DIRECTORY) {
	stbuf->st_mode = S_IFDIR | 0755;
	stbuf->st_nlink = 2;
		stbuf->st_mode = S_IFDIR | 0755;
		stbuf->st_nlink = 2 + pathinfo.typeinfo.dir.childcount;
	} else {
		if (pathinfo.typeinfo.file.executable) {
			stbuf->st_mode = S_IFREG | 0755;
		} else {
			stbuf->st_mode = S_IFREG | 0644;
		}

		stbuf->st_nlink = 1;
		stbuf->st_size = pathinfo.typeinfo.file.size;
	}

	return res;
}

static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
	APPFS_DEBUG("Enter (path = %s, ...)", path);