1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

UNKNOWN_CMD in Plugin

Discussion in 'Plugins' started by Deschutes, Mar 13, 2011.

  1. Deschutes

    Joined:
    Mar 12, 2011
    Messages:
    5
    Likes Received:
    0
    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.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,092
    Likes Received:
    85
    UNKNOWN_CMD is a command. I'd have to see your code to see what the problem might be. (But note that if you have an UNKNOWN_CMD alias, it will override the plugin.)
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    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.
     
  4. Deschutes

    Joined:
    Mar 12, 2011
    Messages:
    5
    Likes Received:
    0
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,129
    Likes Received:
    33
    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.
     
  6. Deschutes

    Joined:
    Mar 12, 2011
    Messages:
    5
    Likes Received:
    0
    Thanks Vince for confirming that my difficulties were not strictly due to my incompetence.
     
  7. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    Rex, did you ever have an opportunity to look at this issue?
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,092
    Likes Received:
    85
    It works fine here (as a command, just like PRE_EXEC, PRE_INPUT, etc.).
     
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    Really? And it's called when you type an unknown command, say FOOBAR?
     
  10. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,129
    Likes Received:
    33
    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"
     
  12. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    Thanks.
     
  13. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    It's working as I would expect in build 23. Thank you, Rex. (I can also confirm that the bookmarks-in-VIEW-with-redirection thing seems to be fixed, too.)
     
  14. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40

Share This Page