2004-07-16 19:56:36 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of polypaudio.
|
|
|
|
|
|
|
|
|
|
polypaudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2004-07-16 19:56:36 +00:00
|
|
|
by the Free Software Foundation; either version 2 of the License,
|
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
polypaudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2004-07-16 19:56:36 +00:00
|
|
|
along with polypaudio; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-07-16 19:16:42 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-18 00:22:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
|
#include "iochannel.h"
|
|
|
|
|
#include "cli.h"
|
2004-07-04 17:40:15 +00:00
|
|
|
#include "sioman.h"
|
2004-09-05 00:03:16 +00:00
|
|
|
#include "log.h"
|
2004-10-30 01:55:16 +00:00
|
|
|
#include "module-cli-symdef.h"
|
2004-07-04 17:40:15 +00:00
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
PA_MODULE_AUTHOR("Lennart Poettering")
|
|
|
|
|
PA_MODULE_DESCRIPTION("Command line interface")
|
|
|
|
|
PA_MODULE_VERSION(PACKAGE_VERSION)
|
2004-09-20 17:19:35 +00:00
|
|
|
PA_MODULE_USAGE("No arguments")
|
2004-09-11 23:17:38 +00:00
|
|
|
|
2004-07-04 17:40:15 +00:00
|
|
|
static void eof_cb(struct pa_cli*c, void *userdata) {
|
|
|
|
|
struct pa_module *m = userdata;
|
|
|
|
|
assert(c && m);
|
|
|
|
|
|
2004-09-14 20:53:25 +00:00
|
|
|
pa_module_unload_request(m);
|
2004-07-04 17:40:15 +00:00
|
|
|
}
|
2004-06-18 00:22:37 +00:00
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
int pa__init(struct pa_core *c, struct pa_module*m) {
|
2004-07-03 23:35:12 +00:00
|
|
|
struct pa_iochannel *io;
|
2004-06-18 00:22:37 +00:00
|
|
|
assert(c && m);
|
|
|
|
|
|
2004-07-11 22:20:08 +00:00
|
|
|
if (m->argument) {
|
2004-09-05 00:03:16 +00:00
|
|
|
pa_log(__FILE__": module doesn't accept arguments.\n");
|
2004-07-11 22:20:08 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-04 17:40:15 +00:00
|
|
|
if (pa_stdio_acquire() < 0) {
|
2004-09-05 00:03:16 +00:00
|
|
|
pa_log(__FILE__": STDIN/STDUSE already in use.\n");
|
2004-06-18 00:22:37 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
2004-06-18 00:22:37 +00:00
|
|
|
assert(io);
|
2004-07-03 23:35:12 +00:00
|
|
|
pa_iochannel_set_noclose(io, 1);
|
2004-06-18 00:22:37 +00:00
|
|
|
|
2004-07-10 20:56:38 +00:00
|
|
|
m->userdata = pa_cli_new(c, io, m);
|
2004-06-18 00:22:37 +00:00
|
|
|
assert(m->userdata);
|
2004-07-04 17:40:15 +00:00
|
|
|
|
|
|
|
|
pa_cli_set_eof_callback(m->userdata, eof_cb, m);
|
|
|
|
|
|
2004-06-18 00:22:37 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
void pa__done(struct pa_core *c, struct pa_module*m) {
|
2004-06-18 00:22:37 +00:00
|
|
|
assert(c && m);
|
|
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
pa_cli_free(m->userdata);
|
2004-07-04 17:40:15 +00:00
|
|
|
pa_stdio_release();
|
2004-06-18 00:22:37 +00:00
|
|
|
}
|