More stuff
This commit is contained in:
parent
2491f85c62
commit
d265ce8756
6 changed files with 22 additions and 11 deletions
|
@ -43,7 +43,7 @@ typedef struct _patty_ax25_if {
|
|||
patty_list *addrs;
|
||||
} patty_ax25_if;
|
||||
|
||||
patty_ax25_if *patty_ax25_if_create(int opts, void *info);
|
||||
patty_ax25_if *patty_ax25_if_new(int opts, void *info);
|
||||
|
||||
void patty_ax25_if_destroy(patty_ax25_if *iface);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
typedef struct _patty_ax25_server patty_ax25_server;
|
||||
|
||||
int patty_ax25_server_init(patty_ax25_server *server);
|
||||
patty_ax25_server *patty_ax25_server_new();
|
||||
|
||||
void patty_ax25_server_destroy(patty_ax25_server *server);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ HEADERS = kiss.h ax25.h ax25/if.h ax25/macros.h ax25/proto.h \
|
|||
OBJS = kiss.o ax25.o if.o call.o frame.o server.o \
|
||||
list.o hash.o dict.o
|
||||
|
||||
EXAMPLES = decode ptmx
|
||||
EXAMPLES = decode ptmx testclient testserver
|
||||
|
||||
HEADERS_BUILD = $(addprefix $(INCLUDE_PATH)/$(HEADER_SUBDIR)/, $(HEADERS))
|
||||
|
||||
|
|
2
src/if.c
2
src/if.c
|
@ -27,7 +27,7 @@ static void close_tnc(patty_ax25_if *iface) {
|
|||
patty_kiss_tnc_close(iface->tnc);
|
||||
}
|
||||
|
||||
patty_ax25_if *patty_ax25_if_create(int opts, void *info) {
|
||||
patty_ax25_if *patty_ax25_if_new(int opts, void *info) {
|
||||
patty_ax25_if *iface;
|
||||
|
||||
if ((iface = malloc(sizeof(*iface))) == NULL) {
|
||||
|
|
|
@ -55,7 +55,6 @@ void *patty_list_set(patty_list *list, off_t index, void *value) {
|
|||
}
|
||||
|
||||
void *patty_list_append(patty_list *list, void *value) {
|
||||
patty_list_item *item = list->first;
|
||||
patty_list_item *new;
|
||||
|
||||
if ((new = malloc(sizeof(*new))) == NULL) {
|
||||
|
@ -63,13 +62,14 @@ void *patty_list_append(patty_list *list, void *value) {
|
|||
}
|
||||
|
||||
new->value = value;
|
||||
new->next = NULL;
|
||||
|
||||
if (list->first == NULL) {
|
||||
list->first = new;
|
||||
list->last = new;
|
||||
} else {
|
||||
for (item = list->first; item->next != NULL; item = item->next);
|
||||
|
||||
item->next = new;
|
||||
list->last->next = new;
|
||||
list->last = new;
|
||||
}
|
||||
|
||||
list->length++;
|
||||
|
|
17
src/server.c
17
src/server.c
|
@ -35,7 +35,13 @@ struct _patty_ax25_server {
|
|||
*clients_by_sock;
|
||||
};
|
||||
|
||||
int patty_ax25_server_init(patty_ax25_server *server) {
|
||||
patty_ax25_server *patty_ax25_server_new() {
|
||||
patty_ax25_server *server;
|
||||
|
||||
if ((server = malloc(sizeof(*server))) == NULL) {
|
||||
goto error_malloc_server;
|
||||
}
|
||||
|
||||
memset(server, '\0', sizeof(*server));
|
||||
|
||||
if ((server->ifaces = patty_list_new()) == NULL) {
|
||||
|
@ -66,7 +72,7 @@ int patty_ax25_server_init(patty_ax25_server *server) {
|
|||
goto error_dict_new_clients_by_sock;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return server;
|
||||
|
||||
error_dict_new_clients_by_sock:
|
||||
patty_dict_destroy(server->clients);
|
||||
|
@ -87,7 +93,10 @@ error_dict_new_socks_by_fd:
|
|||
patty_list_destroy(server->ifaces);
|
||||
|
||||
error_list_new_ifaces:
|
||||
return -1;
|
||||
free(server);
|
||||
|
||||
error_malloc_server:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int destroy_if(patty_ax25_if *iface, void *ctx) {
|
||||
|
@ -1105,4 +1114,6 @@ void patty_ax25_server_destroy(patty_ax25_server *server) {
|
|||
|
||||
patty_ax25_server_each_if(server, destroy_if, NULL);
|
||||
patty_list_destroy(server->ifaces);
|
||||
|
||||
free(server);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue