cli protocol

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@28 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2004-06-19 19:27:47 +00:00
parent 6eddcc2f85
commit 81447ed392
7 changed files with 94 additions and 8 deletions

View file

@ -15,6 +15,8 @@ struct iochannel {
int readable;
int writable;
int no_close;
struct mainloop_source* input_source, *output_source;
};
@ -83,6 +85,7 @@ struct iochannel* iochannel_new(struct mainloop*m, int ifd, int ofd) {
io->callback = NULL;
io->readable = 0;
io->writable = 0;
io->no_close = 0;
if (ifd == ofd) {
assert(ifd >= 0);
@ -109,10 +112,12 @@ struct iochannel* iochannel_new(struct mainloop*m, int ifd, int ofd) {
void iochannel_free(struct iochannel*io) {
assert(io);
if (io->ifd >= 0)
close(io->ifd);
if (io->ofd >= 0 && io->ofd != io->ifd)
close(io->ofd);
if (!io->no_close) {
if (io->ifd >= 0)
close(io->ifd);
if (io->ofd >= 0 && io->ofd != io->ifd)
close(io->ofd);
}
if (io->input_source)
mainloop_source_free(io->input_source);
@ -162,3 +167,8 @@ void iochannel_set_callback(struct iochannel*io, void (*callback)(struct iochann
io->callback = callback;
io->userdata = userdata;
}
void iochannel_set_noclose(struct iochannel*io, int b) {
assert(io);
io->no_close = b;
}