-static int tcl_new_connection(connection_t *connection);
-static int tcl_input(connection_t *connection);
-static int tcl_output(connection_t *connection, const void *buf, ssize_t len);
-static int tcl_closed(connection_t *connection);
+static int tcl_new_connection(struct connection *connection);
+static int tcl_input(struct connection *connection);
+static int tcl_output(struct connection *connection, const void *buf, ssize_t len);
+static int tcl_closed(struct connection *connection);
+
+static int tcl_target_callback_event_handler(struct target *target,
+ enum target_event event, void *priv)
+{
+ struct connection *connection = priv;
+ struct tcl_connection *tclc;
+ char buf[256];
+
+ tclc = connection->priv;
+
+ if (tclc->tc_notify) {
+ snprintf(buf, sizeof(buf), "type target_event event %s\r\n\x1a", target_event_name(event));
+ tcl_output(connection, buf, strlen(buf));
+ }
+
+ if (tclc->tc_laststate != target->state) {
+ tclc->tc_laststate = target->state;
+ if (tclc->tc_notify) {
+ snprintf(buf, sizeof(buf), "type target_state state %s\r\n\x1a", target_state_name(target));
+ tcl_output(connection, buf, strlen(buf));
+ }
+ }
+
+ return ERROR_OK;
+}
+
+static int tcl_target_callback_reset_handler(struct target *target,
+ enum target_reset_mode reset_mode, void *priv)
+{
+ struct connection *connection = priv;
+ struct tcl_connection *tclc;
+ char buf[256];
+
+ tclc = connection->priv;
+
+ if (tclc->tc_notify) {
+ snprintf(buf, sizeof(buf), "type target_reset mode %s\r\n\x1a", target_reset_mode_name(reset_mode));
+ tcl_output(connection, buf, strlen(buf));
+ }
+
+ return ERROR_OK;
+}