Diff

Differences From Artifact [9a50e0345b]:

To Artifact [4cd4495e1d]:


54
55
56
57
58
59
60


61
62
63
64
65
66
67
struct appfs_package {
	struct appfs_package *_next;
	int counter;

	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;







>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
struct appfs_package {
	struct appfs_package *_next;
	int counter;

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

struct appfs_site {
	struct appfs_site *_next;
381
382
383
384
385
386
387


388
389
390
391
392
393
394
	obj = (void *) ckalloc(sizeof(*obj));

	snprintf(obj->name, sizeof(obj->name), "%s", values[0]);
	snprintf(obj->version, sizeof(obj->version), "%s", values[1]);
	snprintf(obj->sha1, sizeof(obj->sha1), "%s", values[2]);
	obj->os = appfs_convert_os_fromString(values[3]);
	obj->cpuArch = appfs_convert_cpuArch_fromString(values[4]);


	if (values[5][0] == '1') {
		obj->isLatest = 1;
	} else {
		obj->isLatest = 0;
	}

	if (*head_p == NULL) {







>
>







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
	obj = (void *) ckalloc(sizeof(*obj));

	snprintf(obj->name, sizeof(obj->name), "%s", values[0]);
	snprintf(obj->version, sizeof(obj->version), "%s", values[1]);
	snprintf(obj->sha1, sizeof(obj->sha1), "%s", values[2]);
	obj->os = appfs_convert_os_fromString(values[3]);
	obj->cpuArch = appfs_convert_cpuArch_fromString(values[4]);
	snprintf(obj->os_str, sizeof(obj->os_str), "%s", values[3]);
	snprintf(obj->cpuArch_str, sizeof(obj->cpuArch_str), "%s", values[4]);
	if (values[5][0] == '1') {
		obj->isLatest = 1;
	} else {
		obj->isLatest = 0;
	}

	if (*head_p == NULL) {
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
	char **retval = _retval;

	*retval = strdup(values[0]);

	return(0);
}

static char *appfs_lookup_package_hash(const char *hostname, const char *package, appfs_os_t os, appfs_cpuArch_t cpuArch, const char *version) {
	char *sql;
	char *retval = NULL;
	int sqlite_ret;

	appfs_update_index(hostname);

	sql = sqlite3_mprintf("SELECT sha1 FROM packages WHERE hostname = %Q AND package = %Q AND os = %Q AND cpuArch = %Q AND version = %Q;",
		hostname,
		package,
		appfs_convert_os_toString(os),
		appfs_convert_cpuArch_toString(cpuArch),
		version
	);
	if (sql == NULL) {
		APPFS_DEBUG("Call to sqlite3_mprintf failed.");

		return(NULL);
	}







|









|
|







503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
	char **retval = _retval;

	*retval = strdup(values[0]);

	return(0);
}

static char *appfs_lookup_package_hash(const char *hostname, const char *package, const char *os, const char *cpuArch, const char *version) {
	char *sql;
	char *retval = NULL;
	int sqlite_ret;

	appfs_update_index(hostname);

	sql = sqlite3_mprintf("SELECT sha1 FROM packages WHERE hostname = %Q AND package = %Q AND os = %Q AND cpuArch = %Q AND version = %Q;",
		hostname,
		package,
		os,
		cpuArch,
		version
	);
	if (sql == NULL) {
		APPFS_DEBUG("Call to sqlite3_mprintf failed.");

		return(NULL);
	}
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
			}

			os_cpuArch_count++;

			if (children) {
				node = (void *) ckalloc(sizeof(*node));
				node->_next = *children;
				snprintf(node->name, sizeof(node->name), "%s-%s", appfs_convert_os_toString(package->os), appfs_convert_cpuArch_toString(package->cpuArch));
				*children = node;
			}
		}

		appfs_free_list_package(packages);

		free(path_s);







|







751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
			}

			os_cpuArch_count++;

			if (children) {
				node = (void *) ckalloc(sizeof(*node));
				node->_next = *children;
				snprintf(node->name, sizeof(node->name), "%s-%s", package->os_str, package->cpuArch_str);
				*children = node;
			}
		}

		appfs_free_list_package(packages);

		free(path_s);
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
	}

	/* Request for a file in a specific package */
	APPFS_DEBUG("Requesting information for hostname = %s, package = %s, os = %s, cpuArch = %s, version = %s, path = %s", 
		hostname, packagename, os, cpuArch, version, path
	);

	package_hash = appfs_lookup_package_hash(hostname, packagename, os_val, cpuArch_val, version);
	if (package_hash == NULL) {
		free(path_s);

		return(-ENOENT);
	}

	APPFS_DEBUG("  ... which hash a hash of %s", package_hash);







|







842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
	}

	/* Request for a file in a specific package */
	APPFS_DEBUG("Requesting information for hostname = %s, package = %s, os = %s, cpuArch = %s, version = %s, path = %s", 
		hostname, packagename, os, cpuArch, version, path
	);

	package_hash = appfs_lookup_package_hash(hostname, packagename, os, cpuArch, version);
	if (package_hash == NULL) {
		free(path_s);

		return(-ENOENT);
	}

	APPFS_DEBUG("  ... which hash a hash of %s", package_hash);