1 /***************************************************************************
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
25 #include "tcl_server.h"
37 #define TCL_SERVER_VERSION "TCL Server 0.1"
38 #define TCL_MAX_LINE (4096)
40 typedef struct tcl_connection_s
{
43 char tc_line
[TCL_MAX_LINE
];
45 int tc_outerror
; /* flag an output error */
48 extern Jim_Interp
*interp
;
49 static unsigned short tcl_port
= 0;
52 static int handle_tcl_port_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
55 static int tcl_new_connection(connection_t
*connection
);
56 static int tcl_input(connection_t
*connection
);
57 static int tcl_output(connection_t
*connection
, const void *buf
, ssize_t len
);
58 static int tcl_closed(connection_t
*connection
);
60 /* write data out to a socket.
62 * this is a blocking write, so the return value must equal the length, if
63 * that is not the case then flag the connection with an output error.
65 int tcl_output(connection_t
*connection
, const void *data
, ssize_t len
)
68 tcl_connection_t
*tclc
;
70 tclc
= connection
->priv
;
71 if (tclc
->tc_outerror
)
72 return ERROR_SERVER_REMOTE_CLOSED
;
74 wlen
= write_socket(connection
->fd
, data
, len
);
78 LOG_ERROR("error during write: %d != %d", wlen
, len
);
79 tclc
->tc_outerror
= 1;
80 return ERROR_SERVER_REMOTE_CLOSED
;
85 static int tcl_new_connection(connection_t
*connection
)
88 tcl_connection_t
*tclc
;
90 tclc
= malloc(sizeof(tcl_connection_t
));
92 return ERROR_CONNECTION_REJECTED
;
94 memset(tclc
, 0, sizeof(tcl_connection_t
));
95 connection
->priv
= tclc
;
99 static int tcl_input(connection_t
*connection
)
106 tcl_connection_t
*tclc
;
109 rlen
= read_socket(connection
->fd
, &in
, sizeof(in
));
112 LOG_ERROR("error during read: %s", strerror(errno
));
113 return ERROR_SERVER_REMOTE_CLOSED
;
116 tclc
= connection
->priv
;
118 return ERROR_CONNECTION_REJECTED
;
120 /* push as much data into the line as possible */
121 for (i
= 0; i
< rlen
; i
++)
123 if (!isprint(in
[i
]) && !isspace(in
[i
]))
126 tclc
->tc_linedrop
= 1;
130 /* buffer the data */
131 tclc
->tc_line
[tclc
->tc_lineoffset
] = in
[i
];
132 if (tclc
->tc_lineoffset
< TCL_MAX_LINE
)
133 tclc
->tc_lineoffset
++;
135 tclc
->tc_linedrop
= 1;
140 /* process the line */
141 if (tclc
->tc_linedrop
) {
142 #define ESTR "line too long\n"
143 retval
= tcl_output(connection
, ESTR
, sizeof(ESTR
));
144 if (retval
!= ERROR_OK
)
148 tclc
->tc_line
[tclc
->tc_lineoffset
-1] = '\0';
149 retval
= Jim_Eval(interp
, tclc
->tc_line
);
150 result
= Jim_GetString(Jim_GetResult(interp
), &reslen
);
151 retval
= tcl_output(connection
, result
, reslen
);
152 if (retval
!= ERROR_OK
)
154 if (memchr(result
, '\n', reslen
) == NULL
)
155 tcl_output(connection
, "\n", 1);
157 tclc
->tc_lineoffset
= 0;
158 tclc
->tc_linedrop
= 0;
164 static int tcl_closed(connection_t
*connection
)
166 /* cleanup connection context */
167 if (connection
->priv
) {
168 free(connection
->priv
);
169 connection
->priv
= NULL
;
180 LOG_WARNING("no tcl port specified, using default port 5555");
184 retval
= add_service("tcl", CONNECTION_TCL
, tcl_port
, 1, tcl_new_connection
, tcl_input
, tcl_closed
, NULL
);
189 int tcl_register_commands(command_context_t
*cmd_ctx
)
191 register_command(cmd_ctx
, NULL
, "tcl_port", handle_tcl_port_command
, COMMAND_CONFIG
, "");
195 static int handle_tcl_port_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
198 tcl_port
= strtoul(args
[0], NULL
, 0);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)