Label and extension list broken when format plugin loaded.

Bugs found in XnView Classic. Please report only one bug per topic!

Moderators: helmut, XnTriq, xnview

Post Reply
epi
Posts: 2
Joined: Sun Aug 23, 2009 12:28 pm

Label and extension list broken when format plugin loaded.

Post by epi »

Hi,

I am writing a plugin for viewing 8-bit Atari images and there is quite big number of extensions that need to be supported at once (currently 19).
I've found that XnView 1.74 provides 64 bytes for both label and extension in gfpGetPluginInfo, and 1.96 provides 128 bytes. I do copying using the same method strlcpy does, and just before returning from gfpGetPluginInfo both copied label and extension are proven to be ok (not longer than *_max_size, and always null-terminated).
However, in 1.74, only first 10 extensions work, and in 1.96 - only first 12. When I open Info > Supported formats..., information set by my plugin appears to be broken - here are screenshots from 1.96 (1.74 does similar thing, but at least it doesn't damage label):

Image

Image

Source:

Code: Select all

#ifndef XNVIEW_FAIL_EXT
#define XNVIEW_FAIL_EXT "rip;gr8;mic;hip;tip;int;inp;apc;ap3;gr9;pic;cpr;cin;cci;fnt;sxs;hr;plm;ilc"
#endif

static size_t strlcpy(char *dst, const char *src, size_t size)
{
	int i;
	for (i = 0; i < size - 1 && src[i] != '\0'; i++)
		dst[i] = src[i];
	dst[i] = '\0';
	while  (src[i] != '\0')
		i++;
	return i;
}

DLL_EXPORT BOOL API gfpGetPluginInfo(DWORD version, LPSTR label, INT label_max_size, LPSTR extension, INT extension_max_size, INT *support)
{
	static const char* fail_label = "First Atari Image Library";
	static const char* fail_ext = XNVIEW_FAIL_EXT;

	if (version != 0x0002)
		return FALSE;
	strlcpy(label, fail_label, label_max_size);
	strlcpy(extension, fail_ext, extension_max_size);

	*support = GFP_READ;

	return TRUE;
}
Is there any way to make it work correctly?
User avatar
xnview
Author of XnView
Posts: 46255
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Label and extension list broken when format plugin loaded.

Post by xnview »

epi wrote: I am writing a plugin for viewing 8-bit Atari images and there is quite big number of extensions that need to be supported at once (currently 19).
You have some Atari formats that XnView don't support?? I'm very interested if you can send me samples?
Else currently, there is a limitation. Only 10 extensions can be used by a plugin...
Pierre.
epi
Posts: 2
Joined: Sun Aug 23, 2009 12:28 pm

Re: Label and extension list broken when format plugin loaded.

Post by epi »

Thank you for your quick response. We decided to make two plugins supporting different extensions. The project has just been released at sf.net and here you can download examples.

You may also be interested in the fact, that XnView is likely to crash when you change the name of existing plugin file in "Plugins" directory, or put a new plugin supporting already supported extension, until xnview.ini is deleted.
Post Reply