1
0
Fork 0

vty: Add a first version that runs a command.

This commit is contained in:
Holger Hans Peter Freyther 2010-09-13 18:03:24 +08:00
parent 826e3a0182
commit cf071f9b49
1 changed files with 45 additions and 0 deletions

View File

@ -142,6 +142,51 @@ Object subclass: OSMOVTY [
]
]
Object subclass: VTYCommand [
<comment: 'I represent a vty command'>
<category: 'libosmovty-st'>
| command callback |
VTYCommand class >> initWith: aCommand help: aHelp [
<category: 'creation'>
"Create a new command. The memory is allocated permamently"
| command |
command := Vty_cmd_element new.
command name value: aCommand.
command doc value: aHelp.
^ (self new)
command: command;
yourself.
]
handleCommand: aCmd vty: aVty argc: aArgc argv: aArgv [
aCmd inspect.
aVty inspect.
aArgc inspect.
aArgv inspect.
Transcript show: 'abc'; nl.
^ 0
]
command: aCommand [
<category: 'private'>
command := aCommand.
callback := CCallbackDescriptor
for: [ :cmd :vty :argc :argv | self handleCommand: cmd vty: vty argc: argc argv: argv.]
returning: #int
withArgs: #(#cObject #cObject #int #(#ptr #string)).
command func value: callback.
]
command [
<category: 'command'>
^ command
]
]
Eval [
OSMOVTY initialize.
]