library/Osmocom_VTY_Functions: cosmetic: coding style changes

Change-Id: Idccdf6fcbda2d020d2263ea1440ea1c5d9ea0e45
This commit is contained in:
Vadim Yanitskiy 2021-01-30 14:06:37 +01:00
parent e00776c5db
commit 26e30aa4e0
1 changed files with 27 additions and 26 deletions

View File

@ -56,39 +56,40 @@ module Osmocom_VTY_Functions {
}
/* wait for any of the permitted prompts; buffer + return all intermediate output */
function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true, charstring log_label := "(?)") return charstring {
function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true, charstring log_label := "(?)")
return charstring {
var charstring rx, buf := "";
var integer fd;
timer T := 2.0;
T.start;
alt {
[] pt.receive(pattern "[\w-]+" & VTY_VIEW_SUFFIX) { };
[] pt.receive(pattern "[\w-]+\# ") { };
[] pt.receive(pattern "[\w-]+\(*\)\# ") { };
[] pt.receive(t_vty_unknown) -> value rx {
if (strict) {
setverdict(fail, "VTY: Unknown Command: " & log_label);
mtc.stop;
} else {
log("VTY: Unknown Command (ignored): " & log_label);
buf := buf & rx;
repeat;
}
};
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
[] pt.receive(integer:?) -> value fd {
if (fd == -1) {
setverdict(fail, "VTY Telnet Connection Failure: " & log_label);
mtc.stop;
} else {
repeat; /* telnet connection succeeded */
}
}
[] T.timeout {
setverdict(fail, "VTY Timeout for prompt: " & log_label);
[] pt.receive(pattern "[\w-]+" & VTY_VIEW_SUFFIX) { };
[] pt.receive(pattern "[\w-]+\# ") { };
[] pt.receive(pattern "[\w-]+\(*\)\# ") { };
[] pt.receive(t_vty_unknown) -> value rx {
if (strict) {
setverdict(fail, "VTY: Unknown Command: " & log_label);
mtc.stop;
};
} else {
log("VTY: Unknown Command (ignored): " & log_label);
buf := buf & rx;
repeat;
}
};
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
[] pt.receive(integer:?) -> value fd {
if (fd == -1) {
setverdict(fail, "VTY Telnet Connection Failure: " & log_label);
mtc.stop;
} else {
repeat; /* telnet connection succeeded */
}
}
[] T.timeout {
setverdict(fail, "VTY Timeout for prompt: " & log_label);
mtc.stop;
};
}
T.stop;
return buf;