mirror of
https://github.com/rwinkhart/cmutton.git
synced 2026-09-05 16:47:28 -04:00
Simplify LibmuttonInit implementation
This commit is contained in:
@@ -81,21 +81,20 @@ func GetOldEntryData(realPath C.PascalString, field int, rcwPassword C.PascalStr
|
|||||||
// An array of ordered responses to inputCB questions.
|
// An array of ordered responses to inputCB questions.
|
||||||
//
|
//
|
||||||
//export LibmuttonInit
|
//export LibmuttonInit
|
||||||
func LibmuttonInit(inputCBResponses C.PascalStringArray, rcwPassword C.PascalString, appendMode bool, forceOfflineMode bool, deviceIDPrefix C.PascalString) *C.char {
|
func LibmuttonInit(configSSH, sshKeyPath, sshKeyProtected, sshUser, sshHost, sshPort, rcwPassword C.PascalString, appendMode bool, forceOfflineMode bool, deviceIDPrefix C.PascalString) *C.char {
|
||||||
inputCBRespSlice := getStringSliceFromCPascalStringArray(inputCBResponses)
|
|
||||||
supplyInputForInit := func(prompt string) string {
|
supplyInputForInit := func(prompt string) string {
|
||||||
if strings.HasPrefix(prompt, "Configure SSH settings (for synchronization)? (Y/n)") {
|
if strings.HasPrefix(prompt, "Configure SSH settings (for synchronization)? (Y/n)") {
|
||||||
return inputCBRespSlice[0]
|
return C.GoStringN(configSSH.data, configSSH.len)
|
||||||
} else if strings.HasPrefix(prompt, "SSH private identity file path (falls back to") {
|
} else if strings.HasPrefix(prompt, "SSH private identity file path (falls back to") {
|
||||||
return inputCBRespSlice[1]
|
return C.GoStringN(sshKeyPath.data, sshKeyPath.len)
|
||||||
} else if strings.HasPrefix(prompt, "Is the identity file password-protected? (y/N)") {
|
} else if strings.HasPrefix(prompt, "Is the identity file password-protected? (y/N)") {
|
||||||
return inputCBRespSlice[2]
|
return C.GoStringN(sshKeyProtected.data, sshKeyProtected.len)
|
||||||
} else if strings.HasPrefix(prompt, "Remote SSH username:") {
|
} else if strings.HasPrefix(prompt, "Remote SSH username:") {
|
||||||
return inputCBRespSlice[3]
|
return C.GoStringN(sshUser.data, sshUser.len)
|
||||||
} else if strings.HasPrefix(prompt, "Remote SSH IP/domain:") {
|
} else if strings.HasPrefix(prompt, "Remote SSH IP/domain:") {
|
||||||
return inputCBRespSlice[4]
|
return C.GoStringN(sshHost.data, sshHost.len)
|
||||||
} else if strings.HasPrefix(prompt, "Remote SSH port:") {
|
} else if strings.HasPrefix(prompt, "Remote SSH port:") {
|
||||||
return inputCBRespSlice[5]
|
return C.GoStringN(sshPort.data, sshPort.len)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user