|
|
#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 | jlocate_standard_on_event_handler (jwgconn conn, jwgpacket packet) |
void | jlocate_grouped_on_event_handler (jwgconn conn, jwgpacket packet) |
int | main (int argc, argv) |
Variables | |
int | showall |
int | groupmode |
int | hideextra |
int | swapjid |
int | exactmatch |
char * | target |
char * | whoami |
|
Definition at line 81 of file jlocate.c. References jid, jwgconn, jwgpacket, swapjid, jwgpacket_struct::x, xode, xode_get_attrib(), xode_get_firstchild(), xode_get_nextsibling(), and xode_get_tag(). Referenced by main(). 00081 { 00082 xode x, y, r, rr; 00083 char *jid, *status, *group, *nick, *resid; 00084 int cnt = 0; 00085 char *spacer; 00086 00087 x = packet->x; 00088 x = xode_get_tag(x, "group"); 00089 while (x) { 00090 group = xode_get_attrib(x, "name"); 00091 if (group) { 00092 printf("%s:\n", strcmp(group,"") ? group : "Unknown"); 00093 spacer = " "; 00094 } 00095 else { 00096 spacer = ""; 00097 } 00098 y = x; 00099 y = xode_get_tag(y, "contact"); 00100 while (y) { 00101 jid = xode_get_attrib(y, "jid"); 00102 nick = xode_get_attrib(y, "nick"); 00103 00104 r = xode_get_tag(y, "resources"); 00105 rr = xode_get_firstchild(r); 00106 if (!rr) { 00107 printf("%s%-45.45s %-15.15s %.16s\n", 00108 spacer, 00109 swapjid && nick ? nick : jid, 00110 "", 00111 "unavailable"); 00112 } 00113 while (rr) { 00114 resid = xode_get_attrib(rr, "name"); 00115 status = xode_get_attrib(rr, "status"); 00116 printf("%s%-45.45s %-15.15s %.16s\n", 00117 spacer, 00118 swapjid && nick ? nick : jid, 00119 resid && strcmp(resid, "NULL") ? resid : "", 00120 status ? status : "unavailable"); 00121 rr = xode_get_nextsibling(rr); 00122 } 00123 00124 if (!hideextra) { 00125 if (swapjid && nick) { 00126 printf("%s JID: %.65s\n", 00127 spacer, 00128 jid); 00129 } 00130 else if (!swapjid && nick) { 00131 printf("%s Nickname: %.60s\n", 00132 spacer, 00133 nick); 00134 } 00135 } 00136 cnt++; 00137 y = xode_get_nextsibling(y); 00138 } 00139 x = xode_get_nextsibling(x); 00140 } 00141 00142 printf("%d contacts found.\n", cnt); 00143 }
|
|
Definition at line 36 of file jlocate.c. References jid, jwgconn, jwgpacket, swapjid, jwgpacket_struct::x, xode, xode_get_attrib(), xode_get_firstchild(), xode_get_nextsibling(), and xode_get_tag(). Referenced by main(). 00036 { 00037 xode x, r, rr; 00038 char *jid, *status, *nick, *resid; 00039 int cnt = 0; 00040 00041 x = packet->x; 00042 x = xode_get_tag(x, "contact"); 00043 for (;;) { 00044 if (!x) break; 00045 jid = xode_get_attrib(x, "jid"); 00046 nick = xode_get_attrib(x, "nick"); 00047 00048 r = xode_get_tag(x, "resources"); 00049 rr = xode_get_firstchild(r); 00050 if (!rr) { 00051 printf("%-49.49s %-15.15s %.16s\n", 00052 swapjid && nick ? nick : jid, 00053 "", 00054 "unavailable"); 00055 } 00056 while (rr) { 00057 resid = xode_get_attrib(rr, "name"); 00058 status = xode_get_attrib(rr, "status"); 00059 printf("%-49.49s %-15.15s %.16s\n", 00060 swapjid && nick ? nick : jid, 00061 resid && strcmp(resid, "NULL") ? resid : "", 00062 status ? status : "unavailable"); 00063 rr = xode_get_nextsibling(rr); 00064 } 00065 00066 if (!hideextra) { 00067 if (swapjid && nick) { 00068 printf(" JID: %.69s\n", jid); 00069 } 00070 else if (!swapjid && nick) { 00071 printf(" Nickname: %.64s\n", nick); 00072 } 00073 } 00074 cnt++; 00075 x = xode_get_nextsibling(x); 00076 } 00077 00078 printf("%d contacts found.\n", cnt); 00079 }
|
|
Definition at line 145 of file jlocate.c. References dinit(), dparseflags(), dprinttypes(), exactmatch, groupmode, hideextra, jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), jwg_event_handler(), jwg_getfd(), jwg_new(), jwg_poll(), jwg_send(), jwg_start(), jwg_stop(), jwgconn, showall, swapjid, target, usage(), whoami, xode, xode_free(), xode_new(), and xode_put_attrib(). 00148 { 00149 int arg; 00150 xode x; 00151 jwgconn jwg; 00152 00153 showall = hideextra = swapjid = groupmode = exactmatch = 0; 00154 target = NULL; 00155 00156 whoami = argv[0]; 00157 dinit(); 00158 00159 arg = 1; 00160 00161 for (; arg < argc; arg++) { 00162 if (*argv[arg] != '-') { 00163 if (target) { 00164 usage(); 00165 } 00166 target = argv[arg]; 00167 showall = 1; 00168 continue; 00169 } 00170 00171 switch (argv[arg][1]) { 00172 #ifndef NODEBUG 00173 case 'd': 00174 arg++; 00175 if (arg >= argc) { 00176 dprinttypes(); 00177 } 00178 dparseflags(argv[arg]); 00179 break; 00180 #endif /* NODEBUG */ 00181 case 'a': 00182 showall = 1; 00183 break; 00184 case 'g': 00185 groupmode = 1; 00186 break; 00187 case 'h': 00188 usage(); 00189 break; 00190 case 'e': 00191 exactmatch = 1; 00192 break; 00193 case 'n': 00194 swapjid = 1; 00195 break; 00196 case 'o': 00197 hideextra = 1; 00198 break; 00199 default: 00200 fprintf(stderr, "Unknown option: %s\n", 00201 argv[arg]); 00202 usage(); 00203 } 00204 } 00205 00206 jwg = jwg_new(); 00207 if (!jwg) { 00208 fprintf(stderr, "jlocate: failed to initialize jwgc connection\n"); 00209 exit(1); 00210 } 00211 if (groupmode) { 00212 jwg_event_handler(jwg, jlocate_grouped_on_event_handler); 00213 } 00214 else { 00215 jwg_event_handler(jwg, jlocate_standard_on_event_handler); 00216 } 00217 jwg_start(jwg); 00218 if (jwg_getfd(jwg) < 0) { 00219 fprintf(stderr, "jlocate: failed to create jwgc connection\n"); 00220 exit(1); 00221 } 00222 x = xode_new("locate"); 00223 if (target) { 00224 xode_put_attrib(x, "target", target); 00225 if (exactmatch) { 00226 xode_put_attrib(x, "match", "strict"); 00227 } 00228 else { 00229 xode_put_attrib(x, "match", "loose"); 00230 } 00231 } 00232 if (groupmode) { 00233 xode_put_attrib(x, "organization", "group"); 00234 } 00235 if (showall) { 00236 xode_put_attrib(x, "showall", "yes"); 00237 } 00238 jwg_send(jwg, x); 00239 xode_free(x); 00240 00241 jwg_poll(jwg, -1); 00242 jwg_stop(jwg); 00243 00244 exit(0); 00245 }
|
|
Definition at line 12 of file jlocate.c. References whoami. 00012 { 00013 fprintf(stderr, "Usage: %s %s[-h] [-e] [-a] [-g] [-n] [-o] [-v] <account name>\n%s\ 00014 -a Show full contact list (normally unavailable is filtered)\n\ 00015 -g Show contacts by group\n\ 00016 -e Exact match on account name (no effect if none specified)\n\ 00017 -h Display help\n\ 00018 -n Show nickname on status line instead of jid\n\ 00019 -o Omit extra information (nickname or jid, depending on if -n is set)\n\ 00020 -v Verbose output\n\ 00021 \n\ 00022 If no <account name> is provided, it returns your full contact list\n\ 00023 ", 00024 whoami, 00025 #ifdef NODEBUG 00026 "", 00027 "" 00028 #else 00029 "[-d <flags>] ", 00030 " -d Enable/Disable debugging (leave <flags> blank for usage)\n" 00031 #endif /* NODEBUG */ 00032 ); 00033 exit(1); 00034 }
|
|
Definition at line 9 of file jlocate.c. Referenced by main(), and test_match(). |
|
Definition at line 9 of file jlocate.c. Referenced by main(). |
|
Definition at line 9 of file jlocate.c. Referenced by main(). |
|
Definition at line 9 of file jlocate.c. Referenced by jwg_on_event_handler(), and main(). |
|
Definition at line 9 of file jlocate.c. Referenced by jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), and main(). |
|
Definition at line 10 of file jlocate.c. Referenced by find_contact_group(), find_list_label(), jwg_on_event_handler(), main(), update_group(), and update_nickname(). |
|
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |