4b089e7d7746c6ed38e9cc2e0e649ff95e7d1a78
[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                 ExitImmediate   bool     `json:"exitImmediate"`   // when true, exit event sent immediately when command exited (IOW, don't wait file synchronization)
33                 CmdTimeout      int      `json:"timeout"`         // command completion timeout in Second
34         }
35
36         // ExecResult JSON result of /exec command
37         ExecResult struct {
38                 Status string `json:"status"` // status OK
39                 CmdID  string `json:"cmdID"`  // command unique ID
40         }
41
42         // ExecSignalResult JSON result of /signal command
43         ExecSignalResult struct {
44                 Status string `json:"status"` // status OK
45                 CmdID  string `json:"cmdID"`  // command unique ID
46         }
47
48         // ExecInMsg Message used to received input characters (stdin)
49         ExecInMsg struct {
50                 CmdID     string `json:"cmdID"`
51                 Timestamp string `json:"timestamp"`
52                 Stdin     string `json:"stdin"`
53         }
54
55         // ExecOutMsg Message used to send output characters (stdout+stderr)
56         ExecOutMsg struct {
57                 CmdID     string `json:"cmdID"`
58                 Timestamp string `json:"timestamp"`
59                 Stdout    string `json:"stdout"`
60                 Stderr    string `json:"stderr"`
61         }
62
63         // ExecExitMsg Message sent when executed command exited
64         ExecExitMsg struct {
65                 CmdID     string `json:"cmdID"`
66                 Timestamp string `json:"timestamp"`
67                 Code      int    `json:"code"`
68                 Error     error  `json:"error"`
69         }
70
71         // ExecSignalArgs JSON parameters of /exec/signal command
72         ExecSignalArgs struct {
73                 CmdID  string `json:"cmdID" binding:"required"`  // command id
74                 Signal string `json:"signal" binding:"required"` // signal number
75         }
76 )
77
78 const (
79         // ExecInEvent Event send in WS when characters are sent (stdin)
80         ExecInEvent = "exec:input"
81
82         // ExecOutEvent Event send in WS when characters are received (stdout or stderr)
83         ExecOutEvent = "exec:output"
84
85         // ExecExitEvent Event send in WS when program exited
86         ExecExitEvent = "exec:exit"
87
88         // ExecInferiorInEvent Event send in WS when characters are sent to an inferior (used by gdb inferior/tty)
89         ExecInferiorInEvent = "exec:inferior-input"
90
91         // ExecInferiorOutEvent Event send in WS when characters are received by an inferior
92         ExecInferiorOutEvent = "exec:inferior-output"
93 )