📄 dintern.doc
字号:
Distribution Internals----------------------This file documents some useful functions in the distribution VTCcode. It does not document functions and globals that are notintended for outside use, or for functions which are essentiallycommand handlers.avl.vtc-------Data type: Tree (Ttree) A tree is a data structure for associating keys with values. Insertions, deletions, and searches are performed in O(ln n) time. Because the tree is an AVL tree, there is no problem with inserting pre-sorted data. tree->cfunc Comparison function tree->root Root nodePLIST make_tree(FPTR/PPTR compare_func)This returns a new tree, using <compare_func> to compare keys.<compare_func> is expected to act like strcmp(), that is, returningless than zero, zero, or greater than zero depending on the orderingof the two arguments.NULL insert_tree(PLIST tree, ?? key, ?? data)Inserts <data> in <tree>, associated with <key>. If <key> is alreadypresent in the tree, the data associated with it will be replaced.<data> should not be NULL.?? find_tree(PLIST tree, ?? key)Searches for <key> in <tree> and returns the associated data if it isfound. If <key> is not found, find_tree() returns NULL.NULL/1 delete_tree(PLIST tree, ?? key)Deletes the data value associated with <key> in <tree>. Ifdelete_tree() is successful, it returns true (1); otherwise, itreturns false (NULL).NULL traverse_tree(PLIST tree, FPTR/PPTR map_func, [...])Applies <map_func> to each element of <tree>. Any arguments beyondthe second passed to traverse_tree() will also be passed after thetree element to <map_func>.bind.vtc--------It's worth noting that the newline key is bound to accept(), soanything you want to have done every time you press return can go inthere. For instance, you might put a call to reset_pager() insideaccept().Commands: /list_keyscommand.vtc-----------Data type: Command (Tcommand) command->name command->args Number of args or -1 command->fptr Function to run when invoked command->fmt For /helpCommands: /def /help /list_defs /undef?? efind(FPTR/PPTR fptr, SPTR thing, SPTR s)efind() calls (*fptr)(s) and returns the result, if it is true. Ifthe result is false, indicating a failure to find <s>, efind()displays an error message and aborts the current process. efind() isused for building find functions that can be relied on to returnsuccessfully or not at all. For instance: func Find_world(s) { efind(.find_world, "world", s); }NULL add_cmd(SPTR name, INT args, FPTR/PPTR fptr, SPTR fmt)Adds a new command, named by <name>, taking <args> args. If <args> isnegative, <fptr> is called with one string containing the entireargument line. If <args> is nonnegative, <fptr> is called with onestring for each argument on the argument line.The <fmt> shows up in /help. To make a command that does not show upon the /help list, use add_macro() with a function macro body.PLIST/NULL find_cmd(SPTR name)PLIST Find_cmd(SPTR name)Returns the command with the name <name>. find_cmd() will return NULLif the command is not found; Find_cmd() will display an error messageand abort.NULL add_macro(SPTR name, SPTR/FPTR cmd)Adds a new macro. When the macro is invoked, if <cmd> is a stringpointer, it will be evaluated according to the rules in dist.doc. If<cmd> is a function pointer, it will be called as (*cmd)(line, args),where <line> is the unprocessed argument string and <args> is an arraywith args[0] == line and args[1..n] are the space-separated argumentsin the argument string.SPTR/FPTR/NULL find_macro(SPTR name)SPTR/FPTR Find_macro(SPTR name)Returns the command string of the macro with the name <name>.find_macro() will return NULL if the macro is not found; Find_cmd()will display an error mesage and abort.NULL process_cmdline(SPTR line, [SPTR full, APTR args])Processes a line <line> according to the rules in dist.doc. If theline is a macro or trigger body, <full> should be the unprocessedargument string and <args> should be a table of arguments forsubstitution (%0 --> args[0], etc.)hist.vtc--------Data type: History line (Tline) line->text (*text) is style, (text + 1) is line line->worldGlobals: lineno Line number of next line to go in historyCommands: /recallNULL add_hist(SPTR line, [INT style, ?? PLIST world])Adds a line to the history. <style> defaults to S_NORM and <world>defaults to the current world.SPTR/NULL get_histline(INT num)Gets the line numbered <num> in the history, or NULL if it isn'tstored in the history.NULL recall(INT num, SPTR pattern, INT all, INT gag, INT hilite, INT names, INT linenos, PLIST/NULL world)Recalls <num> lines matching <pattern>. <all>, <gag>, <hilite>,<names>, and <linenos> are flags corresponding to the /recall options-a, -g, -h, -n, and -l. If <world> is NULL, then the current world isused (unless <all> is true).NULL histdump(INT start, INT end)This function displays an interval of lines. The display stylecorresponds to /recall -ahnl.hook.vtc--------A "hook" is a list of function pointers to be called when a particularevent occurs. The arguments passed to the functions depends on theparticular hook.APTR make_hook(...)Creates a new hook. Any arguments are included in the hook.NULL add_to_hook(APTR hook, FPTR/PPTR fptr)Adds a function to a hook, so that it will be run whenever the hook isexecuted.NULL del_from_hook(APTR hook, FPTR/PPTR fptr)Removes a function from a hook.NULL exec_hook(APTR hook, ...)Calls each function in <hook> with the remaining arguments.line.vtc--------Commands: /add_lineNULL add_line(SPTR name, SPTR addr, INT port)Adds a line-based world to the worlds tree.main.vtc--------Commands: /loadNULL load_cmd(SPTR fname) Loads in the file <fname> as if it were a list of commands typed bythe user. Lines beginning with '#' are treated as comments andignored.misc.vtc--------Hook: save_hook Each function in save_hook is called as (*f)(fp) when the /save command is given.Commands: /beep /echo /parse /path /quit /receive /save /sh /shw /versionNULL save_one(FPTR funcptr, SPTR fname)Attempts to open a file <fname> for writing. If successful, calls(*funcptr)(fp) and closes the file. <funcptr> is usually one of.save_worlds, .save_macros, or .save_trigs, or a similar function.mud.vtc-------Commands: /add_lineNULL add_mud(SPTR name, SPTR addr, INT port, SPTR char, SPTR pwd)Adds a mud world to the worlds tree.quote.vtc---------Commands: /quote /repeatraw.vtc-------Commands: /add_rawNULL add_raw(SPTR name, SPTR addr, INT port)Adds a raw world to the worlds tree.remote.vtc----------Remote objects under the distribution code are always worlds. Seeworld.vtc.Commands: /dc /log /world /wrapspacePLIST/NULL cur_world()Returns the current remote's world, or NULL if there is no currentremote.NULL dispatch(SPTR line, [RMT rmt])Calls the remote's outbound function on <line>. This is the preferredway of sending a line to a remote.NULL receive(SPTR line)Acts as if <line> were received by cur_rmt. Is equivalent topass(line, cur_rmt).RMT/NULL world(PLIST world, [INT login, WIN win])Attempts to open a connection to <world>. If successful, initializesthe world and displays it in <win>. <login> should be 1 for world()to intruct the initialization function to automatically log in.resident.vtc------------Globals: mailcheck_interval Seconds between mail checkstrig.vtc--------Data type: Trigger (Ttrig) trig->name Possibly an empty string trig->pattern Pattern string trig->reg Compiled regexp, for regexp triggers only trig->cmd String or function pointer trig->pri Trigger priority trig->world NULL if not restricted to a world trig->enabled Trigger does not function if 0 trig->rearm If 0, trigger turns off after hit trig->style S_NORM, S_GAG, S_NOHISTGAG, S_HILITECommands: /edit /gag /hilite /list_gags /list_hilites /list_norms /list_trigs /trig /untrigNULL add_trig(SPTR name, SPTR pattern, SPTR/FPTR cmd, INT pri, PLIST/NULL world, INT enabled, INT rearm, INT style, INT isreg)Adds a new trigger. <enabled>, <rearm>, and <isreg> are flagscorresponding to the -e, +1, and -r options of /trig. <style> isS_NORM, S_GAG, S_NOHISTGAG, or S_HILITE, where the latter threecorrespond to the -g, -G, and -h options of /trig. The <name>, <pri>,and <world> arguments correspond to the -n, -p, and -w options of/trig.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -