Rework last changes about LD_LIBRARY_PATH issue
[src/xds/xds-agent.git] / lib / xaapiv1 / exec.go
1 /*
2  * Copyright (C) 2017-2018 "IoT.bzh"
3  * Author Sebastien Douheret <sebastien@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package xaapiv1
19
20 type (
21         // ExecArgs JSON parameters of /exec command
22         ExecArgs struct {
23                 ID               string   `json:"id" binding:"required"`
24                 SdkID            string   `json:"sdkID"` // sdk ID to use for setting env
25                 CmdID            string   `json:"cmdID"` // command unique ID
26                 Cmd              string   `json:"cmd" binding:"required"`
27                 Args             []string `json:"args"`
28                 Env              []string `json:"env"`
29                 RPath            string   `json:"rpath"`            // relative path into project
30                 TTY              bool     `json:"tty"`              // Use a tty, specific to gdb --tty option
31                 TTYGdbserverFix  bool     `json:"ttyGdbserverFix"`  // Set to true to activate gdbserver workaround about inferior output
32                 LdLibPathNoReset bool     `json:"ldLibPathNoReset"` // Set to true to not reset LD_LIBRARY_PATH when sourcing environment file
33                 ExitImmediate    bool     `json:"exitImmediate"`    // when true, exit event sent immediately when command exited (IOW, don't wait file synchronization)
34                 CmdTimeout       int      `json:"timeout"`          // command completion timeout in Second
35         }
36
37         // ExecResult JSON result of /exec command
38         ExecResult struct {
39                 Status string `json:"status"` // status OK
40                 CmdID  string `json:"cmdID"`  // command unique ID
41         }
42
43         // ExecSignalResult JSON result of /signal command
44         ExecSignalResult struct {
45                 Status string `json:"status"` // status OK
46                 CmdID  string `json:"cmdID"`  // command unique ID
47         }
48
49         // ExecInMsg Message used to received input characters (stdin)
50         ExecInMsg struct {
51                 CmdID     string `json:"cmdID"`
52                 Timestamp string `json:"timestamp"`
53                 Stdin     string `json:"stdin"`
54         }
55
56         // ExecOutMsg Message used to send output characters (stdout+stderr)
57         ExecOutMsg struct {
58                 CmdID     string `json:"cmdID"`
59                 Timestamp string `json:"timestamp"`
60                 Stdout    string `json:"stdout"`
61                 Stderr    string `json:"stderr"`
62         }
63
64         // ExecExitMsg Message sent when executed command exited
65         ExecExitMsg struct {
66                 CmdID     string `json:"cmdID"`
67                 Timestamp string `json:"timestamp"`
68                 Code      int    `json:"code"`
69                 Error     error  `json:"error"`
70         }
71
72         // ExecSignalArgs JSON parameters of /exec/signal command
73         ExecSignalArgs struct {
74                 CmdID  string `json:"cmdID" binding:"required"`  // command id
75                 Signal string `json:"signal" binding:"required"` // signal number
76         }
77 )
78
79 const (
80         // ExecInEvent Event send in WS when characters are sent (stdin)
81         ExecInEvent = "exec:input"
82
83         // ExecOutEvent Event send in WS when characters are received (stdout or stderr)
84         ExecOutEvent = "exec:output"
85
86         // ExecExitEvent Event send in WS when program exited
87         ExecExitEvent = "exec:exit"
88
89         // ExecInferiorInEvent Event send in WS when characters are sent to an inferior (used by gdb inferior/tty)
90         ExecInferiorInEvent = "exec:inferior-input"
91
92         // ExecInferiorOutEvent Event send in WS when characters are received by an inferior
93         ExecInferiorOutEvent = "exec:inferior-output"
94 )