DetectString blues

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
ctiberg
Member
Member
Posts: 194
Joined: 2003-10-24, 14:10 UTC
Location: Kristianstad, Sweden

DetectString blues

Post by *ctiberg »

We've now found out some more about the troubles with the DetectString returned from lister plugins..

One troublesome area is of course the length limitation inherent in the way it's called - a plugin can never return a longer one than the length supplied by TC. This one improved a tiny bit in that TC6 had increased the available buffer size.

Another area of concern seems to be the way TC stores these strings in the INI file. Perfectly valid detectstrings work fine as long as you're in the same session with TC, but TC reports errors when reading them back from the INI file - this is the case in our ImageLister plugin.

I don't think that anyone wants to have plugins return just "MULTIMEDIA" with nothing more. That'd increase the load times dramatically for all files, even files that the plugin has no interest in.

But this is the route that we'll take in the next version of ImageLister - not out of malice, but because we're restricted by this problem in the functionality that we can expose to TC users.

Any opinions on this is welcome :)
Best regards,
Christian Tiberg
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Another area of concern seems to be the way TC stores these strings in the INI file. Perfectly valid detectstrings work fine as long as you're in the same session with TC, but TC reports errors when reading them back from the INI file - this is the case in our ImageLister plugin.
It's important to enclose the detect string in extra double quotes, because when a string in an INI starts and ends with double quotes, Windows will cut them off. Or try putting your string un round brackets ().
Author of Total Commander
https://www.ghisler.com
User avatar
ctiberg
Member
Member
Posts: 194
Joined: 2003-10-24, 14:10 UTC
Location: Kristianstad, Sweden

Post by *ctiberg »

Here's what our plugin would return, if it had worked better than it does:

MULTIMEDIA & (EXT="bmp" | EXT="ico" | EXT="wmf" | EXT="emf" | EXT="jfif" | EXT="jpg" | EXT="jpe" | EXT="jpeg" | EXT="rle" | EXT="dib" | EXT="win" | EXT="vst" | EXT="vda" | EXT="tga" | EXT="icb" | EXT="tiff" | EXT="tif" | EXT="fax" | EXT="eps" | EXT="pcx" | EXT="pcc" | EXT="scr" | EXT="rpf" | EXT="rla" | EXT="sgi" | EXT="rgba" | EXT="rgb" | EXT="bw" | EXT="psd" | EXT="pdd" | EXT="ppm" | EXT="pgm" | EXT="pbm" | EXT="cel" | EXT="pic" | EXT="pcd" | EXT="gif" | EXT="cut" | EXT="psp" | EXT="png")

Some statistics:
Lengh returned: 495
MaxLen from TC: 2045

Lines in INI file as a result of registering with above string:
6=G:\Program\TotalCmd\Plugins\ImageLister.wlx
6_detect="MULTIMEDIA & (EXT="bmp" | EXT="ico" | EXT="wmf" | EXT="emf" | EXT="jfif" | EXT="jpg" | EXT="jpe" | EXT="jpeg" | EXT="rle" | EXT="dib" | EXT="win" | EXT="vst" | EXT="vda" | EXT="tga" | EXT="icb" | EXT="tiff" | EXT="tif" | EXT="fax" | EXT="eps" | EXT="pcx" | "

As you can see, the INI file line 6_detect is wrong, and would cause error messages ever after..

Are we doing something wrong, or are you?
Best regards,
Christian Tiberg
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, no idea - I will check it, thanks for the info.
Author of Total Commander
https://www.ghisler.com
User avatar
ctiberg
Member
Member
Posts: 194
Joined: 2003-10-24, 14:10 UTC
Location: Kristianstad, Sweden

Post by *ctiberg »

One suggestion we'd like you to consider is the following function:

int __stdcall ListGetDetectStringEx(char* DetectString,int maxlen);

This function would copy the detect string if maxlen was enough, and then return the length of the copied string.

If the DetectString buffer doesn't have enough space, the function would return the required amount, whereupon TC would extend the buffer and call again to get the string...

This would free plugin authors to use whatever length strings they want to.. Provided that TC's INI reading/writing is fixed too, of course...
Best regards,
Christian Tiberg
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I checked my code, and found out why the string is cut off: The function to add double quotes is limited to 259 characters. :-(

I will change this in the upcoming TC 6.02. Sorry for the inconvenience!
Author of Total Commander
https://www.ghisler.com
User avatar
ctiberg
Member
Member
Posts: 194
Joined: 2003-10-24, 14:10 UTC
Location: Kristianstad, Sweden

Post by *ctiberg »

Hehe... No problem, then we'll release a fully enabled plugin too :)
Best regards,
Christian Tiberg
User avatar
ctiberg
Member
Member
Posts: 194
Joined: 2003-10-24, 14:10 UTC
Location: Kristianstad, Sweden

Post by *ctiberg »

Just a reminder - the function we suggested above would be better (at least according to us) than just sending a 2500 byte buffer... Who knows, some strange plugin might come up with a string longer than that some day...

If ListGetDetectStringEx is implemented, and you fix the read/write to the INI, there won't be no more problems in this area as far as we can see...
Best regards,
Christian Tiberg
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I don't want to have a string which is too long, because of the 64k ini file limit. In such a case it's better to create a small base plugin wlx which contains the detection stuff, and put the big work stuff in external dlls which are loaded when they are needed. This way your wlx would load very quickly, so there would be no problem with loading it on every call. The main idea of the detect string was that specialized plugins (e.g. for PDF, DOC etc) won't get loaded for every file.
Author of Total Commander
https://www.ghisler.com
User avatar
nevidimka
Senior Member
Senior Member
Posts: 385
Joined: 2004-06-20, 21:38 UTC

Post by *nevidimka »

I checked my code, and found out why the string is cut off: The function to add double quotes is limited to 259 characters.
I will change this in the upcoming TC 6.02. Sorry for the inconvenience!
Problem still exists!!!
My Imagine detect string will be cutted
original (301 characters):
0_detect="ext="JPG"|ext="GIF"|ext="PNG"|ext="BMP"|ext="PCX"|ext="TGA"|ext="PSD"|ext="TIF"|ext="LBM"|ext="IFF"|ext="FLI"|ext="FLC"|ext="SPR"|ext="PCD"|ext="JPC"|ext="JP2"|ext="J2K"|ext="PBM"|ext="PGM"|ext="PPM"|ext="RAS"|ext="SGI"|ext="JBG"|ext="ICO"|ext="CUR"|ext="ANI"|ext="CLP"|ext="RLE"|ext="CDR""

cutted (269 characters):
0_detect="ext="JPG"|ext="GIF"|ext="PNG"|ext="BMP"|ext="PCX"|ext="TGA"|ext="PSD"|ext="TIF"|ext="LBM"|ext="IFF"|ext="FLI"|ext="FLC"|ext="SPR"|ext="PCD"|ext="JPC"|ext="JP2"|ext="J2K"|ext="PBM"|ext="PGM"|ext="PPM"|ext="RAS"|ext="SGI"|ext="JBG"|ext="ICO"|ext="CUR"|ext="AN"

What I did: I added an another lister plugin with plugin autoinstallation. This another plugin has nothing to do with Imagine plugin. Therefore I cann't understand why TC touched the Imagine detect string. The same problem exists if you sort lister plugins with TC (window "Lister plugin").

Plz could it be possible to keep all detectstrings untouched in this cases (because this strings have not to be changed in this cases!)? Thanx.
The doorstep to the temple of wisdom is a knowledge of our own ignorance. Benjamin Franklin
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

That's really strange, I had tested it and it worked here. I will try again...
Author of Total Commander
https://www.ghisler.com
User avatar
nevidimka
Senior Member
Senior Member
Posts: 385
Joined: 2004-06-20, 21:38 UTC

Post by *nevidimka »

history.txt wrote:19.05.05 Fixed: Plugin detect string was cut at 259 chars when adding OTHER plugin
Thanx, it works fine now. :D
The doorstep to the temple of wisdom is a knowledge of our own ignorance. Benjamin Franklin
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for checking!
Author of Total Commander
https://www.ghisler.com
Post Reply