28 #ifdef CCXX_NAMESPACES
38 static int initial(
int argc,
char **argv)
40 static bool usage =
false;
42 static struct option long_options[] = {
43 {
"hangup", 0, 0,
'd'},
45 {
"background", 0, 0,
'D'},
46 {
"foreground", 0, 0,
'F'},
47 {
"daemon", 0, 0,
'D'},
48 {
"multicast", 0, 0,
'm'},
49 {
"unicast", 0, 0,
'u'},
51 {
"priority", 1, 0,
'p'},
55 char *cp = strchr(argv[0],
'/');
64 while(EOF != (opt = getopt_long(argc, argv,
"mudp:FDh", long_options, &idx)))
92 std::cerr <<
"use: phone [options] [parties...]" << std::endl;
103 fd = ::open(
".phonepid", O_RDONLY);
116 #ifdef CCXX_NAMESPACES
120 int main(
int argc,
char **argv)
122 int pid = 0, wpid = 0;
126 chdir(getenv(
"HOME"));
127 if(canAccess(
".phonepid"))
128 if(canModify(
".phonectrl"))
131 idx = initial(argc, argv);
135 ::remove(
".phonectrl");
136 ::mkfifo(
".phonectrl", 0660);
144 ::waitpid(pid, NULL, 0);
148 fifo.open(
".phonectrl", std::ios::out);
151 std::cerr <<
"phone: cannot get control interface" << std::endl;
154 if(idx == argc &&
drop)
155 fifo <<
"DROP *" << std::endl;
160 fifo <<
"DROP " << argv[idx++] << std::endl;
162 fifo <<
"JOIN " << argv[idx++] << std::endl;
168 ::waitpid(wpid, NULL, 0);
173 #ifdef CCXX_NAMESPACES
int main(int argc, char **argv)