Thread: iLiad FBReader 0.8.17 problem
View Single Post
Old 12-06-2008, 07:53 PM   #1
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
FBReader 0.8.17 problem

I have built FBReader 0.8.17 for iLiad.
It works in Scratchbox enviroment but fialed on iLiad.
I added some notification into its source code and found where it failed. But I can't figure why.

This is the main entrance in "main.cpp"
Code:
int main(int argc, char **argv) {
	printf("1\n");//my personal addon
	if (!ZLibrary::init(argc, argv)) {
		printf("!ZLibrary::init\n");
		return 1;
	}
	printf("2\n");//my personal addon
	ZLibrary::run(new FBReader(argc == 1 ? std::string() : argv[1]));
	printf("3\n");//my personal addon
	ZLibrary::shutdown();
	return 0;
}

"ZLibrary.cpp" called by "main.cpp"
Code:
bool ZLibrary::init(int &argc, char **&argv) {
#ifdef ZLSHARED
	const std::string pluginPath = std::string(LIBDIR) + "/zlibrary/ui";

	void *handle = 0;
	printf("11\n");//my personal addon
	fflush(stdout);
	if ((argc > 2) && std::string("-zlui") == argv[1]) {
		handle = dlopen((pluginPath + "/zlui-" + argv[2] + ".so").c_str(), RTLD_NOW);
		argc -= 2;
		argv += 2;
	}
	printf("12\n");//my personal addon
	fflush(stdout);
	if (handle == 0) {
		DIR *dir = opendir(pluginPath.c_str());
		if (dir == 0) {
			return false;
		}
		std::vector<std::string> names;
		const dirent *file;
		struct stat fileInfo;
		while ((file = readdir(dir)) != 0) {
			const std::string shortName = file->d_name;
			if ((shortName.substr(0, 5) != "zlui-") ||
					!ZLStringUtil::stringEndsWith(shortName, ".so")) {
				continue;
			}
			const std::string fullName = pluginPath + "/" + shortName;
			stat(fullName.c_str(), &fileInfo);
			if (!S_ISREG(fileInfo.st_mode)) {
				continue;
			}
			names.push_back(fullName);
		}
		closedir(dir);
	printf("13\n");//my personal addon
fflush(stdout);
		std::sort(names.begin(), names.end());
		for (std::vector<std::string>::const_iterator it = names.begin();
				 (it != names.end()) && (handle == 0); ++it) {
			handle = dlopen(it->c_str(), RTLD_NOW);
		}

		if (handle == 0) {
			return false;
		}
	}
	dlerror();
	printf("14\n");//my personal addon
fflush(stdout);
	void (*initLibrary)();
	*(void**)&initLibrary = dlsym(handle, "initLibrary");
	if (dlerror() != 0) {
		return false;
	}
#endif /* ZLSHARED */
	printf("15\n");
fflush(stdout);
	initLibrary();
	printf("16\n");//my personal addon
fflush(stdout);
	if (ZLibraryImplementation::Instance == 0) {
		return false;
	}
	printf("17\n");//my personal addon
fflush(stdout);
	ZLibraryImplementation::Instance->init(argc, argv);
	return true;
}
When I execute FBReader in mrxvt on iLiad, I got output:
Quote:
1
!ZLibrary::init
Then FBReader stopped. And ZLibrary::init didn't output anything. (The reasone that ZLibrary::init() didn't output anything was caused by my forgetting to update lib file. ZLibrary::init() did executed to printf("13\n") and returned false.)

Last edited by ericshliao; 12-06-2008 at 10:09 PM.
ericshliao is offline   Reply With Quote