Exemple #1
0
static bool display_info(char *package_path) {
	printf("=== %s\n", package_path);

	struct OPK *opk = opk_open(package_path);
	if (!opk) {
		fprintf(stderr, "Failed to open %s\n", package_path);
		printf("\n");
		return false;
	}

	bool ok = true;

	while (true) {
		const char *metadata_name;
		if (opk_open_metadata(opk, &metadata_name) <= 0)
			break;

		const char *key, *val;
		size_t skey, sval;
		printf("\n");
		printf("Metadata file: %s\n\n", metadata_name);
		while(opk_read_pair(opk, &key, &skey, &val, &sval) && key)
			printf("%.*s: %.*s\n", (int) skey, key, (int) sval, val);
	}

	opk_close(opk);

	printf("\n");
	return ok;
}
Exemple #2
0
void merge_fileList_to_opkList(spFileListPointer fileList,pLocation location)
{
	spFileListPointer file = fileList;
	while (file)
	{
		//Searching the last /
		int i;
		for (i = strlen(file->name)-1; i >= 0; i--)
			if (file->name[i] == '/')
				break;
		char* filename = &(file->name[i+1]);
		struct OPK* opkFile = opk_open(file->name);
		if (opkFile == NULL)
		{
			file = file->next;
			continue;
		}
		char* longname = NULL;
		char* description = NULL;
		char* long_description = NULL;
		const char* metaname = NULL;
		if (opk_open_metadata(opkFile, &metaname) != 1)
		{
			file = file->next;
			continue;
		}
		const char *key, *val;
		size_t skey, sval;
		while(opk_read_pair(opkFile, &key, &skey, &val, &sval) && key)
		{
			char key_string[256];
			sprintf(key_string,"%.*s",(int)skey,key);
			if (strcmp(key_string,"Name") == 0)
			{
				longname = (char*)malloc(sval+1);
				memcpy(longname,val,sval);
				longname[sval] = 0;
				printf("Loading %s\n",longname);
			}
			if (strcmp(key_string,"Comment") == 0)
			{
				description = (char*)malloc(sval+1);
				memcpy(description,val,sval);
				description[sval] = 0;
			}
		}
		opk_close(opkFile);
		if (longname == NULL)
		{
			longname = (char*)malloc(strlen("Error while reading applications name!")+1);
			sprintf(longname,"Error while reading applications name!");
		}
		add_file_to_opkList(longname,filename,location,file->last_mod,description,NULL);
		file = file->next;
	}
}