diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-02-05 09:47:10 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-02-05 09:47:10 +0100 |
commit | c912d0844a01f67ae1c95c8725526ca8b6751a89 (patch) | |
tree | 6d4b60260bde837a1bcff6f2ff4347a1c5e83248 | |
parent | 295b95085f3d7cf7d405771e81bb33902838286e (diff) | |
download | jacc-c912d0844a01f67ae1c95c8725526ca8b6751a89.tar.gz |
-rw-r--r-- | jacc.c | 820 | ||||
-rw-r--r-- | jacc.tar | bin | 102400 -> 0 bytes | |||
-rw-r--r-- | jacc/dat.c | 320 | ||||
-rw-r--r-- | jacc/dat.h | 25 | ||||
-rw-r--r-- | jacc/jacc.c (renamed from jacc-paste.c) | 0 | ||||
-rw-r--r-- | jacc/jacc.h | 69 | ||||
-rw-r--r-- | jacc/mkfile | 24 | ||||
-rw-r--r-- | jacc/mkfile.plan9port | 25 | ||||
-rw-r--r-- | jacc/recv.c | 887 | ||||
-rw-r--r-- | jacc/recv.h | 6 | ||||
-rw-r--r-- | jacc/roster.c | 213 | ||||
-rw-r--r-- | jacc/roster.h | 43 | ||||
-rw-r--r-- | jacc/xmlpull.h | 51 | ||||
-rw-r--r-- | jacs/dat.c | 89 | ||||
-rw-r--r-- | jacs/dat.h | 10 | ||||
-rw-r--r-- | jacs/jacs.c | 231 | ||||
-rw-r--r-- | jacs/jacs.h | 33 | ||||
-rw-r--r-- | jacs/mkfile | 24 | ||||
-rw-r--r-- | jacs/mkfile.plan9port | 25 | ||||
-rw-r--r-- | jacs/recv.c | 292 | ||||
-rw-r--r-- | jacs/recv.h | 8 | ||||
-rw-r--r-- | jacs/roster.c | 102 | ||||
-rw-r--r-- | jacs/roster.h | 33 | ||||
-rw-r--r-- | jacs/xmlpull.h | 51 | ||||
-rw-r--r-- | mkfile | 53 | ||||
-rw-r--r-- | mkfile.plan9port | 53 | ||||
-rw-r--r-- | vcard.example | 143 |
27 files changed, 2810 insertions, 820 deletions
@@ -1,820 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" -"http://www.w3.org/TR/html4/loose.dtd"> -<html> -<head> -<meta http-equiv=Content-Type content="text/html; charset=utf8"> -<title>/n/sources/contrib/stassats/jacc.c - Plan 9 from Bell Labs</title> -<!-- THIS FILE IS AUTOMATICALLY GENERATED. --> -<!-- EDIT sources.tr INSTEAD. --> -</meta> -</head> -<body> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<p style="line-height: 1.2em; margin-left: 1.00in; text-indent: 0.00in; margin-right: 1.00in; margin-top: 0; margin-bottom: 0; text-align: center;"> -<span style="font-size: 10pt"><a href="http://plan9.bell-labs.com/plan9/">Plan 9 from Bell Labs</a>’s /n/sources/contrib/stassats/jacc.c</span></p> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<center><font size=-1> -Copyright © 2009 Alcatel-Lucent.<br /> -Distributed under the -<a href="http://plan9.bell-labs.com/plan9/license.html">Lucent Public License version 1.02</a>. -<br /> -<a href="http://plan9.bell-labs.com/plan9/download.html">Download the Plan 9 distribution.</a> -</font> -</center> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<table width="100%" cellspacing=0 border=0><tr><td align="center"> -<table cellspacing=0 cellpadding=5 bgcolor="#eeeeff"><tr><td align="left"> -<pre> -<!-- END HEADER --> -/* - * Copy me if you can. - * by 20h - */ - -#include <u.h> -#include <libc.h> -#include <auth.h> -#include <mp.h> -#include <libsec.h> -#include "xmlpull.h" -#include "jacc.h" -#include "dat.h" -#include "roster.h" -#include "recv.h" - -#define NAME "jacc - Jabber Client for Plan9" -#define VERSION "3rd ed" -#define OS "Plan 9 4th ed" - -extern int doignore; - -int -xmljacc(int sock) -{ - return fprint(sock, "<?xml version=\"1.0\"?>\n"); -} - -int -loginjacc(int sock, char *serv) -{ - return fprint(sock, "<stream:stream xmlns:stream=\"http://etherx.jabber.org/streams\"" - " xmlns=\"jabber:client\" to=\"%s\">\n", serv); -} - -int -userjacc(int sock, char *user, char *pass, char *res) -{ - return fprint(sock, "<iq type=\"set\" id=\"auth_1\">\n" - "<query xmlns=\"jabber:iq:auth\">\n" - "<username>%s</username>\n" - "<password>%s</password>\n" - "<resource>%s</resource>\n" - "</query>\n" - "</iq>\n", user, pass, res); -} - -int -versionjacc(int sock, char *from, char *to, char *id) -{ - return fprint(sock, "<iq from=\"%s\" type=\"result\" id=\"%s\" to=\"%s\">\n" - "<query xmlns=\"jabber:iq:version\">\n" - "<name>" NAME "</name>\n" - "<version>" VERSION "</version>\n" - "<os>" OS "</os>\n" - "</query>\n" - "</iq>\n", from, (id == nil) ? "" : id, to); -} - -int -featuresjacc(int sock, char *from, char *to, char *id) -{ - return fprint(sock, "<iq from=\"%s\" type=\"result\" to=\"%s\" id=\"%s\">\n" - "<query xmlns=\"http://jabber.org/protocol/disco#info\">\n" - "<identity category=\"client\" type=\"pc\"/>\n" - "<feature var=\"jabber:iq:time\"/>\n" - "<feature var=\"jabber:iq:version\"/>\n" - "<feature var=\"http://jabber.org/protocol/muc\"/>\n" - "</query>\n" - "</iq>\n", from, to, (id == nil) ? "" : id); -} - -int -timejacc(int sock, char *from, char *to, char *id) -{ - Tm *lo, *gm; - - lo = localtime(time(0)); - gm = gmtime(time(0)); - - return fprint(sock, "<iq from=\"%s\" type=\"result\" to=\"%s\" id=\"%s\">\n" - "<query xmlns=\"jabber:iq:time\">\n" - "<utc>%.4d%.2d%.2dT%.2d:%.2d:%.2d</utc>\n" - "<display>%s %s %.2d %.2d:%.2d:%.2d %.4d</display>\n" - "<tz>%s</tz>\n" - "</query>\n" - "</iq>\n", from, to, (id == nil) ? "" : id, gm->year + 1900, - gm->mon + 1, gm->mday, gm->hour, gm->min, - gm->sec, getday(lo->wday), getmonth(lo->mon), - lo->mday, lo->hour, lo->min, lo->sec, - lo->year + 1900, lo->zone); -} - -int -lastjacc(int sock, char *from, char *to, char *id, int d) -{ - return fprint(sock, "<iq from=\"%s\" type=\"result\" to=\"%s\" id=\"%s\">\n" - "<query xmlns=\"jabber:iq:last\" seconds=\"%d\"/>\n" - "</iq>\n", from, to, (id == nil) ? "" : id, d); -} - -int -registerjacc(int sock, char *serv, char *user, char *pass) -{ - return fprint(sock, "<iq type=\"set\" id=\"req\" to=\"%s\">\n" - "<query xmlns=\"jabber:iq:register\">\n" - "<username>%s</username>\n" - "<password>%s</password>\n" - "</query>\n" - "</iq>\n", serv, user, pass); -} - -int -vcardgetjacc(int sock, char *from, char *type) -{ - return fprint(sock, "<iq %s=\"%s\" type=\"get\" id=\"v1\">\n" - "<vCard xmlns=\"vcard-temp\"/>\n" - "</iq>\n", type, from); -} - -int -vcardsetjacc(int sock, char *from, int fd) -{ - fprint(sock, "<iq from=\"%s\" type=\"set\" id=\"v2\">\n" - "<vCard xmlns=\"vcard-temp\">\n", from); - readwrite(sock, fd); - - return fprint(sock, "</vCard>\n" - "</iq>\n"); -} - -int -presencejacc(int sock, char *stat, char *show, char *from, char *to) -{ - return fprint(sock, "<presence%s%s%s%s%s%s>\n" - "<show>%s</show>\n" - "<status>%s</status>\n" - "<priority>9</priority>\n" - "</presence>\n", (from != nil) ? " from=\"" : "", - (from != nil) ? from : "", - (from != nil) ? "\"" : "", - (to != nil) ? " to=\"" : "", - (to != nil) ? to : "", - (to != nil) ? "\"" : "", - (show != nil) ? show : "", - (stat != nil) ? stat : ""); -} - -int -presencetypejacc(int sock, char *from, char *to, char *type) -{ - return fprint(sock, "<presence type=\"%s\" from=\"%s\" to=\"%s\"/>\n", - type, from, to); -} - -int -rosterjacc(int sock) -{ - return fprint(sock, "<iq type=\"get\" id=\"auth_2\">\n" - "<query xmlns=\"jabber:iq:roster\"/>\n" - "</iq>\n"); -} - -int -messagejacc(int sock, char *from, char *to, char *msg, char *type) -{ - return fprint(sock, "<message from=\"%s\" to=\"%s\" type=\"%s\">\n" - "<body>%s</body>\n" - "</message>\n", from, to, type, msg); -} - -int -addbuddyjacc(int sock, char *jid, char *na, char *group) -{ - if(na == nil){ - na = jid; - jid = strchr(na, '@'); - - if(jid == nil) - return -1; - *jid++ = '\0'; - - return fprint(sock, "<iq type=\"set\">\n" - "<query xmlns=\"jabber:iq:roster\">\n" - "<item jid=\"%s@%s\" name=\"%s\"/>\n" - "%s%s%s" - "</query>\n" - "</iq>\n", na, jid, na, - (group != nil) ? "<group>" : "", - (group != nil) ? group : "", - (group != nil) ? "</group>\n" : ""); - } - - return fprint(sock, "<iq type=\"set\">\n" - "<query xmlns=\"jabber:iq:roster\">\n" - "<item jid=\"%s\" name=\"%s\"/>\n" - "%s%s%s" - "</query>\n" - "</iq>\n", jid, na, - (group != nil) ? "<group>" : "", - (group != nil) ? group : "", - (group != nil) ? "</group>\n" : ""); -} - -int -delbuddyjacc(int sock, char *jid) -{ - return fprint(sock, "<iq type=\"set\">\n" - "<query xmlns=\"jabber:iq:roster\">\n" - "<item jid=\"%s\" subscription=\"remove\"/>\n" - "</query>\n" - "</iq>\n", jid); -} - -int -xmlnsjacc(int sock, char *who, char *t, char *id) -{ - return fprint(sock, "<iq type=\"get\" to=\"%s\" id=\"%s\">\n" - "<query xmlns=\"%s\"/>\n" - "</iq>\n", who, id, t); -} - -void -printrostern(rostern *r, char *w) -{ - char *tmstmp; - - tmstmp = mktmstmp('(', ')'); - while(r != nil){ - if(w != nil){ - if(r->status != nil) - if(!strcmp(r->status, w)) - goto got_one; - if(r->name != nil) - if(!strcmp(r->name, w)) - goto got_one; - if(r->jid != nil) - if(!strcmp(r->jid, w)) - goto got_one; - if(r->show != nil) - if(!strcmp(r->show, w)) - goto got_one; - if(r->group != nil) - if(!strcmp(r->group, w)) - goto got_one; - } else { -got_one: - print("%s%s/%s on %s -> %s/%s\n", tmstmp, r->name, r->jid, r->group, r->show, r->status); - } - - r = r->n; - } - - return; -} - -void -usage(void) -{ - print("usage: [-dgit] [-r res] [-s tosrv] [net!]server[!port]\n"); - exits(0); -} - -void admin (int sock, char *id, char *room, char *item) -{ - fprint(sock, "<iq id=\"%s\" to=\"%s\" type=\"set\"><query xmlns=\"http://jabber.org/protocol/muc#admin\"><item %s /></query></iq>", id, room, item); -} - - - -int -main(int argc, char *argv[]) -{ - char *server, *user, *lbl, *b, *tmstmp, *buf, *toserver, *role, *tmp; - int sock, ts, reg, debug, tls; - UserPasswd *i; - TLSconn conn; - jabberc *me; - - tls = 0; - b = nil; - reg = 0; - debug = 0; - toserver = nil; - - ARGBEGIN { - case 't': - tls = 1; - break; - case 'r': - b = EARGF(usage()); - break; - case 'g': - reg = 1; - break; - case 'd': - debug = 1; - break; - case 'i': - doignore = 1; - break; - case 's': - toserver = EARGF(usage()); - break; - default: - usage(); - } ARGEND; - - if(argc < 1) - usage(); - server = strdup(argv[0]); - - lbl = getwindowlbl(); - user = reallocj(nil, strlen(server) + 9, 2); - snprint(user, strlen(server) + 8, "jacc - %s", server); - setwindowlbl(user); - free(user); - - i = auth_getuserpasswd(auth_getkey, "proto=pass server=%s service=jabber", server); - if(i == nil) - sysfatal("auth_getuserpasswd: %r"); - - sock = dial(netmkaddr(server, "tcp", tls ? "5223" : "5222"), 0, 0, 0); - if(sock < 0) - sysfatal("dial: %r"); - - if(tls){ - ts = tlsClient(sock, &conn); - if(ts < 0) - sysfatal("tlsClient: %r"); - sock = ts; - - if(conn.cert != nil) - free(conn.cert); - } - - buf = strchr(server, '!'); - if(buf != nil) { - *buf++ = '\0'; - user = strchr(buf, '!'); - if(user != nil) - *user = '\0'; - user = strdup(buf); - free(server); - server = user; - } - - if(toserver == nil) - toserver = server; - - me = mkjabberc(); - me->show = strdup("Online"); - me->stat = strdup("Online"); - me->name = strdup(i->user); - me->serv = strdup(toserver); - - if(b != nil) - me->reso = strdup(b); - else - me->reso = strdup("Plan9"); - me->jid = printjid(me->name, me->serv, me->reso); - me->debug = debug; - me->reg = reg; - me->last = time(0); - - free(server); - - ts = getpid(); - -#ifdef PLAN9PORT - switch(fork()) { -#endif -#ifndef PLAN9PORT - switch(rfork(RFPROC|RFFDG|RFMEM)) { -#endif - case -1: - sysfatal("fork: %r"); - case 0: - if(recvjacc(sock, me, i->passwd) < 0) - perror("recvjacc"); - - if(lbl != nil){ - setwindowlbl(lbl); - lbl = nil; - free(lbl); - } - killproc(ts); - exits(0); - default: - user = reallocj(nil, 1025, 2); - buf = nil; - while(sock > 0 && user != nil){ - ts = -1; - memset(user, 0, 1025); - - while(read(0, &user[++ts], 1) && ts < 1024 && sock > 0) - if(user[ts] == '\n') - break; - user[ts] = '\0'; - me->last = time(0); - - tmstmp = mktmstmp('(', ')'); - if(user[0] != '/'){ - if(buf != nil){ - b = filterhin(user, 0); - messagejacc(sock, me->jid, buf, b, "chat"); - print("%s\n", tmstmp); - free(b); - } - free(tmstmp); - continue; - } - if (user[1] == 'x'){ - b = getarg(user, 1, 0); - if(b != nil){ - if (strcmp(b, "join") == 0){ - free(b); - - server = getarg(user, 2, 0); - - if(server != nil){ - b = getarg(user, 3, 0); - if(b == nil) - b = strdup(me->name); - - fprint(sock, "<presence to=\"%s/%s\"/>", server, b); - free (server); - free(b); - } - } - else - if (strcmp(b, "leave") == 0){ - free(b); - server = getarg(user, 2, 0); - if(server != nil) { - fprint(sock, - "<presence to='%s' type='unavailable'/>", server); - free (server); - } - - } - else - if (strcmp(b, "say") == 0){ - free(b); - server = getarg(user, 2, 0); - if(server != nil){ - b = getarg(user, 3, 2); - if(b != nil){ - messagejacc(sock, - me->jid, server, b, "groupchat"); - free(b); - } - free(server); - } - } - else - if (strcmp(b, "priv") == 0){ - free(b); - server = getarg(user, 2, 0); - if(server != nil){ - role = getarg(user, 3, 0); - if(role != nil){ - b = getarg(user, 4, 2); - if(b != nil){ - tmp = server; - server = smprint("%s/%s", server, role); - free(tmp); - - messagejacc(sock, - me->jid, server, b, "chat"); - free(b); - } - free(role); - } - free(server); - } - } - else - if (strcmp(b, "role") == 0){ - free(b); - server = getarg(user, 2, 0); - if(server != nil){ - role = getarg(user, 3, 0); - if(role != nil){ - b = getarg(user, 4, 2); - if(b != nil){ - tmp = b; - b = smprint("nick='%s' role='%s'", b, role); - free(tmp); - - admin(sock, role, server, b); - free(b); - } - free(role); - } - free(server); - } - } - else - if (strcmp(b, "affil") == 0){ - free(b); - server = getarg(user, 2, 0); - if(server != nil){ - role = getarg(user, 3, 0); - if(role != nil){ - b = getarg(user, 4, 2); - if(b != nil){ - tmp = b; - b = smprint("jid='%s' affiliation='%s'", b, role); - free(tmp); - - admin(sock, role, server, b); - free(b); - } - free(role); - } - free(server); - } - } - else - free(b); - } - } - else - switch(user[1]){ - case 'h': - case 'H': - print("%sHelp for jacc:\n", tmstmp); - print("%s /a [+|-|*]jid - authenticate jid\n", tmstmp); - print("%s /b - turn debugging on or off\n", tmstmp); - print("%s /c file - set vcard on server\n", tmstmp); - print("%s /d jid [feat] - do a discovery request\n", tmstmp); - print("%s /e jid - get time from jid\n", tmstmp); - print("%s /g jid - get agents information from jid\n", tmstmp); - print("%s /h - print out this help\n", tmstmp); - print("%s /i jid - get version of jid\n", tmstmp); - print("%s /l [status|jid|user] - list the roster\n", tmstmp); - print("%s /m jid - send a message to jid\n", tmstmp); - print("%s /p [show] [status] - set status and show\n", tmstmp); - print("%s /q - quit jacc\n", tmstmp); - print("%s /s [jid] - set active jid\n", tmstmp); - print("%s /t jid - get idle time of jid\n",tmstmp); - print("%s /u [+|-]jid [alias] - manage roster\n", tmstmp); - print("%s /v [jid] - get vcard from jid\n", tmstmp); - - print("%s /x command - operate with groupchat\n", tmstmp); - print("%s commands:\n", tmstmp); - print("%s groupchat - leave groupchat\n", tmstmp); - print("%s join groupchat [nick] - join to the groupchat\n", tmstmp); -// print("%s names groupchat - occupants' list\n", tmstmp); - print("%s say groupchat - send a message to groupchat\n", tmstmp); - print("%s priv groupchat nick - send a private message to occupant\n", tmstmp); - print("%s leave groupchat - leave groupchat\n", tmstmp); - print("%s affil groupchat affilation jid - set affilation\n", tmstmp); - print("%s role groupchat role nick - set role\n", tmstmp); - break; - - case 'q': - case 'Q': - fprint(sock, "<presence from=\"%s\" type=\"unavailable\"/>", - me->jid); - fprint(sock, "</stream:stream>"); - free(user); - user = nil; - break; - case 's': - case 'S': - server = getarg(user, 1, 0); - if(server == nil){ - print("%s%s\n", tmstmp, (buf != nil) ? buf : "<nil>"); - break; - } - - buf = setchan(buf, namerostern(me->rost, nil, server)); - free(server); - break; - case 'l': - case 'L': - server = getarg(user, 1, 0); - - printrostern(me->rost, server); - - if(server != nil) - free(server); - break; - case 'm': - case 'M': - server = getarg(user, 1, 0); - if(server != nil){ - - b = getarg(user, 2, 2); - if(b != nil){ - messagejacc(sock, me->jid, namerostern(me->rost, nil, server), b, "normal"); - free(b); - } - - free(server); - } - break; - case 'p': - case 'P': - server = getarg(user, 1, 0); - if(server == nil){ - print("%s%s\n", tmstmp, me->stat); - break; - } - - b = getarg(user, 2, 2); - if(b != nil){ - presencejacc(sock, b, server, nil, nil); - free(me->stat); - me->stat = strdup(b); - } else - presencejacc(sock, nil, server, nil, nil); - free(me->show); - me->show = strdup(server); - statusrostern(me->rost, me->jid, me->jid, server, b); - free(server); - break; - case 'c': - case 'C': - server = getarg(user, 1, 0); - if(server != nil){ - ts = open(server, OREAD); - if(ts >= 0){ - vcardsetjacc(sock, me->jid, ts); - close(ts); - } - free(server); - } - break; - case 'v': - case 'V': - server = getarg(user, 1, 0); - if(server == nil){ - vcardgetjacc(sock, me->jid, "from"); - break; - } - - vcardgetjacc(sock, namerostern(me->rost, nil, server), "to"); - print("Vcard of: %s\n", namerostern(me->rost, nil, server)); - free(server); - break; - case 'u': - case 'U': - server = getarg(user, 1, 0); - if(server != nil){ - if(server[0] == '-') - delbuddyjacc(sock, namerostern(me->rost, server + 1, server + 1)); - else { - b = getarg(user, 2, 0); - if(server[0] == '+') - addbuddyjacc(sock, server + 1, b, nil); - else - addbuddyjacc(sock, server, b, nil); - } - free(server); - } - break; - case 'a': - case 'A': - server = getarg(user, 1, 0); - if(server != nil){ - switch(server[0]){ - case '+': - presencetypejacc(sock, me->jid, namerostern(me->rost, nil, server + 1), "subscribed"); - break; - case '-': - presencetypejacc(sock, me->jid, namerostern(me->rost, nil, server + 1), "unsubscribe"); - break; - case '*': - presencetypejacc(sock, me->jid, namerostern(me->rost, nil, server + 1), "subscribe"); - break; - default: - presencetypejacc(sock, me->jid, namerostern(me->rost, nil, server), "subscribed"); - break; - } - free(server); - } - break; - case 'd': - case 'D': - server = getarg(user, 1, 0); - if(server != nil){ - b = getarg(user, 2, 2); - if(b == nil) - b = strdup("info"); - - free(tmstmp); - tmstmp = reallocj(nil, 35 + strlen(b), 2); - sprint(tmstmp, "http://jabber.org/protocol/disco#%s", b); - - xmlnsjacc(sock, server, tmstmp, "disco0"); - free(b); - free(server); - } - break; - case 'b': - case 'B': - if(me->debug == 0) - me->debug = 1; - else - me->debug = 0; - print("%sDebug: %c\n", tmstmp, me->debug); - break; - case 't': - case 'T': - server = getarg(user, 1, 0); - if(server != nil){ - xmlnsjacc(sock, namerostern(me->rost, nil, server), "jabber:iq:last", "last0"); - free(server); - } - break; - case 'i': - case 'I': - server = getarg(user, 1, 0); - if(server != nil){ - xmlnsjacc(sock, namerostern(me->rost, nil, server), "jabber:iq:version", "version0"); - free(server); - } - break; - case 'e': - case 'E': - server = getarg(user, 1, 0); - if(server != nil){ - xmlnsjacc(sock, namerostern(me->rost, nil, server), "jabber:iq:time", "time0"); - free(server); - } - break; - case 'g': - case 'G': - server = getarg(user, 1, 0); - if(server != nil){ - xmlnsjacc(sock, namerostern(me->rost, nil, server), "jabber:iq:agents", "agents0"); - free(server); - } - break; - - default: - break; - } - free(tmstmp); - } - - wait(); - if(lbl != nil){ - setwindowlbl(lbl); - lbl = nil; - free(lbl); - } - break; - } - - freejabberc(me); - exits(0); - return 0; -} -<!-- BEGIN TAIL --> -</pre> -</td></tr></table> -</td></tr></table> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<p style="line-height: 1.2em; margin-left: 1.00in; text-indent: 0.00in; margin-right: 1.00in; margin-top: 0; margin-bottom: 0; text-align: center;"> -<span style="font-size: 10pt">(This is a user-contributed directory and <br> should not be interpreted as statement by Lucent.)</span></p> -<p style="margin-top: 0; margin-bottom: 0.50in"></p> -<p style="margin-top: 0; margin-bottom: 0.33in"></p> -<center><table border="0"><tr> -<td valign="middle"><a href="http://www.alcatel-lucent.com/"><img border="0" src="/plan9/img/logo_ft.gif" alt="Bell Labs" /> -</a></td> -<td valign="middle"><a href="http://www.opensource.org"><img border="0" alt="OSI certified" src="/plan9/img/osi-certified-60x50.gif" /> -</a></td> -<td><img style="padding-right: 45px;" alt="Powered by Plan 9" src="/plan9/img/power36.gif" /> -</td> -</tr></table></center> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<center> -<span style="font-size: 10pt">(<a href="/plan9/">Return to Plan 9 Home Page</a>)</span> -</center> -<p style="margin-top: 0; margin-bottom: 0.17in"></p> -<center><font size=-1> -<span style="font-size: 10pt"><a href="http://www.lucent.com/copyright.html">Copyright</a></span> -<span style="font-size: 10pt">© 2009 Alcatel-Lucent.</span> -<span style="font-size: 10pt">All Rights Reserved.</span> -<br /> -<span style="font-size: 10pt">Comments to</span> -<span style="font-size: 10pt"><a href="mailto:webmaster@plan9.bell-labs.com">webmaster@plan9.bell-labs.com</a>.</span> -</font></center> -</body> -</html> - diff --git a/jacc.tar b/jacc.tar Binary files differdeleted file mode 100644 index a037c8d..0000000 --- a/jacc.tar +++ /dev/null diff --git a/jacc/dat.c b/jacc/dat.c new file mode 100644 index 0000000..053df30 --- /dev/null +++ b/jacc/dat.c @@ -0,0 +1,320 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "dat.h" + +char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0}; +char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec", 0}; + +int +fileexists(char *path) +{ + uchar buf[STATMAX]; + int fd; + + fd = stat(path, buf, STATMAX); + if(fd < 0) + return 0; + + close(fd); + return 1; +} + +void +playmp3(char *file) +{ + char cmd[256]; + + if(!fileexists("/dev/audio")) + return; + + memset(cmd, 0, 256); + strncpy(cmd, file, 255); + if(getenv("home") != nil){ + snprint(cmd, 255, "%s/audio/%s", getenv("home"), file); + if(!fileexists(cmd)) + strncpy(cmd, file, 255); + } + if(!fileexists(cmd)) + return; + + if(fork() == 0) + execl("/bin/madplay", "madplay", "-Q", cmd, 0); + wait(); +} + +void * +reallocj(void *p, int s, short d) +{ + p = realloc(p, s); + if(p == nil) + sysfatal("realloc: %r"); + + if(d != 0) + memset(p, 0, s); + + return (void *)p; +} + +void +killproc(int p) +{ + char *e; + int fd; + + e = mallocz(65, 2); + snprint(e, 64, "/proc/%d/ctl", p); + + fd = open(e, OWRITE); + if(fd != -1){ + write(fd, "kill", 4); + close(fd); + } + free(e); +} + +char * +setwindowlbl(char *w) +{ + int s; + + s = open("/dev/label", OWRITE); + if(s < 0) + return nil; + + write(s, w, strlen(w)); + + close(s); + return w; +} + +char * +getwindowlbl(void) +{ + int s; + char *ret; + short i; + + s = open("/dev/label", OREAD); + if(s < 0) + return nil; + + i = 0; + ret = malloc(0); + while(realloc(ret, ++i) != nil && read(s, &ret[i - 1], 1) > 0 && + i < 513); + + ret[i - 1] = '\0'; + + close(s); + return ret; +} + +char * +mktmstmp(char bord, char bord_e) +{ + Tm *tim; + char *ret; + + ret = reallocj(nil, 32, 2); + tim = localtime(time(0)); + snprint(ret, 31, "%c%.2d:%.2d%c ", bord, tim->hour, tim->min, bord_e); + + return ret; +} + +char * +setchan(char *old, char *new) +{ + old = reallocj(old, strlen(new) + 1, 2); + strcpy(old, new); + + return old; +} + +char * +printjid(char *user, char *serv, char *reso) +{ + char *ret; + int i; + + if(user == nil || serv == nil) + return nil; + + i = strlen(user) + strlen(serv) + 3 + ((reso != nil) ? strlen(reso) : 0); + + ret = reallocj(nil, i, 2); + snprint(ret, i, "%s@%s%s%s", user, serv, (reso != nil) ? "/" : "\0", + ((reso != nil) ? reso : "")); + + return ret; +} + +char * +getarg(char *b, char n, char t) +{ + char *ret, delim; + + ret = nil; + + while(n-- > 0){ + if(*b == '\'' || *b == '\"'){ + delim = *b; + b++; + ret = strchr(b, delim); + } else + ret = strchr(b, ' '); + if(ret == nil) + return nil; + + b = ret + 1; + } + + if(t == 0) + b = strchr(ret + 1, ' '); + else + b = nil; + + if(b == nil) + ret = strdup(ret + 1); + else { + n = *b; + *b = '\0'; + ret = strdup(ret + 1); + *b = n; + } + + ret = filterhin(ret, 2); + + return ret; +} + +void +readwrite(int sock, int fd) +{ + char *b; + int l; + + l = 2048; + b = reallocj(nil, 2048, 2); + while(l == 2048){ + l = read(fd, b, 2048); + if(l > 0) + write(sock, b, l); + } + + free(b); + return; +} + +char * +getmonth(int m) +{ + if(m > 11 || m < 0) + return nil; + + return month[m]; +} + +char * +getday(int d) +{ + if(d > 6 || d < 0) + return nil; + + return wdays[d]; +} + +char * +filterhin(char *in, int a) +{ + char *ret, *z; + int l; + + l = 0; + ret = reallocj(nil, 1, 0); + z = in; + + while(*in != '\0'){ + switch(*in){ + case '<': + l += 4; + ret = reallocj(ret, l + 1, 0); + strncpy(&ret[l - 4], "<", 4); + break; + case '&': + l += 5; + ret = reallocj(ret, l + 1, 0); + strncpy(&ret[l - 5], "&", 5); + break; + case '>': + l += 4; + ret = reallocj(ret, l + 1, 0); + strncpy(&ret[l - 4], ">", 4); + break; + case '"': + l += 6; + ret = reallocj(ret, l + 1, 0); + strncpy(&ret[l - 6], """, 6); + break; + default: + ret = reallocj(ret, ++l + 1, 0); + ret[l - 1] = *in; + break; + } + in++; + } + ret[l] = '\0'; + + if(a != 0) + free(z); + + return ret; +} + +char * +filterzur(char *out) +{ + char *a, *b; + int changed; + + changed = 1; + + while(changed){ + changed = 0; + if((a = strstr(out, "<")) != nil) { + *a = '<'; + strcpy(a + 1, a + 4); + changed = 1; + } + if((a = strstr(out, ">")) != nil) { + *a = '>'; + strcpy(a + 1, a + 4); + changed = 1; + } + if((a = strstr(out, """)) != nil) { + *a = '"'; + strcpy(a + 1, a + 6); + changed = 1; + } + if((a = strstr(out, "&")) != nil) { + *a = '&'; + strcpy(a + 1, a + 5); + changed = 1; + } + if((a = strstr(out, "text/x-aolrtf;")) != nil) { + b = strchr(a, ':'); + if(b != nil) { + strcpy(a, b + 2); + changed = 1; + } + } + } + + return out; +} diff --git a/jacc/dat.h b/jacc/dat.h new file mode 100644 index 0000000..8d69d62 --- /dev/null +++ b/jacc/dat.h @@ -0,0 +1,25 @@ +#ifndef JDAT_H +#define JDAT_H + +typedef struct command command; +struct command { + char **params; + int l; +}; + +void playmp3(char *file); +void *reallocj(void *p, int s, short d); +void killproc(int p); +char *setwindowlbl(char *w); +char *getwindowlbl(void); +char *mktmstmp(char bord, char bord_e); +char *setchan(char *old, char *new); +char *printjid(char *user, char *serv, char *reso); +char *getarg(char *b, char n, char t); +void readwrite(int sock, int fd); +char *getmonth(int m); +char *getday(int d); +char *filterhin(char *in, int a); +char *filterzur(char *out); + +#endif diff --git a/jacc-paste.c b/jacc/jacc.c index 6874b93..6874b93 100644 --- a/jacc-paste.c +++ b/jacc/jacc.c diff --git a/jacc/jacc.h b/jacc/jacc.h new file mode 100644 index 0000000..2687f15 --- /dev/null +++ b/jacc/jacc.h @@ -0,0 +1,69 @@ +#ifndef JACC_H +#define JACC_H + +enum { + NONE = 0x00, + STREAM, + AUTH, + ERROR, + MESSAGE, + MESSAGE_INNER, + MESSAGE_HTML, + PRESENCE, + PRESENCE_STATUS, + PRESENCE_SHOW, + PRESENCE_ERROR, + PRESENCE_X, + PRESENCE_SET, + IQ, + IQ_INNER, + IQ_ITEM, + IQ_GROUP, + IQ_VCARD, + IQ_VCARD_INNER, + IQ_ERROR, + IQ_DISCO, + IQ_DISCO_IDENT, + IQ_DISCO_FEATU, + IQ_DISCO_ITEM, + IQ_DISCO_EMPTY, + IQ_VERSION, + IQ_VERSION_OS, + IQ_VERSION_NAME, + IQ_VERSION_VER, + IQ_TIME, + IQ_TIME_UTC, + IQ_TIME_TZ, + IQ_TIME_DISPLAY, + IQ_AGENTS, + IQ_AGENTS_AGENT, + IQ_AGENTS_NAME, + IQ_AGENTS_DESC, + IQ_AGENTS_SERV, + IQ_LAST, + ROSTER, + ROSTER_INNER, + ROSTER_GROUP, + END +}; + +int xmljacc(int sock); +int loginjacc(int sock, char *serv); +int userjacc(int sock, char *user, char *pass, char *res); +int versionjacc(int sock, char *from, char *to, char *id); +int featuresjacc(int sock, char *from, char *to, char *id); +int timejacc(int sock, char *from, char *to, char *id); +int lastjacc(int sock, char *from, char *to, char *id, int d); +int registerjacc(int sock, char *serv, char *user, char *pass); +int vcardgetjacc(int sock, char *from, char *type); +int vcardsetjacc(int sock, char *from, int fd); +int presencejacc(int sock, char *stat, char *show, char *from, char *to); +int presencetypejacc(int sock, char *from, char *to, char *type); +int rosterjacc(int sock); +int messagejacc(int sock, char *from, char *to, char *msg, char *type); +int addbuddyjacc(int sock, char *jid, char *na, char *type); +int delbuddyjacc(int sock, char *jid); +int xmlnsjacc(int sock, char *who, char *t, char *id); + +#endif + diff --git a/jacc/mkfile b/jacc/mkfile new file mode 100644 index 0000000..d515d6b --- /dev/null +++ b/jacc/mkfile @@ -0,0 +1,24 @@ +</$objtype/mkfile +BIN=/$objtype/bin + +TARG=jacc +OFILES=\ + dat.$O\ + roster.$O\ + recv.$O\ + jacc.$O\ + +HFILES=\ + roster.h\ + dat.h\ + recv.h\ + jacc.h\ + +UPDATE=\ + mkfile\ + $HFILES\ + ${OFILES:%.$O=%.c}\ + ${TARG:%=/$cputype/bin/%}\ + +</sys/src/cmd/mkone + diff --git a/jacc/mkfile.plan9port b/jacc/mkfile.plan9port new file mode 100644 index 0000000..4705cdd --- /dev/null +++ b/jacc/mkfile.plan9port @@ -0,0 +1,25 @@ +</$PLAN9/src/mkhdr +BIN=$PLAN9/bin + +LDFLAGS=-lxmlpull +CFLAGS=-DPLAN9PORT +TARG=jacc +OFILES=\ + dat.$O\ + roster.$O\ + recv.$O\ + jacc.$O\ + +HFILES=\ + roster.h\ + dat.h\ + recv.h\ + jacc.h\ + +UPDATE=\ + mkfile\ + $HFILES\ + ${OFILES:%.$O=%.c}\ + ${TARG:%=$PLAN9/bin/%}\ + +<$PLAN9/src/mkone diff --git a/jacc/recv.c b/jacc/recv.c new file mode 100644 index 0000000..a00fda5 --- /dev/null +++ b/jacc/recv.c @@ -0,0 +1,887 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "xmlpull.h" +#include "jacc.h" +#include "dat.h" +#include "roster.h" + +int doignore; + +int +recvjacc(int sock, jabberc *me, char *pass) +{ + xmlpull *x, *b; + char *id, *to, *from, *tmstmp, st, *type, *va, *xm; + rostern *ac, *p; + + type = nil; + id = nil; + from = nil; + to = nil; + xm = nil; + va = nil; + st = NONE; + ac = me->rost; + + if(xmljacc(sock) < 0) + return -1; + if(loginjacc(sock, me->serv) < 0) + return -1; + + x = openxmlpull(sock); + while((b = nextxmlpull(x)) != nil && st != END){ + tmstmp = mktmstmp('(', ')'); + if(x->na != nil) + x->na = filterzur(x->na); + if(x->va != nil) + x->va = filterzur(x->va); + switch(b->ev){ + case START_DOCUMENT: + if(me->debug) + print("Start.\n"); + st = NONE; + break; + case START_TAG: + if(me->debug) + print("Tag: %s\n", x->na); + if(!strcmp(x->na, "stream:stream")){ + st = STREAM; + break; + } + if(!strcmp(x->na, "stream:error")){ + st = ERROR; + break; + } + if(st == ERROR){ + if(strcmp(x->na, "text")) + fprint(2, "%serror: %s\n", tmstmp, x->na); + break; + } + if(!strcmp(x->na, "message")){ + st = MESSAGE; + break; + } + if(!strcmp(x->na, "presence")){ + id = nil; + st = PRESENCE; + break; + } + if(!strcmp(x->na, "iq")){ + st = IQ; + break; + } + if(!strcmp(x->na, "vCard") && st == IQ){ + st = IQ_VCARD; + break; + } + if(!strcmp(x->na, "error") && st == IQ){ + st = IQ_ERROR; + break; + } + if(!strcmp(x->na, "body") && st == MESSAGE){ + st = MESSAGE_INNER; + break; + } + if(!strcmp(x->na, "html") && st == MESSAGE){ + st = MESSAGE_HTML; + break; + } + if(!strcmp(x->na, "status") && (st == PRESENCE || st == PRESENCE_SET)){ + st = PRESENCE_STATUS; + break; + } + if(!strcmp(x->na, "show") && (st == PRESENCE || st == PRESENCE_SET)){ + st = PRESENCE_SHOW; + break; + } + if(!strcmp(x->na, "error") && (st == PRESENCE || st == PRESENCE_SET)){ + st = PRESENCE_ERROR; + break; + } + if(!strcmp(x->na, "x") && st == PRESENCE){ + st = PRESENCE_X; + break; + } + if(!strcmp(x->na, "item") && st == ROSTER){ + if(me->rost == nil){ + me->rost = mkrostern(); + ac = mkrostern(); + me->rost->n = ac; + me->rost->p = nil; + me->rost->name = strdup(me->name); + me->rost->jid = strdup(me->jid); + me->rost->status = strdup(me->stat); + me->rost->show = strdup(me->show); + me->rost->subsc = strdup("self"); + me->rost->group = strdup("self"); + } else { + ac->n = mkrostern(); + ac->n->p = ac; + ac = ac->n; + ac->n = nil; + } + + st = ROSTER_INNER; + break; + } + if(!strcmp(x->na, "query") && st == IQ){ + st = IQ_INNER; + break; + } + if(!strcmp(x->na, "item") && st == IQ_INNER){ + st = IQ_ITEM; + ac = mkrostern(); + break; + } + if(!strcmp(x->na, "group") && st == IQ_ITEM){ + st = IQ_GROUP; + break; + } + if(!strcmp(x->na, "group") && st == ROSTER_INNER){ + st = ROSTER_GROUP; + break; + } + if(!strcmp(x->na, "utc") && st == IQ_TIME){ + st = IQ_TIME_UTC; + break; + } + if(!strcmp(x->na, "tz") && st == IQ_TIME){ + st = IQ_TIME_TZ; + break; + } + if(!strcmp(x->na, "display") && st == IQ_TIME){ + st = IQ_TIME_DISPLAY; + break; + } + if(!strcmp(x->na, "item") && st == IQ_DISCO){ + st = IQ_DISCO_ITEM; + break; + } + if(!strcmp(x->na, "identity") && st == IQ_DISCO){ + print("%sserver identity:\n", tmstmp); + st = IQ_DISCO_IDENT; + break; + } + if(!strcmp(x->na, "feature") && st == IQ_DISCO){ + st = IQ_DISCO_FEATU; + break; + } + if(!strcmp(x->na, "empty") && st == IQ_DISCO){ + st = IQ_DISCO_EMPTY; + break; + } + if(!strcmp(x->na, "version") && st == IQ_VERSION){ + st = IQ_VERSION_VER; + break; + } + if(!strcmp(x->na, "os") && st == IQ_VERSION){ + st = IQ_VERSION_OS; + break; + } + if(!strcmp(x->na, "name") && st == IQ_VERSION){ + st = IQ_VERSION_NAME; + break; + } + if(!strcmp(x->na, "agent") && st == IQ_AGENTS){ + st = IQ_AGENTS_AGENT; + break; + } + if(!strcmp(x->na, "name") && st == IQ_AGENTS_AGENT){ + st = IQ_AGENTS_NAME; + break; + } + if(!strcmp(x->na, "description") && st == IQ_AGENTS_AGENT){ + st = IQ_AGENTS_DESC; + break; + } + if(!strcmp(x->na, "transport") && st == IQ_AGENTS_AGENT){ + print("%s This is a transport.\n", tmstmp); + break; + } + if(!strcmp(x->na, "groupchat") && st == IQ_AGENTS_AGENT){ + print("%s You can groupchat here.\n", tmstmp); + break; + } + if(!strcmp(x->na, "service") && st == IQ_AGENTS_AGENT){ + st = IQ_AGENTS_SERV; + break; + } + if(!strcmp(x->na, "register") && st == IQ_AGENTS_AGENT){ + print("%s You can register here.\n", tmstmp); + break; + } + if(!strcmp(x->na, "search") && st == IQ_AGENTS_AGENT){ + print("%s You can search here.\n", tmstmp); + break; + } + if(st == IQ_VCARD){ + if(!strcmp(x->na, "FN")) + goto is_vcard_inner; + if(!strcmp(x->na, "GIVEN")) + goto is_vcard_inner; + if(!strcmp(x->na, "FAMILY")) + goto is_vcard_inner; + if(!strcmp(x->na, "MIDDLE")) + goto is_vcard_inner; + if(!strcmp(x->na, "PREFIX")) + goto is_vcard_inner; + if(!strcmp(x->na, "SUFFIX")) + goto is_vcard_inner; + if(!strcmp(x->na, "VERSION")) + goto is_vcard_inner; + if(!strcmp(x->na, "NICKNAME")) + goto is_vcard_inner; + if(!strcmp(x->na, "PHOTO")) + goto is_vcard_inner; + if(!strcmp(x->na, "BDAY")) + goto is_vcard_inner; + if(!strcmp(x->na, "POBOX")) + goto is_vcard_inner; + if(!strcmp(x->na, "EXTADR")) + goto is_vcard_inner; + if(!strcmp(x->na, "STREET")) + goto is_vcard_inner; + if(!strcmp(x->na, "LOCALITY")) + goto is_vcard_inner; + if(!strcmp(x->na, "REGION")) + goto is_vcard_inner; + if(!strcmp(x->na, "PCODE")) + goto is_vcard_inner; + if(!strcmp(x->na, "CTRY")) + goto is_vcard_inner; + if(!strcmp(x->na, "NUMBER")) + goto is_vcard_inner; + if(!strcmp(x->na, "USERID")) + goto is_vcard_inner; + if(!strcmp(x->na, "JABBERID")) + goto is_vcard_inner; + if(!strcmp(x->na, "MAILER")) + goto is_vcard_inner; + if(!strcmp(x->na, "LAT")) + goto is_vcard_inner; + if(!strcmp(x->na, "LON")) + goto is_vcard_inner; + if(!strcmp(x->na, "TITLE")) + goto is_vcard_inner; + if(!strcmp(x->na, "ROLE")) + goto is_vcard_inner; + if(!strcmp(x->na, "AGENT")) + goto is_vcard_inner; + if(!strcmp(x->na, "ORGNAME")) + goto is_vcard_inner; + if(!strcmp(x->na, "ORGUNIT")) + goto is_vcard_inner; + if(!strcmp(x->na, "NOTE")) + goto is_vcard_inner; + if(!strcmp(x->na, "PRODID")) + goto is_vcard_inner; + if(!strcmp(x->na, "REV")) + goto is_vcard_inner; + if(!strcmp(x->na, "PHONETIC")) + goto is_vcard_inner; + if(!strcmp(x->na, "DESC")) + goto is_vcard_inner; + if(!strcmp(x->na, "CRED")) + goto is_vcard_inner; + if(!strcmp(x->na, "HOME")) + goto is_vcard_end; + if(!strcmp(x->na, "WORK")) + goto is_vcard_end; + if(!strcmp(x->na, "POSTAL")) + goto is_vcard_end; + if(!strcmp(x->na, "PARCEL")) + goto is_vcard_end; + if(!strcmp(x->na, "DOM")) + goto is_vcard_end; + if(!strcmp(x->na, "INTL")) + goto is_vcard_end; + if(!strcmp(x->na, "PREF")) + goto is_vcard_end; + if(!strcmp(x->na, "VOICE")) + goto is_vcard_end; + if(!strcmp(x->na, "FAX")) + goto is_vcard_end; + if(!strcmp(x->na, "PAGER")) + goto is_vcard_end; + if(!strcmp(x->na, "MSG")) + goto is_vcard_end; + if(!strcmp(x->na, "CELL")) + goto is_vcard_end; + if(!strcmp(x->na, "VIDEO")) + goto is_vcard_end; + if(!strcmp(x->na, "BBS")) + goto is_vcard_end; + if(!strcmp(x->na, "MODEM")) + goto is_vcard_end; + if(!strcmp(x->na, "ISDN")) + goto is_vcard_end; + if(!strcmp(x->na, "PCS")) + goto is_vcard_end; + if(!strcmp(x->na, "INTERNET")) + goto is_vcard_end; + if(!strcmp(x->na, "X400")) + goto is_vcard_end; + break; +is_vcard_end: + print("%s%s\n", tmstmp, x->na); + break; +is_vcard_inner: + print("%s%s = ", tmstmp, x->na); + st = IQ_VCARD_INNER; + break; + } + break; + case START_END_TAG: + if(me->debug) + print("Startend: %s\n", x->na); + if(!strcmp(x->na, "empty") && st == IQ_DISCO){ + print("%s <empty>\n", tmstmp); + break; + } + if(!strcmp(x->na, "transport") && st == IQ_AGENTS_AGENT){ + print("%s This is a transport.\n", tmstmp); + break; + } + if(!strcmp(x->na, "groupchat") && st == IQ_AGENTS_AGENT){ + print("%s You can groupchat here.\n", tmstmp); + break; + } + if(!strcmp(x->na, "register") && st == IQ_AGENTS_AGENT){ + print("%s You can register here.\n", tmstmp); + break; + } + if(!strcmp(x->na, "search") && st == IQ_AGENTS_AGENT){ + print("%s You can search here.\n", tmstmp); + break; + } + if(st == ERROR || st == PRESENCE_ERROR || st == IQ_ERROR){ + fprint(2, "%serror: %s\n", tmstmp, x->na); + break; + } + break; + case TEXT: + if(me->debug) + print("Text: %s\n", x->na); + switch(st){ + case MESSAGE_INNER: + type = strdup(x->na); + break; + case PRESENCE_SHOW: + if(type == nil || (type != nil && strcmp(type, "error"))) + if(statusrostern(me->rost, from, from, nil, x->na) != nil) + print("%s%s> %s\n", tmstmp, namerostern(me->rost, from, nil), x->na); + break; + case PRESENCE_STATUS: + if(type == nil || (type != nil && strcmp(type, "error"))) + if(statusrostern(me->rost, from, from, x->na, nil) != nil) + print("%s%s> %s\n", tmstmp, namerostern(me->rost, from, nil), x->na); + break; + case PRESENCE_ERROR: + print("%s%s# %s\n", tmstmp, namerostern(me->rost, from, nil), x->na); + free(type); + type = strdup("isdone"); + break; + case ROSTER_GROUP: + if(ac->group == nil) + ac->group = strdup(x->na); + break; + case IQ_GROUP: + if(ac->group == nil) + ac->group = strdup(x->na); + break; + case IQ_ERROR: + print("%sIQ-Error: %s\n", tmstmp, x->na); + break; + case IQ_VCARD_INNER: + print("%s\n", x->na); + break; + case IQ_VERSION_OS: + print("%s os = %s\n", tmstmp, x->na); + break; + case IQ_VERSION_NAME: + print("%s name = %s\n", tmstmp, x->na); + break; + case IQ_VERSION_VER: + print("%s version = %s\n", tmstmp, x->na); + break; + case IQ_TIME_UTC: + print("%sutc = %s\n", tmstmp, x->na); + break; + case IQ_TIME_TZ: + print("%stz = %s\n", tmstmp, x->na); + break; + case IQ_TIME_DISPLAY: + print("%sdisplay = %s\n", tmstmp, x->na); + break; + case IQ_AGENTS_NAME: + print("%s name = %s\n", tmstmp, x->na); + break; + case IQ_AGENTS_DESC: + print("%s description = %s\n", tmstmp, x->na); + break; + case IQ_AGENTS_SERV: + print("%s service = %s\n", tmstmp, x->na); + break; + default: + break; + } + break; + case ATTR: + if(me->debug) + print("Attr: %s = %s\n", x->na, x->va); + switch(st){ + case STREAM: + if(!strcmp(x->na, "id")){ + st = NONE; + if(me->reg){ + registerjacc(sock, me->serv, me->name, pass); + break; + } + if(userjacc(sock, me->name, pass, me->reso) < 0) { + memset(pass, 0, strlen(pass)); + st = AUTH; + break; + } + } + break; + case MESSAGE: + if(!strcmp(x->na, "from")) + from = strdup(x->va); + if(!strcmp(x->na, "to")) + to = strdup(x->va); + if(!strcmp(x->na, "type")) + type = strdup(x->va); + break; + case PRESENCE: + if(!strcmp(x->na, "from")) + from = strdup(x->va); + if(!strcmp(x->na, "type")) + type = strdup(x->va); + break; + case IQ: + if(!strcmp(x->na, "id")){ + if(!strcmp(x->va, "auth_1")) + rosterjacc(sock); + if(!strcmp(x->va, "auth_2")) + st = ROSTER; + if(!strcmp(x->va, "disco0")) + st = IQ_DISCO; + if(!strcmp(x->va, "time0")) + st = IQ_TIME; + if(!strcmp(x->va, "agents0")) + st = IQ_AGENTS; + if(!strcmp(x->va, "last0")) + st = IQ_LAST; + if(!strcmp(x->va, "version0")) + st = IQ_VERSION; + id = strdup(x->va); + } + if(!strcmp(x->na, "from")) + from = strdup(x->va); + if(!strcmp(x->na, "to")) + to = strdup(x->va); + if(!strcmp(x->na, "type")) + type = strdup(x->va); + break; + case ROSTER_INNER: + if(!strcmp(x->na, "name")){ + ac->name = strdup(x->va); + break; + } + if(!strcmp(x->na, "jid")){ + ac->jid = strdup(x->va); + break; + } + break; + case IQ_INNER: + if(!strcmp(x->na, "xmlns")){ + if(xm != nil) + free(xm); + xm = strdup(x->va); + } + if(!strcmp(x->na, "name")){ + if(va != nil) + free(va); + va = strdup(x->va); + } + break; + case IQ_ITEM: + if(!strcmp(x->na, "subscription")){ + ac->subsc = strdup(x->va); + break; + } + if(!strcmp(x->na, "jid")){ + ac->jid = strdup(x->va); + break; + } + if(!strcmp(x->na, "name")){ + ac->name = strdup(x->va); + break; + } + break; + case IQ_DISCO_IDENT: + print("%s%s = %s\n", tmstmp, x->na, x->va); + break; + case IQ_DISCO_FEATU: + print("%s %s\n", tmstmp, x->va); + break; + case IQ_DISCO_ITEM: + if(!strcmp(x->na, "name")){ + if(id != nil) + free(id); + id = strdup(x->va); + } + if(!strcmp(x->na, "jid")){ + if(to != nil) + free(to); + to = strdup(x->va); + } + break; + case IQ_AGENTS_AGENT: + if(!strcmp(x->na, "jid")) + print("%s%s:\n", tmstmp, x->va); + break; + case IQ_LAST: + if(!strcmp(x->na, "seconds")) + print("%s%s> %ss away\n", tmstmp, namerostern(me->rost, nil, from), x->va); + break; + default: + break; + } + break; + case END_TAG: + if(me->debug) + print("Endtag: %s\n", x->na); + if(!strcmp(x->na, "stream:stream")){ + st = END; + break; + } + if(!strcmp(x->na, "stream:error") && st == ERROR){ + st = NONE; + break; + } + if(st == ERROR) + break; + if(!strcmp(x->na, "message") && st == MESSAGE){ + if(type != nil) { + print("%s(%s-%s)%% %s\n", tmstmp, + (from != nil) ? namerostern(me->rost, from, nil) : "<nil>", + (to != nil) ? namerostern(me->rost, to, nil) : "<nil>", + type); + playmp3("jacc_gotmessage.mp3"); + } + if(from != nil) + free(from); + if(to != nil) + free(to); + if(type != nil) + free(type); + from = nil; + to = nil; + type = nil; + st = NONE; + break; + } + if(!strcmp(x->na, "presence") && st == PRESENCE_SET){ + if(type != nil) + free(type); + if(from != nil) + free(from); + type = nil; + from = nil; + st = NONE; + break; + } + if(!strcmp(x->na, "presence") && st == PRESENCE){ + if(type != nil && from != nil){ + if(!strcmp(type, "unavailable") || !strcmp(type, "error")){ + if(statusrostern(me->rost, from, from, nil, "Offline") != nil) + print("%s%s> Offline\n", tmstmp, namerostern(me->rost, from, nil)); + goto presence_strcmp; + } + if(!strcmp(type, "probe")){ + presencejacc(sock, me->stat, me->show, me->jid, from); + goto presence_strcmp; + } + if(!strcmp(type, "subscribe")){ + statusrostern(me->rost, from, from, nil, "Online"); + print("%s%s wants to subscribe\n", tmstmp, namerostern(me->rost, from, nil)); + goto presence_strcmp; + } + if(!strcmp(type, "unsubscribe")){ + if(statusrostern(me->rost, from, from, nil, "Offline") != nil) + print("%s%s wants to unsubscribe\n", tmstmp, namerostern(me->rost, from, nil)); + goto presence_strcmp; + } + if(!strcmp(type, "subscribed")){ + print("%s%s has accepted the subscription request\n", tmstmp, namerostern(me->rost, from, nil)); + goto presence_strcmp; + } + if(!strcmp(type, "isdone")) + goto presence_strcmp; + } + if(from != nil) { + statusrostern(me->rost, from, from, nil, "Online"); + print("%s%s> Online\n", tmstmp, namerostern(me->rost, from, nil)); + } +presence_strcmp: + if(type != nil) + free(type); + if(from != nil) + free(from); + type = nil; + from = nil; + + st = NONE; + break; + } + if(!strcmp(x->na, "iq") && (st == IQ || st == IQ_DISCO)){ + if(from != nil) + free(from); + if(to != nil) + free(to); + if(type != nil) + free(type); + if(id != nil) + free(id); + if(va != nil) + free(va); + if(xm != nil) + free(xm); + from = nil; + to = nil; + id = nil; + type = nil; + va = nil; + xm = nil; + st = NONE; + break; + } + if(!strcmp(x->na, "iq") && st == ROSTER){ + if(from != nil) + free(from); + if(to != nil) + free(to); + if(type != nil) + free(type); + if(id != nil) + free(id); + from = nil; + to = nil; + id = nil; + type = nil; + presencejacc(sock, me->stat, me->show, nil, nil); + st = NONE; + break; + } + if(!strcmp(x->na, "vCard") && st == IQ_VCARD){ + st = IQ; + break; + } + if(!strcmp(x->na, "error") && st == IQ_ERROR){ + st = IQ; + break; + } + if(!strcmp(x->na, "body") && st == MESSAGE_INNER){ + st = MESSAGE; + break; + } + if(!strcmp(x->na, "html") && st == MESSAGE_HTML){ + st = MESSAGE; + break; + } + if(!strcmp(x->na, "status") && st == PRESENCE_STATUS){ + st = PRESENCE_SET; + break; + } + if(!strcmp(x->na, "show") && st == PRESENCE_SHOW){ + st = PRESENCE_SET; + break; + } + if(!strcmp(x->na, "x") && st == PRESENCE_X){ + st = PRESENCE; + break; + } + if(!strcmp(x->na, "error") && st == PRESENCE_ERROR){ + st = PRESENCE; + break; + } + if(!strcmp(x->na, "item") && st == ROSTER_INNER){ + if(!doignore) + print("%sAdded user: %s/%s/%s\n", tmstmp, ac->name, ac->jid, ac->group); + st = ROSTER; + break; + } + if(!strcmp(x->na, "query") && (st == IQ_INNER || st == IQ_VERSION || st == IQ_TIME || st == IQ_LAST || st == IQ_AGENTS)){ + if(st == IQ_INNER && xm != nil){ + if(!strcmp(xm, "jabber:iq:version")){ + if(strcmp(to, me->jid)) + break; + else + versionjacc(sock, me->jid, from, id); + break; + } + if(!strcmp(xm, "jabber:iq:last")) + if(!strcmp(me->jid, to)) + lastjacc(sock, to, from, id, time(0) - me->last); + if(!strcmp(xm, "http://jabber.org/protocol/disco#info")) + if(!strcmp(me->jid, to)) + if(id != nil && strcmp(id, "http://jabber.org/protocol/muc#rooms")) + featuresjacc(sock, to, from, id); + if(!strcmp(xm, "jabber:iq:time")) + if(!strcmp(me->jid, to)) + timejacc(sock, to, from, id); + } + st = IQ; + break; + } + if(!strcmp(x->na, "item") && st == IQ_ITEM){ + st = IQ_INNER; + if(ac != nil && ac->subsc != nil){ + if(!strcmp(ac->subsc, "remove")){ + me->rost = delname(me->rost, ac->name, ac->jid); + print("%sremoved: %s\n", tmstmp, ac->jid); + freerostern(ac); + break; + } + if(!strcmp(ac->subsc, "both") || !strcmp(ac->subsc, "to") || + !strcmp(ac->subsc, "from") || !strcmp(ac->subsc, "none") || + !strcmp(ac->subsc, "ask")){ + if(!strcmp(ac->subsc, "ask")) + print("%s%s asks for authorisation.\n", tmstmp, ac->jid); + if((p = searchrostern(me->rost, ac->name, ac->jid)) == nil){ + ac->subsc = strdup(ac->subsc); + addrostern(me->rost, ac); + if(strcmp(ac->subsc, "ask")) + print("%sadded: %s\n", tmstmp, ac->jid); + } else { + if(p->jid != nil) + free(p->jid); + if(ac->jid != nil) + p->jid = strdup(ac->jid); + else + p->jid = nil; + + if(p->name != nil) + free(p->name); + if(ac->name != nil) + p->name = strdup(ac->name); + else + p->name = nil; + + if(p->subsc != nil) + free(p->subsc); + if(ac->subsc != nil) + p->subsc = strdup(ac->subsc); + else + p->subsc = nil; + + print("%supdate: %s/%s\n", tmstmp, (ac->name == nil) ? "<nil>" : ac->name + , (ac->jid == nil) ? "<nil>" : ac->jid); + freerostern(ac); + } + } + } + ac = nil; + break; + } + if(!strcmp(x->na, "group") && st == IQ_GROUP){ + st = IQ_ITEM; + break; + } + if(!strcmp(x->na, "group") && st == ROSTER_GROUP){ + st = ROSTER_INNER; + break; + } + if(!strcmp(x->na, "item") && st == IQ_DISCO_ITEM){ + print("%s %s | %s\n", tmstmp, to, id); + st = IQ_DISCO; + break; + } + if(!strcmp(x->na, "identity") && st == IQ_DISCO_IDENT){ + print("%sfeatures:\n", tmstmp); + st = IQ_DISCO; + break; + } + if(!strcmp(x->na, "feature") && st == IQ_DISCO_FEATU){ + st = IQ_DISCO; + break; + } + if(!strcmp(x->na, "empty") && st == IQ_DISCO_EMPTY){ + st = IQ_DISCO; + break; + } + if(!strcmp(x->na, "utc") && st == IQ_TIME_UTC){ + st = IQ_TIME; + break; + } + if(!strcmp(x->na, "tz") && st == IQ_TIME_TZ){ + st = IQ_TIME; + break; + } + if(!strcmp(x->na, "display") && st == IQ_TIME_DISPLAY){ + st = IQ_TIME; + break; + } + if(!strcmp(x->na, "version") && st == IQ_VERSION_VER){ + st = IQ_VERSION; + break; + } + if(!strcmp(x->na, "name") && st == IQ_VERSION_NAME){ + st = IQ_VERSION; + break; + } + if(!strcmp(x->na, "os") && st == IQ_VERSION_OS){ + st = IQ_VERSION; + break; + } + if(!strcmp(x->na, "agent") && st == IQ_AGENTS_AGENT){ + st = IQ_AGENTS; + print("%s\n", tmstmp); + break; + } + if(!strcmp(x->na, "name") && st == IQ_AGENTS_NAME){ + st = IQ_AGENTS_AGENT; + break; + } + if(!strcmp(x->na, "description") && st == IQ_AGENTS_DESC){ + st = IQ_AGENTS_AGENT; + break; + } + if((!strcmp(x->na, "transport") || !strcmp(x->na, "groupchat") + || !strcmp(x->na, "register") || !strcmp(x->na, "search")) && + st == IQ_AGENTS_AGENT) + break; + if(!strcmp(x->na, "service") && st == IQ_AGENTS_SERV){ + st = IQ_AGENTS_AGENT; + break; + } + if(st == IQ_VCARD_INNER){ + st = IQ_VCARD; + break; + } + break; + case END_DOCUMENT: + if(me->debug) + print("Documentend.\n"); + st = END; + break; + default: + print("Please contact the xmlpull author about this. %x\n", b->ev); + st = END; + break; + } + free(tmstmp); + } + + if(id != nil) + free(id); + freexmlpull(x); + + return 0; +} diff --git a/jacc/recv.h b/jacc/recv.h new file mode 100644 index 0000000..6c6c4a5 --- /dev/null +++ b/jacc/recv.h @@ -0,0 +1,6 @@ +#ifndef RECV_H +#define RECV_H + +int recvjacc(int sock, jabberc *me, char *pass); + +#endif diff --git a/jacc/roster.c b/jacc/roster.c new file mode 100644 index 0000000..6ffdfbc --- /dev/null +++ b/jacc/roster.c @@ -0,0 +1,213 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "dat.h" +#include "roster.h" + +void +freerostern(rostern *r) +{ + if(r != nil){ + if(r->name != nil) + free(r->name); + if(r->jid != nil) + free(r->jid); + if(r->status != nil) + free(r->status); + if(r->group != nil) + free(r->group); + if(r->show != nil) + free(r->show); + if(r->subsc != nil) + free(r->subsc); + free(r); + } + return; +} + +void +freerosterl(rostern *r) +{ + rostern *b; + + if(r != nil){ + while(r->n != nil){ + b = r->n; + freerostern(r); + r = b; + } + freerostern(r); + } + + return; +} + +void +freejabberc(jabberc *j) +{ + + if(j != nil){ + if(j->stat != nil) + free(j->stat); + if(j->name != nil) + free(j->name); + if(j->reso != nil) + free(j->reso); + if(j->serv != nil) + free(j->serv); + if(j->jid != nil) + free(j->jid); + if(j->rost != nil) + freerosterl(j->rost); + if(j->show != nil) + free(j->show); + free(j); + } + return; +} + +rostern * +mkrostern(void) +{ + return reallocj(nil, sizeof(rostern), 2); +} + +jabberc * +mkjabberc(void) +{ + return reallocj(nil, sizeof(jabberc), 2); +} + +rostern * +delrostern(rostern *r) +{ + rostern *ret; + + ret = nil; + + //print("delrostern: %x r->n: %x r->p: %x\n", r, r->n, r->p); + if(r->n != nil && r->p != nil){ + r->n->p = r->p; + r->p->n = r->n; + ret = r->p; + } else { + if(r->n != nil){ + r->n->p = nil; + ret = r->n; + } else { + if(r->p != nil){ + r->p->n = nil; + ret = r->p; + } + } + } + freerostern(r); + + return ret; +} + +rostern * +lastrostern(rostern *r) +{ + while(r->n != nil) + r = r->n; + + return r; +} + +rostern * +addrostern(rostern *r, rostern *n) +{ + rostern *ret; + + //print("addrostern: %x %x %x\n", r, n, n->jid); + ret = lastrostern(r); + ret->n = n; + n->p = ret; + n->n = nil; + + return n; +} + +rostern * +statusrostern(rostern *r, char *name, char *jid, char *status, char *show) +{ + r = searchrostern(r, name, jid); + if(r != nil){ + if(show != nil){ + if(r->show != nil) + if(!strcmp(r->show, show)) + return nil; + if(r->show != nil) + free(r->show); + r->show = strdup(show); + } + if(status != nil){ + if(r->status != nil) + if(!strcmp(r->status, status)) + return nil; + if(r->status != nil) + free(r->status); + r->status = strdup(status); + } + } + + return r; +} + +char * +namerostern(rostern *r, char *jid, char *name) +{ + + r = searchrostern(r, name, jid); + if(r != nil){ + if(jid != nil) + if(r->name != nil) + return r->name; + if(name != nil) + if(r->jid != nil) + return r->jid; + } + + if(jid != nil) + return jid; + return name; +} + +rostern * +searchrostern(rostern *r, char *name, char *jid) +{ + + //print("searchrostern: r: %x n: %x j: %x\n", r, name, jid); + while(r != nil){ + if(name != nil && r->name != nil) + if(!strcmp(name, r->name)) + return r; + if(jid != nil && r->jid != nil) + if(!strncmp(jid, r->jid, strlen(jid)) || !strncmp(jid, r->jid, strlen(r->jid))) + return r; + r = r->n; + } + + return nil; +} + +rostern * +delname(rostern *r, char *name, char *jid) +{ + rostern *ret; + + ret = searchrostern(r, name, jid); + if(ret != nil){ + if(ret == r) + return delrostern(ret); + + delrostern(ret); + } + + return r; +} diff --git a/jacc/roster.h b/jacc/roster.h new file mode 100644 index 0000000..de7b45e --- /dev/null +++ b/jacc/roster.h @@ -0,0 +1,43 @@ +#ifndef ROSTER_H +#define ROSTER_H + +typedef struct rostern rostern; +struct rostern { + rostern *n; + rostern *p; + char *name; + char *jid; + char *status; + char *show; + char *subsc; + char *group; +}; + +typedef struct jabberc jabberc; +struct jabberc { + char *stat; + char *show; + char *name; + char *reso; + char *serv; + char *jid; + int debug; + int reg; + int last; + rostern *rost; +}; + +void freerostern(rostern *r); +void freerosterl(rostern *r); +void freejabberc(jabberc *j); +rostern *mkrostern(void); +jabberc *mkjabberc(void); +rostern *delrostern(rostern *r); +rostern *lastrostern(rostern *r); +rostern *addrostern(rostern *r, rostern *n); +rostern *statusrostern(rostern *r, char *name, char *jid, char *status, char *show); +char *namerostern(rostern *r, char *jid, char *name); +rostern *searchrostern(rostern *r, char *name, char *jid); +rostern *delname(rostern *r, char *name, char *jid); + +#endif diff --git a/jacc/xmlpull.h b/jacc/xmlpull.h new file mode 100644 index 0000000..5a008f4 --- /dev/null +++ b/jacc/xmlpull.h @@ -0,0 +1,51 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifdef nil +#pragma lib "libxmlpull.a" +#endif + +#ifndef XMLPULL_H +#define XMLPULL_H + +#ifndef nil +#define nil NULL +#define print printf +#define snprint snprintf +#define exits return +#endif + +enum { + START_DOCUMENT = 0x0, + START_TAG, + START_END_TAG, + TEXT, + TEXT_C, + ATTR, + END_TAG, + END_TAG_S, + END_TAG_N, + END_DOCUMENT, +}; + +typedef struct xmlpull xmlpull; +struct xmlpull { + int fd; + char ev; + char nev; + char *lm; + char *na; + char *va; + int la; + int lv; + int ln; +}; + +void freexmlpull(xmlpull *x); +xmlpull *openxmlpull(int fd); +xmlpull *nextxmlpull(xmlpull *x); +xmlpull *writexmlpull(xmlpull *x); + +#endif diff --git a/jacs/dat.c b/jacs/dat.c new file mode 100644 index 0000000..094f27f --- /dev/null +++ b/jacs/dat.c @@ -0,0 +1,89 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "dat.h" + +void * +reallocj(void *p, int s, short d) +{ + p = realloc(p, s); + if(p == nil) + sysfatal("realloc: %r"); + + if(d != 0) + memset(p, 0, s); + + return (void *)p; +} + +char * +setwindowlbl(char *w) +{ + int s; + + s = open("/dev/label", OWRITE); + if(s < 0) + return nil; + + write(s, w, strlen(w)); + + close(s); + return w; +} + +char * +getwindowlbl(void) +{ + int s; + char *ret; + short i; + + s = open("/dev/label", OREAD); + if(s < 0) + return nil; + + i = 0; + ret = malloc(0); + while(realloc(ret, ++i) != nil && read(s, &ret[i - 1], 1) > 0 && + i < 513); + + ret[i - 1] = '\0'; + + close(s); + return ret; +} + +char * +mktmstmp(char bord, char bord_e) +{ + Tm *tim; + char *ret; + + ret = reallocj(nil, 32, 2); + tim = localtime(time(0)); + snprint(ret, 31, "%c%.2d:%.2d%c ", bord, tim->hour, tim->min, bord_e); + + return ret; +} + +char * +printjid(char *user, char *serv, char *reso) +{ + char *ret; + int i; + + if(user == nil || serv == nil) + return nil; + + i = strlen(user) + strlen(serv) + 3 + ((reso != nil) ? strlen(reso) : 0); + + ret = reallocj(nil, i, 2); + snprint(ret, i, "%s@%s%s%s", user, serv, (reso != nil) ? "/" : "\0", + ((reso != nil) ? reso : "")); + + return ret; +} diff --git a/jacs/dat.h b/jacs/dat.h new file mode 100644 index 0000000..fca069f --- /dev/null +++ b/jacs/dat.h @@ -0,0 +1,10 @@ +#ifndef JDAT_H +#define JDAT_H + +void *reallocj(void *p, int s, short d); +char *setwindowlbl(char *w); +char *getwindowlbl(void); +char *mktmstmp(char bord, char bord_e); +char *printjid(char *user, char *serv, char *reso); + +#endif diff --git a/jacs/jacs.c b/jacs/jacs.c new file mode 100644 index 0000000..21f3139 --- /dev/null +++ b/jacs/jacs.c @@ -0,0 +1,231 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include <auth.h> +#include <mp.h> +#include <libsec.h> +#include "xmlpull.h" +#include "jacs.h" +#include "dat.h" +#include "roster.h" +#include "recv.h" + +#define NAME "jacs - Jabber Service Registry for Plan9" +#define VERSION "2nd ed" +#define OS "Plan9 4th ed" + +int +xmljacc(int sock) +{ + return fprint(sock, "<?xml version=\"1.0\"?>\n"); +} + +int +loginjacc(int sock, char *serv) +{ + return fprint(sock, "<stream:stream xmlns:stream=\"http://etherx.jabber.org/streams\"" + " xmlns=\"jabber:client\" to=\"%s\">\n", serv); +} + +int +userjacc(int sock, char *user, char *pass, char *res) +{ + return fprint(sock, "<iq type=\"set\" id=\"auth_1\">\n" + "<query xmlns=\"jabber:iq:auth\">\n" + "<username>%s</username>\n" + "<password>%s</password>\n" + "<resource>%s</resource>\n" + "</query>\n" + "</iq>\n", user, pass, res); +} + +int +presencejacc(int sock, char *stat, char *show, char *from, char *to) +{ + return fprint(sock, "<presence%s%s%s%s%s%s>\n" + "<show>%s</show>\n" + "<status>%s</status>\n" + "<priority>1</priority>\n" + "</presence>\n", (from != nil) ? " from=\"" : "", + (from != nil) ? from : "", + (from != nil) ? "\"" : "", + (to != nil) ? " to=\"" : "", + (to != nil) ? to : "", + (to != nil) ? "\"" : "", + (show != nil) ? show : "", + (stat != nil) ? stat : ""); +} + +int +versionjacc(int sock, char *from, char *to, char *id) +{ + return fprint(sock, "<iq from=\"%s\" type=\"result\" id=\"%s\" to=\"%s\">\n" + "<query xmlns=\"jabber:iq:version\">\n" + "<name>" NAME "</name>\n" + "<version>" VERSION "</version>\n" + "<os>" OS "</os>\n" + "</query>\n" + "</iq>\n", from, id, to); +} + +int +featuresjacc(int sock, char *from, char *to, char *id) +{ + return fprint(sock, "<iq from=\"%s\" type=\"result\" to=\"%s\" id=\"%s\">\n" + "<query xmlns=\"http://jabber.org/protocol/disco#info\">\n" + "</query>\n" + "</iq>\n", from, to, id); +} + +int +answersjacc(int sock, char *who, char *t, char *id, ilist *l) +{ + fprint(sock, "<iq type=\"set\" to=\"%s\" id=\"%s\">\n" + "<query xmlns=\"%s\">\n", who, id, t); + for(; l; l = l->n) + fprint(sock, "<%s>%s</%s>\n", l->name, l->val, l->name); + + return fprint(sock, "</query>\n" + "</iq>\n"); +} + +int +xmlnsjacc(int sock, char *who, char *t, char *id) +{ + return fprint(sock, "<iq type=\"get\" to=\"%s\" id=\"%s\">\n" + "<query xmlns=\"%s\"/>\n" + "</iq>\n", who, id, t); +} + +int +xmlnsnegjacc(int sock, char *who, char *t, char* id) +{ + return fprint(sock, "<iq type=\"set\" to=\"%s\" id=\"%s\">\n" + "<query xmlns=\"%s\">\n" + "<remove/>\n" + "</query>\n" + "</iq>\n", who, id, t); +} + +void +usage(void) +{ + print("usage: jacs [-dtu] [-e dest] [-s tosrv] [-r res] net!server!port\n"); + exits(0); +} + +int +main(int argc, char *argv[]) +{ + char *server, *user, *lbl, *b, *dest, *buf, *toserver; + int sock, ts, tls, debug, unreg; + UserPasswd *i; + TLSconn conn; + jabberc *me; + + tls = 0; + b = nil; + dest = nil; + unreg = 0; + debug = 0; + toserver = nil; + + ARGBEGIN { + case 't': + tls = 1; + break; + case 'r': + b = EARGF(usage()); + break; + case 'e': + dest = EARGF(usage()); + break; + case 'u': + unreg = 1; + break; + case 'd': + debug = 1; + break; + case 's': + toserver = EARGF(usage()); + break; + default: + usage(); + } ARGEND; + + if(argc < 1 || dest == nil) + usage(); + server = strdup(argv[0]); + + lbl = getwindowlbl(); + user = reallocj(nil, strlen(server) + 9, 2); + snprint(user, strlen(server) + 8, "jacs - %s", server); + setwindowlbl(user); + free(user); + + i = auth_getuserpasswd(auth_getkey, "proto=pass server=%s service=jabber", server); + if(i == nil) + sysfatal("auth_getuserpasswd: %r"); + + sock = dial(netmkaddr(server, "tcp", tls ? "5223" : "5222"), 0, 0, 0); + if(sock < 0) + sysfatal("dial: &r"); + + if(tls){ + ts = tlsClient(sock, &conn); + if(ts < 0) + sysfatal("tlsClient: %r"); + sock = ts; + + if(conn.cert != nil) + free(conn.cert); + } + + buf = strchr(server, '!'); + if(buf != nil) { + *buf++ = '\0'; + user = strchr(buf, '!'); + if(user != nil) + *user = '\0'; + user = strdup(buf); + free(server); + server = user; + } + + if(toserver == nil) + toserver = server; + + me = mkjabberc(); + me->dest = strdup(dest); + me->show = strdup("Online"); + me->stat = strdup("Online"); + me->name = strdup(i->user); + me->serv = strdup(toserver); + + if(b != nil) + me->reso = strdup(b); + else + me->reso = strdup("Plan9-Service"); + me->jid = printjid(me->name, me->serv, me->reso); + me->debug = debug; + me->unreg = unreg; + + free(buf); + + if(recvjacc(sock, me, i->passwd) < 0) + perror("recv_jacc"); + + if(lbl != nil){ + setwindowlbl(lbl); + lbl = nil; + free(lbl); + } + + freejabberc(me); + exits(0); + return 0; +} diff --git a/jacs/jacs.h b/jacs/jacs.h new file mode 100644 index 0000000..2475a23 --- /dev/null +++ b/jacs/jacs.h @@ -0,0 +1,33 @@ +#ifndef JACS_H +#define JACS_H + +#include "roster.h" + +enum { + NONE = 0x00, + STREAM, + AUTH, + ERROR, + MESSAGE, + MESSAGE_INNER, + IQ, + IQ_INNER, + IQ_ERROR, + IQ_REGISTER, + IQ_REGISTER_INST, + IQ_REGISTER_INNE, + END +}; + +int xmljacc(int sock); +int loginjacc(int sock, char *serv); +int userjacc(int sock, char *user, char *pass, char *res); +int versionjacc(int sock, char *from, char *to, char *id); +int presencejacc(int sock, char *stat, char *show, char *from, char *to); +int featuresjacc(int sock, char *from, char *to, char *id); +int answersjacc(int sock, char *who, char *t, char *id, ilist *l); +int xmlnsjacc(int sock, char *who, char *t, char *id); +int xmlnsnegjacc(int sock, char *who, char *t, char *id); + +#endif + diff --git a/jacs/mkfile b/jacs/mkfile new file mode 100644 index 0000000..eeebb9a --- /dev/null +++ b/jacs/mkfile @@ -0,0 +1,24 @@ +</$objtype/mkfile +BIN=/$objtype/bin + +TARG=jacs +OFILES=\ + dat.$O\ + roster.$O\ + recv.$O\ + jacs.$O\ + +HFILES=\ + roster.h\ + dat.h\ + recv.h\ + jacs.h\ + +UPDATE=\ + mkfile\ + $HFILES\ + ${OFILES:%.$O=%.c}\ + ${TARG:%=/386/bin/%}\ + +</sys/src/cmd/mkone + diff --git a/jacs/mkfile.plan9port b/jacs/mkfile.plan9port new file mode 100644 index 0000000..0003be3 --- /dev/null +++ b/jacs/mkfile.plan9port @@ -0,0 +1,25 @@ +</$PLAN9/src/mkhdr +BIN=$PLAN9/bin + +LDFLAGS=-lxmlpull +CFLAGS=-DPLAN9PORT +TARG=jacc +OFILES=\ + dat.$O\ + roster.$O\ + recv.$O\ + jacs.$O\ + +HFILES=\ + roster.h\ + dat.h\ + recv.h\ + jacs.h\ + +UPDATE=\ + mkfile\ + $HFILES\ + ${OFILES:%.$O=%.c}\ + ${TARG:%=/386/bin/%}\ + +<$PLAN9/src/mkone diff --git a/jacs/recv.c b/jacs/recv.c new file mode 100644 index 0000000..63b1b91 --- /dev/null +++ b/jacs/recv.c @@ -0,0 +1,292 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "xmlpull.h" +#include "jacs.h" +#include "dat.h" +#include "roster.h" + +char * +getline(void) +{ + char *ret; + int l; + + l = -1; + ret = reallocj(nil, 1025, 2); + + while(read(0, &ret[++l], 1) && l < 1024) + if(ret[l] == '\n') + break; + ret[l] = '\0'; + + return ret; +} + +void +askanswers(ilist *i, char *tmstmp) +{ + ilist *ac; + char *val; + + ac = i; + while(ac != nil){ + print("%s%s[%s] = ", tmstmp, ac->name, (ac->val != nil) ? ac->val : ""); + val = getline(); + if(ac->val == nil) + ac->val = val; + else { + if(*val != '\0'){ + free(ac->val); + ac->val = val; + } else + free(val); + } + ac = ac->n; + } + + return; +} + +int +recvjacc(int sock, jabberc *me, char *pass) +{ + xmlpull *x, *b; + char *id, *to, *from, *tmstmp, st, *type; + ilist *ac; + + type = nil; + id = nil; + from = nil; + to = nil; + st = NONE; + ac = nil; + + if(xmljacc(sock) < 0) + return -1; + if(loginjacc(sock, me->serv) < 0) + return -1; + + x = openxmlpull(sock); + while((b = nextxmlpull(x)) != nil && st != END){ + tmstmp = mktmstmp('(', ')'); + switch(b->ev){ + case START_DOCUMENT: + if(me->debug) + print("Start.\n"); + st = NONE; + break; + case START_TAG: + if(me->debug) + print("Tag: %s\n", x->na); + if(!strcmp(x->na, "stream:stream")){ + st = STREAM; + break; + } + if(!strcmp(x->na, "stream:error")){ + st = ERROR; + break; + } + if(st == ERROR){ + if(strcmp(x->na, "text")) + fprint(2, "%serror: %s\n", tmstmp, x->na); + break; + } + if(!strcmp(x->na, "iq")){ + st = IQ; + break; + } + if(!strcmp(x->na, "error") && st == IQ){ + st = IQ_ERROR; + break; + } + if(st == IQ_ERROR){ + print("IQ-Error: %s\n", x->na); + break; + } + if(!strcmp(x->na, "query") && st == IQ){ + st = IQ_INNER; + break; + } + if(!strcmp(x->na, "instructions") && st == IQ_REGISTER){ + st = IQ_REGISTER_INST; + break; + } + if(!strcmp(x->na, "query") && st == IQ_REGISTER) + break; + if(st == IQ_REGISTER){ + st = IQ_REGISTER_INNE; + me->list = addilist(me->list, x->na, nil); + ac = lastilist(me->list); + break; + } + break; + case START_END_TAG: + if(me->debug) + print("Startend: %s\n", x->na); + if(st == IQ_REGISTER){ + if(!strcmp(x->na, "registered")){ + print("%sAlready registerd.\n", tmstmp); + break; + } + if(strcmp(x->na, "remove")) + me->list = addilist(me->list, x->na, nil); + break; + } + if(st == ERROR){ + fprint(2, "%serror: %s\n", tmstmp, x->na); + break; + } + break; + case TEXT: + if(me->debug) + print("Text: %s\n", x->na); + switch(st){ + case IQ_REGISTER_INST: + print("%s %s\n", tmstmp, x->na); + break; + case IQ_REGISTER_INNE: + ac->val = strdup(x->na); + break; + default: + break; + } + break; + case ATTR: + if(me->debug) + print("Attr: %s = %s\n", x->na, x->va); + switch(st){ + case STREAM: + if(!strcmp(x->na, "id")){ + st = NONE; + if(userjacc(sock, me->name, pass, me->reso) < 0) { + memset(pass, 0, strlen(pass)); + st = AUTH; + break; + } + } + break; + case IQ: + if(!strcmp(x->na, "id")){ + if(!strcmp(x->va, "auth_1")) { + presencejacc(sock, me->stat, me->show, me->jid, nil); + if(me->unreg) + xmlnsnegjacc(sock, me->dest, "jabber:iq:register", "service_1"); + else + xmlnsjacc(sock, me->dest, "jabber:iq:register", "service_0"); + } + if(!strcmp(x->va, "service_0")) + st = IQ_REGISTER; + id = strdup(x->va); + } + if(!strcmp(x->na, "from")) + from = strdup(x->va); + if(!strcmp(x->na, "to")) + to = strdup(x->va); + if(!strcmp(x->na, "type")) + type = strdup(x->va); + break; + case IQ_INNER: + if(!strcmp(x->na, "xmlns")){ + if(!strcmp(x->va, "jabber:iq:version")) { + if(!strcmp(to, me->jid)){ + print("%s%s:\n", tmstmp, from); + break; + } else + versionjacc(sock, me->jid, from, id); + break; + } + if(!strcmp(x->va, "http://jabber.org/protocol/disco#info")) + if(!strcmp(me->jid, to)) + featuresjacc(sock, to, from, id); + + } + break; + default: + break; + } + break; + case END_TAG: + if(me->debug) + print("Endtag: %s\n", x->na); + if(!strcmp(x->na, "stream:stream")){ + st = END; + break; + } + if(!strcmp(x->na, "stream:error") && st == ERROR){ + st = NONE; + break; + } + if(st == ERROR) + break; + if(!strcmp(x->na, "iq") && (st == IQ || st == IQ_REGISTER)){ + st = NONE; + if(type != nil){ + if(!strcmp(type, "result") && !strcmp(id, "service_1")){ + print("%sSuccess.\n", tmstmp); + st = END; + } + free(type); + } + if(from != nil) + free(from); + if(to != nil) + free(to); + if(id != nil) + free(id); + from = nil; + to = nil; + id = nil; + type = nil; + break; + } + if(!strcmp(x->na, "error") && st == IQ_ERROR){ + st = IQ; + break; + } + if(!strcmp(x->na, "query") && st == IQ_INNER){ + st = IQ; + break; + } + if(!strcmp(x->na, "query") && st == IQ_REGISTER){ + st = IQ; + if(me->list != nil){ + askanswers(me->list, tmstmp); + answersjacc(sock, me->dest, "jabber:iq:register", "service_1", me->list); + freeilist(me->list); + me->list = nil; + } + break; + } + if(!strcmp(x->na, "instructions") && st == IQ_REGISTER_INST){ + st = IQ_REGISTER; + break; + } + if(st == IQ_REGISTER_INNE){ + st = IQ_REGISTER; + break; + } + break; + case END_DOCUMENT: + if(me->debug) + print("Documentend.\n"); + st = END; + break; + default: + print("Please contact the xmlpull author about this. %x\n", b->ev); + st = END; + break; + } + free(tmstmp); + } + + if(id != nil) + free(id); + freexmlpull(x); + + return 0; +} diff --git a/jacs/recv.h b/jacs/recv.h new file mode 100644 index 0000000..94f09ff --- /dev/null +++ b/jacs/recv.h @@ -0,0 +1,8 @@ +#ifndef RECV_H +#define RECV_H + +char *getline(void); +void askanswer(ilist *i, char *tmstmp); +int recvjacc(int sock, jabberc *me, char *pass); + +#endif diff --git a/jacs/roster.c b/jacs/roster.c new file mode 100644 index 0000000..d4cc372 --- /dev/null +++ b/jacs/roster.c @@ -0,0 +1,102 @@ +/* + * Copy me if you can. + * by 20h + */ + +#include <u.h> +#include <libc.h> +#include "dat.h" +#include "roster.h" + +void +freeilist(ilist *i) +{ + while(i != nil){ + if(i->name != nil) + free(i->name); + if(i->val != nil) + free(i->val); + if(i->n != nil){ + i = i->n; + free(i->p); + } else { + free(i); + i = nil; + } + } +} + + +void +freejabberc(jabberc *j) +{ + if(j != nil){ + if(j->stat != nil) + free(j->stat); + if(j->name != nil) + free(j->name); + if(j->reso != nil) + free(j->reso); + if(j->serv != nil) + free(j->serv); + if(j->jid != nil) + free(j->jid); + if(j->show != nil) + free(j->show); + if(j->dest != nil) + free(j->dest); + if(j->list != nil) + freeilist(j->list); + free(j); + } + return; +} + +jabberc * +mkjabberc(void) +{ + return reallocj(nil, sizeof(jabberc), 2); +} + +ilist * +lastilist(ilist *i) +{ + if(i != nil) + while(i->n != nil) + i = i->n; + + return i; +} + +ilist * +mkilist(char *name, char *val) +{ + ilist *ret; + + ret = reallocj(nil, sizeof(ilist), 2); + if(name != nil) + ret->name = strdup(name); + if(val != nil) + ret->val = strdup(val); + + return ret; +} + +ilist * +addilist(ilist *i, char *name, char *val) +{ + ilist *ret; + + ret = lastilist(i); + if(ret == nil) + return mkilist(name, val); + else { + ret->n = mkilist(name, val); + ret->n->p = ret; + } + ret->n->n = nil; + + return i; +} + +
\ No newline at end of file diff --git a/jacs/roster.h b/jacs/roster.h new file mode 100644 index 0000000..75d49b5 --- /dev/null +++ b/jacs/roster.h @@ -0,0 +1,33 @@ +#ifndef ROSTER_H +#define ROSTER_H + +typedef struct ilist ilist; +struct ilist { + char *name; + char *val; + ilist *p; + ilist *n; +}; + +typedef struct jabberc jabberc; +struct jabberc { + char *stat; + char *show; + char *name; + char *reso; + char *serv; + char *jid; + char *dest; + ilist *list; + int debug; + int unreg; +}; + +void freeilist(ilist *i); +void freejabberc(jabberc *j); +jabberc *mkjabberc(void); +ilist *lastilist(ilist *i); +ilist *mkilist(char *name, char *val); +ilist *addilist(ilist *i, char *name, char *val); + +#endif diff --git a/jacs/xmlpull.h b/jacs/xmlpull.h new file mode 100644 index 0000000..5a008f4 --- /dev/null +++ b/jacs/xmlpull.h @@ -0,0 +1,51 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifdef nil +#pragma lib "libxmlpull.a" +#endif + +#ifndef XMLPULL_H +#define XMLPULL_H + +#ifndef nil +#define nil NULL +#define print printf +#define snprint snprintf +#define exits return +#endif + +enum { + START_DOCUMENT = 0x0, + START_TAG, + START_END_TAG, + TEXT, + TEXT_C, + ATTR, + END_TAG, + END_TAG_S, + END_TAG_N, + END_DOCUMENT, +}; + +typedef struct xmlpull xmlpull; +struct xmlpull { + int fd; + char ev; + char nev; + char *lm; + char *na; + char *va; + int la; + int lv; + int ln; +}; + +void freexmlpull(xmlpull *x); +xmlpull *openxmlpull(int fd); +xmlpull *nextxmlpull(xmlpull *x); +xmlpull *writexmlpull(xmlpull *x); + +#endif @@ -0,0 +1,53 @@ +</$objtype/mkfile + +DIRS=\ + jacc\ + jacs\ + +all:V: $DIRS + +$DIRS:V: + for(i in $DIRS) + @{ + echo mk $i; + cd $i; + mk; + } + +install:V: installdirs + +installdirs:V: + for(i in $DIRS) + @{ + echo mk $i; + cd $i; + mk install; + } + +nuke:V: nukedirs + +clean:V: + for (i in $DIRS) + @{ + echo clean $i; + cd $i; + mk clean; + } + rm -f [$OS].* *.[$OS]; + +nukedirs:V: + for (i in $DIRS) + @{ + echo nuke $i; + cd $i; + mk nuke; + } + +update:V: + update $UPDATEFLAGS $UPDATE + for(i in $DIRS) + @{ + echo update $i; + cd $i; + mk 'UPDATEFLAGS='$"UPDATEFLAGS update; + } diff --git a/mkfile.plan9port b/mkfile.plan9port new file mode 100644 index 0000000..10dfae9 --- /dev/null +++ b/mkfile.plan9port @@ -0,0 +1,53 @@ +</$PLAN9/src/mkhdr + +DIRS=\ + jacc\ + jacs\ + +all:V: $DIRS + +$DIRS:V: + cd jacc; + mk -f mkfile.plan9port; + cd ..; + cd jacs; + mk -f mkfile.plan9port; + cd ..; + +install:V: installdirs + +installdirs:V: + cd jacc; + mk -f mkfile.plan9port install; + cd ..; + cd jacs; + mk -f mkfile.plan9port install; + cd ..; + +nuke:V: nukedirs + +clean:V: + cd jacc; + mk -f mkfile.plan9port clean; + cd ..; + cd jacs; + mk -f mkfile.plan9port clean; + cd ..; + rm -f [$OS].* *.[$OS]; + +nukedirs:V: + cd jacc; + mk -f mkfile.plan9port nuke; + cd ..; + cd jacs; + mk -f mkfile.plan9port nuke; + cd ..; + +update:V: + update $UPDATEFLAGS $UPDATE + cd jacc; + mk -f mkfile.plan9port 'UPDATEFLAGS='$"UPDATEFLAGS update; + cd ..; + cd jacs; + mk -f mkfile.plan9port 'UPDATEFLAGS='$"UPDATEFLAGS update; + cd ..; diff --git a/vcard.example b/vcard.example new file mode 100644 index 0000000..4e98499 --- /dev/null +++ b/vcard.example @@ -0,0 +1,143 @@ +<!-- <vCard> - done by jacc --> + <FN></FN> + <N> + <FAMILY></FAMILY> + <GIVEN></GIVEN> + <MIDDLE></MIDDLE> + <PREFIX></PREFIX> + <SUFFIX></SUFFIX> + </N> + <NICKNAME></NICKNAME> + <PHOTO> + <!-- BINVAL or EXTVAL --> + <TYPE>BEXTVAL</TYPE> + <!-- Base64 data of the photo --> + <!-- <BINVAL></BINVAL> --> + <!-- URI of the photo --> + <BEXTVAL>http://www.somewhere.com/photo.png</BEXTVAL> + </PHOTO> + <BDAY></BDAY> +<!-- One or more of these complexes are allowed. --> + <ADR> + <!-- one of these elements for which address you mean + <HOME/> + <WORK/> + <POSTAL/> --> + <PARCEL/> + <!-- int'l or domestic + <DOM/> --> + <INTL/> + <!-- preferred address? --> + <PREF/> + <POBOX></POBOX> + <EXTADR></EXTADR> + <STREET></STREET> + <LOCALITY></LOCALITY> + <REGION></REGION> + <PCODE></PCODE> + <CTRY></CTRY> + </ADR> +<!-- One or more of these complexes are allowed. --> + <LABEL> + <!-- one of these elements for which address you mean + <HOME/> + <WORK/> + <POSTAL/> --> + <PARCEL/> + <!-- int'l or domestic + <DOM/> --> + <INTL/> + <!-- preferred address? --> + <PREF/> + <LINE></LINE> + </LABEL> +<!-- One or more of these complexes are allowed. --> + <TEL> + <!-- one of these elements for which telephone number you mean + <HOME/> + <WORK/> + <VOICE/> + <FAX/> + <PAGER/> + <MSG/> + <CELL/> + <VIDEO/> + <BBS/> + <MODEM/> + <ISDN/> --> + <PCS/> + <!-- preferred number? --> + <PREF/> + <NUMBER></NUMBER> + </TEL> +<!-- One or more of these complexes are allowed. --> + <EMAIL> + <!-- one of these elements for which telephone number you mean + <HOME/> + <WORK/> + <INTERNET/> --> + <X400/> + <!-- preferred E-Mail? --> + <PREF/> + <USERID></USERID> + </EMAIL> + <JABBERID></JABBERID> + <MAILER></MAILER> +<!-- Value must be an ISO 8601 formatted UTC offset. --> + <TZ></TZ> +<!-- Values are the decimal degrees and should havce six decimal + places --> + <GEO> + <LAT></LAT> + <LON></LON> + </GEO> + <TITLE></TITLE> + <ROLE></ROLE> + <LOGO> + <!-- BINVAL or EXTVAL --> + <TYPE>BEXTVAL</TYPE> + <!-- Base64 data of the logo --> + <!-- <BINVAL></BINVAL> --> + <!-- URI of the photo --> + <BEXTVAL>http://www.somewhere.com/logo.png</BEXTVAL> + </LOGO> + <AGENT> + <!-- Either a whole vCard or an external value + <vCard></vCard> --> + <EXTVAL>http://microsoft.com/bil.gates.vcard</EXTVAL> + </AGENT> + <ORG> + <ORGNAME></ORGNAME> + <ORGUNIT></ORGUNIT> + </ORG> + <CATEGORIES> + <KEYWORD></KEYWORD> + <KEYWORD></KEYWORD> + <!-- ... --> + </CATEGORIES> + <NOTE></NOTE> + <PRODID>acme</PRODID> +<!-- ISO 8601 formatted UTC date/time - fill something inside --> + <REV></REV> + <SORT-STRING></SORT-STRING> + <SOUND> + <!-- again many options noone needs. + <PHONETIC></PHOENTIC> + <BINVAL></BINVAL> --> + <EXTVAL>http://www.sun.com/fresh_coffee.fl</EXTVAL> + </SOUND> + <UID></UID> + <URL></URL> + <DESC></DESC> + <CLASS> + <!-- No, not school. + <PUBLIC/> + <PRIVATE/> --> + <CONFIDENTIAL/> + </CLASS> + <KEY> + <TYPE>CRED</TYPE> + <!-- Either envryption or credential. --> + <CRED></CRED> + </KEY> +<!-- </vCard> --> |