#include "server.h"#include <getopt.h>#include <sys/wait.h>#include <iostream>#include <fstream>Go to the source code of this file.
Functions | |
| static int | initial (int argc, char **argv) |
| static int | getPid () |
| int | main (int argc, char **argv) |
Variables | |
| bool | multicast = false |
| bool | daemon = false |
| bool | drop = false |
| bool | answer = false |
|
|
Definition at line 94 of file phone.cpp. Referenced by main(). 00095 { 00096 int pid, fd; 00097 char buf[20]; 00098 00099 fd = ::open(".phonepid", O_RDONLY); 00100 if(fd < 0) 00101 return 0; 00102 00103 ::read(fd, buf, 16); 00104 buf[10] = 0; 00105 ::close(fd); 00106 pid = atol(buf); 00107 if(kill(pid, 0)) 00108 return 0; 00109 return pid; 00110 }
|
|
||||||||||||
|
Definition at line 34 of file phone.cpp. References daemon, drop, keythreads, and multicast. Referenced by main(), and IncomingDataQueue::recordReception(). 00035 { 00036 static bool usage = false; 00037 00038 static struct option long_options[] = { 00039 {"hangup", 0, 0, 'd'}, 00040 {"drop", 0, 0, 'd'}, 00041 {"background", 0, 0, 'D'}, 00042 {"foreground", 0, 0, 'F'}, 00043 {"daemon", 0, 0, 'D'}, 00044 {"multicast", 0, 0, 'm'}, 00045 {"unicast", 0, 0, 'u'}, 00046 {"help", 0, 0, 'h'}, 00047 {"priority", 1, 0, 'p'}, 00048 {0, 0, 0, 0}}; 00049 00050 int idx, opt; 00051 char *cp = strchr(argv[0], '/'); 00052 if(cp) 00053 ++cp; 00054 else 00055 cp = argv[0]; 00056 00057 if(*cp == 'm') 00058 multicast = true; 00059 00060 while(EOF != (opt = getopt_long(argc, argv, "mudp:FDh", long_options, &idx))) 00061 { 00062 switch(opt) 00063 { 00064 case 'm': 00065 multicast = true; 00066 break; 00067 case 'u': 00068 multicast = false; 00069 break; 00070 case 'p': 00071 keythreads.setValue("priority", optarg); 00072 break; 00073 case 'F': 00074 daemon = false; 00075 break; 00076 case 'D': 00077 daemon = true; 00078 break; 00079 case 'd': 00080 drop = true; 00081 break; 00082 default: 00083 usage = true; 00084 } 00085 } 00086 if(usage) 00087 { 00088 std::cerr << "use: phone [options] [parties...]" << std::endl; 00089 exit(-1); 00090 } 00091 return optind; 00092 }
|
|
||||||||||||
|
Definition at line 116 of file phone.cpp. References daemon, drop, getPid(), initial(), and server(). 00117 { 00118 int pid = 0, wpid = 0; 00119 int idx; 00120 std::ofstream fifo; 00121 00122 chdir(getenv("HOME")); 00123 if(canAccess(".phonepid")) 00124 if(canModify(".phonectrl")) 00125 pid = getPid(); 00126 00127 idx = initial(argc, argv); 00128 00129 if(!pid) 00130 { 00131 ::remove(".phonectrl"); 00132 ::mkfifo(".phonectrl", 0660); 00133 pid = ::fork(); 00134 if(!pid) 00135 { 00136 server(); 00137 exit(0); 00138 } 00139 if(daemon) 00140 ::waitpid(pid, NULL, 0); 00141 else 00142 wpid = pid; 00143 } 00144 fifo.open(".phonectrl", std::ios::out); 00145 if(!fifo.is_open()) 00146 { 00147 std::cerr << "phone: cannot get control interface" << std::endl; 00148 exit(-1); 00149 } 00150 if(idx == argc && drop) 00151 fifo << "DROP *" << std::endl; 00152 00153 while(idx < argc) 00154 { 00155 if(drop) 00156 fifo << "DROP " << argv[idx++] << std::endl; 00157 else 00158 fifo << "JOIN " << argv[idx++] << std::endl; 00159 } 00160 00161 fifo.close(); 00162 00163 if(wpid > 0) 00164 ::waitpid(wpid, NULL, 0); 00165 00166 exit(0); 00167 }
|
|
|
|
|
|
|
|
|
Definition at line 31 of file phone.cpp. Referenced by RTPBaseUDPIPv4Socket::drop(), initial(), and main(). |
|
|
Definition at line 29 of file phone.cpp. Referenced by initial(). |