|
|
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <libjwgc.h>
Go to the source code of this file.
Functions | |
void | usage () |
void | jstat_on_event_handler (jwgconn conn, jwgpacket packet) |
int | main (int argc, argv) |
Variables | |
char * | whoami |
|
Definition at line 30 of file jstat.c. References jid, jwgconn, jwgpacket, jwgpacket_struct::x, xode, xode_get_attrib(), xode_get_firstchild(), xode_get_name(), xode_get_nextsibling(), xode_get_tag(), and xode_get_tagdata(). Referenced by main(). 00031 { 00032 xode x, y; 00033 char *cdata; 00034 00035 x = packet->x; 00036 cdata = xode_get_tagdata(x, "user"); 00037 if (cdata) { 00038 printf("User: %.58s\n", cdata); 00039 } 00040 00041 cdata = xode_get_tagdata(x, "server"); 00042 if (cdata) { 00043 printf("Server: %.58s\n", cdata); 00044 } 00045 00046 cdata = xode_get_tagdata(x, "resource"); 00047 if (cdata) { 00048 printf("Resource: %.58s\n", cdata); 00049 } 00050 00051 cdata = xode_get_tagdata(x, "version"); 00052 if (cdata) { 00053 printf("Jwgc Version: %.58s\n", cdata); 00054 } 00055 00056 cdata = xode_get_tagdata(x, "machinetype"); 00057 if (cdata) { 00058 printf("Machine Type: %.58s\n", cdata); 00059 } 00060 00061 cdata = xode_get_tagdata(x, "localtime"); 00062 if (cdata) { 00063 printf("Localhost Time: %.58s\n", cdata); 00064 } 00065 00066 cdata = xode_get_tagdata(x, "connecttime"); 00067 if (cdata) { 00068 printf("Connection Time: %.58s\n", cdata); 00069 } 00070 00071 cdata = xode_get_tagdata(x, "connectstate"); 00072 if (cdata) { 00073 printf("Connection State: %.58s\n", cdata); 00074 } 00075 00076 printf("\nServices Available:\n"); 00077 y = xode_get_tag(x, "agents"); 00078 y = xode_get_firstchild(y); 00079 while (y) { 00080 char *name, *service, *jid; 00081 xode z; 00082 00083 name = xode_get_attrib(y, "name"); 00084 service = xode_get_attrib(y, "service"); 00085 jid = xode_get_attrib(y, "jid"); 00086 printf(" %-30.30s %41.41s\n", name, jid); 00087 printf(" Provides: %s", service); 00088 z = xode_get_firstchild(y); 00089 while (z) { 00090 printf(" %s", xode_get_name(z)); 00091 z = xode_get_nextsibling(z); 00092 } 00093 printf("\n"); 00094 y = xode_get_nextsibling(y); 00095 } 00096 00097 cdata = xode_get_tagdata(x, "bugreport"); 00098 if (cdata) { 00099 printf("\nPlease report bugs to %s.\n", cdata); 00100 } 00101 }
|
|
Definition at line 105 of file jstat.c. References dinit(), dparseflags(), dprinttypes(), jstat_on_event_handler(), jwg_event_handler(), jwg_getfd(), jwg_new(), jwg_poll(), jwg_send(), jwg_start(), jwg_stop(), jwgconn, usage(), whoami, xode, xode_free(), and xode_new(). 00108 { 00109 int arg; 00110 xode x; 00111 jwgconn jwg; 00112 00113 whoami = argv[0]; 00114 dinit(); 00115 00116 arg = 1; 00117 00118 for (; arg < argc; arg++) { 00119 switch (argv[arg][1]) { 00120 #ifndef NODEBUG 00121 case 'd': 00122 arg++; 00123 if (arg >= argc) { 00124 dprinttypes(); 00125 } 00126 dparseflags(argv[arg]); 00127 break; 00128 #endif /* NODEBUG */ 00129 case 'h': 00130 usage(); 00131 break; 00132 default: 00133 fprintf(stderr, "Unknown option: %s\n", 00134 argv[arg]); 00135 usage(); 00136 } 00137 } 00138 00139 jwg = jwg_new(); 00140 if (!jwg) { 00141 fprintf(stderr, "jstat: failed to initialize jwgc connection\n"); 00142 exit(1); 00143 } 00144 jwg_event_handler(jwg, jstat_on_event_handler); 00145 jwg_start(jwg); 00146 if (jwg_getfd(jwg) < 0) { 00147 fprintf(stderr, "jstat: failed to create jwgc connection\n"); 00148 exit(1); 00149 } 00150 x = xode_new("status"); 00151 jwg_send(jwg, x); 00152 xode_free(x); 00153 00154 jwg_poll(jwg, -1); 00155 jwg_stop(jwg); 00156 00157 exit(0); 00158 }
|
|
Definition at line 12 of file jstat.c. References whoami. 00013 { 00014 fprintf(stderr, "Usage: %s %s[-h]\n%s\ 00015 -h Display help\n\ 00016 ", 00017 whoami, 00018 #ifdef NODEBUG 00019 "", 00020 "" 00021 #else 00022 "[-d <flags>] ", 00023 " -d Enable/Disable debugging (leave <flags> blank for usage)\n" 00024 #endif /* NODEBUG */ 00025 ); 00026 exit(1); 00027 }
|
|
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |