diff options
| author | Donald Delmar Davis <don@suspectdevices.com> | 2013-05-27 13:04:17 -0700 |
|---|---|---|
| committer | Donald Delmar Davis <don@suspectdevices.com> | 2013-05-27 13:04:17 -0700 |
| commit | 9745948e82415be8840294df7b6f913271c24e02 (patch) | |
| tree | ab04dd1f8a533bff7a5999346548c51122c5d777 /RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c | |
| parent | dc504335161da18e06b6baf43ca086de88b44b06 (diff) | |
Add serproxy source, bin directory and consolidate bikewedge into a single script.
Diffstat (limited to 'RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c')
| -rw-r--r-- | RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c b/RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c new file mode 100644 index 0000000..48a82f3 --- /dev/null +++ b/RetoolingForOpenSprints/serproxy-0.1.3.src/pipe.c @@ -0,0 +1,43 @@ +/* + * pipe.c + * + * serial port <-> TCP/IP piping + * + * (C)1999 Stefano Busti + * + */ + +#include <stdlib.h> + +#include "pipe.h" + +int pipe_init(pipe_s *pipe, int sock_port) +{ + if (sio_init(&pipe->sio)) + return -1; + + if (tcp_init(&pipe->sock, sock_port)) + return -1; + + pipe->mutex = malloc(sizeof(thr_mutex_t)); + *(pipe->mutex) = thr_mutex_create(); + + return 0; +} + +void pipe_cleanup(pipe_s *pipe) +{ + sio_cleanup(&pipe->sio); + tcp_cleanup(&pipe->sock); + thr_mutex_unlock(pipe->mutex); + thr_mutex_destroy(pipe->mutex); + free(pipe->mutex); +} + +void pipe_destroy(void *data) +{ + pipe_s *pipe = (pipe_s *)data; + + pipe_cleanup(pipe); + free(pipe); +} |
