connection_t -> struct connection
authorZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 16:10:43 +0000 (08:10 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 19:58:08 +0000 (11:58 -0800)
Remove misleading typedef and redundant suffix from struct connection.

src/server/gdb_server.c
src/server/server.c
src/server/server.h
src/server/tcl_server.c
src/server/telnet_server.c

index fe916c2677c2373a9906e5243b030a5a421fe3fb..389710eb61502de7519176f32ffca611261a1f92 100644 (file)
@@ -45,7 +45,7 @@ static struct gdb_connection *current_gdb_connection;
 static int gdb_breakpoint_override;
 static enum breakpoint_type gdb_breakpoint_override_type;
 
-extern int gdb_error(connection_t *connection, int retval);
+extern int gdb_error(struct connection *connection, int retval);
 static unsigned short gdb_port = 3333;
 static const char *DIGITS = "0123456789abcdef";
 
@@ -87,7 +87,7 @@ int gdb_last_signal(target_t *target)
        }
 }
 
-int check_pending(connection_t *connection, int timeout_s, int *got_data)
+int check_pending(struct connection *connection, int timeout_s, int *got_data)
 {
        /* a non-blocking socket will block if there is 0 bytes available on the socket,
         * but return with as many bytes as are available immediately
@@ -128,7 +128,7 @@ int check_pending(connection_t *connection, int timeout_s, int *got_data)
        return ERROR_OK;
 }
 
-int gdb_get_char(connection_t *connection, int* next_char)
+int gdb_get_char(struct connection *connection, int* next_char)
 {
        struct gdb_connection *gdb_con = connection->priv;
        int retval = ERROR_OK;
@@ -236,7 +236,7 @@ int gdb_get_char(connection_t *connection, int* next_char)
        return retval;
 }
 
-int gdb_putback_char(connection_t *connection, int last_char)
+int gdb_putback_char(struct connection *connection, int last_char)
 {
        struct gdb_connection *gdb_con = connection->priv;
 
@@ -256,7 +256,7 @@ int gdb_putback_char(connection_t *connection, int last_char)
 /* The only way we can detect that the socket is closed is the first time
  * we write to it, we will fail. Subsequent write operations will
  * succeed. Shudder! */
-int gdb_write(connection_t *connection, void *data, int len)
+int gdb_write(struct connection *connection, void *data, int len)
 {
        struct gdb_connection *gdb_con = connection->priv;
        if (gdb_con->closed)
@@ -281,7 +281,7 @@ int gdb_write(connection_t *connection, void *data, int len)
        return ERROR_SERVER_REMOTE_CLOSED;
 }
 
-int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
+int gdb_put_packet_inner(struct connection *connection, char *buffer, int len)
 {
        int i;
        unsigned char my_checksum = 0;
@@ -422,7 +422,7 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
        return ERROR_OK;
 }
 
-int gdb_put_packet(connection_t *connection, char *buffer, int len)
+int gdb_put_packet(struct connection *connection, char *buffer, int len)
 {
        struct gdb_connection *gdb_con = connection->priv;
        gdb_con->busy = 1;
@@ -435,7 +435,7 @@ int gdb_put_packet(connection_t *connection, char *buffer, int len)
        return retval;
 }
 
-static __inline__ int fetch_packet(connection_t *connection, int *checksum_ok, int noack, int *len, char *buffer)
+static __inline__ int fetch_packet(struct connection *connection, int *checksum_ok, int noack, int *len, char *buffer)
 {
        unsigned char my_checksum = 0;
        char checksum[3];
@@ -544,7 +544,7 @@ static __inline__ int fetch_packet(connection_t *connection, int *checksum_ok, i
        return ERROR_OK;
 }
 
-int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
+int gdb_get_packet_inner(struct connection *connection, char *buffer, int *len)
 {
        int character;
        int retval;
@@ -619,7 +619,7 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
        return ERROR_OK;
 }
 
-int gdb_get_packet(connection_t *connection, char *buffer, int *len)
+int gdb_get_packet(struct connection *connection, char *buffer, int *len)
 {
        struct gdb_connection *gdb_con = connection->priv;
        gdb_con->busy = 1;
@@ -628,7 +628,7 @@ int gdb_get_packet(connection_t *connection, char *buffer, int *len)
        return retval;
 }
 
-int gdb_output_con(connection_t *connection, const char* line)
+int gdb_output_con(struct connection *connection, const char* line)
 {
        char *hex_buffer;
        int i, bin_size;
@@ -658,7 +658,7 @@ int gdb_output(struct command_context_s *context, const char* line)
 }
 
 
-static void gdb_frontend_halted(struct target_s *target, connection_t *connection)
+static void gdb_frontend_halted(struct target_s *target, struct connection *connection)
 {
        struct gdb_connection *gdb_connection = connection->priv;
 
@@ -698,7 +698,7 @@ static void gdb_frontend_halted(struct target_s *target, connection_t *connectio
 int gdb_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv)
 {
        int retval;
-       connection_t *connection = priv;
+       struct connection *connection = priv;
 
        target_handle_event(target, event);
        switch (event)
@@ -723,7 +723,7 @@ int gdb_target_callback_event_handler(struct target_s *target, enum target_event
        return ERROR_OK;
 }
 
-int gdb_new_connection(connection_t *connection)
+int gdb_new_connection(struct connection *connection)
 {
        struct gdb_connection *gdb_connection = malloc(sizeof(struct gdb_connection));
        struct gdb_service *gdb_service = connection->service->priv;
@@ -779,7 +779,7 @@ int gdb_new_connection(connection_t *connection)
        return ERROR_OK;
 }
 
-int gdb_connection_closed(connection_t *connection)
+int gdb_connection_closed(struct connection *connection)
 {
        struct gdb_service *gdb_service = connection->service->priv;
        struct gdb_connection *gdb_connection = connection->priv;
@@ -826,14 +826,14 @@ int gdb_connection_closed(connection_t *connection)
        return ERROR_OK;
 }
 
-void gdb_send_error(connection_t *connection, uint8_t the_error)
+void gdb_send_error(struct connection *connection, uint8_t the_error)
 {
        char err[4];
        snprintf(err, 4, "E%2.2X", the_error);
        gdb_put_packet(connection, err, 3);
 }
 
-int gdb_last_signal_packet(connection_t *connection, target_t *target, char* packet, int packet_size)
+int gdb_last_signal_packet(struct connection *connection, target_t *target, char* packet, int packet_size)
 {
        char sig_reply[4];
        int signal;
@@ -915,7 +915,7 @@ void gdb_target_to_reg(target_t *target, char *tstr, int str_len, uint8_t *bin)
        }
 }
 
-int gdb_get_registers_packet(connection_t *connection, target_t *target, char* packet, int packet_size)
+int gdb_get_registers_packet(struct connection *connection, target_t *target, char* packet, int packet_size)
 {
        reg_t **reg_list;
        int reg_list_size;
@@ -965,7 +965,7 @@ int gdb_get_registers_packet(connection_t *connection, target_t *target, char* p
        return ERROR_OK;
 }
 
-int gdb_set_registers_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_set_registers_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        int i;
        reg_t **reg_list;
@@ -1027,7 +1027,7 @@ int gdb_set_registers_packet(connection_t *connection, target_t *target, char *p
        return ERROR_OK;
 }
 
-int gdb_get_register_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_get_register_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        char *reg_packet;
        int reg_num = strtoul(packet + 1, NULL, 16);
@@ -1062,7 +1062,7 @@ int gdb_get_register_packet(connection_t *connection, target_t *target, char *pa
        return ERROR_OK;
 }
 
-int gdb_set_register_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_set_register_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        char *separator;
        uint8_t *bin_buf;
@@ -1111,7 +1111,7 @@ int gdb_set_register_packet(connection_t *connection, target_t *target, char *pa
        return ERROR_OK;
 }
 
-int gdb_error(connection_t *connection, int retval)
+int gdb_error(struct connection *connection, int retval)
 {
        switch (retval)
        {
@@ -1142,7 +1142,7 @@ int gdb_error(connection_t *connection, int retval)
  *
  * 8191 bytes by the looks of it. Why 8191 bytes instead of 8192?????
  */
-int gdb_read_memory_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_read_memory_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        char *separator;
        uint32_t addr = 0;
@@ -1216,7 +1216,7 @@ int gdb_read_memory_packet(connection_t *connection, target_t *target, char *pac
        return retval;
 }
 
-int gdb_write_memory_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_write_memory_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        char *separator;
        uint32_t addr = 0;
@@ -1273,7 +1273,7 @@ int gdb_write_memory_packet(connection_t *connection, target_t *target, char *pa
        return retval;
 }
 
-int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_write_memory_binary_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        char *separator;
        uint32_t addr = 0;
@@ -1321,7 +1321,7 @@ int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, c
        return ERROR_OK;
 }
 
-int gdb_step_continue_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_step_continue_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        int current = 0;
        uint32_t address = 0x0;
@@ -1354,7 +1354,7 @@ int gdb_step_continue_packet(connection_t *connection, target_t *target, char *p
        return retval;
 }
 
-int gdb_breakpoint_watchpoint_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_breakpoint_watchpoint_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        int type;
        enum breakpoint_type bp_type = BKPT_SOFT /* dummy init to avoid warning */;
@@ -1554,7 +1554,7 @@ static int compare_bank (const void * a, const void * b)
        }
 }
 
-int gdb_query_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_query_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        command_context_t *cmd_ctx = connection->cmd_ctx;
        struct gdb_connection *gdb_connection = connection->priv;
@@ -1810,7 +1810,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
        return ERROR_OK;
 }
 
-int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int packet_size)
+int gdb_v_packet(struct connection *connection, target_t *target, char *packet, int packet_size)
 {
        struct gdb_connection *gdb_connection = connection->priv;
        struct gdb_service *gdb_service = connection->service->priv;
@@ -1947,7 +1947,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
        return ERROR_OK;
 }
 
-int gdb_detach(connection_t *connection, target_t *target)
+int gdb_detach(struct connection *connection, target_t *target)
 {
        struct gdb_service *gdb_service = connection->service->priv;
 
@@ -1959,7 +1959,7 @@ int gdb_detach(connection_t *connection, target_t *target)
 static void gdb_log_callback(void *priv, const char *file, unsigned line,
                const char *function, const char *string)
 {
-       connection_t *connection = priv;
+       struct connection *connection = priv;
        struct gdb_connection *gdb_con = connection->priv;
 
        if (gdb_con->busy)
@@ -1974,7 +1974,7 @@ static void gdb_log_callback(void *priv, const char *file, unsigned line,
 /* Do not allocate this on the stack */
 char gdb_packet_buffer[GDB_BUFFER_SIZE];
 
-static void gdb_sig_halted(connection_t *connection)
+static void gdb_sig_halted(struct connection *connection)
 {
        char sig_reply[4];
        snprintf(sig_reply, 4, "T%2.2x", 2);
@@ -1982,7 +1982,7 @@ static void gdb_sig_halted(connection_t *connection)
 
 }
 
-int gdb_input_inner(connection_t *connection)
+int gdb_input_inner(struct connection *connection)
 {
        struct gdb_service *gdb_service = connection->service->priv;
        target_t *target = gdb_service->target;
@@ -2180,7 +2180,7 @@ int gdb_input_inner(connection_t *connection)
        return ERROR_OK;
 }
 
-int gdb_input(connection_t *connection)
+int gdb_input(struct connection *connection)
 {
        int retval = gdb_input_inner(connection);
        struct gdb_connection *gdb_con = connection->priv;
index 59ed1a5c3d9577f6183d33d226eb5ff47ce1b860..5614ef98682a60b20111aa43056018b0f60c0c49 100644 (file)
@@ -48,11 +48,11 @@ int server_use_pipes = 0;
 int add_connection(struct service *service, command_context_t *cmd_ctx)
 {
        socklen_t address_size;
-       connection_t *c, **p;
+       struct connection *c, **p;
        int retval;
        int flag = 1;
 
-       c = malloc(sizeof(connection_t));
+       c = malloc(sizeof(struct connection));
        c->fd = -1;
        memset(&c->sin, 0, sizeof(c->sin));
        c->cmd_ctx = copy_command_context(cmd_ctx);
@@ -109,10 +109,10 @@ int add_connection(struct service *service, command_context_t *cmd_ctx)
        return ERROR_OK;
 }
 
-int remove_connection(struct service *service, connection_t *connection)
+int remove_connection(struct service *service, struct connection *connection)
 {
-       connection_t **p = &service->connections;
-       connection_t *c;
+       struct connection **p = &service->connections;
+       struct connection *c;
 
        /* find connection */
        while ((c = *p))
@@ -329,7 +329,7 @@ int server_loop(command_context_t *command_context)
 
                        if (service->connections)
                        {
-                               connection_t *c;
+                               struct connection *c;
 
                                for (c = service->connections; c; c = c->next)
                                {
@@ -423,7 +423,7 @@ int server_loop(command_context_t *command_context)
                        /* handle activity on connections */
                        if (service->connections)
                        {
-                               connection_t *c;
+                               struct connection *c;
 
                                for (c = service->connections; c;)
                                {
@@ -431,7 +431,7 @@ int server_loop(command_context_t *command_context)
                                        {
                                                if ((retval = service->input(c)) != ERROR_OK)
                                                {
-                                                       connection_t *next = c->next;
+                                                       struct connection *next = c->next;
                                                        if (service->type == CONNECTION_PIPE)
                                                        {
                                                                /* if connection uses a pipe then shutdown openocd on error */
index 2bfedb490ab43b5a976238d50d845ffd84eeb8b9..062691b0a2c5be1df5ad854f8e26b7c9944c2f91 100644 (file)
@@ -38,7 +38,7 @@ enum connection_type
        CONNECTION_PIPE
 };
 
-typedef struct connection_s
+struct connection
 {
        int fd;
        struct sockaddr_in sin;
@@ -46,12 +46,12 @@ typedef struct connection_s
        struct service *service;
        int input_pending;
        void *priv;
-       struct connection_s *next;
-} connection_t;
+       struct connection *next;
+};
 
-typedef int (*new_connection_handler_t)(connection_t *connection);
-typedef int (*input_handler_t)(connection_t *connection);
-typedef int (*connection_closed_handler_t)(connection_t *connection);
+typedef int (*new_connection_handler_t)(struct connection *connection);
+typedef int (*input_handler_t)(struct connection *connection);
+typedef int (*connection_closed_handler_t)(struct connection *connection);
 
 struct service
 {
@@ -61,7 +61,7 @@ struct service
        int fd;
        struct sockaddr_in sin;
        int max_connections;
-       connection_t *connections;
+       struct connection *connections;
        new_connection_handler_t new_connection;
        input_handler_t input;
        connection_closed_handler_t connection_closed;
index b5bdbc28935f2fb74b5da7632ed8e2783eaa9865..eed483ca2c9901192d811d7449094cb41fc03aed 100644 (file)
@@ -37,17 +37,17 @@ struct tcl_connection {
 static unsigned short tcl_port = 6666;
 
 /* handlers */
-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);
 
 /* write data out to a socket.
  *
  * this is a blocking write, so the return value must equal the length, if
  * that is not the case then flag the connection with an output error.
  */
-int tcl_output(connection_t *connection, const void *data, ssize_t len)
+int tcl_output(struct connection *connection, const void *data, ssize_t len)
 {
        ssize_t wlen;
        struct tcl_connection *tclc;
@@ -66,7 +66,7 @@ int tcl_output(connection_t *connection, const void *data, ssize_t len)
 }
 
 /* connections */
-static int tcl_new_connection(connection_t *connection)
+static int tcl_new_connection(struct connection *connection)
 {
        struct tcl_connection *tclc;
 
@@ -79,7 +79,7 @@ static int tcl_new_connection(connection_t *connection)
        return ERROR_OK;
 }
 
-static int tcl_input(connection_t *connection)
+static int tcl_input(struct connection *connection)
 {
        int retval;
        int i;
@@ -146,7 +146,7 @@ static int tcl_input(connection_t *connection)
        return ERROR_OK;
 }
 
-static int tcl_closed(connection_t *connection)
+static int tcl_closed(struct connection *connection)
 {
        /* cleanup connection context */
        if (connection->priv) {
index 13ac0877a2f7a7452afbfd0b41c306fd9f5cc19e..93028b14dbd29314bfe734adb6fc4b5f3b9fb8e6 100644 (file)
@@ -44,7 +44,7 @@ static char *negotiate =
  * we write to it, we will fail. Subsequent write operations will
  * succeed. Shudder!
  */
-int telnet_write(connection_t *connection, const void *data, int len)
+int telnet_write(struct connection *connection, const void *data, int len)
 {
        struct telnet_connection *t_con = connection->priv;
        if (t_con->closed)
@@ -58,7 +58,7 @@ int telnet_write(connection_t *connection, const void *data, int len)
        return ERROR_SERVER_REMOTE_CLOSED;
 }
 
-int telnet_prompt(connection_t *connection)
+int telnet_prompt(struct connection *connection)
 {
        struct telnet_connection *t_con = connection->priv;
 
@@ -66,7 +66,7 @@ int telnet_prompt(connection_t *connection)
        return telnet_write(connection, t_con->prompt, strlen(t_con->prompt));
 }
 
-int telnet_outputline(connection_t *connection, const char *line)
+int telnet_outputline(struct connection *connection, const char *line)
 {
        int len;
 
@@ -96,7 +96,7 @@ int telnet_outputline(connection_t *connection, const char *line)
 
 int telnet_output(struct command_context_s *cmd_ctx, const char* line)
 {
-       connection_t *connection = cmd_ctx->output_handler_priv;
+       struct connection *connection = cmd_ctx->output_handler_priv;
 
        return telnet_outputline(connection, line);
 }
@@ -104,7 +104,7 @@ int telnet_output(struct command_context_s *cmd_ctx, const char* line)
 void telnet_log_callback(void *priv, const char *file, unsigned line,
                const char *function, const char *string)
 {
-       connection_t *connection = priv;
+       struct connection *connection = priv;
        struct telnet_connection *t_con = connection->priv;
        int i;
 
@@ -131,7 +131,7 @@ void telnet_log_callback(void *priv, const char *file, unsigned line,
                telnet_write(connection, "\b", 1);
 }
 
-int telnet_new_connection(connection_t *connection)
+int telnet_new_connection(struct connection *connection)
 {
        struct telnet_connection *telnet_connection = malloc(sizeof(struct telnet_connection));
        struct telnet_service *telnet_service = connection->service->priv;
@@ -175,7 +175,7 @@ int telnet_new_connection(connection_t *connection)
        return ERROR_OK;
 }
 
-void telnet_clear_line(connection_t *connection, struct telnet_connection *t_con)
+void telnet_clear_line(struct connection *connection, struct telnet_connection *t_con)
 {
        /* move to end of line */
        if (t_con->line_cursor < t_con->line_size)
@@ -192,7 +192,7 @@ void telnet_clear_line(connection_t *connection, struct telnet_connection *t_con
        t_con->line_cursor = 0;
 }
 
-int telnet_input(connection_t *connection)
+int telnet_input(struct connection *connection)
 {
        int bytes_read;
        char buffer[TELNET_BUFFER_SIZE];
@@ -537,7 +537,7 @@ int telnet_input(connection_t *connection)
        return ERROR_OK;
 }
 
-int telnet_connection_closed(connection_t *connection)
+int telnet_connection_closed(struct connection *connection)
 {
        struct telnet_connection *t_con = connection->priv;
        int i;
@@ -575,7 +575,7 @@ int telnet_connection_closed(connection_t *connection)
        return ERROR_OK;
 }
 
-int telnet_set_prompt(connection_t *connection, char *prompt)
+int telnet_set_prompt(struct connection *connection, char *prompt)
 {
        struct telnet_connection *t_con = connection->priv;