UNKNOWN_CMD in Plugin

Mar 12, 2011
5
0
#1
According to the docs, I can have my TCC Plugin handle an UNKNOWN_CMD, but I've failed to get this working. In one place in the docs, its says my plugin should implement UNKNOWN_CMD as a "function" and in another place it says my plugin should implement UNKNOWN_CMD as a "command." But neither of these work, my plugin is never called in either case. Other functions and commands in my plugin work just fine so I don't think I'm doing anything obviously wrong. I was just wondering if anyone has successfully implemented UNKNOWN_CMD in a plugin and what the trick is to get it working.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,586
46
Albuquerque, NM
prospero.unm.edu
#3
I messed with it a bit tonight, and I couldn't get it to work either. Is that the correct capitalization: UNKNOWN_CMD? I tried some obvious variations: unknown_cmd, Unknown_Cmd, UNKNOWN_Cmd. No dice; my code only executes if the command line actually begins with "unknown_cmd".

A couple other thoughts: For commands, the command name is stripped from the string passed to the plugin. In the case of UNKNOWN_CMD, it would make sense for the plugin to see the actual command as typed by the user. Also, what happens if UNKNOWN_CMD returns the magic value 0xFEDCBA98? It might be useful in this case for the parser to retry the command, in case the plugin function has modified the command string somehow. Probably you're way ahead of me here, but I didn't see either mentioned in the docs.
 
Mar 12, 2011
5
0
#4
Thanks for looking into this, Charles. I played with it some more and am convinced it doesn't work as it should in TCC. My plugin has an UNKNOWN_CMD command and I do not have an UNKNOWN_CMD alias. In this case my UNKNOWN_CMD handler is never called. However, if I create an UNKNOWN_CMD alias and set it to anything (ALIAS UNKNOWN_CMD=foo) then my UNKNOWN_CMD handler will be called just once. After my UNKNOWN_CMD handler is called one time, from then on TCC will act as though I have neither an UNKNOWN_CMD handler nor an UNKNOWN_CMD alias. Clearly TCC is misbehaving.

I have a workaround though. I created a command in my plugin called UNKNOWN_CMD_HANDLER and then set the UNKNOWN_CMD alias to point to it (ALIAS UNKNOWN_CMD=UNKNOWN_CMD_HANDLER). Then my UNKNOWN_CMD_HANDLER is called as expected. For now, I'll just go with this workaround unless someone else has a better solution.
 
#5
On Mon, 14 Mar 2011 00:07:49 -0400, you wrote:

|Thanks for looking into this, Charles. I played with it some more and am convinced it doesn't work as it should in TCC.

I tried it too, exporting INT WINAPI UNKNOWN_CMD ( WCHAR* ) via a DEF file and
both including and not including it in the list of advertized functions. It
didn't work for me either.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,586
46
Albuquerque, NM
prospero.unm.edu
#7
According to the docs, I can have my TCC Plugin handle an UNKNOWN_CMD, but I've failed to get this working. In one place in the docs, its says my plugin should implement UNKNOWN_CMD as a "function" and in another place it says my plugin should implement UNKNOWN_CMD as a "command." But neither of these work, my plugin is never called in either case. Other functions and commands in my plugin work just fine so I don't think I'm doing anything obviously wrong. I was just wondering if anyone has successfully implemented UNKNOWN_CMD in a plugin and what the trick is to get it working.
Rex, did you ever have an opportunity to look at this issue?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,586
46
Albuquerque, NM
prospero.unm.edu
#10
Did you change something in build 22? Now it seems that an UNKNOWN_CMD plugin command is called for the first, and only the first, unknown command encountered:

Code:
C:\>which unknown_cmd
unknown_cmd is a plugin command (ReDir)

C:\>goondorf
UNKNOWN_CMD: "goondorf"

C:\>goondorf
TCC: Unknown command "goondorf"

C:\>goondorf
TCC: Unknown command "goondorf"

C:\>
 
#11
I see the same thing. My exported UNKNOWN_CMD just BEEPs, and it only works once in a session:

Code:
v:\> gibberish 
(beep)

v:\> gibberish
TCC: Unknown command "gibberish"
Did you change something in build 22? Now it seems that an UNKNOWN_CMD plugin command is called for the first, and only the first, unknown command encountered:

Code:
C:\>which unknown_cmd
unknown_cmd is a plugin command (ReDir)

C:\>goondorf
UNKNOWN_CMD: "goondorf"

C:\>goondorf
TCC: Unknown command "goondorf"

C:\>goondorf
TCC: Unknown command "goondorf"

C:\>