\r
\r
struct shmid_ds buf;\r
-\r
-int wait = 0, opt;\r
-\r
enum{ NOP_SHM, WAIT_ATTACH_SHM, TRY_ATTACH_SHM, MAT_SHM, CLEAN_UP_SHM, RUN_SHM };\r
\r
-unsigned int shm_statem = TRY_ATTACH_SHM;\r
+\r
\r
void run_shm(void);\r
\r
+\r
int main(int argc, char **argv) \r
{\r
-\r
-key_t key = 0x53021d79;\r
-\r
- while ((opt = getopt(argc, argv, "w")) != -1) {\r
- switch (opt) {\r
+ int wait = 0, opt;\r
+ unsigned int shm_statem = TRY_ATTACH_SHM;\r
+ \r
+ key_t key = 0x53021d79;\r
+ //key = ftok(".", 'S'); // using my own key for now. makes dev easier will fix\r
+\r
+ while ((opt = getopt(argc, argv, "w")) != -1) \r
+ {\r
+ switch (opt) \r
+ {\r
case 'w':\r
wait = 1;\r
break;\r
default: /* '?' */\r
fprintf(stderr, "Usage: %s [-w]\n", argv[0]);\r
fprintf(stderr, "\t-w - Wait for umurmurd to create shm area. useful if you need to start from init.d script\n" );\r
+ //My version of this talks to custom PIC18 hardware acting as a i2c slave to a RaspberryPI to \r
+ //sound buzzer and turn on a LED when my umurmurd server has users in it. I leave this in here\r
+ //in case you need it. \r
exit(EXIT_FAILURE);\r
}\r
}\r
\r
\r
- //key = ftok(".", 'S'); // check if ftok works if both umurmur and mon-umurmur are in same dir\r
- // using my own key for now. makes dev easier will fix\r
- shmptr = NULL;\r
\r
+ \r
if( wait )\r
shm_statem = WAIT_ATTACH_SHM;\r
\r
while( shm_statem )\r
{\r
-\r
switch( shm_statem )\r
{\r
-\r
case RUN_SHM:\r
run_shm();\r
break; \r
shm_statem = MAT_SHM;\r
break;\r
case MAT_SHM: \r
- if( ( shmptr = shmat( shmid, 0, 0 ) ) == (void *) (-1) ) ////MJP BUG? \r
+ if( ( shmptr = shmat( shmid, 0, 0 ) ) == (void *) (-1) )\r
{\r
perror("shmat");\r
exit(EXIT_FAILURE);\r
}\r
printf( "shmid: %i\n\r", shmid );\r
- printf( "umumurd PID: %u\n\r", shmptr->umurmurd_pid );\r
+ printf( "Connected to umumurd PID: %u\n\r", shmptr->umurmurd_pid );\r
+ sleep( 1 );\r
shm_statem = RUN_SHM; \r
break;\r
case CLEAN_UP_SHM: \r
shmdt( shmptr ); \r
- break;\r
- \r
+ break; \r
}\r
}\r
- fflush(stdout);\r
- return 0;\r
+ fflush(stdout);\r
+ return 0;\r
}\r
\r
\r
void run_shm(void)\r
{\r
+ int cc;\r
+ \r
+ shmctl( shmid, IPC_STAT, &buf ); //MJP BUG check for errors here\r
\r
-int cc;\r
-\r
- \r
- \r
- shmctl( shmid, IPC_STAT, &buf ); //MJP BUG check for errors here\r
-\r
- printf("\033[2J\033[H"); //clear screen VT100\r
+ printf("\033[2J\033[H"); //clear screen VT100\r
\r
- printf( "attach: %lu SCC: %i SMC: %i\n", (unsigned long int)buf.shm_nattch, shmptr->clientcount, shmptr->server_max_clients );\r
- for( cc = 0 ; cc < shmptr->server_max_clients ; cc++ )\r
- {\r
- \r
- if( !shmptr->client[cc].authenticated )\r
+ printf( "attach: %lu SCC: %i SMC: %i\n", (unsigned long int)buf.shm_nattch, shmptr->clientcount, shmptr->server_max_clients );\r
+ \r
+ for( cc = 0 ; cc < shmptr->server_max_clients ; cc++ )\r
+ { \r
+ if( !shmptr->client[cc].authenticated )\r
continue; \r
\r
- printf( "%s@%s:%i in channel: %s\n\\r
- \tlastActivity/connectTime/idleTime: %llu/%llu/%llu idleTime: %llu \n\\r
- \tUDP_Avg/Var: %3.2f/%3.2f \n\\r
- \tTCP_Avg/Var: %3.2f/%3.2f \n\\r
- \tUDP_C/TCP_C: %lu/%lu\n", \r
-\r
+ printf( "%s@%s:%i in channel: %s\n\\r
+ \tOnline(secs): %lu Idle(secs): %lu\n\\r
+ \tusingUDP=%i\n\\r
+ \tdeaf=%i, mute=%i\n\\r
+ \tself_deaf=%i, self_mute=%i\n\\r
+ \trecording=%i\n\\r
+ \tbOpus=%i\n\\r
+ \tUDP_Avg/Var: %3.2f/%3.2f \n\\r
+ \tTCP_Avg/Var: %3.2f/%3.2f \n\\r
+ \tUDP_C/TCP_C: %lu/%lu\n", \r
+ shmptr->client[cc].username,\r
+ shmptr->client[cc].ipaddress,\r
+ shmptr->client[cc].udp_port,\r
+ shmptr->client[cc].channel,\r
+ shmptr->client[cc].online_secs,\r
+ shmptr->client[cc].idle_secs,\r
+ \r
+ shmptr->client[cc].bUDP,\r
+ shmptr->client[cc].deaf,\r
+ shmptr->client[cc].mute,\r
+ shmptr->client[cc].self_deaf,\r
+ shmptr->client[cc].self_mute,\r
+ shmptr->client[cc].recording,\r
+ shmptr->client[cc].bOpus,\r
\r
- \r
- shmptr->client[cc].username,\r
- shmptr->client[cc].ipaddress,\r
- shmptr->client[cc].udp_port,\r
- shmptr->client[cc].channel,\r
- shmptr->client[cc].lastActivity,\r
- shmptr->client[cc].connectTime,\r
- shmptr->client[cc].idleTime,\r
- (long long unsigned int)shmptr->client[cc].lastActivity - shmptr->client[cc].idleTime,\r
- shmptr->client[cc].UDPPingAvg,\r
- shmptr->client[cc].UDPPingVar,\r
- shmptr->client[cc].TCPPingAvg,\r
- shmptr->client[cc].TCPPingVar,\r
- shmptr->client[cc].UDPPackets,\r
- shmptr->client[cc].TCPPackets\r
- ); fflush(stdout); // fflush need because of sleep() call\r
- } \r
- sleep( 1 ); // Sleep for 1 sec\r
- \r
-\r
+ shmptr->client[cc].UDPPingAvg,\r
+ shmptr->client[cc].UDPPingVar,\r
+ shmptr->client[cc].TCPPingAvg,\r
+ shmptr->client[cc].TCPPingVar,\r
+ shmptr->client[cc].UDPPackets,\r
+ shmptr->client[cc].TCPPackets\r
+ ); fflush(stdout); // fflush need because of sleep() call\r
+ } \r
+ sleep( 1 ); // Sleep for 1 sec\r
}
\ No newline at end of file