diff --git a/README.md b/README.md index 547b751..31c17c8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Main menu - Message areas, private mail, chat, paging and doors (DOS doors in dosemu2, or Linux programs) - File areas with X/Y/ZMODEM, Kermit, IND$FILE and FTP -- Networks: FidoNet and other FTNs, QWK, NNTP newsgroups, IRC, AIM and ICQ, and MRC +- Networks: FidoNet and other FTNs, QWK, NNTP newsgroups, IRC, AIM and ICQ, MSN Messenger, and MRC - Terminals: ANSI, VT, PETSCII, RIPscrip, sixel and 3270 graphics - On the web: a forum, image boards, a web terminal and an HTTP API - Time: follows NTP, NTS and PTP servers, and serves all three diff --git a/TODO.md b/TODO.md index 5d5f7b3..50ba3e3 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,36 @@ Ideas not yet started, with what is known of them. +## An AOL front end + +*Status: started; the FDO91 layer (`internal/aol/fdo`) and P3 +(`internal/aol/p3`) are done.* + +For AOL 3.0 and 4.0 for Windows, the real clients, over TCP (port 5190, the +client's `AmericaOnline.aol.com`) and by modem. + +- **FDO91** (done): atom streams read and written, all eight encoding + styles and large atoms; a compiler from FDO91 source that matches + Ada32.dll byte for byte on AtomForge's corpus (1,889 forms, 74,369 + single atoms, 44 live captures); a decompiler whose text compiles back + to the same bytes. +- **P3** (done): packets (CRC-16/ARC, AOL 4.0's `**`), and the host's + end of a link: INIT acknowledged, DATA in order in and within a window + of 16 out, ACKs every 8 or soon after, NAKs and go-back-N resends, + heartbeats after 12 seconds, 10 of them and the link is down. +- **Listener**, next: OSCAR's port 5190 already hands a connection that + starts with P3's sync byte to `oscar.Server.P3`; serve it there with + `p3.Serve`, and sniff a P3 INIT (`p3.Sniff`) on the telnet port too. +- **Tokens**: `Dd` sign-on (the form's two `de_data`) to the BBS's login, + then chat (`Aa`), IMs (`iS`), mail (`m4`, MIP), keywords (`k1`/`f1`) to + areas, `pE` sign-off; each answered with forms compiled from source. +- **Modem callers**: the client's CCL script expects a network's prompts + (SprintNet, Tymnet) before P3; emulate one, or ship a CCL that dials + straight in. +- **To decide**: AOL 4.0's RSA handshake (revival servers turn it off in + the client); which client forms (32-xxxx) are in its own database and + which the host must send. + ## Doors for 3270 callers: an ANSI to 3270 layer *Status: being thought about; other ways to solve it may win.* diff --git a/bbs.conf.sample b/bbs.conf.sample index 5ad4e9c..df950a3 100644 --- a/bbs.conf.sample +++ b/bbs.conf.sample @@ -146,6 +146,11 @@ throttle_time = 600 ; and an empty line: app_dmodem's DMODEM_* or a ; modemmenu item's MODEM_* (rate, caller ID, number) ; header_timeout = 10 seconds for the header +; handoff = no type = raw on a unix socket, with header = yes: +; the caller's line itself may come with the header +; (SCM_RIGHTS, modemmenu's item with handoff = yes), +; the session then on that terminal, nothing copied; +; closing the connection gives the line back ; trust_user = no yes: the header's MODEM_USER (an rlogin's server ; user) is logged in without a password. Only where ; nothing but trusted menus can connect @@ -249,6 +254,18 @@ address = 127.0.0.1:2513 ;socket_mode = 0660 ;socket_group = asterisk +; the same with the caller's line itself (modemmenu's item with +; handoff = yes): the BBS on the modem's terminal, nothing copied between +;[listen handoff] +;type = raw +;address = /run/bbs/handoff.sock +;header = yes +;handoff = yes +;trust_user = yes +;create_users = yes +;socket_mode = 0660 +;socket_group = asterisk + ; modemmenu's auth socket ([authd] there): the accounts modemmenu logs in ; (no password here) log in by telnet, SSH, the web ... with their ; modemmenu password, asked of modemmenu's backends. See @@ -653,6 +670,28 @@ address = 127.0.0.1:2513 ; the screen name the BBS's notices come from ;system = OnlineHost +; MSN Messenger: the chat for MSN Messenger 1.0 to 4.7 and Windows +; Messenger 4.x (MSNP2 to 7), beside IRC and AIM. Users sign in as +; name@domain with their BBS passwords; contacts are their friends list; +; an IM is a private message (a PRIVMSG on IRC), kept for one away. The +; clients must be pointed at this host (see the wiki page). +; See docs/wiki/MSN-Messenger.md +;[msn] +;address = :1863 +; where clients are sent for conversations, host:port (default: the +; address each one came to; set it behind NAT) +;host = msn.example.org:1863 +; handles are name@domain (default bbs.invalid); clients may sign in with +; any domain, as MSN 1.0's @hotmail.com +;domain = msn.example.org +;max_clients = 256 +; each conversation is a connection of its own +;max_per_ip = 16 +; the name the BBS's notices come from +;system = BBS +; a web address the clients' links (inbox, profiles) open +;site = https://bbs.example.org/ + ; Multi Relay Chat: the BBSes' chat network. Its rooms are the chat rooms ; beginning mrc- here (mrc-lobby is its lobby), on terminals and IRC alike. ; See docs/wiki/MRC.md diff --git a/cmd/bbs/main.go b/cmd/bbs/main.go index 8111715..cdaaa74 100644 --- a/cmd/bbs/main.go +++ b/cmd/bbs/main.go @@ -70,6 +70,7 @@ import ( "github.com/D-Modem/bbs/internal/imageboard" "github.com/D-Modem/bbs/internal/ircd" "github.com/D-Modem/bbs/internal/mrc" + "github.com/D-Modem/bbs/internal/msn" "github.com/D-Modem/bbs/internal/news" "github.com/D-Modem/bbs/internal/nntp" "github.com/D-Modem/bbs/internal/oscar" @@ -205,6 +206,9 @@ func main() { if l.Header { extra += ", header" } + if l.Handoff { + extra += ", handoff" + } if l.TrustUser { extra += ", trust_user" } @@ -268,6 +272,9 @@ func main() { if o := cfg.OSCAR; o != nil { fmt.Printf("oscar: %q, reconnect at %q, ICQ numbers from %d\n", o.Address, o.Host, o.UINBase) } + if m := cfg.MSN; m != nil { + fmt.Printf("msn: %q, conversations at %q, handles @%s\n", m.Address, m.Host, m.Domain) + } if cfg.Finger != nil { fmt.Printf("finger: %s (online %v, users %v)\n", cfg.Finger.Address, cfg.Finger.Online, cfg.Finger.Users) } @@ -479,6 +486,19 @@ func serve(cfg *server.Config, path string) int { } }() } + if cfg.MSN != nil { + msrv, err := msn.New(b, *cfg.MSN) + if err != nil { + lg.Printf("%v", err) + return 1 + } + go func() { + if err := msrv.Run(ctx); err != nil { + lg.Printf("%v", err) + stop() + } + }() + } if cfg.Finger != nil { fs := &finger.Server{B: b, S: *cfg.Finger} go func() { diff --git a/docs/cis/04-cim-hmi.md b/docs/cis/04-cim-hmi.md index 3e11e60..66478de 100644 --- a/docs/cis/04-cim-hmi.md +++ b/docs/cis/04-cim-hmi.md @@ -205,7 +205,18 @@ Code: `internal/cis/slp.go`, `internal/cis/hmi.go`, `internal/xfer/cisbtl.go`. T - `0x07` hangs up. - Everything else gets an ack on stream 1. - The first message after the Transport Layer starts is sent twice, 300 ms apart. Every answer waits 120 ms first, as E's does. -- **Page names:** `CIS:` and `HOM:` both resolve through the ASCII service's page tree (`pages.txt`, IDs and GO words). Aliases: `NEWPAGE` → `NEW`, `CONTENTS` → `TOP`, `MAILHMI` → `MAIL`. Pages go out as `CIS:`, numbered with a 24-bit hash of the ID. `CIS:FORUMS` is the forum list. A forum, `MAIL` and `CB` are, for now, articles that say to use a terminal (milestone 8). An unknown name gets an article saying so, never nothing. +- **Page names:** `CIS:` and `HOM:` both resolve through the ASCII service's page tree (`pages.txt`, IDs and GO words). Aliases: `NEWPAGE` → `NEW`, `CONTENTS` → `TOP`, `MAILHMI` → `MAIL`. Pages go out as `CIS:`, numbered with a 24-bit hash of the ID. An unknown name gets an article saying so, never nothing. +- **Forums and Mail (milestone 8), as pages, the way E measured WinCIM asking for them** (`internal/cis/hmiforum.go`): + - `CIS:FORUMS` lists the forums. + - `CIS:` is one forum: its sections, then its libraries. + - `CIS:/S` lists a section's messages, newest first, up to 200. + - `CIS:/M` is one message as an article, in the forum software 4 header format. Reading it sets the last-read mark. + - `CIS:/L` is a library's file list, as an article. + - `CIS:MAIL` is the mailbox: `HOM:MAILHMI` from Get Mail, newest first, unread letters marked `*`. + - `CIS:MAIL/` is one letter. Reading it marks it read. + - Every item has kind 0. E found that kind 1 draws a label the client will not select. + - Pages are made afresh on each request. +- **Not yet:** sending mail. E found that it is the `IInMailSendTV` transaction, sent at Send/Retrieve All, and its bytes are not recovered. Forum posting (`IFoMsgSendTV`), library transfers (`IFoLibSendTV`, streams 2/3/6/8), the CB, and the forms layer (`FORMCB.DLL`) are not done either. ## 5. Reverse-engineering plan for the gaps diff --git a/docs/wiki/AIM-and-ICQ.md b/docs/wiki/AIM-and-ICQ.md index 9e2f6b4..64ff14c 100644 --- a/docs/wiki/AIM-and-ICQ.md +++ b/docs/wiki/AIM-and-ICQ.md @@ -49,14 +49,22 @@ could sign on by AIM as that user, as with any AIM server. ## Buddies -The buddy list holds BBS names (or ICQ numbers). A buddy is online while -they are on the BBS by any route, and shown away when they are away on -AIM or IRC. Their profile is the one their AIM client set, or for someone -not on AIM their line about themselves, their location and what they are -doing on which node. The list itself is kept on the server (AIM 5's and -ICQ 2001's "server-stored" list) or by the client (older ones); both work. -Permit and deny lists, "allow only buddies" and ICQ's invisible status -hide the user and refuse their IMs, from AIM users and others alike. +The buddy list is the user's [friends list](Chat-and-Paging#friends): +the same list the BBS's chat and IRC show, so a buddy is always a BBS +user (by name, or ICQ number). Adding anyone else is refused. A friend +added by IRC or the BBS comes to an AIM client that is on at once, in +their group (`Friends` if they have none); one added or removed on AIM +is on or off the list everywhere. Groups and aliases are kept with the +friends list; the list's other items (permit and deny entries, +preferences) as the client sent them. A client that keeps its own list +(AIM 3 and 4) has its buddies put on the friends list as it sends them. + +A buddy is online while they are on the BBS by any route, and shown away +when they are away on AIM or IRC. Their profile is the one their AIM +client set, or for someone not on AIM their line about themselves, their +location and what they are doing on which node. Permit and deny lists, +"allow only buddies" and ICQ's invisible status hide the user and refuse +their IMs, from AIM users and others alike. ## IMs @@ -64,9 +72,12 @@ An IM to a BBS user reaches every node they are on: an AIM or ICQ client gets it as an IM (from AIM to AIM with its fonts and colours), an IRC client as a `PRIVMSG`, a caller on a terminal as a message line. What they send back comes as an IM from them. Typing notices, file transfers and direct -connections pass between AIM clients. An IM to someone not online is -refused as AIM refused them ("not logged on"); there are no offline -messages. The BBS's notices (new mail, a page for the sysop) come as IMs +connections pass between AIM clients. IMs are [kept](Chat-and-Paging#private-messages). +An IM to a BBS user who isn't on is kept for them, and the sender told so +(once) by `OnlineHost`; they get it when they next sign on: on AIM as an +IM marked with when it was sent, on ICQ as an offline message, on IRC or +a terminal as a message line. An IM to a name that is no BBS user's is +refused ("not logged on"). The BBS's notices (new mail, a page for the sysop) come as IMs from `OnlineHost`. ## Chat rooms diff --git a/docs/wiki/Chat-and-Paging.md b/docs/wiki/Chat-and-Paging.md index 5574d72..456fc97 100644 --- a/docs/wiki/Chat-and-Paging.md +++ b/docs/wiki/Chat-and-Paging.md @@ -1,5 +1,6 @@ Callers on different nodes can talk to each other in three ways: in chat -rooms, by sending a message to one node, and by paging the sysop. +rooms, by private messages, and by paging the sysop. Each user also keeps +a [friends list](#friends). ## Chat rooms @@ -16,7 +17,11 @@ last caller leaves, unless the sysop has made it | `/who` | who is in this room | | `/rooms` | the rooms in use, and who is in them | | `/join ROOM` | go to another room (letters, digits and `-`, up to 20) | -| `/msg NODE TEXT` | a line to one node, wherever its caller is | +| `/msg WHO TEXT` | a private message to a user (or to a node, by its number), [kept](#private-messages) if they are away | +| `/history [WHO]` | those you have talked with, or your last lines with one | +| `/friends` | your [friends list](#friends), and who on it is on | +| `/friend WHO`, `/unfriend WHO` | put a user on your friends list, or take them off | +| `/block WHO`, `/unblock WHO` | refuse a user's private messages, or take them again ([blocking](#blocking)) | | `/topic [TEXT]` | the room's topic; the sysop sets a [permanent room](IRC#permanent-rooms)'s | | `/quit` | leave the chat | | `/help` | these | @@ -35,13 +40,39 @@ with other BBSes. The rooms are also channels on the BBS's [IRC](IRC) server (`#main` and the rest), with IRC clients in them alongside the callers. -## Messages to a node +## Private messages On the text BBS, *Who's online* ends by offering to send a line to a -node, and `/msg NODE TEXT` does the same from chat (on a 3270 too). The -line reaches the caller wherever they are: on the text BBS, at whatever -prompt they are at; on a 3270, on the message line of their next screen -(with `(+N)` when more are waiting). +node, and `/msg WHO TEXT` sends one from chat (on a 3270 too), to a user +by name or to a node by its number. The line reaches the caller +wherever they are: on the text BBS, at whatever prompt they are at; on a +3270, on the message line of their next screen (with `(+N)` when more +are waiting); on [IRC](IRC) as a `PRIVMSG`; on [AIM or ICQ](AIM-and-ICQ) +or [MSN](MSN-Messenger) as an IM. + +Private messages are kept, however they were sent: the BBS's chat, IRC, +AIM, ICQ or MSN. A message to a user who isn't on is kept for them, and they +get it when they next log in, with the time it was sent (an ICQ client +gets them as its offline messages). `/history WHO` (on IRC, `/msg +BBSServ HISTORY nick`) shows your last lines with someone. Only the two +users in a conversation can read it back. + +## Friends + +Every user has one friends list, of BBS users. It is the same list +everywhere: `/friends` in chat, `FRIENDS` to BBSServ on IRC, and the +buddy list on [AIM and ICQ](AIM-and-ICQ#buddies), the contact list on +[MSN](MSN-Messenger#contacts). A friend added on one shows on the others; +an AIM or MSN client that is on gets them at once, in their group +(`Friends` on AIM if they have none). + +## Blocking + +Every user also has one blocked list. `/block WHO` puts a user on it +(and `/unblock WHO` takes them off), as does MSN's "Block". A blocked +user's private messages are refused, however they send them (chat, IRC, +AIM, MSN) and whether or not you are on, and MSN shows you offline to +them. ## Paging the sysop diff --git a/docs/wiki/CompuServe.md b/docs/wiki/CompuServe.md index 8b858d4..5c16d6f 100644 --- a/docs/wiki/CompuServe.md +++ b/docs/wiki/CompuServe.md @@ -49,10 +49,20 @@ with their identification, which shows in who's online. A CIM client CIM clients speak HMI, a binary protocol inside B Plus packets. The service follows what 24high/CompuServe-Emulator recovered from WinCIM 3.0.2: the Secure Login, the terminal-mode trade after it, the B Plus -Transport Layer, and the HMI messages for pages. WinCIM can show the main -menu, the menus and articles of `pages.txt`, What's New and the Table of -Contents, and use Find. Forums, Mail and the CB are not in CIM yet; their -pages say to use a terminal program for now. +Transport Layer, and the HMI messages for pages. In WinCIM you can: + +- browse the main menu, the menus and articles of `pages.txt`, What's New + and the Table of Contents, and use Find; +- read the forums: the forum list, a forum's sections and libraries, a + section's messages (newest first) and each message, which then counts + as read; +- see a library's files (downloads still need a terminal program); +- read your mail with **Get Mail**: the mailbox, newest first, unread + letters marked `*`. A letter read is marked read. + +Sending mail, posting to forums, downloads and the CB are not in CIM yet. +WinCIM sends mail and forum messages through transactions of its own, +which nobody has recovered yet. Use a terminal program for those for now. Point WinCIM at the listener over TCP. In CIS.INI, the connector's `CommType=WINSOCK`, `WinsockCommType=Local` and `HostIPAddress` set @@ -250,7 +260,8 @@ so only callers using the same key read each other. | Libraries on the file areas, with B+ downloads and uploads | | | CompuServe Mail on the BBS's private mail | A kept address book, binary mail | | The CB Simulator on the chat rooms | Forum conferences (CO) | -| CIM: Secure Login, the B Plus Transport Layer, HMI pages, menus, articles and Find | Forums, Mail, libraries and CB in CIM | +| CIM: Secure Login, the B Plus Transport Layer, HMI pages, menus, articles and Find | | +| CIM: reading forums and Mail, library lists | CIM: sending mail, posting, downloads, CB | The research behind all this, with sources, is in [docs/cis](https://github.com/D-Modem/bbs/tree/main/docs/cis). diff --git a/docs/wiki/Configuration-Reference.md b/docs/wiki/Configuration-Reference.md index 542d7e6..cc3d046 100644 --- a/docs/wiki/Configuration-Reference.md +++ b/docs/wiki/Configuration-Reference.md @@ -32,6 +32,7 @@ the file is laid out. | [`[door NAME]`](#door-name) | A door: a program callers play, or another system's doors. | | [`[irc]`](#irc) | IRC: the chat rooms as channels (#main ...), for IRC clients. | | [`[oscar]`](#oscar) | AIM and ICQ: the chat for AIM and ICQ clients (OSCAR), beside IRC. | +| [`[msn]`](#msn) | MSN Messenger: the chat for MSN Messenger 1.0 to 4.7 and Windows Messenger 4.x (MSNP2 to 7), beside IRC and AIM. | | [`[mrc]`](#mrc) | Multi Relay Chat: the BBSes' chat network. | | [`[finger]`](#finger) | finger: who is on ("finger @host"), and who a user is ("finger name@host"). | | [`[gopher]`](#gopher) | gopher: about the system, who is on, and what areas the sysop opens: no login, so anyone sees them. | @@ -99,7 +100,7 @@ There may be any number of these, each with its own NAME. | key | default | live | what it does | |---|---|---|---| | `type` | `telnet` | | a telnet server; with tn3270 = yes (the default), a client that says it is a 3270 (IBM-3278-2-E, IBM-DYNAMIC) gets the 3270 screens raw the caller's bytes as they come, no protocol: app_dmodem's mode = tcp, modemmenu tcp/unix items rlogin RFC 1282, as modemmenu's rlogin items speak it ssh SSH: passwords or users' keys (host_keys, legacy) Examples: `telnet`, `raw`, `ssh`, `rlogin`. | -| `address` | `host:port` | | or a unix socket's path (/run/bbs/bbs.sock) Examples: `:2300`, `:992`, `127.0.0.1:2323`, `:2324`, `:2222`, `127.0.0.1:2513`, `/run/bbs/menu.sock`. | +| `address` | `host:port` | | or a unix socket's path (/run/bbs/bbs.sock) Examples: `:2300`, `:992`, `127.0.0.1:2323`, `:2324`, `:2222`, `127.0.0.1:2513`, `/run/bbs/menu.sock`, `/run/bbs/handoff.sock`. | | `via` | `...` | | how its callers came, in who's online (telnet, modem, rlogin by type) | | `ansi` | `auto` | | the terminal's ANSI color: auto asks the terminal (or believes its terminal type), yes, no. | | `utf8` | `auto` | | UTF-8 both ways: auto by the terminal type (xterm and friends yes; "ansi" BBS terminals no), yes, no. | @@ -110,6 +111,7 @@ There may be any number of these, each with its own NAME. | `max_per_ip` | `4` | | connections at once from one address (loopback and unix sockets: no limit, they are modem servers) | | `header` | `no` | | yes: a session header comes first, NAME=value lines and an empty line: app_dmodem's DMODEM_* or a modemmenu item's MODEM_* (rate, caller ID, number) Examples: `yes`. | | `header_timeout` | `10` | | seconds for the header. | +| `handoff` | `no` | | type = raw on a unix socket, with header = yes: the caller's line itself may come with the header (SCM_RIGHTS, modemmenu's item with handoff = yes), the session then on that terminal, nothing copied; closing the connection gives the line back. Examples: `yes`. | | `trust_user` | `no` | | yes: the header's MODEM_USER (an rlogin's server user) is logged in without a password. Only where nothing but trusted menus can connect. Examples: `yes`. | | `create_users` | `no` | | yes, with trust_user: a user unknown here gets an account (with no password of its own) Examples: `yes`. | | `socket_mode` | `0660` | | a unix socket's permissions. | @@ -452,6 +454,21 @@ AIM and ICQ: the chat for AIM and ICQ clients (OSCAR), beside IRC. Users sign o | `system` | | | the screen name the BBS's notices come from. Examples: `OnlineHost`. | +## `[msn]` + +MSN Messenger: the chat for MSN Messenger 1.0 to 4.7 and Windows Messenger 4.x (MSNP2 to 7), beside IRC and AIM. Users sign in as name@domain with their BBS passwords; contacts are their friends list; an IM is a private message (a PRIVMSG on IRC), kept for one away. The clients must be pointed at this host (see the wiki page). See docs/wiki/MSN-Messenger.md. + +| key | default | live | what it does | +|---|---|---|---| +| `address` | | | See the section above. Examples: `:1863`. | +| `host` | | | where clients are sent for conversations, host:port (default: the address each one came to; set it behind NAT) Examples: `msn.example.org:1863`. | +| `domain` | | | handles are name@domain (default bbs.invalid); clients may sign in with any domain, as MSN 1.0's @hotmail.com. Examples: `msn.example.org`. | +| `max_clients` | | | handles are name@domain (default bbs.invalid); clients may sign in with any domain, as MSN 1.0's @hotmail.com. Examples: `256`. | +| `max_per_ip` | | | each conversation is a connection of its own. Examples: `16`. | +| `system` | | | the name the BBS's notices come from. Examples: `BBS`. | +| `site` | | | a web address the clients' links (inbox, profiles) open. Examples: `https://bbs.example.org/`. | + + ## `[mrc]` Multi Relay Chat: the BBSes' chat network. Its rooms are the chat rooms beginning mrc- here (mrc-lobby is its lobby), on terminals and IRC alike. See docs/wiki/MRC.md. diff --git a/docs/wiki/Home.md b/docs/wiki/Home.md index b34dc79..3379ffe 100644 --- a/docs/wiki/Home.md +++ b/docs/wiki/Home.md @@ -79,7 +79,8 @@ which is generated from `bbs.conf.sample`. - [Newsgroups](Newsgroups-and-NNTP) served by NNTP and exchanged with other news servers - [IRC](IRC), where the chat rooms are channels, [AIM and ICQ](AIM-and-ICQ) - for AIM and ICQ clients on the same chat, and [MRC](MRC), the chat + for AIM and ICQ clients on the same chat, [MSN Messenger](MSN-Messenger) + for MSN clients, and [MRC](MRC), the chat network shared with other BBSes - [Finger and gopher](Finger-and-Gopher) - [Time](Time): NTP, NTS and PTP, followed and served @@ -136,6 +137,7 @@ which is generated from `bbs.conf.sample`. | [Chat and paging](Chat-and-Paging) | chat rooms, node messages, paging the sysop | | [IRC](IRC) | the IRC server, with the chat rooms as channels | | [AIM and ICQ](AIM-and-ICQ) | the OSCAR server: AIM and ICQ clients, buddies, IMs and chat rooms | +| [MSN Messenger](MSN-Messenger) | the MSN server: MSN Messenger 1.0 to 4.7, contacts and IMs | | [MRC](MRC) | Multi Relay Chat: chat rooms shared with other BBSes | | [Finger and gopher](Finger-and-Gopher) | who is on, and the BBS in gopherspace | | [Time](Time) | NTP, NTS and PTP: the clock following time servers, and serving time | diff --git a/docs/wiki/IRC.md b/docs/wiki/IRC.md index 61a992e..104bc59 100644 --- a/docs/wiki/IRC.md +++ b/docs/wiki/IRC.md @@ -54,7 +54,7 @@ up to 20 at once. Joining shows the room's last 20 lines. |---|---| | `PRIVMSG #room :text` | a line in the room | | `/me waves` (CTCP ACTION) | `* alice waves` | -| `PRIVMSG nick :text` | a message to that user's nodes | +| `PRIVMSG nick :text` | a message to that user's nodes; to one not on, [kept](Chat-and-Paging#private-messages) for them (`301` says so) | | a caller's node message | a `PRIVMSG` to you | | `NAMES`, `WHO`, `WHOIS` | who is in a room, on which node and how (`bob!telnet@node3`) | | `LIST` | the rooms in use | @@ -68,6 +68,10 @@ stripped from lines going into the rooms. A sysop is told of a page by a `NOTICE`. Joining `#sysop-N` answers the page from node N, just as `/answer` does in the BBS's chat. +Messages kept for you while you were away come as `PRIVMSG`s once you +log in, each with its time: as `server-time` if your client takes it, +otherwise at the start of the line. + The server offers the IRCv3 capabilities `sasl`, `server-time` (the time of each line, the history replayed on join included), `echo-message`, `multi-prefix` and `userhost-in-names`. @@ -117,6 +121,8 @@ answers come as notices. | `KEYS`, `KEYS ADD` *password key*, `KEYS DEL` *n* | your [SSH keys](SSH). Adding one asks for your password, since a key opens your account | | `TOKENS`, `TOKENS REVOKE` *id* | your [HTTP API](HTTP-API) tokens | | `ROOMS`; `ROOM ADD`\|`DEL`\|`TOPIC` *#room* | the [permanent rooms](#permanent-rooms); making them (the sysop) | +| `FRIENDS`, `FRIENDS ADD`\|`DEL` *nick* | your [friends list](Chat-and-Paging#friends), and who on it is on | +| `HISTORY`, `HISTORY` *nick* [*lines*] | those you have talked with; your last lines with one (50, up to 500) | The same checks apply as on the BBS: an alias that is someone's name is refused, and so is a setting's wrong value. A wrong password (`KEYS diff --git a/docs/wiki/MSN-Messenger.md b/docs/wiki/MSN-Messenger.md new file mode 100644 index 0000000..1a5d2bc --- /dev/null +++ b/docs/wiki/MSN-Messenger.md @@ -0,0 +1,113 @@ +The BBS has an MSN Messenger server (MSNP, the protocol of Microsoft's +MSN Messenger), beside its [IRC](IRC) and [AIM](AIM-and-ICQ) servers and +on the same chat. Someone signed in with MSN Messenger 1.0 to 4.7 or +Windows Messenger 4.x sees their BBS friends as contacts and IMs anyone on +the BBS: other MSN users, IRC and AIM users, and callers on telnet, SSH, +3270s and the web terminal. + +```ini +[msn] +address = :1863 +host = msn.example.org:1863 +domain = msn.example.org +``` + +| Setting | Default | What it sets | +|---|---|---| +| `address` | `:1863` | where to listen | +| `host` | the address each client came to | where clients are sent for conversations (`host:port`); set it behind NAT | +| `domain` | `bbs.invalid` | users' handles are `name@domain` | +| `max_clients` | `256` | connections at once | +| `max_per_ip` | `16` | from one address (each conversation is a connection) | +| `system` | `BBS` | the name the BBS's notices come from | +| `site` | none | a web address the client's links (inbox, profiles) open | + +One port serves the whole of it: sign-in, the contact list and presence +(the "notification server"), and the conversations ("switchboards"). + +## Versions served + +MSNP2 to MSNP7: MSN Messenger 1.0 to 4.7, Windows Messenger 4.0 to 4.7, +and third-party clients that speak those versions. They sign in by MD5 +(MSN 1.0 by the password itself) over plain TCP. MSN Messenger 5.0 and +later, and Windows Live Messenger, sign in by Passport over HTTPS, which +is not served yet: they are told the version is not supported, and the +log says so. + +## Pointing a client at the BBS + +The clients were made for Microsoft's servers, so each must be pointed +at the BBS: + +- MSN Messenger 1.0 to 4.7: the `Server` value (a string) under + `HKEY_CURRENT_USER\Software\Microsoft\MessengerService` in the + registry, set to the BBS's host (with `:1863` if the port is another). + A hosts file entry sending `messenger.hotmail.com` to the BBS may also + work. Neither has been tried with the real clients yet. +- Third-party clients (aMSN, Miranda, Trillian and others) take a server + and port in the account's settings. + +The deny list and bans in `[security]` apply as they do everywhere else. + +## Signing in + +Every MSN user is a BBS user. They sign in with `name@domain` as the +e-mail address (a name with spaces may be typed with or without them, +`CarolAnn@msn.example.org`) and their BBS password. The domain part is not +checked, so a client that insists on `@hotmail.com` (MSN 1.0) works too. +Failed sign-ins count towards the throttle and the hack log, like any +other login, and the user's access level must allow chat. One account is +signed in on one MSN client at a time: signing in again signs the older +one out. + +MSN clients send the password as an MD5 digest, which the BBS's password +hashes can't check. So the BBS keeps each account's MSN digest too, made +whenever the password is known: when the account is made, when its +password is set, and at any login by password. An account from before +`[msn]` was set up has none yet: its user logs in once some other way +(telnet, SSH, IRC, AIM, the web) and can then sign in with MSN. The log +says so when that is why a sign-in failed. The digest is kept only while +`[msn]` is set up. MSN's challenge for an account is the same each time, +as it was on Microsoft's servers, so anyone who saw a sign-in on the wire +(or read the digest from the database) could sign in by MSN as that +user. The connection is not encrypted. + +## Contacts + +The contact list is the user's [friends list](Chat-and-Paging#friends), +the same list the BBS's chat, IRC and AIM show, with its groups (MSN +Messenger 4.6 and later show them). A contact is always a BBS user; +adding anyone else is refused. A friend added elsewhere comes to a +client that is on at once, and one added or removed on MSN is on or off +the list everywhere. Someone who adds an MSN user is on their reverse +list, so the client asks "X has added you to their contact list". + +The block list is the user's [blocked list](Chat-and-Paging#blocking), +shared with the chat's `/block`: a blocked user's messages are refused +however they come, and the user appears offline to them. "Only people on +my Allow List can see my status" shows the user offline to those not on +their friends list. + +A contact is online while they are on the BBS by any route: with the +status their MSN client set (busy, away, appearing offline...), or plain +online on any other route. + +## Conversations + +An IM to an MSN user opens a conversation on their client as usual. An +IM to a BBS user on another route puts them in the conversation at once: +what is said reaches them as a private message (a `PRIVMSG` on IRC, an +IM on AIM, a message line on a terminal), and what they send back comes +into it. A private message from someone not on MSN opens a conversation +with them on the client. Conversations of several MSN users work as they +did on Microsoft's servers; typing notices and invitations pass between +MSN clients, not to other routes. + +Every line is [kept](Chat-and-Paging#private-messages). One to a user who +isn't on is kept for them, and the sender told so (once); they get it +when they next log in. Lines kept for an MSN user come when they sign in, +in a conversation from each sender, marked with when they were sent. The +BBS's notices (new mail, a page for the sysop) come from the `system` +name. Calling someone who is offline is refused, as on Microsoft's +servers: to leave a message for them, use their conversation while it is +open, or another route. diff --git a/docs/wiki/_Sidebar.md b/docs/wiki/_Sidebar.md index 25c27f4..e2c5456 100644 --- a/docs/wiki/_Sidebar.md +++ b/docs/wiki/_Sidebar.md @@ -34,6 +34,7 @@ - [Chat and paging](Chat-and-Paging) - [IRC](IRC) - [AIM and ICQ](AIM-and-ICQ) +- [MSN Messenger](MSN-Messenger) - [MRC](MRC) - [Finger and gopher](Finger-and-Gopher) - [Time: NTP, NTS and PTP](Time) diff --git a/internal/aol/fdo/LICENSE.atomforge b/internal/aol/fdo/LICENSE.atomforge new file mode 100644 index 0000000..2309d70 --- /dev/null +++ b/internal/aol/fdo/LICENSE.atomforge @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 AtomForge Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/internal/aol/fdo/atoms.go b/internal/aol/fdo/atoms.go new file mode 100644 index 0000000..e65613b --- /dev/null +++ b/internal/aol/fdo/atoms.go @@ -0,0 +1,192 @@ +package fdo + +import ( + "strings" + "sync" +) + +// Type is an atom's argument type, as ADA.BIN gives it. It decides how the +// compiler reads the atom's argument and how the decompiler shows it. +type Type uint8 + +const ( + TypeRaw Type = 0x01 // bytes, shown as hex + TypeDword Type = 0x02 // a number, big-endian in as few bytes as it needs + TypeString Type = 0x03 // text + TypeBool Type = 0x04 // yes / no + TypeGID Type = 0x05 // a global id: 32-105, 1-0-1329 + TypeStream Type = 0x06 // a nested atom stream (the act_ atoms' actions) + TypeObject Type = 0x07 // an object type and title: + TypeOrient Type = 0x08 // an orientation code: vff, hef... + TypeToken Type = 0x09 // a two-character token, then data: <"pE"> + TypeCriterion Type = 0x0A // an action criterion: select, close, 1001... + TypeAlert Type = 0x0B // an alert type and its text: + TypeAtom Type = 0x0C // the name of another atom (two bytes) + TypeByteList Type = 0x0D // numbers, a byte each (the if_ atoms) + TypeIgnore Type = 0x0E // compiler-internal (the large-atom atoms) + TypeVarNumber Type = 0x0F // a variable letter and a number: + TypeVarString Type = 0x10 // a variable letter and a string: + TypeVar Type = 0x11 // a variable letter, A-Z + TypeList Type = 0x12 // several values: mat_size <25, 1, 32> + TypeEnum Type = 0x13 // a named value or values or'd: center_center + TypeType14 Type = 0x14 // (de_typed_data, mat_spacing...) + TypeType15 Type = 0x15 // (mip_folder_id...) +) + +// Flags are an atom's layout flags: where the decompiler indents. +type Flags uint8 + +const ( + FlagIndent Flags = 1 << iota // the atoms after this one are indented + FlagOutdent // this atom and those after it are outdented + FlagEOS // this atom ends a stream +) + +// Atom is one entry of the atom table. +type Atom struct { + Proto uint8 + Num uint8 + Name string + Type Type + Flags Flags +} + +// Protocol numbers (the FDO91 manual's "protocols"; NINA's atoms table for +// those the manual doesn't cover). +const ( + ProtoUNI = 0x00 // universal: stream control + ProtoMAN = 0x01 // display manager + ProtoACT = 0x02 // actions + ProtoDE = 0x03 // data extraction + ProtoBUF = 0x04 // buffer + ProtoIDB = 0x05 // local database + ProtoXFER = 0x07 // file transfer + ProtoFM = 0x08 // file manager + ProtoLM = 0x09 // list manager + ProtoCM = 0x0A // code manager + ProtoCHAT = 0x0B + ProtoVAR = 0x0C // variables + ProtoASYNC = 0x0D + ProtoSM = 0x0E // shorthand + ProtoIF = 0x0F // conditionals + ProtoMAT = 0x10 // object attributes + ProtoMIP = 0x11 // mail + ProtoMMI = 0x14 // multimedia + ProtoIMGXFER = 0x15 + ProtoIMAGE = 0x16 + ProtoCHART = 0x17 + ProtoMORG = 0x18 + ProtoRICH = 0x19 // rich text + ProtoEXAPI = 0x1A + ProtoDOD = 0x1B // data on demand + ProtoRADIO = 0x1C + ProtoPICTALK = 0x1D + ProtoIRC = 0x1E + ProtoDOC = 0x1F + ProtoCCL = 0x22 + ProtoP3 = 0x23 + ProtoAD = 0x27 + ProtoAPP = 0x28 + ProtoMT = 0x2A // tool manager + ProtoVRM = 0x2F // Visual Rainman + ProtoWWW = 0x30 + ProtoJAVA = 0x31 + ProtoHFS = 0x33 // host forms server + ProtoBLANK = 0x34 + ProtoVID = 0x35 + ProtoACTIVEX = 0x36 + ProtoGALLERY = 0x38 + ProtoDICE = 0x39 + ProtoSPELL = 0x3D + ProtoADP = 0x42 + ProtoBUDDY = 0x49 + ProtoHTMLVW = 0x4B +) + +// protoNames are the protocols' atom-name prefixes. +var protoNames = map[uint8]string{ + ProtoUNI: "uni", ProtoMAN: "man", ProtoACT: "act", ProtoDE: "de", + ProtoBUF: "buf", ProtoIDB: "idb", ProtoXFER: "xfer", ProtoFM: "fm", + ProtoLM: "lm", ProtoCM: "cm", ProtoCHAT: "chat", ProtoVAR: "var", + ProtoASYNC: "async", ProtoSM: "sm", ProtoIF: "if", ProtoMAT: "mat", + ProtoMIP: "mip", ProtoMMI: "mmi", ProtoIMGXFER: "imgxfer", + ProtoIMAGE: "image", ProtoCHART: "chart", ProtoMORG: "morg", + ProtoRICH: "rich", ProtoEXAPI: "exapi", ProtoDOD: "dod", + ProtoRADIO: "radio", ProtoPICTALK: "pictalk", ProtoIRC: "irc", + ProtoDOC: "doc", ProtoCCL: "ccl", ProtoP3: "p3", ProtoAD: "ad", + ProtoAPP: "app", ProtoMT: "mt", ProtoVRM: "vrm", ProtoWWW: "www", + ProtoJAVA: "java", ProtoHFS: "hfs", ProtoBLANK: "blank", + ProtoVID: "vid", ProtoACTIVEX: "activex", ProtoGALLERY: "gallery", + ProtoDICE: "dice", ProtoSPELL: "spell", ProtoADP: "adp", + ProtoBUDDY: "buddy", ProtoHTMLVW: "htmlview", +} + +// ProtocolName is a protocol's prefix ("man" for 1), or "" if it has none. +func ProtocolName(proto uint8) string { return protoNames[proto] } + +var ( + tableOnce sync.Once + byName map[string]*Atom + byNum map[uint16]*Atom +) + +// moreAtoms are atoms of AOL 4.0's protocols that the ADA.BIN dump lacks, +// with their numbers as Ada32 compiled them in AtomForge's corpus. +var moreAtoms = []Atom{ + {ProtoGALLERY, 6, "gallery_open", TypeRaw, 0}, + {ProtoGALLERY, 7, "gallery_send_img_to_mail", TypeRaw, 0}, + {ProtoDICE, 0, "dice_set_context_tool", TypeDword, 0}, + {ProtoDICE, 2, "dice_end_context", TypeRaw, 0}, + {ProtoDICE, 11, "dice_disconnect", TypeRaw, 0}, + {ProtoDICE, 19, "dice_send_message", TypeDword, 0}, + {ProtoDICE, 39, "dice_access_search_form", TypeRaw, 0}, + {ProtoDICE, 41, "dice_disp_connect_summary", TypeRaw, 0}, + {ProtoSPELL, 0, "spell_rules_dlg", TypeRaw, 0}, + {ProtoBUDDY, 0, "buddy_action_command", TypeRaw, 0}, + {ProtoHTMLVW, 0, "htmlview_manage", TypeRaw, 0}, +} + +func loadTable() { + byName = make(map[string]*Atom, len(atomTable)+len(moreAtoms)) + byNum = make(map[uint16]*Atom, len(atomTable)+len(moreAtoms)) + add := func(a *Atom) { + byName[a.Name] = a + byNum[uint16(a.Proto)<<8|uint16(a.Num)] = a + } + for i := range atomTable { + add(&atomTable[i]) + } + for i := range moreAtoms { + add(&moreAtoms[i]) + } +} + +// Lookup finds an atom by name (case doesn't matter, and an "atom$" +// prefix, as the manual writes them, is allowed). +func Lookup(name string) (*Atom, bool) { + tableOnce.Do(loadTable) + name = strings.ToLower(name) + name = strings.TrimPrefix(name, "atom$") + a, ok := byName[name] + return a, ok +} + +// LookupNum finds an atom by protocol and number. +func LookupNum(proto, num uint8) (*Atom, bool) { + tableOnce.Do(loadTable) + a, ok := byNum[uint16(proto)<<8|uint16(num)] + return a, ok +} + +// Atoms is the whole table. +func Atoms() []Atom { return append(atomTable[:len(atomTable):len(atomTable)], moreAtoms...) } + +// MustLookup is Lookup for names known when the program is written; it +// panics on a name that isn't in the table. +func MustLookup(name string) *Atom { + a, ok := Lookup(name) + if !ok { + panic("fdo: no atom " + name) + } + return a +} diff --git a/internal/aol/fdo/atomtable.go b/internal/aol/fdo/atomtable.go new file mode 100644 index 0000000..b685669 --- /dev/null +++ b/internal/aol/fdo/atomtable.go @@ -0,0 +1,1638 @@ +// Code generated by go run ./internal/aol/fdo/gen; DO NOT EDIT. + +// From AtomForge's dump of ADA.BIN (src/test/resources/ada-bin-baseline.json, +// generated 2025-12-07T22:33:22.676241Z), atomforge-fdo-java at f28ad7a994db93297e2440a46a6ebd035bad5749 +// (Copyright AtomForge Contributors, MIT License: LICENSE.atomforge). + +package fdo + +var atomTable = [...]Atom{ + {0, 0, "uni_void", TypeRaw, 0}, + {0, 1, "uni_start_stream", TypeRaw, FlagIndent}, + {0, 2, "uni_end_stream", TypeRaw, FlagOutdent | FlagEOS}, + {0, 3, "uni_abort_stream", TypeDword, FlagOutdent | FlagEOS}, + {0, 4, "uni_start_large_atom", TypeIgnore, 0}, + {0, 5, "uni_large_atom_segment", TypeIgnore, 0}, + {0, 6, "uni_end_large_atom", TypeIgnore, 0}, + {0, 7, "uni_sync_skip", TypeDword, 0}, + {0, 8, "uni_start_loop", TypeRaw, 0}, + {0, 9, "uni_end_loop", TypeRaw, 0}, + {0, 10, "uni_use_last_atom_string", TypeList, 0}, + {0, 11, "uni_use_last_atom_value", TypeList, 0}, + {0, 12, "uni_save_result", TypeRaw, 0}, + {0, 14, "uni_data", TypeRaw, 0}, + {0, 15, "uni_wait_on", TypeRaw, 0}, + {0, 16, "uni_wait_off", TypeRaw, 0}, + {0, 17, "uni_start_stream_wait_on", TypeRaw, FlagIndent}, + {0, 18, "uni_wait_off_end_stream", TypeRaw, FlagOutdent | FlagEOS}, + {0, 19, "uni_invoke_no_context", TypeGID, 0}, + {0, 20, "uni_invoke_local", TypeGID, 0}, + {0, 21, "uni_get_result", TypeRaw, 0}, + {0, 22, "uni_next_atom_typed", TypeEnum, 0}, + {0, 23, "uni_start_typed_data", TypeEnum, 0}, + {0, 24, "uni_end_typed_data", TypeRaw, 0}, + {0, 32, "uni_force_processing", TypeRaw, 0}, + {0, 33, "uni_set_command_set", TypeDword, 0}, + {0, 34, "uni_wait_clear", TypeRaw, 0}, + {0, 35, "uni_change_stream_id", TypeDword, 0}, + {0, 36, "uni_diagnostic_msg", TypeList, 0}, + {0, 37, "uni_hold", TypeRaw, 0}, + {0, 40, "uni_invoke_local_preserve", TypeGID, 0}, + {0, 41, "uni_invoke_local_later", TypeGID, 0}, + {0, 42, "uni_convert_last_atom_string", TypeRaw, 0}, + {0, 43, "uni_break", TypeRaw, 0}, + {0, 44, "uni_single_step", TypeRaw, 0}, + {0, 45, "uni_convert_last_atom_data", TypeRaw, 0}, + {0, 46, "uni_get_first_stream", TypeRaw, 0}, + {0, 47, "uni_get_next_stream", TypeRaw, 0}, + {0, 48, "uni_get_stream_window", TypeDword, 0}, + {0, 49, "uni_cancel_action", TypeDword, 0}, + {0, 50, "uni_get_current_stream_id", TypeRaw, 0}, + {0, 51, "uni_set_data_length", TypeDword, 0}, + {0, 52, "uni_use_last_atom_data", TypeAtom, 0}, + {0, 53, "uni_set_watchdog_interval", TypeDword, 0}, + {0, 54, "uni_udo_complete", TypeRaw, 0}, + {0, 55, "uni_test_update", TypeRaw, 0}, + {0, 56, "uni_insert_stream", TypeString, 0}, + {0, 57, "uni_next_atom_mixed_data", TypeRaw, 0}, + {0, 58, "uni_start_mixed_data_mode", TypeRaw, 0}, + {0, 59, "uni_end_mixed_data_mode", TypeRaw, 0}, + {0, 60, "uni_transaction_id", TypeDword, 0}, + {0, 61, "uni_result_code", TypeDword, 0}, + {0, 62, "uni_command", TypeRaw, 0}, + {0, 63, "uni_get_from_stream_reg", TypeRaw, 0}, + {0, 64, "uni_save_to_stream_reg", TypeRaw, 0}, + {0, 65, "uni_reset_stream_regs", TypeRaw, 0}, + {0, 66, "uni_string_to_gid", TypeString, 0}, + {1, 0, "man_start_object", TypeObject, FlagIndent}, + {1, 1, "man_start_sibling", TypeObject, FlagIndent | FlagOutdent}, + {1, 2, "man_end_object", TypeRaw, FlagOutdent}, + {1, 3, "man_close", TypeGID, 0}, + {1, 4, "man_close_children", TypeGID, 0}, + {1, 5, "man_do_magic_token_arg", TypeToken, 0}, + {1, 6, "man_do_magic_response_id", TypeDword, 0}, + {1, 7, "man_set_response_id", TypeDword, 0}, + {1, 8, "man_set_context_response_id", TypeDword, 0}, + {1, 9, "man_set_context_globalid", TypeGID, 0}, + {1, 10, "man_set_context_relative", TypeDword, 0}, + {1, 11, "man_set_context_index", TypeDword, 0}, + {1, 12, "man_change_context_relative", TypeDword, 0}, + {1, 14, "man_clear_relative", TypeDword, 0}, + {1, 15, "man_clear_object", TypeGID, 0}, + {1, 16, "man_use_default_title", TypeRaw, 0}, + {1, 17, "man_update_display", TypeGID, 0}, + {1, 18, "man_update_woff_end_stream", TypeGID, FlagOutdent | FlagEOS}, + {1, 19, "man_update_end_object", TypeRaw, FlagOutdent}, + {1, 20, "man_append_data", TypeString, 0}, + {1, 21, "man_replace_data", TypeString, 0}, + {1, 22, "man_preset_gid", TypeGID, 0}, + {1, 23, "man_preset_title", TypeString, 0}, + {1, 24, "man_place_cursor", TypeDword, 0}, + {1, 25, "man_set_domain_type", TypeRaw, 0}, + {1, 26, "man_set_domain_info", TypeRaw, 0}, + {1, 27, "man_response_pop", TypeDword, 0}, + {1, 28, "man_close_update", TypeGID, 0}, + {1, 29, "man_end_context", TypeRaw, 0}, + {1, 32, "man_item_get", TypeDword, 0}, + {1, 33, "man_item_set", TypeRaw, 0}, + {1, 34, "man_start_first", TypeObject, FlagIndent}, + {1, 35, "man_do_edit_menu", TypeDword, 0}, + {1, 36, "man_logging_command", TypeDword, 0}, + {1, 37, "man_get_index_by_title", TypeString, 0}, + {1, 40, "man_start_alpha", TypeObject, FlagIndent}, + {1, 41, "man_start_last", TypeObject, FlagIndent}, + {1, 44, "man_insert_object_after", TypeDword, 0}, + {1, 45, "man_cut_object", TypeRaw, 0}, + {1, 46, "man_copy_object", TypeRaw, 0}, + {1, 47, "man_paste_object", TypeRaw, 0}, + {1, 48, "man_is_rendered", TypeRaw, 0}, + {1, 51, "man_preset_relative", TypeDword, 0}, + {1, 52, "man_insert_object_before", TypeDword, 0}, + {1, 53, "man_make_focus", TypeGID, 0}, + {1, 54, "man_get_top_window", TypeRaw, 0}, + {1, 55, "man_get_first_response_id", TypeRaw, 0}, + {1, 56, "man_get_next_response_id", TypeRaw, 0}, + {1, 57, "man_get_response_window", TypeDword, 0}, + {1, 58, "man_get_request_window", TypeDword, 0}, + {1, 59, "man_ignore_response", TypeDword, 0}, + {1, 60, "man_get_first_window", TypeRaw, 0}, + {1, 61, "man_get_next_window", TypeRaw, 0}, + {1, 62, "man_is_response_pending", TypeDword, 0}, + {1, 63, "man_is_response_ignored", TypeDword, 0}, + {1, 64, "man_get_attribute", TypeAtom, 0}, + {1, 65, "man_set_item_type", TypeDword, 0}, + {1, 66, "man_set_default_title", TypeString, 0}, + {1, 67, "man_get_child_count", TypeRaw, 0}, + {1, 68, "man_check_and_set_context_rid", TypeDword, 0}, + {1, 69, "man_clear_file_name", TypeRaw, 0}, + {1, 71, "man_is_window_iconic", TypeGID, 0}, + {1, 72, "man_post_update_gid", TypeGID, 0}, + {1, 73, "man_end_data", TypeRaw, 0}, + {1, 74, "man_update_fonts", TypeRaw, 0}, + {1, 75, "man_enable_one_shot_timer", TypeRaw, 0}, + {1, 76, "man_enable_continuous_timer", TypeRaw, 0}, + {1, 77, "man_kill_timer", TypeRaw, 0}, + {1, 78, "man_force_update", TypeRaw, 0}, + {1, 81, "man_set_edit_position", TypeDword, 0}, + {1, 82, "man_set_edit_position_to_end", TypeDword, 0}, + {1, 83, "man_preset_authoring_form", TypeRaw, 0}, + {1, 84, "man_add_date_time", TypeDword, 0}, + {1, 85, "man_start_title", TypeString, 0}, + {1, 86, "man_add_title_text", TypeString, 0}, + {1, 87, "man_add_title_tab", TypeRaw, 0}, + {1, 88, "man_add_title_date_time", TypeRaw, 0}, + {1, 89, "man_end_title", TypeString, 0}, + {1, 90, "man_preset_url", TypeString, 0}, + {1, 91, "man_get_dropped_url", TypeRaw, 0}, + {1, 92, "man_force_old_style_dod", TypeBool, 0}, + {1, 93, "man_preset_tag", TypeRaw, 0}, + {1, 94, "man_build_font_list", TypeRaw, 0}, + {1, 96, "man_spell_check", TypeRaw, 0}, + {1, 97, "man_obj_stack_push", TypeGID, 0}, + {1, 98, "man_obj_stack_pop", TypeDword, 0}, + {1, 99, "man_display_popup_menu", TypeDword, 0}, + {1, 100, "man_wm_close", TypeRaw, 0}, + {1, 101, "man_set_append_secure_data", TypeString, 0}, + {1, 102, "man_append_secure_data", TypeRaw, 0}, + {1, 103, "man_start_ip_session", TypeToken, 0}, + {1, 104, "man_end_ip_session", TypeRaw, 0}, + {1, 105, "man_build_savemail_menu", TypeRaw, 0}, + {1, 106, "man_build_favorites_menu", TypeRaw, 0}, + {1, 107, "man_get_display_characteristics", TypeList, 0}, + {1, 108, "man_build_signatures_menu", TypeRaw, 0}, + {1, 109, "man_sort_items", TypeDword, 0}, + {1, 110, "man_treectrl_action_command", TypeDword, 0}, + {1, 111, "man_set_context_first_selection", TypeGID, 0}, + {1, 112, "man_set_context_next_selection", TypeGID, 0}, + {2, 0, "act_set_criterion", TypeCriterion, 0}, + {2, 1, "act_do_action", TypeCriterion, 0}, + {2, 2, "act_set_inheritance", TypeRaw, 0}, + {2, 3, "act_replace_action", TypeStream, FlagIndent}, + {2, 4, "act_replace_select_action", TypeStream, FlagIndent}, + {2, 5, "act_sound_beep", TypeRaw, 0}, + {2, 6, "act_modify_action", TypeStream, 0}, + {2, 7, "act_set_test_index", TypeRaw, 0}, + {2, 8, "act_clr_test_index", TypeRaw, 0}, + {2, 9, "act_set_index", TypeRaw, 0}, + {2, 32, "act_append_action", TypeStream, 0}, + {2, 33, "act_prepend_action", TypeStream, 0}, + {2, 34, "act_change_action", TypeStream, 0}, + {2, 35, "act_append_select_action", TypeStream, 0}, + {2, 36, "act_prepend_select_action", TypeStream, 0}, + {2, 37, "act_change_select_action", TypeStream, 0}, + {2, 38, "act_copy_action_to_reg", TypeRaw, 0}, + {2, 39, "act_replace_action_from_reg", TypeRaw, 0}, + {2, 40, "act_append_action_from_reg", TypeRaw, 0}, + {2, 41, "act_prepend_action_from_reg", TypeRaw, 0}, + {2, 42, "act_change_action_from_reg", TypeRaw, 0}, + {2, 43, "act_set_action_in_reg", TypeRaw, 0}, + {2, 44, "act_interpret_packet", TypeRaw, 0}, + {2, 46, "act_set_db_length", TypeDword, 0}, + {2, 47, "act_get_db_record", TypeGID, 0}, + {2, 48, "act_set_db_id", TypeGID, 0}, + {2, 49, "act_set_db_record", TypeGID, 0}, + {2, 50, "act_set_guest_flag", TypeRaw, 0}, + {2, 51, "act_set_newuser_flag", TypeRaw, 0}, + {2, 52, "act_set_db_offset", TypeDword, 0}, + {2, 53, "act_get_db_value", TypeRaw, 0}, + {2, 54, "act_format_quote", TypeString, 0}, + {2, 55, "act_replace_popup_menu_action", TypeStream, 0}, + {3, 0, "de_set_extraction_type", TypeEnum, 0}, + {3, 1, "de_data", TypeString, 0}, + {3, 2, "de_start_extraction", TypeEnum, 0}, + {3, 3, "de_set_data_type", TypeEnum, 0}, + {3, 4, "de_set_variable_id", TypeDword, 0}, + {3, 5, "de_set_text_column", TypeDword, 0}, + {3, 6, "de_get_data", TypeEnum, 0}, + {3, 7, "de_end_extraction", TypeRaw, 0}, + {3, 8, "de_get_data_value", TypeEnum, 0}, + {3, 9, "de_get_data_pointer", TypeEnum, 0}, + {3, 10, "de_ez_send_form", TypeToken, FlagOutdent | FlagEOS}, + {3, 11, "de_custom_data", TypeRaw, 0}, + {3, 12, "de_ez_send_list_text", TypeToken, FlagOutdent | FlagEOS}, + {3, 14, "de_ez_send_list_index", TypeToken, FlagOutdent | FlagEOS}, + {3, 15, "de_ez_send_field", TypeToken, FlagOutdent | FlagEOS}, + {3, 16, "de_validate", TypeEnum, 0}, + {3, 17, "de_typed_data", TypeType14, 0}, + {4, 0, "buf_start_buffer", TypeEnum, 0}, + {4, 1, "buf_add_atom_pointer", TypeString, 0}, + {4, 2, "buf_add_atom_data", TypeDword, 0}, + {4, 3, "buf_add_pointer", TypeString, 0}, + {4, 4, "buf_add_data", TypeDword, 0}, + {4, 5, "buf_add_token", TypeToken, 0}, + {4, 6, "buf_set_token", TypeToken, 0}, + {4, 7, "buf_clear_buffer", TypeRaw, 0}, + {4, 8, "buf_close_buffer", TypeRaw, 0}, + {4, 9, "buf_save_buffer_to_db", TypeGID, 0}, + {4, 10, "buf_load_buffer_from_db", TypeGID, 0}, + {4, 11, "buf_send_buffer_to_host", TypeRaw, 0}, + {4, 12, "buf_set_flags", TypeEnum, 0}, + {4, 14, "buf_add_atom_pointer_filter", TypeString, 0}, + {4, 15, "buf_use_buffer", TypeEnum, 0}, + {4, 16, "buf_add_atom_data_trim", TypeString, 0}, + {4, 17, "buf_add_data_trim", TypeDword, 0}, + {4, 18, "buf_set_data_atom", TypeAtom, 0}, + {4, 19, "buf_destroy_buffer", TypeRaw, 0}, + {4, 20, "buf_add_string_raw", TypeString, 0}, + {4, 21, "buf_add_data_raw", TypeDword, 0}, + {4, 22, "buf_set_protocol", TypeRaw, 0}, + {4, 23, "buf_get_flags", TypeRaw, 0}, + {4, 24, "buf_get_data_atom", TypeRaw, 0}, + {4, 25, "buf_get_protocol", TypeRaw, 0}, + {4, 26, "buf_start_scrbuf", TypeRaw, 0}, + {4, 27, "buf_end_scrbuf", TypeRaw, 0}, + {4, 28, "buf_add_string_to_scrbuf", TypeRaw, 0}, + {4, 29, "buf_add_value_to_scrbuf", TypeRaw, 0}, + {4, 30, "buf_get_scrbuf", TypeRaw, 0}, + {4, 32, "buf_set_callback", TypeRaw, 0}, + {4, 33, "buf_debug_dump_buffers", TypeRaw, 0}, + {4, 34, "buf_restart_buffer", TypeRaw, 0}, + {4, 35, "buf_add_atom_typed_data", TypeRaw, 0}, + {4, 36, "buf_add_atom_pointer_flip", TypeRaw, 0}, + {4, 37, "buf_add_atom_data_flip", TypeDword, 0}, + {4, 38, "buf_add_data_flip", TypeDword, 0}, + {4, 39, "buf_set_security_tokens", TypeToken, 0}, + {4, 40, "buf_meter_abort", TypeRaw, 0}, + {5, 0, "idb_atr_dod", TypeRaw, 0}, + {5, 1, "idb_start_obj", TypeString, 0}, + {5, 2, "idb_end_obj", TypeRaw, 0}, + {5, 3, "idb_delete_obj", TypeGID, 0}, + {5, 4, "idb_close_obj", TypeGID, 0}, + {5, 5, "idb_exists", TypeGID, 0}, + {5, 6, "idb_start_extraction", TypeRaw, 0}, + {5, 7, "idb_end_extraction", TypeRaw, 0}, + {5, 8, "idb_get_data", TypeRaw, 0}, + {5, 9, "idb_get_value", TypeRaw, 0}, + {5, 10, "idb_dod_failed", TypeRaw, 0}, + {5, 11, "idb_append_data", TypeRaw, 0}, + {5, 12, "idb_data", TypeRaw, 0}, + {5, 14, "idb_change_context", TypeGID, 0}, + {5, 15, "idb_end_context", TypeRaw, 0}, + {5, 16, "idb_reset", TypeRaw, 0}, + {5, 17, "idb_get_string", TypeRaw, 0}, + {5, 18, "idb_cancel", TypeRaw, 0}, + {5, 19, "idb_set_context", TypeGID, 0}, + {5, 20, "idb_atr_globalid", TypeGID, 0}, + {5, 21, "idb_atr_length", TypeDword, 0}, + {5, 22, "idb_atr_stamp", TypeRaw, 0}, + {5, 23, "idb_atr_offset", TypeDword, 0}, + {5, 24, "idb_atr_type", TypeString, 0}, + {5, 25, "idb_atr_compressed", TypeRaw, 0}, + {5, 26, "idb_atr_encrypted", TypeRaw, 0}, + {5, 27, "idb_atr_expiration", TypeRaw, 0}, + {5, 28, "idb_atr_compress", TypeRaw, 0}, + {5, 29, "idb_use_default_icon", TypeRaw, 0}, + {5, 30, "idb_get_length", TypeRaw, 0}, + {5, 31, "idb_dod_progress_gauge", TypeString, 0}, + {5, 32, "idb_get_data_null_terminated", TypeRaw, 0}, + {5, 33, "idb_check_and_set_ftv", TypeRaw, 0}, + {5, 34, "idb_clear_ftv", TypeDword, 0}, + {7, 0, "xfer_abort", TypeRaw, 0}, + {7, 1, "xfer_show_file_description", TypeRaw, 0}, + {7, 2, "xfer_show_file_status", TypeRaw, 0}, + {7, 3, "xfer_start_download", TypeRaw, 0}, + {7, 4, "xfer_toggle_signoff", TypeRaw, 0}, + {7, 5, "xfer_finish_later", TypeRaw, 0}, + {7, 6, "xfer_decompress_file", TypeRaw, 0}, + {7, 7, "xfer_set_rle_flag", TypeRaw, 0}, + {7, 8, "xfer_clear_rle_flag", TypeRaw, 0}, + {7, 9, "xfer_refresh_prefs", TypeRaw, 0}, + {7, 10, "xfer_bool_in_progress", TypeRaw, 0}, + {7, 11, "xfer_invoke_dl_manager", TypeRaw, 0}, + {7, 12, "xfer_delete_spool_file", TypeRaw, 0}, + {7, 14, "xfer_start_object", TypeRaw, 0}, + {7, 15, "xfer_atr_request_id", TypeDword, 0}, + {7, 16, "xfer_atr_file_size", TypeDword, 0}, + {7, 17, "xfer_atr_title", TypeString, 0}, + {7, 18, "xfer_atr_file_name", TypeString, 0}, + {7, 19, "xfer_end_object", TypeRaw, 0}, + {7, 20, "xfer_invoke_archive", TypeRaw, 0}, + {7, 21, "xfer_atr_library", TypeString, 0}, + {7, 22, "xfer_bool_mail", TypeBool, 0}, + {7, 23, "xfer_atr_create_date", TypeDword, 0}, + {7, 24, "xfer_batch_download", TypeRaw, 0}, + {7, 25, "xfer_locate_file", TypeRaw, 0}, + {7, 26, "xfer_set_no_dialogs", TypeRaw, 0}, + {8, 0, "fm_start", TypeRaw, 0}, + {8, 1, "fm_end", TypeRaw, 0}, + {8, 2, "fm_item_type", TypeEnum, 0}, + {8, 3, "fm_item_set", TypeString, 0}, + {8, 4, "fm_item_get", TypeEnum, 0}, + {8, 5, "fm_broadcast", TypeRaw, 0}, + {8, 6, "fm_handle_error", TypeEnum, 0}, + {8, 7, "fm_add_file_type", TypeRaw, 0}, + {8, 8, "fm_delete_file_type", TypeRaw, 0}, + {8, 9, "fm_add_file_type_mask", TypeRaw, 0}, + {8, 10, "fm_delete_file_type_mask", TypeRaw, 0}, + {8, 11, "fm_register", TypeRaw, 0}, + {8, 12, "fm_unregister", TypeRaw, 0}, + {8, 14, "fm_add_type_to_group", TypeRaw, 0}, + {8, 15, "fm_delete_type_from_group", TypeRaw, 0}, + {8, 16, "fm_find_file_type", TypeString, 0}, + {8, 17, "fm_dialog_get_file", TypeString, 0}, + {8, 18, "fm_dialog_put_file", TypeString, 0}, + {8, 19, "fm_dialog_get_type", TypeRaw, 0}, + {8, 20, "fm_dialog_print", TypeString, 0}, + {8, 21, "fm_create_file", TypeRaw, 0}, + {8, 22, "fm_open_file", TypeRaw, 0}, + {8, 23, "fm_delete_file", TypeString, 0}, + {8, 24, "fm_rename_file", TypeRaw, 0}, + {8, 25, "fm_check_disk_space", TypeRaw, 0}, + {8, 26, "fm_close_file", TypeRaw, 0}, + {8, 27, "fm_append_data", TypeRaw, 0}, + {8, 28, "fm_position_file", TypeRaw, 0}, + {8, 29, "fm_position_eof", TypeRaw, 0}, + {8, 30, "fm_send_contents_to_buffer", TypeRaw, 0}, + {8, 31, "fm_dump", TypeRaw, 0}, + {8, 32, "fm_get_first_file", TypeString, 0}, + {8, 33, "fm_get_next_file", TypeRaw, 0}, + {8, 34, "fm_ini_read_data", TypeRaw, 0}, + {8, 35, "fm_ini_write_data", TypeRaw, 0}, + {8, 36, "fm_set_relative_path", TypeString, 0}, + {8, 37, "fm_read_file", TypeRaw, 0}, + {8, 38, "fm_unregister_list", TypeRaw, 0}, + {8, 39, "fm_flush_file", TypeRaw, 0}, + {8, 40, "fm_ini_get_section", TypeRaw, 0}, + {8, 41, "fm_ini_get_next_line", TypeRaw, 0}, + {8, 42, "fm_copy_file", TypeString, 0}, + {8, 43, "fm_keyword_okay", TypeBool, 0}, + {8, 44, "fm_ini_delete_file", TypeString, 0}, + {8, 45, "fm_dialog_init_get", TypeRaw, 0}, + {8, 46, "fm_dialog_end_get", TypeRaw, 0}, + {8, 47, "fm_dialog_cancel_get", TypeRaw, 0}, + {8, 48, "fm_edit_attachment_command", TypeRaw, 0}, + {9, 0, "lm_open_window", TypeGID, 0}, + {9, 1, "lm_close_window", TypeGID, 0}, + {9, 2, "lm_user_delete_item", TypeDword, 0}, + {9, 3, "lm_start_list", TypeRaw, 0}, + {9, 4, "lm_end_list", TypeRaw, 0}, + {9, 5, "lm_start_list_entry", TypeRaw, 0}, + {9, 6, "lm_end_list_entry", TypeRaw, 0}, + {9, 7, "lm_attr_list_type", TypeRaw, 0}, + {9, 8, "lm_attr_list_form", TypeRaw, 0}, + {9, 9, "lm_display_list", TypeRaw, 0}, + {9, 10, "lm_attr_list_entry_id", TypeRaw, 0}, + {9, 11, "lm_get_list_entry_title", TypeRaw, 0}, + {9, 12, "lm_get_list_entry_id", TypeRaw, 0}, + {9, 14, "lm_retrieve_item", TypeRaw, 0}, + {9, 15, "lm_render_item", TypeRaw, 0}, + {9, 16, "lm_table_clear", TypeGID, 0}, + {9, 17, "lm_table_use_table", TypeGID, 0}, + {9, 19, "lm_table_use_key", TypeString, 0}, + {9, 20, "lm_table_get_item", TypeString, 0}, + {9, 21, "lm_table_set_item", TypeString, 0}, + {9, 22, "lm_table_delete_item", TypeString, 0}, + {9, 23, "lm_table_get_first_key", TypeRaw, 0}, + {9, 24, "lm_table_get_next_key", TypeRaw, 0}, + {9, 25, "lm_get_selected_item", TypeGID, 0}, + {9, 26, "lm_get_selected_item_id", TypeRaw, 0}, + {9, 27, "lm_attr_list_entry_type", TypeDword, 0}, + {9, 28, "lm_get_num_selections", TypeRaw, 0}, + {9, 29, "lm_get_first_selection", TypeRaw, 0}, + {9, 30, "lm_get_next_selection", TypeRaw, 0}, + {9, 31, "lm_check_item_id", TypeDword, 0}, + {9, 32, "lm_uncheck_item_id", TypeDword, 0}, + {9, 33, "lm_delete_item_id", TypeDword, 0}, + {9, 34, "lm_add_entry_text", TypeString, 0}, + {9, 35, "lm_add_entry_tab", TypeRaw, 0}, + {9, 36, "lm_add_entry_date_time", TypeDword, 0}, + {9, 38, "lm_table_get_item_value", TypeString, 0}, + {9, 39, "lm_table_set_item_value", TypeDword, 0}, + {9, 40, "lm_table_encrypt_table", TypeRaw, 0}, + {10, 0, "cm_mark_tool_invalid", TypeDword, 0}, + {10, 1, "cm_set_byte_count", TypeDword, 0}, + {10, 5, "cm_force_off", TypeString, 0}, + {10, 6, "cm_inquire_add_tool", TypeDword, 0}, + {10, 7, "cm_inquire", TypeRaw, 0}, + {10, 8, "cm_inquire_all", TypeRaw, 0}, + {10, 9, "cm_clear_list", TypeRaw, 0}, + {10, 10, "cm_load_tool", TypeString, 0}, + {10, 11, "cm_kill_tool", TypeDword, 0}, + {10, 12, "cm_bounce_tool", TypeDword, 0}, + {10, 14, "cm_version", TypeDword, 0}, + {10, 17, "cm_check_tool", TypeDword, 0}, + {10, 18, "cm_cancel_job", TypeDword, 0}, + {10, 21, "cm_mark_proto_invalid", TypeDword, 0}, + {10, 22, "cm_mark_atom_invalid", TypeDword, 0}, + {10, 23, "cm_mark_token_invalid", TypeToken, 0}, + {10, 24, "cm_use_proto", TypeDword, 0}, + {10, 25, "cm_start_block", TypeRaw, 0}, + {10, 26, "cm_end_block", TypeRaw, 0}, + {10, 28, "cm_set_cancel_record", TypeGID, 0}, + {10, 29, "cm_set_to_restart", TypeBool, 0}, + {10, 30, "cm_cancel_held_streams", TypeRaw, 0}, + {10, 31, "cm_check_wid", TypeRaw, 0}, + {10, 32, "cm_get_tid_from_wid", TypeRaw, 0}, + {10, 33, "cm_start_required_tool_list", TypeRaw, 0}, + {10, 34, "cm_end_required_tool_list", TypeRaw, 0}, + {10, 35, "cm_add_required_tool", TypeString, 0}, + {10, 36, "cm_is_tool_loaded", TypeDword, 0}, + {10, 37, "cm_disk_space_needed", TypeDword, 0}, + {10, 38, "cm_set_splash_record", TypeGID, 0}, + {10, 39, "cm_update_notify_token", TypeToken, 0}, + {10, 40, "cm_tod_name", TypeString, 0}, + {10, 41, "cm_set_request_record", TypeGID, 0}, + {10, 42, "cm_mark_widget_invalid", TypeDword, 0}, + {10, 43, "cm_accept_update", TypeRaw, 0}, + {10, 44, "cm_reject_update", TypeRaw, 0}, + {10, 45, "cm_get_disk_space_required", TypeRaw, 0}, + {10, 46, "cm_get_time_estimate", TypeRaw, 0}, + {10, 47, "cm_is_restart_necessary", TypeRaw, 0}, + {10, 48, "cm_show_tools", TypeRaw, 0}, + {10, 49, "cm_inquire_changed", TypeRaw, 0}, + {10, 50, "cm_trigger_tod", TypeRaw, 0}, + {10, 51, "cm_tool_verify_set_tid", TypeRaw, 0}, + {10, 52, "cm_tool_verify", TypeRaw, 0}, + {10, 53, "cm_set_cleanup_record", TypeGID, 0}, + {10, 54, "cm_host_lib_index", TypeDword, 0}, + {10, 55, "cm_lib_start_date", TypeDword, 0}, + {10, 56, "cm_lib_end_date", TypeDword, 0}, + {10, 64, "cm_version_info", TypeRaw, 0}, + {10, 65, "cm_missing_protocol", TypeDword, 0}, + {10, 66, "cm_missing_atom", TypeDword, 0}, + {10, 67, "cm_missing_tool", TypeDword, 0}, + {10, 68, "cm_missing_token", TypeToken, 0}, + {10, 69, "cm_job_id", TypeDword, 0}, + {10, 70, "cm_packet_num", TypeDword, 0}, + {10, 71, "cm_tool_id", TypeDword, 0}, + {10, 72, "cm_widget_id", TypeDword, 0}, + {10, 73, "cm_host_update_ack", TypeRaw, 0}, + {10, 80, "cm_tb_set_name", TypeRaw, 0}, + {10, 81, "cm_tb_test_ver", TypeRaw, 0}, + {10, 82, "cm_tb_get_ver", TypeRaw, 0}, + {10, 83, "cm_tb_get_path", TypeRaw, 0}, + {10, 84, "cm_tb_test_name_loaded", TypeRaw, 0}, + {10, 85, "cm_tb_clear_name", TypeRaw, 0}, + {10, 86, "cm_tb_test_name_exists", TypeRaw, 0}, + {10, 87, "cm_tb_get_windows_dir", TypeRaw, 0}, + {10, 88, "cm_tb_win_getregistrykey", TypeRaw, 0}, + {10, 89, "cm_tb_get_physical_memsize", TypeRaw, 0}, + {11, 0, "chat_room_open", TypeRaw, 0}, + {11, 1, "chat_add_user", TypeRaw, 0}, + {11, 2, "chat_end_object", TypeRaw, 0}, + {11, 3, "chat_remove_user", TypeRaw, 0}, + {11, 4, "chat_show_arrival", TypeRaw, 0}, + {11, 5, "chat_message", TypeString, 0}, + {11, 6, "chat_refresh_pref", TypeRaw, 0}, + {11, 7, "chat_host", TypeString, 0}, + {11, 8, "chat_name_view", TypeString, 0}, + {11, 9, "chat_new_room_open", TypeString, 0}, + {11, 10, "chat_screen_name", TypeString, 0}, + {11, 11, "chat_new_message", TypeString, 0}, + {11, 12, "chat_user_enter_thru_list", TypeString, 0}, + {11, 14, "chat_user_exit", TypeString, 0}, + {11, 15, "chat_log_room", TypeDword, 0}, + {11, 16, "chat_link_view_to_list", TypeDword, 0}, + {11, 17, "chat_host_message", TypeString, 0}, + {11, 18, "chat_link_count_to_list", TypeDword, 0}, + {11, 19, "chat_set_view_log_priority", TypeDword, 0}, + {11, 20, "chat_log_path_rid", TypeDword, 0}, + {11, 21, "chat_close_room", TypeRaw, 0}, + {11, 22, "chat_bool_announce", TypeBool, 0}, + {11, 23, "chat_is_chat_view", TypeDword, 0}, + {11, 24, "chat_screen_name_color", TypeDword, 0}, + {11, 25, "chat_screen_name_back_color", TypeDword, 0}, + {11, 26, "chat_screen_name_font_size", TypeDword, 0}, + {11, 27, "chat_enum_rooms_in_list", TypeRaw, 0}, + {11, 28, "chat_is_new_chat_room", TypeDword, 0}, + {11, 29, "chat_is_room_being_logged", TypeDword, 0}, + {11, 30, "chat_get_log_file_name", TypeDword, 0}, + {11, 31, "chat_set_users_list_icon", TypeDword, 0}, + {11, 32, "chat_user_enter", TypeString, 0}, + {11, 33, "chat_start_message", TypeString, 0}, + {11, 34, "chat_add_message_text", TypeString, 0}, + {11, 35, "chat_add_message_date_time", TypeRaw, 0}, + {11, 36, "chat_end_message", TypeString, 0}, + {12, 0, "var_number_save", TypeVarNumber, 0}, + {12, 1, "var_number_set", TypeVarNumber, 0}, + {12, 2, "var_number_set_from_atom", TypeVar, 0}, + {12, 3, "var_number_get", TypeVar, 0}, + {12, 4, "var_number_set_id_one_value", TypeRaw, 0}, + {12, 5, "var_string_set", TypeVarString, 0}, + {12, 6, "var_string_null", TypeVar, 0}, + {12, 7, "var_string_save", TypeVarNumber, 0}, + {12, 8, "var_string_set_from_atom", TypeVar, 0}, + {12, 9, "var_string_get", TypeVar, 0}, + {12, 10, "var_string_set_id_one_value", TypeRaw, 0}, + {12, 11, "var_data_set", TypeRaw, 0}, + {12, 12, "var_data_zero", TypeVar, 0}, + {12, 14, "var_data_save", TypeVarNumber, 0}, + {12, 15, "var_data_set_from_atom", TypeVar, 0}, + {12, 16, "var_data_get", TypeVar, 0}, + {12, 17, "var_data_set_id_one_value", TypeRaw, 0}, + {12, 19, "var_lookup_by_id", TypeVarNumber, 0}, + {12, 20, "var_numa_zero", TypeRaw, 0}, + {12, 21, "var_numa_ones", TypeRaw, 0}, + {12, 22, "var_numa_increment", TypeRaw, 0}, + {12, 23, "var_numa_decrement", TypeRaw, 0}, + {12, 32, "var_number_increment_save", TypeVar, 0}, + {12, 33, "var_number_decrement_save", TypeVar, 0}, + {12, 34, "var_number_zero_save", TypeVar, 0}, + {12, 35, "var_number_ones_save", TypeVar, 0}, + {12, 36, "var_number_add", TypeDword, 0}, + {12, 37, "var_number_sub", TypeDword, 0}, + {12, 38, "var_number_mul", TypeDword, 0}, + {12, 39, "var_number_div", TypeDword, 0}, + {12, 40, "var_number_anding", TypeDword, 0}, + {12, 41, "var_number_oring", TypeDword, 0}, + {12, 42, "var_number_shl", TypeDword, 0}, + {12, 43, "var_number_shr", TypeDword, 0}, + {12, 44, "var_number_copy_between_regs", TypeVar, 0}, + {12, 45, "var_number_swap_between_regs", TypeVar, 0}, + {12, 46, "var_number_clear_id", TypeVar, 0}, + {12, 47, "var_number_increment", TypeVar, 0}, + {12, 48, "var_number_decrement", TypeVar, 0}, + {12, 49, "var_number_zero", TypeVar, 0}, + {12, 50, "var_number_ones", TypeVar, 0}, + {12, 65, "var_string_copy_stra_to_strb", TypeRaw, 0}, + {12, 66, "var_string_copy_strb_to_stra", TypeRaw, 0}, + {12, 67, "var_string_copy_between_regs", TypeVar, 0}, + {12, 68, "var_string_swap_between_regs", TypeVar, 0}, + {12, 69, "var_string_clear_id", TypeVar, 0}, + {12, 70, "var_string_trim_spaces", TypeRaw, 0}, + {12, 71, "var_string_trim_spaces_safely", TypeString, 0}, + {12, 81, "var_data_copy_data_to_datb", TypeRaw, 0}, + {12, 82, "var_data_copy_datb_to_data", TypeRaw, 0}, + {12, 83, "var_data_copy_between_regs", TypeVar, 0}, + {12, 84, "var_data_swap_between_regs", TypeVar, 0}, + {12, 85, "var_data_clear_id", TypeVar, 0}, + {12, 96, "var_reset", TypeRaw, 0}, + {12, 99, "var_random_number", TypeDword, 0}, + {12, 100, "var_string_concatenate_regs", TypeVar, 0}, + {12, 101, "var_check_string_type_and_convert", TypeVar, 0}, + {12, 102, "var_get_string_convert_len", TypeRaw, 0}, + {12, 103, "var_number", TypeRaw, 0}, + {12, 104, "var_string", TypeRaw, 0}, + {12, 105, "var_data", TypeRaw, 0}, + {13, 0, "async_exit", TypeRaw, 0}, + {13, 1, "async_password", TypeRaw, 0}, + {13, 2, "async_guest_password", TypeRaw, 0}, + {13, 3, "async_exit_damnit", TypeRaw, 0}, + {13, 4, "async_online", TypeRaw, 0}, + {13, 5, "async_offline", TypeRaw, 0}, + {13, 6, "async_error_box", TypeString, 0}, + {13, 7, "async_alert", TypeAlert, 0}, + {13, 8, "async_display_netnews", TypeRaw, 0}, + {13, 9, "async_go_netnews", TypeRaw, 0}, + {13, 10, "async_moreinfo_netnews", TypeRaw, 0}, + {13, 11, "async_playsound", TypeString, 0}, + {13, 12, "async_exit_aux", TypeRaw, 0}, + {13, 13, "async_exec_help", TypeRaw, 0}, + {13, 14, "async_exec_context_help", TypeRaw, 0}, + {13, 15, "async_play_sound_dammit", TypeString, 0}, + {13, 16, "async_exec_help_file", TypeString, 0}, + {13, 17, "async_force_off", TypeString, 0}, + {13, 18, "async_send_clientstatus", TypeRaw, 0}, + {13, 19, "async_get_stat_count", TypeRaw, 0}, + {13, 20, "async_extract_stats", TypeRaw, 0}, + {13, 21, "async_stat_collection_state", TypeRaw, 0}, + {13, 22, "async_clear_stats", TypeRaw, 0}, + {13, 23, "async_stat_record", TypeRaw, 0}, + {13, 24, "async_get_alert_result", TypeRaw, 0}, + {13, 25, "async_exec_app", TypeString, 0}, + {13, 26, "async_screen_name_changed", TypeRaw, 0}, + {13, 27, "async_is_known_subaccount", TypeRaw, 0}, + {13, 28, "async_dump_diag", TypeString, 0}, + {13, 29, "async_get_screen_name", TypeRaw, 0}, + {13, 30, "async_sign_on", TypeRaw, 0}, + {13, 31, "async_alert_start", TypeString, 0}, + {13, 32, "async_alert_add_text", TypeString, 0}, + {13, 33, "async_alert_add_date_time", TypeDword, 0}, + {13, 34, "async_alert_end", TypeString, 0}, + {13, 35, "async_invoke_timezone_pref", TypeRaw, 0}, + {13, 36, "async_invoke_language_pref", TypeRaw, 0}, + {13, 37, "async_set_screen_name", TypeString, 0}, + {13, 38, "async_auto_launch", TypeRaw, 0}, + {13, 39, "async_launcher_name", TypeRaw, 0}, + {13, 40, "async_is_client_32bit", TypeRaw, 0}, + {13, 41, "async_display_errors", TypeRaw, 0}, + {13, 42, "async_is_guest", TypeRaw, 0}, + {13, 43, "async_relogon_init", TypeRaw, 0}, + {13, 44, "async_relogon", TypeRaw, 0}, + {13, 45, "async_storename", TypeString, 0}, + {13, 46, "async_storepassword", TypeString, 0}, + {13, 47, "async_signoff", TypeRaw, 0}, + {13, 48, "async_is_current_screenname", TypeString, 0}, + {13, 49, "async_logout", TypeRaw, 0}, + {13, 50, "async_check_and_invoke_driveway", TypeRaw, 0}, + {13, 51, "async_record_error", TypeString, 0}, + {13, 52, "async_system_usage", TypeString, 0}, + {13, 53, "async_replace_pref", TypeString, 0}, + {13, 54, "async_bool_diag_on", TypeBool, 0}, + {13, 55, "async_allow_switch_screen_names", TypeRaw, 0}, + {13, 56, "async_install_sound", TypeDword, 0}, + {13, 57, "async_voice_recognition", TypeDword, 0}, + {14, 0, "sm_do_list_action", TypeDword, FlagOutdent | FlagEOS}, + {14, 1, "sm_end_object_with_action", TypeStream, FlagOutdent}, + {14, 2, "sm_end_object_with_var", TypeRaw, FlagOutdent}, + {14, 3, "sm_send_k1", TypeGID, FlagOutdent | FlagEOS}, + {14, 4, "sm_send_er", TypeGID, FlagOutdent | FlagEOS}, + {14, 5, "sm_send_mr", TypeGID, FlagOutdent | FlagEOS}, + {14, 6, "sm_send_mf", TypeGID, FlagOutdent | FlagEOS}, + {14, 7, "sm_send_bm", TypeGID, FlagOutdent | FlagEOS}, + {14, 8, "sm_send_bn", TypeGID, FlagOutdent | FlagEOS}, + {14, 9, "sm_send_f1", TypeGID, FlagOutdent | FlagEOS}, + {14, 10, "sm_check_domain", TypeRaw, 0}, + {14, 11, "sm_set_domain", TypeRaw, 0}, + {14, 12, "sm_send_token_arg", TypeToken, FlagOutdent | FlagEOS}, + {14, 14, "sm_p_send_token_arg", TypeToken, FlagOutdent | FlagEOS}, + {14, 15, "sm_mp_send_token_arg", TypeToken, FlagOutdent | FlagEOS}, + {14, 16, "sm_send_token_raw", TypeToken, FlagOutdent | FlagEOS}, + {14, 17, "sm_m_send_token_raw", TypeToken, FlagOutdent | FlagEOS}, + {14, 18, "sm_send_window_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 19, "sm_m_send_window_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 20, "sm_p_send_window_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 21, "sm_mp_send_window_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 22, "sm_send_list_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 23, "sm_m_send_list_var", TypeToken, FlagOutdent | FlagEOS}, + {14, 24, "sm_m_send_token_arg", TypeToken, FlagOutdent | FlagEOS}, + {14, 25, "sm_idb_get_data", TypeRaw, 0}, + {14, 26, "sm_set_object_domain", TypeRaw, 0}, + {14, 27, "sm_send_free_k1", TypeGID, FlagOutdent | FlagEOS}, + {14, 28, "sm_send_paid_k1", TypeGID, FlagOutdent | FlagEOS}, + {14, 29, "sm_send_free_f1", TypeGID, FlagOutdent | FlagEOS}, + {14, 30, "sm_send_paid_f1", TypeGID, FlagOutdent | FlagEOS}, + {14, 31, "sm_set_plus_group", TypeRaw, 0}, + {14, 32, "sm_check_plus_group", TypeRaw, 0}, + {14, 33, "sm_enter_paid", TypeRaw, 0}, + {14, 34, "sm_enter_free", TypeRaw, 0}, + {14, 35, "sm_send_selection_code", TypeDword, 0}, + {15, 0, "if_numa_false_then", TypeByteList, 0}, + {15, 1, "if_numb_true_then", TypeByteList, 0}, + {15, 2, "if_numb_false_then", TypeByteList, 0}, + {15, 3, "if_numa_eq_one_then", TypeByteList, 0}, + {15, 4, "if_numa_gt_one_then", TypeByteList, 0}, + {15, 5, "if_numb_eq_one_then", TypeByteList, 0}, + {15, 6, "if_numb_gt_one_then", TypeByteList, 0}, + {15, 7, "if_stra_eq_null_then", TypeByteList, 0}, + {15, 8, "if_strb_eq_null_then", TypeByteList, 0}, + {15, 9, "if_stra_neq_null_then", TypeByteList, 0}, + {15, 10, "if_strb_neq_null_then", TypeByteList, 0}, + {15, 11, "if_data_eq_zero_then", TypeByteList, 0}, + {15, 12, "if_datb_eq_zero_then", TypeByteList, 0}, + {15, 14, "if_data_neq_zero_then", TypeByteList, 0}, + {15, 15, "if_datb_neq_zero_then", TypeByteList, 0}, + {15, 16, "if_free_area_then", TypeByteList, 0}, + {15, 17, "if_test_index_true_then", TypeByteList, 0}, + {15, 18, "if_test_index_false_then", TypeByteList, 0}, + {15, 19, "if_last_return_true_then", TypeByteList, 0}, + {15, 20, "if_last_return_false_then", TypeByteList, 0}, + {15, 21, "if_last_return_true_exit", TypeByteList, 0}, + {15, 22, "if_last_return_false_exit", TypeByteList, 0}, + {15, 23, "if_paid_area_then", TypeByteList, 0}, + {15, 32, "if_numa_eq_numb_then", TypeByteList, 0}, + {15, 33, "if_numa_neq_numb_then", TypeByteList, 0}, + {15, 34, "if_numa_gt_numb_then", TypeByteList, 0}, + {15, 35, "if_numa_gte_numb_then", TypeByteList, 0}, + {15, 36, "if_numa_lt_numb_then", TypeByteList, 0}, + {15, 37, "if_numa_lte_numb_then", TypeByteList, 0}, + {15, 38, "if_numa_and_numb_then", TypeByteList, 0}, + {15, 39, "if_numa_or_numb_then", TypeByteList, 0}, + {15, 40, "if_numa_true_then", TypeByteList, 0}, + {15, 64, "if_stra_eq_strb_then", TypeByteList, 0}, + {15, 65, "if_stra_neq_strb_then", TypeByteList, 0}, + {15, 66, "if_stra_in_strb_prefix_then", TypeByteList, 0}, + {15, 67, "if_strb_in_stra_prefix_then", TypeByteList, 0}, + {15, 80, "if_data_eq_datb_then", TypeByteList, 0}, + {15, 81, "if_data_neq_datb_then", TypeByteList, 0}, + {15, 82, "if_data_in_datb_prefix_then", TypeByteList, 0}, + {15, 83, "if_datb_in_data_prefix_then", TypeByteList, 0}, + {15, 96, "if_online_then", TypeByteList, 0}, + {15, 97, "if_offline_then", TypeByteList, 0}, + {15, 98, "if_guest_then", TypeByteList, 0}, + {15, 99, "if_owner_then", TypeByteList, 0}, + {15, 100, "if_newuser_then", TypeByteList, 0}, + {15, 101, "if_am_then", TypeByteList, 0}, + {15, 102, "if_pm_then", TypeByteList, 0}, + {15, 103, "if_debug_true_then", TypeByteList, 0}, + {15, 104, "if_debug_false_then", TypeByteList, 0}, + {16, 0, "mat_bool_vertical_scroll", TypeBool, 0}, + {16, 1, "mat_bool_disabled", TypeBool, 0}, + {16, 2, "mat_bool_default", TypeBool, 0}, + {16, 3, "mat_bool_resize_vertical", TypeBool, 0}, + {16, 4, "mat_bool_resize_horizontal", TypeBool, 0}, + {16, 5, "mat_bool_modal", TypeBool, 0}, + {16, 6, "mat_bool_invisible", TypeBool, 0}, + {16, 7, "mat_bool_hidden", TypeBool, 0}, + {16, 8, "mat_orientation", TypeOrient, 0}, + {16, 9, "mat_capacity", TypeDword, 0}, + {16, 10, "mat_font_sis", TypeList, 0}, + {16, 11, "mat_relative_tag", TypeDword, 0}, + {16, 12, "mat_object_id", TypeGID, 0}, + {16, 14, "mat_art_id", TypeGID, 0}, + {16, 15, "mat_width", TypeDword, 0}, + {16, 16, "mat_height", TypeDword, 0}, + {16, 17, "mat_title_pos", TypeEnum, 0}, + {16, 18, "mat_ruler", TypeByteList, 0}, + {16, 19, "mat_object_color", TypeByteList, 0}, + {16, 20, "mat_vertical_spacing", TypeDword, 0}, + {16, 21, "mat_iconify_as", TypeRaw, 0}, + {16, 22, "mat_plus_group", TypeRaw, 0}, + {16, 23, "mat_size", TypeList, 0}, + {16, 24, "mat_title", TypeString, 0}, + {16, 25, "mat_title_width", TypeDword, 0}, + {16, 26, "mat_bool_list_icons", TypeBool, 0}, + {16, 27, "mat_bool_graphic_view", TypeBool, 0}, + {16, 28, "mat_bool_palette", TypeBool, 0}, + {16, 32, "mat_bool_horizontal_scroll", TypeBool, 0}, + {16, 33, "mat_bool_force_scroll", TypeBool, 0}, + {16, 34, "mat_bool_protected_input", TypeBool, 0}, + {16, 35, "mat_bool_force_no_scroll", TypeBool, 0}, + {16, 36, "mat_bool_non_closeable", TypeBool, 0}, + {16, 37, "mat_bool_exportable", TypeBool, 0}, + {16, 38, "mat_bool_importable", TypeBool, 0}, + {16, 39, "mat_bool_writeable", TypeBool, 0}, + {16, 40, "mat_bool_floating", TypeBool, 0}, + {16, 41, "mat_bool_contiguous", TypeBool, 0}, + {16, 42, "mat_bool_menu", TypeBool, 0}, + {16, 43, "mat_bool_default_send", TypeBool, 0}, + {16, 44, "mat_bool_double_space", TypeBool, 0}, + {16, 45, "mat_object_type", TypeObject, 0}, + {16, 46, "mat_vert_scroll_capacity", TypeDword, 0}, + {16, 47, "mat_horz_scroll_capacity", TypeDword, 0}, + {16, 48, "mat_font_id", TypeEnum, 0}, + {16, 49, "mat_font_size", TypeDword, 0}, + {16, 50, "mat_font_style", TypeEnum, 0}, + {16, 51, "mat_value", TypeDword, 0}, + {16, 52, "mat_border", TypeRaw, 0}, + {16, 53, "mat_command_key", TypeRaw, 0}, + {16, 54, "mat_dirty_query", TypeBool, 0}, + {16, 55, "mat_managed_by", TypeDword, 0}, + {16, 56, "mat_validation", TypeDword, 0}, + {16, 57, "mat_horizontal_spacing", TypeDword, 0}, + {16, 58, "mat_style_id", TypeGID, 0}, + {16, 59, "mat_minimum", TypeDword, 0}, + {16, 60, "mat_maximum", TypeDword, 0}, + {16, 61, "mat_horz_scroll_value", TypeDword, 0}, + {16, 62, "mat_vert_scroll_value", TypeDword, 0}, + {16, 63, "mat_bool_invert", TypeBool, 0}, + {16, 64, "mat_position", TypeEnum, 0}, + {16, 65, "mat_log_object", TypeEnum, 0}, + {16, 66, "mat_paragraph", TypeBool, 0}, + {16, 67, "mat_scroll_threshold", TypeDword, 0}, + {16, 68, "mat_shortcut_key", TypeString, 0}, + {16, 69, "mat_sort_order", TypeEnum, 0}, + {16, 70, "mat_unfocused", TypeBool, 0}, + {16, 71, "mat_bool_permanent", TypeBool, 0}, + {16, 72, "mat_bool_ignore", TypeBool, 0}, + {16, 73, "mat_increment", TypeDword, 0}, + {16, 74, "mat_bool_no_border", TypeBool, 0}, + {16, 75, "mat_bool_modified", TypeBool, 0}, + {16, 76, "mat_link_content_to_rid", TypeDword, 0}, + {16, 77, "mat_bool_precise", TypeBool, 0}, + {16, 78, "mat_precise_width", TypeDword, 0}, + {16, 79, "mat_precise_height", TypeDword, 0}, + {16, 80, "mat_precise_x", TypeDword, 0}, + {16, 81, "mat_precise_y", TypeDword, 0}, + {16, 82, "mat_color_face", TypeByteList, 0}, + {16, 83, "mat_color_text", TypeByteList, 0}, + {16, 84, "mat_color_top_edge", TypeByteList, 0}, + {16, 85, "mat_color_bottom_edge", TypeByteList, 0}, + {16, 86, "mat_bool_gradual_shadow", TypeBool, 0}, + {16, 87, "mat_frame_style", TypeEnum, 0}, + {16, 88, "mat_trigger_style", TypeEnum, 0}, + {16, 89, "mat_color_selected", TypeByteList, 0}, + {16, 90, "mat_color_text_shadow", TypeByteList, 0}, + {16, 91, "mat_timer_event", TypeDword, 0}, + {16, 92, "mat_timer_duration", TypeDword, 0}, + {16, 93, "mat_bool_background_pic", TypeBool, 0}, + {16, 94, "mat_bool_background_flood", TypeBool, 0}, + {16, 95, "mat_color_frame_hilight", TypeByteList, 0}, + {16, 96, "mat_color_frame_shadow", TypeByteList, 0}, + {16, 97, "mat_art_frame", TypeDword, 0}, + {16, 98, "mat_art_animation_rate", TypeDword, 0}, + {16, 99, "mat_art_animation_seq", TypeByteList, 0}, + {16, 100, "mat_bool_repeat_animation", TypeBool, 0}, + {16, 101, "mat_bool_background_tile", TypeBool, 0}, + {16, 102, "mat_context_help", TypeString, 0}, + {16, 103, "mat_drop_data_type", TypeDword, 0}, + {16, 104, "mat_field_script", TypeEnum, 0}, + {16, 105, "mat_encode_type", TypeRaw, 0}, + {16, 106, "mat_bool_first_script", TypeBool, 0}, + {16, 108, "mat_bool_list_allow_entry", TypeBool, 0}, + {16, 109, "mat_url", TypeString, 0}, + {16, 110, "mat_bool_expand_to_fit", TypeBool, 0}, + {16, 111, "mat_sink", TypeString, 0}, + {16, 112, "mat_bool_sane", TypeBool, 0}, + {16, 113, "mat_bool_url_sink", TypeBool, 0}, + {16, 114, "mat_bool_drop_at_top", TypeBool, 0}, + {16, 115, "mat_form_icon", TypeGID, 0}, + {16, 116, "mat_content_tag", TypeString, 0}, + {16, 117, "mat_bool_language_popup", TypeBool, 0}, + {16, 118, "mat_language_sensitive", TypeDword, 0}, + {16, 119, "mat_bool_palette_art", TypeBool, 0}, + {16, 120, "mat_set_dflt_extract_type", TypeDword, 0}, + {16, 121, "mat_art_hint_width", TypeDword, 0}, + {16, 122, "mat_art_hint_height", TypeDword, 0}, + {16, 123, "mat_art_hint_title", TypeString, 0}, + {16, 124, "mat_art_hint_placeholder_id", TypeGID, 0}, + {16, 125, "mat_art_hint_title_x", TypeDword, 0}, + {16, 126, "mat_bool_tool_group", TypeBool, 0}, + {16, 127, "mat_art_hint_title_y", TypeDword, 0}, + {16, 128, "mat_art_hint_title_font_size", TypeDword, 0}, + {16, 129, "mat_art_hint_title_font_id", TypeDword, 0}, + {16, 130, "mat_art_hint_title_font_style", TypeDword, 0}, + {16, 131, "mat_bool_small_icon", TypeBool, 0}, + {16, 132, "mat_art_hint_select_placeholder", TypeDword, 0}, + {16, 133, "mat_object_index", TypeDword, 0}, + {16, 134, "mat_bool_encode_unicode", TypeBool, 0}, + {16, 135, "mat_text_on_picture_pos", TypeEnum, 0}, + {16, 136, "mat_secure_form", TypeToken, 0}, + {16, 137, "mat_fp_compose_mail", TypeRaw, 0}, + {16, 138, "mat_fp_send_im", TypeRaw, 0}, + {16, 139, "mat_fp_save_to_fp", TypeRaw, 0}, + {16, 140, "mat_bool_page_control", TypeBool, 0}, + {16, 141, "mat_bool_spinner", TypeBool, 0}, + {16, 142, "mat_bool_detached", TypeBool, 0}, + {16, 143, "mat_bool_customizable", TypeBool, 0}, + {16, 144, "mat_bool_detachable", TypeBool, 0}, + {16, 145, "mat_bool_dock_horizontal", TypeBool, 0}, + {16, 146, "mat_bool_dock_vertical", TypeBool, 0}, + {16, 147, "mat_bool_children_removable", TypeBool, 0}, + {16, 148, "mat_bool_children_movable", TypeBool, 0}, + {16, 149, "mat_bool_child_removable", TypeBool, 0}, + {16, 150, "mat_bool_child_movable", TypeBool, 0}, + {16, 151, "mat_bool_child_line_feed", TypeBool, 0}, + {16, 152, "mat_title_append_screen_name", TypeEnum, 0}, + {16, 153, "mat_url_list", TypeEnum, 0}, + {16, 154, "mat_tab_set_cur_sel", TypeDword, 0}, + {16, 155, "mat_tab_get_cur_sel", TypeRaw, 0}, + {16, 156, "mat_bool_shared_style", TypeBool, 0}, + {16, 157, "mat_bool_active_offline", TypeBool, 0}, + {16, 158, "mat_bool_active_online", TypeBool, 0}, + {16, 159, "mat_bool_inactive_for_guest", TypeBool, 0}, + {16, 160, "mat_bool_dropdown_button", TypeBool, 0}, + {16, 161, "mat_bool_popup_menu", TypeBool, 0}, + {16, 162, "mat_bool_ignore_url_list", TypeBool, 0}, + {16, 163, "mat_popup_relative_id", TypeDword, 0}, + {16, 164, "mat_popup_pfc_path", TypeString, 0}, + {16, 165, "mat_bool_draw_focus", TypeBool, 0}, + {16, 166, "mat_url_next", TypeString, 0}, + {16, 167, "mat_url_prev", TypeString, 0}, + {16, 168, "mat_url_parent", TypeString, 0}, + {16, 169, "mat_bool_loggable", TypeBool, 0}, + {16, 170, "mat_secure_field", TypeDword, 0}, + {16, 171, "mat_bool_hide_url", TypeBool, 0}, + {16, 172, "mat_bool_auto_closeable", TypeBool, 0}, + {16, 173, "mat_bool_signoff_menu", TypeBool, 0}, + {16, 175, "mat_bool_ignore_url", TypeBool, 0}, + {16, 176, "mat_bool_savable_to_pfc", TypeBool, 0}, + {16, 177, "mat_bool_static_url", TypeBool, 0}, + {16, 178, "mat_intl_font_sis", TypeList, 0}, + {16, 179, "mat_navarrow_pos", TypeRaw, 0}, + {16, 180, "mat_navarrow_art", TypeDword, 0}, + {16, 181, "mat_navarrow_pos_x", TypeDword, 0}, + {16, 182, "mat_navarrow_pos_y", TypeDword, 0}, + {16, 183, "mat_art_seq", TypeList, 0}, + {16, 184, "mat_sage_context_help", TypeString, 0}, + {16, 185, "mat_auto_complete", TypeList, 0}, + {16, 186, "mat_left_spacing", TypeType14, 0}, + {16, 187, "mat_top_spacing", TypeType14, 0}, + {16, 188, "mat_right_spacing", TypeType14, 0}, + {16, 189, "mat_bottom_spacing", TypeType14, 0}, + {16, 190, "mat_spacing", TypeType14, 0}, + {16, 191, "mat_factory_id", TypeGID, 0}, + {16, 192, "mat_treectrl_set_class", TypeDword, 0}, + {16, 193, "mat_title_access", TypeString, 0}, + {16, 196, "mat_title_access_rid", TypeDword, 0}, + {16, 197, "mat_thumb_size", TypeDword, 0}, + {16, 198, "mat_bool_hide_ticks", TypeBool, 0}, + {16, 199, "mat_color_thumb", TypeByteList, 0}, + {16, 200, "mat_color_channel", TypeByteList, 0}, + {16, 201, "mat_bool_is_slider", TypeBool, 0}, + {17, 0, "mip_start_message", TypeRaw, 0}, + {17, 1, "mip_header_complete", TypeRaw, 0}, + {17, 2, "mip_end_message", TypeRaw, 0}, + {17, 3, "mip_header_accepted", TypeRaw, 0}, + {17, 4, "mip_message_accepted", TypeRaw, 0}, + {17, 5, "mip_error", TypeList, 0}, + {17, 6, "mip_abort", TypeRaw, 0}, + {17, 7, "mip_start_block", TypeRaw, 0}, + {17, 8, "mip_end_block", TypeRaw, 0}, + {17, 9, "mip_addressee", TypeRaw, 0}, + {17, 10, "mip_subject", TypeRaw, 0}, + {17, 11, "mip_text", TypeRaw, 0}, + {17, 12, "mip_data", TypeRaw, 0}, + {17, 14, "mip_message_id", TypeRaw, 0}, + {17, 15, "mip_author", TypeRaw, 0}, + {17, 16, "mip_message_date", TypeRaw, 0}, + {17, 17, "mip_message_datestr", TypeRaw, 0}, + {17, 18, "mip_forward", TypeRaw, 0}, + {17, 19, "mip_attr_addressee_type", TypeRaw, 0}, + {17, 20, "mip_attr_data_type", TypeRaw, 0}, + {17, 21, "mip_attr_file_name", TypeRaw, 0}, + {17, 22, "mip_attr_file_size", TypeRaw, 0}, + {17, 23, "mip_attr_file_type", TypeRaw, 0}, + {17, 24, "mip_attr_file_create_date", TypeRaw, 0}, + {17, 25, "mip_attr_message_type", TypeRaw, 0}, + {17, 26, "mip_bool_return_receipt", TypeRaw, 0}, + {17, 27, "mip_attr_list_type", TypeRaw, 0}, + {17, 28, "mip_addressee_comment", TypeRaw, 0}, + {17, 29, "mip_action_command", TypeRaw, 0}, + {17, 30, "mip_set_calling_form_id", TypeRaw, 0}, + {17, 31, "mip_end_of_data", TypeRaw, 0}, + {17, 32, "mip_scheduler_mode", TypeRaw, 0}, + {17, 33, "mip_flip_it", TypeRaw, 0}, + {17, 34, "mip_edit_outbox", TypeRaw, 0}, + {17, 35, "mip_preset_form_title", TypeRaw, 0}, + {17, 36, "mip_get_active_name_count", TypeRaw, 0}, + {17, 37, "mip_is_name_active", TypeString, 0}, + {17, 38, "mip_set_name_active", TypeString, 0}, + {17, 39, "mip_clear_active_names", TypeRaw, 0}, + {17, 40, "mip_set_forward_ref", TypeDword, 0}, + {17, 41, "mip_attr_folder", TypeString, 0}, + {17, 42, "mip_abort_all", TypeRaw, 0}, + {17, 43, "mip_preset_message_id", TypeDword, 0}, + {17, 44, "mip_change_message_status", TypeDword, 0}, + {17, 45, "mip_attr_encoding_format", TypeRaw, 0}, + {17, 46, "mip_bool_everyone_invisible", TypeBool, 0}, + {17, 47, "mip_reply_to", TypeString, 0}, + {17, 48, "mip_do_not_reply_to", TypeString, 0}, + {17, 49, "mip_read_mail", TypeDword, 0}, + {17, 50, "mip_bool_will_ack", TypeBool, 0}, + {17, 51, "mip_bool_inet_quoting", TypeBool, 0}, + {17, 52, "mip_start_errors", TypeRaw, 0}, + {17, 53, "mip_end_errors", TypeRaw, 0}, + {17, 54, "mip_display_mail_form", TypeDword, 0}, + {17, 55, "mip_delete_online_lists", TypeRaw, 0}, + {17, 56, "mip_attr_message_size", TypeDword, 0}, + {17, 57, "mip_error_code", TypeDword, 0}, + {17, 58, "mip_folder_name", TypeString, 0}, + {17, 59, "mip_folder_password", TypeString, 0}, + {17, 60, "mip_transaction_type", TypeDword, 0}, + {17, 61, "mip_bool_more_to_come", TypeBool, 0}, + {17, 62, "mip_sender_id", TypeString, 0}, + {17, 63, "mip_get_next_typed", TypeDword, 0}, + {17, 64, "mip_get_prev_typed", TypeDword, 0}, + {17, 66, "mip_spell_check_send_now", TypeRaw, 0}, + {17, 67, "mip_spell_check_send_later", TypeRaw, 0}, + {17, 68, "mip_attr_embed_object", TypeRaw, 0}, + {17, 69, "mip_email_id_p1", TypeRaw, 0}, + {17, 70, "mip_email_id_p2", TypeRaw, 0}, + {17, 71, "mip_email_id_alias", TypeRaw, 0}, + {17, 72, "mip_exp_class_id", TypeType15, 0}, + {17, 73, "mip_exp_class_name", TypeString, 0}, + {17, 74, "mip_filter_active", TypeBool, 0}, + {17, 75, "mip_filter_name", TypeString, 0}, + {17, 76, "mip_filter_class_id", TypeEnum, 0}, + {17, 77, "mip_filter_number", TypeType15, 0}, + {17, 78, "mip_folder_id", TypeType15, 0}, + {17, 79, "mip_storage_class_id", TypeType15, 0}, + {17, 80, "mip_storage_class_name", TypeString, 0}, + {17, 81, "mip_uid_validity", TypeType15, 0}, + {20, 0, "mmi_open_file", TypeString, 0}, + {20, 1, "mmi_atr_toolbar", TypeBool, 0}, + {20, 2, "mmi_atr_rid_play", TypeDword, 0}, + {20, 3, "mmi_atr_rid_pause", TypeDword, 0}, + {20, 4, "mmi_atr_rid_stop", TypeDword, 0}, + {20, 5, "mmi_atr_rid_rewind", TypeDword, 0}, + {20, 6, "mmi_play", TypeRaw, 0}, + {20, 7, "mmi_pause", TypeRaw, 0}, + {20, 8, "mmi_stop", TypeRaw, 0}, + {20, 9, "mmi_rewind", TypeRaw, 0}, + {20, 10, "mmi_start_data", TypeRaw, 0}, + {20, 11, "mmi_append_data", TypeRaw, 0}, + {20, 12, "mmi_end_data", TypeRaw, 0}, + {20, 14, "mmi_atr_type", TypeDword, 0}, + {20, 15, "mmi_db_id", TypeGID, 0}, + {20, 16, "mmi_open_file_relative", TypeString, 0}, + {20, 17, "mmi_atr_rid_counter_digit", TypeDword, 0}, + {20, 18, "mmi_atr_loop", TypeDword, 0}, + {20, 19, "mmi_manage", TypeRaw, 0}, + {20, 20, "mmi_refresh_prefs", TypeRaw, 0}, + {20, 21, "mmi_set_attr_priority", TypeDword, 0}, + {20, 22, "mmi_get_attr_priority", TypeDword, 0}, + {20, 23, "mmi_xfer_data", TypeRaw, 0}, + {20, 24, "mmi_cancel_xfer", TypeRaw, 0}, + {21, 0, "imgxfer_set_context", TypeRaw, 0}, + {21, 1, "imgxfer_end_context", TypeRaw, 0}, + {21, 2, "imgxfer_set_rid", TypeRaw, 0}, + {21, 3, "imgxfer_set_gid", TypeRaw, 0}, + {21, 4, "imgxfer_attr_wait_active", TypeBool, 0}, + {21, 6, "imgxfer_is_spoolfile", TypeRaw, 0}, + {21, 7, "imgxfer_get_spoolfile_name", TypeRaw, 0}, + {21, 8, "imgxfer_preset_keep_spool", TypeBool, 0}, + {22, 0, "image_set_file_name", TypeString, 0}, + {22, 1, "image_attr_rotate", TypeRaw, 0}, + {22, 2, "image_flip_horizontal", TypeRaw, 0}, + {22, 3, "image_flip_vertical", TypeRaw, 0}, + {22, 4, "image_invert", TypeRaw, 0}, + {22, 5, "image_attr_sharpness", TypeRaw, 0}, + {22, 6, "image_attr_brightness", TypeRaw, 0}, + {22, 7, "image_attr_contrast", TypeRaw, 0}, + {22, 8, "image_attr_image_type", TypeDword, 0}, + {22, 9, "image_attr_use_suggested_size", TypeBool, 0}, + {22, 10, "image_attr_aspect_ratio", TypeBool, 0}, + {22, 11, "image_attr_dynamic_display", TypeRaw, 0}, + {22, 12, "image_get_attr", TypeRaw, 0}, + {22, 14, "image_invoke_editor", TypeRaw, 0}, + {22, 15, "image_make_gray_scale", TypeRaw, 0}, + {22, 16, "image_revert", TypeRaw, 0}, + {22, 17, "image_set_to_orginal_size", TypeRaw, 0}, + {22, 18, "image_cancel_modal", TypeRaw, 0}, + {22, 19, "image_attr_extraction_format", TypeRaw, 0}, + {22, 20, "image_attr_comp_quality", TypeRaw, 0}, + {22, 21, "image_crop_image", TypeRaw, 0}, + {22, 22, "image_attr_hotspot", TypeRaw, 0}, + {22, 23, "image_attr_hotspot_action_id", TypeRaw, 0}, + {22, 24, "image_delete_hotspot", TypeRaw, 0}, + {22, 25, "image_attr_hotspot_grid", TypeRaw, 0}, + {22, 26, "image_attr_image_cropable", TypeRaw, 0}, + {22, 27, "image_attr_draw_hotspot_grid", TypeRaw, 0}, + {22, 28, "image_attr_hotspot_def_action", TypeRaw, 0}, + {22, 29, "image_attr_show_hotspot", TypeRaw, 0}, + {22, 30, "image_attr_fit_to_view", TypeBool, 0}, + {22, 31, "image_attr_background_blend", TypeRaw, 0}, + {22, 32, "image_attr_hotspot_type", TypeRaw, 0}, + {22, 33, "image_attr_custom_hilight", TypeRaw, 0}, + {22, 34, "image_attr_hotspot_offset", TypeRaw, 0}, + {22, 35, "image_attr_hilight_type", TypeRaw, 0}, + {22, 36, "image_attr_custom_offset", TypeRaw, 0}, + {22, 37, "image_attr_file_id", TypeDword, 0}, + {22, 38, "image_attr_thumbnail", TypeBool, 0}, + {22, 39, "image_attr_save_orig_size", TypeBool, 0}, + {22, 40, "image_open_file_relative", TypeString, 0}, + {22, 41, "image_db_id", TypeDword, 0}, + {22, 42, "image_attr_scale_display", TypeDword, 0}, + {22, 43, "image_attr_scale_best_fit", TypeBool, 0}, + {23, 0, "chart_type", TypeDword, 0}, + {23, 1, "chart_xmax", TypeDword, 0}, + {23, 2, "chart_ymax", TypeDword, 0}, + {23, 3, "chart_xmin", TypeDword, 0}, + {23, 4, "chart_ymin", TypeDword, 0}, + {23, 5, "chart_scale", TypeDword, 0}, + {23, 6, "chart_set_stripe_top", TypeDword, 0}, + {23, 7, "chart_bottom_label", TypeString, 0}, + {23, 8, "chart_left_label", TypeString, 0}, + {23, 9, "chart_title", TypeString, 0}, + {23, 10, "chart_checkpoint", TypeRaw, 0}, + {23, 11, "chart_request_interval", TypeDword, 0}, + {23, 12, "chart_start_dataset", TypeDword, 0}, + {23, 14, "chart_end_dataset", TypeRaw, 0}, + {23, 15, "chart_set_dataset_context", TypeDword, 0}, + {23, 16, "chart_end_dataset_context", TypeRaw, 0}, + {23, 17, "chart_set_dataset_shape", TypeDword, 0}, + {23, 18, "chart_right_label", TypeString, 0}, + {23, 19, "chart_set_dataset_color", TypeRaw, 0}, + {23, 20, "chart_set_bar_init_value", TypeDword, 0}, + {23, 21, "chart_set_point_context", TypeDword, 0}, + {23, 22, "chart_set_point_value", TypeDword, 0}, + {23, 23, "chart_set_constant", TypeDword, 0}, + {23, 24, "chart_set_xvalue", TypeDword, 0}, + {23, 25, "chart_set_stripe_bottom", TypeDword, 0}, + {23, 26, "chart_set_ylegend_context", TypeDword, 0}, + {23, 27, "chart_set_3d_x_rotation", TypeDword, 0}, + {23, 28, "chart_set_3d_y_rotation", TypeDword, 0}, + {23, 29, "chart_set_marker_size", TypeDword, 0}, + {23, 30, "chart_set_dataset_bkcolor", TypeDword, 0}, + {23, 31, "chart_set_point_type", TypeDword, 0}, + {23, 32, "chart_set_decimals", TypeDword, 0}, + {23, 33, "chart_set_constant_bkcolor", TypeRaw, 0}, + {23, 34, "chart_set_constant_color", TypeRaw, 0}, + {23, 35, "chart_set_constant_width", TypeDword, 0}, + {23, 36, "chart_set_constant_label", TypeString, 0}, + {23, 37, "chart_set_pattern_scheme", TypeDword, 0}, + {23, 38, "chart_set_line_bkcolor", TypeRaw, 0}, + {23, 39, "chart_set_line_color", TypeRaw, 0}, + {23, 40, "chart_set_line_style", TypeDword, 0}, + {23, 41, "chart_set_line_width", TypeDword, 0}, + {23, 42, "chart_set_chart_bkcolor", TypeRaw, 0}, + {23, 43, "chart_set_bkcolor", TypeRaw, 0}, + {23, 44, "chart_title_font_sis", TypeRaw, 0}, + {23, 45, "chart_right_font_sis", TypeRaw, 0}, + {23, 46, "chart_left_font_sis", TypeRaw, 0}, + {23, 47, "chart_bottom_font_sis", TypeRaw, 0}, + {23, 48, "chart_add_dataset_legend", TypeString, 0}, + {23, 49, "chart_bool_stacked", TypeBool, 0}, + {23, 50, "chart_bool_horiz_grid", TypeBool, 0}, + {23, 51, "chart_bool_vert_grid", TypeBool, 0}, + {23, 52, "chart_bool_horiz_bar", TypeBool, 0}, + {23, 53, "chart_bool_show_tools", TypeBool, 0}, + {23, 54, "chart_bool_3d_view", TypeBool, 0}, + {23, 55, "chart_bool_show_palette", TypeBool, 0}, + {23, 56, "chart_bool_show_patterns", TypeBool, 0}, + {23, 57, "chart_bool_show_menu", TypeBool, 0}, + {23, 58, "chart_bool_show_legend", TypeBool, 0}, + {23, 59, "chart_bool_bars_together", TypeBool, 0}, + {23, 60, "chart_bool_show_points", TypeBool, 0}, + {23, 61, "chart_bool_show_zero", TypeBool, 0}, + {23, 62, "chart_bool_each_bar", TypeBool, 0}, + {23, 63, "chart_bool_cluster", TypeBool, 0}, + {23, 64, "chart_bool_showdata", TypeBool, 0}, + {23, 65, "chart_bool_dlggray", TypeBool, 0}, + {23, 66, "chart_add_ylegend_text", TypeString, 0}, + {23, 67, "chart_add_xlegend_text", TypeString, 0}, + {23, 68, "chart_set_constant_context", TypeDword, 0}, + {23, 69, "chart_set_stripe_color", TypeRaw, 0}, + {23, 70, "chart_set_stripe_context", TypeDword, 0}, + {23, 71, "chart_start_stripe", TypeDword, 0}, + {23, 72, "chart_end_stripe", TypeRaw, 0}, + {23, 73, "chart_add_key_legend_text", TypeString, 0}, + {23, 74, "chart_set_ylegend_gap", TypeDword, 0}, + {23, 75, "chart_start_constant", TypeDword, 0}, + {23, 76, "chart_end_constant", TypeDword, 0}, + {23, 77, "chart_set_constant_style", TypeDword, 0}, + {23, 78, "chart_get_attribute", TypeDword, 0}, + {23, 79, "chart_set_atom_decimal_places", TypeDword, 0}, + {23, 80, "chart_xlegend_font_sis", TypeRaw, 0}, + {23, 81, "chart_ylegend_font_sis", TypeRaw, 0}, + {23, 82, "chart_constant_font_sis", TypeRaw, 0}, + {23, 83, "chart_legend_font_sis", TypeRaw, 0}, + {23, 84, "chart_set_response_token", TypeToken, 0}, + {23, 85, "chart_atr_num_datasets", TypeDword, 0}, + {23, 86, "chart_dataset_chart_type", TypeDword, 0}, + {23, 87, "chart_set_close_token", TypeToken, 0}, + {23, 88, "chart_set_close_arg", TypeDword, 0}, + {23, 89, "chart_set_tools", TypeDword, 0}, + {23, 90, "chart_set_gallery", TypeDword, 0}, + {23, 91, "chart_set_pattern", TypeDword, 0}, + {23, 92, "chart_set_toolbar_pos", TypeDword, 0}, + {23, 93, "chart_set_legend_pos", TypeDword, 0}, + {23, 94, "chart_set_dataset_legend_pos", TypeDword, 0}, + {23, 95, "chart_bool_show_ds_legend", TypeBool, 0}, + {23, 96, "chart_mac_set_attr", TypeRaw, 0}, + {23, 97, "chart_bool_legend_2level", TypeBool, 0}, + {23, 98, "chart_bool_legend_vertical", TypeBool, 0}, + {23, 99, "chart_manage", TypeRaw, 0}, + {23, 100, "chart_set_y_inc_gap", TypeDword, 0}, + {23, 101, "chart_set_margins", TypeRaw, 0}, + {23, 102, "chart_add_date_legend_text", TypeRaw, 0}, + {24, 0, "morg_prompt_create_folder", TypeString, 0}, + {24, 1, "morg_delete_current_object", TypeRaw, 0}, + {24, 2, "morg_view_path", TypeString, 0}, + {24, 3, "morg_view_id", TypeGID, 0}, + {24, 4, "morg_obj_count_children", TypeRaw, 0}, + {24, 6, "morg_view_include_root", TypeBool, 0}, + {24, 7, "morg_prompt_rename_object", TypeRaw, 0}, + {24, 8, "morg_view_select_object", TypeRaw, 0}, + {24, 9, "morg_view_set_to_spawn_path", TypeRaw, 0}, + {24, 10, "morg_obj_destroy", TypeString, 0}, + {24, 11, "morg_manage", TypeRaw, 0}, + {24, 12, "morg_view_highlight_full_line", TypeBool, 0}, + {24, 14, "morg_view_allow_multi_select", TypeBool, 0}, + {24, 15, "morg_view_search", TypeRaw, 0}, + {24, 16, "morg_obj_destroy_children", TypeString, 0}, + {24, 17, "morg_obj_set_context", TypeString, 0}, + {24, 18, "morg_obj_end_context", TypeRaw, 0}, + {24, 19, "morg_obj_start_obj", TypeDword, 0}, + {24, 20, "morg_obj_end_obj", TypeRaw, 0}, + {24, 21, "morg_atr_title", TypeString, 0}, + {24, 22, "morg_atr_url", TypeString, 0}, + {24, 23, "morg_flag_open", TypeBool, 0}, + {24, 24, "morg_obj_start_folder", TypeString, 0}, + {24, 25, "morg_obj_start_bookmark", TypeString, 0}, + {24, 26, "morg_view_has_mult_selections", TypeRaw, 0}, + {24, 27, "morg_obj_set_context_selection", TypeRaw, 0}, + {24, 28, "morg_obj_can_delete", TypeRaw, 0}, + {24, 29, "morg_obj_can_rename", TypeRaw, 0}, + {24, 30, "morg_obj_get_class", TypeRaw, 0}, + {24, 31, "morg_jump_bookmark", TypeRaw, 0}, + {24, 32, "morg_add_bookmark", TypeString, 0}, + {24, 33, "morg_set_bookmark_url", TypeString, 0}, + {24, 34, "morg_modify_bookmark", TypeString, 0}, + {24, 35, "morg_edit_bookmark", TypeRaw, 0}, + {24, 36, "morg_finish_jump_bookmark", TypeRaw, 0}, + {24, 37, "morg_set_bookmark_close_form", TypeRaw, 0}, + {24, 38, "morg_view_allow_delete_key", TypeBool, 0}, + {24, 39, "morg_pfc_compress_database", TypeRaw, 0}, + {24, 40, "morg_jump_url", TypeString, 0}, + {24, 41, "morg_pfc_cancel_compression", TypeRaw, 0}, + {24, 42, "morg_pfc_check_db", TypeRaw, 0}, + {24, 43, "morg_pfc_check_fragment", TypeRaw, 0}, + {24, 44, "morg_obj_can_create", TypeRaw, 0}, + {24, 45, "morg_act_on_selected", TypeDword, 0}, + {24, 46, "morg_set_tab_list", TypeString, 0}, + {24, 47, "morg_obj_get_name", TypeRaw, 0}, + {24, 48, "morg_obj_set_context_by_index", TypeDword, 0}, + {24, 49, "morg_save_folder", TypeRaw, 0}, + {24, 50, "morg_view_hide_folder", TypeString, 0}, + {24, 51, "morg_view_show_folder", TypeString, 0}, + {24, 52, "morg_set_selection", TypeRaw, 0}, + {24, 53, "morg_swap_screenname", TypeString, 0}, + {24, 54, "morg_replace_screenname", TypeString, 0}, + {24, 55, "morg_add_folder", TypeString, 0}, + {24, 56, "morg_save", TypeDword, 0}, + {24, 57, "morg_restore", TypeRaw, 0}, + {24, 58, "morg_sort_items", TypeDword, 0}, + {25, 0, "rich_manage", TypeRaw, 0}, + {25, 1, "rich_edit_action", TypeDword, 0}, + {25, 2, "rich_add_url", TypeString, 0}, + {25, 3, "rich_set_color_item", TypeDword, 0}, + {25, 4, "rich_bool_read_only", TypeBool, 0}, + {25, 5, "rich_open_file", TypeString, 0}, + {25, 6, "rich_text_color", TypeRaw, 0}, + {25, 7, "rich_font_justify", TypeDword, 0}, + {25, 8, "rich_background_color", TypeRaw, 0}, + {25, 9, "rich_font_size", TypeDword, 0}, + {25, 10, "rich_font_attribute", TypeDword, 0}, + {25, 11, "rich_window_color", TypeRaw, 0}, + {25, 12, "rich_get_text_alignment", TypeRaw, 0}, + {25, 14, "rich_get_text_style", TypeRaw, 0}, + {25, 15, "rich_set_static", TypeRaw, 0}, + {25, 16, "rich_color_dialog", TypeRaw, 0}, + {25, 17, "rich_view_text_color", TypeDword, 0}, + {25, 18, "rich_view_text_background_color", TypeDword, 0}, + {25, 19, "rich_view_background_color", TypeDword, 0}, + {25, 20, "rich_font_select_face", TypeString, 0}, + {25, 21, "rich_font_select_size", TypeDword, 0}, + {25, 22, "rich_drop_picture", TypeRaw, 0}, + {25, 23, "rich_drop_link", TypeRaw, 0}, + {25, 24, "rich_get_text_font_size", TypeRaw, 0}, + {25, 25, "rich_get_font", TypeRaw, 0}, + {25, 26, "rich_allow_justify", TypeBool, 0}, + {25, 27, "rich_allow_fontsize", TypeBool, 0}, + {25, 28, "rich_allow_backcolor", TypeBool, 0}, + {25, 29, "rich_allow_fontwindow", TypeBool, 0}, + {25, 30, "rich_allow_embeds", TypeBool, 0}, + {25, 31, "rich_allow_textfile", TypeBool, 0}, + {25, 32, "rich_ignore_tabs", TypeBool, 0}, + {25, 33, "rich_allow_attributes", TypeDword, 0}, + {25, 34, "rich_image_max", TypeDword, 0}, + {25, 35, "rich_drop_back_picture", TypeRaw, 0}, + {25, 36, "rich_drop_text_file", TypeRaw, 0}, + {25, 37, "rich_scale_images", TypeBool, 0}, + {25, 38, "rich_insert_smilie", TypeRaw, 0}, + {25, 39, "rich_enable_smilie", TypeBool, 0}, + {25, 40, "rich_html_mode", TypeRaw, 0}, + {26, 0, "exapi_list_start_context", TypeDword, 0}, + {26, 1, "exapi_list_set_stream", TypeRaw, 0}, + {26, 2, "exapi_list_attr_set_style", TypeDword, 0}, + {26, 3, "exapi_list_attr_set_title", TypeString, 0}, + {26, 4, "exapi_list_attr_set_gid", TypeDword, 0}, + {26, 5, "exapi_list_item_start", TypeRaw, 0}, + {26, 6, "exapi_list_item_set_sreg", TypeDword, 0}, + {26, 7, "exapi_list_item_set_str", TypeString, 0}, + {26, 8, "exapi_list_item_set_nreg", TypeDword, 0}, + {26, 9, "exapi_list_item_set_num", TypeDword, 0}, + {26, 10, "exapi_list_item_set_freg", TypeDword, 0}, + {26, 11, "exapi_list_item_set_flag", TypeDword, 0}, + {26, 12, "exapi_list_item_set_stream", TypeRaw, 0}, + {26, 13, "exapi_list_item_set_address", TypeString, 0}, + {26, 14, "exapi_list_item_set_port", TypeDword, 0}, + {26, 15, "exapi_list_item_end", TypeRaw, 0}, + {26, 16, "exapi_list_end_context", TypeRaw, 0}, + {26, 17, "exapi_manage", TypeRaw, 0}, + {26, 18, "exapi_version_verify", TypeRaw, 0}, + {26, 19, "exapi_list_clear", TypeDword, 0}, + {26, 20, "exapi_list_item_delete", TypeDword, 0}, + {26, 21, "exapi_is_valid_version", TypeRaw, 0}, + {26, 22, "exapi_enter_anteroom", TypeRaw, 0}, + {26, 23, "exapi_leave_anteroom", TypeDword, 0}, + {26, 24, "exapi_set_selection_item", TypeDword, 0}, + {26, 25, "exapi_gain_focus", TypeDword, 0}, + {26, 26, "exapi_get_serial_info", TypeDword, 0}, + {26, 27, "exapi_set_selection_list", TypeDword, 0}, + {26, 28, "exapi_get_instance_info", TypeRaw, 0}, + {26, 29, "exapi_get_participant_list", TypeRaw, 0}, + {26, 30, "exapi_get_participant_info", TypeRaw, 0}, + {26, 31, "exapi_begin_versioning", TypeDword, 0}, + {26, 32, "exapi_component_begin", TypeRaw, 0}, + {26, 33, "exapi_component_file_id", TypeDword, 0}, + {26, 34, "exapi_component_file_size", TypeDword, 0}, + {26, 35, "exapi_component_file_date", TypeDword, 0}, + {26, 36, "exapi_component_file_offset", TypeDword, 0}, + {26, 37, "exapi_component_file_library", TypeDword, 0}, + {26, 38, "exapi_component_sysfile", TypeString, 0}, + {26, 39, "exapi_component_sysver", TypeString, 0}, + {26, 40, "exapi_component_end", TypeRaw, 0}, + {26, 41, "exapi_end_versioning", TypeRaw, 0}, + {26, 42, "exapi_delete_context", TypeDword, 0}, + {26, 43, "exapi_begin_install", TypeDword, 0}, + {26, 44, "exapi_set_default_folder_name", TypeRaw, 0}, + {26, 45, "exapi_set_required_space", TypeDword, 0}, + {26, 46, "exapi_set_config_style", TypeDword, 0}, + {26, 47, "exapi_set_program_name", TypeString, 0}, + {26, 48, "exapi_set_app_name", TypeString, 0}, + {26, 49, "exapi_end_install", TypeRaw, 0}, + {26, 50, "exapi_get_version_info", TypeDword, 0}, + {26, 51, "exapi_launch_application", TypeDword, 0}, + {26, 52, "exapi_component_total_size", TypeDword, 0}, + {26, 53, "exapi_set_setup_app_name", TypeString, 0}, + {26, 54, "exapi_component_setup_app", TypeString, 0}, + {26, 55, "exapi_component_set_flags", TypeDword, 0}, + {26, 56, "exapi_set_flags", TypeDword, 0}, + {26, 57, "exapi_component_set_id", TypeDword, 0}, + {26, 58, "exapi_move_shared_dir", TypeString, 0}, + {26, 59, "exapi_set_current_address", TypeString, 0}, + {26, 60, "exapi_uninstall_app", TypeDword, 0}, + {26, 61, "exapi_set_uninstaller_name", TypeString, 0}, + {26, 62, "exapi_app_terminate", TypeRaw, 0}, + {26, 63, "exapi_set_session_id", TypeDword, 0}, + {26, 64, "exapi_set_session_flags", TypeDword, 0}, + {26, 65, "exapi_set_platform", TypeDword, 0}, + {26, 66, "exapi_perform_versioning", TypeRaw, 0}, + {26, 67, "exapi_set_message_handler", TypeString, 0}, + {26, 90, "exapi_set_idle_interval", TypeDword, 0}, + {26, 91, "exapi_idle", TypeDword, 0}, + {26, 92, "exapi_get_ver_info_wreplytoken", TypeDword, 0}, + {26, 93, "exapi_set_reply_token", TypeString, 0}, + {27, 0, "dod_start", TypeRaw, 0}, + {27, 1, "dod_type", TypeDword, 0}, + {27, 2, "dod_gid", TypeGID, 0}, + {27, 3, "dod_form_id", TypeGID, 0}, + {27, 4, "dod_end", TypeRaw, 0}, + {27, 5, "dod_data", TypeRaw, 0}, + {27, 6, "dod_gain_focus", TypeRaw, 0}, + {27, 7, "dod_close_form", TypeRaw, 0}, + {27, 8, "dod_not_available", TypeRaw, 0}, + {27, 9, "dod_hints", TypeRaw, 0}, + {27, 10, "dod_lose_focus", TypeRaw, 0}, + {27, 11, "dod_no_hints", TypeRaw, 0}, + {27, 12, "dod_end_form", TypeRaw, 0}, + {27, 13, "dod_end_data", TypeRaw, 0}, + {27, 14, "dod_hints_no_action", TypeRaw, 0}, + {27, 15, "dod_tag", TypeRaw, 0}, + {27, 16, "dod_hints_mismatch", TypeGID, 0}, + {28, 0, "radio_codec", TypeDword, 0}, + {28, 1, "radio_atr_file_name", TypeString, 0}, + {28, 2, "radio_atr_stream_name", TypeString, 0}, + {28, 3, "radio_atr_stream_descr", TypeString, 0}, + {28, 4, "radio_atr_wave_file_name", TypeString, 0}, + {28, 5, "radio_atr_stream_source", TypeDword, 0}, + {28, 6, "radio_atr_stream_target", TypeDword, 0}, + {28, 7, "radio_start_stream", TypeRaw, 0}, + {28, 8, "radio_stop_stream", TypeRaw, 0}, + {28, 9, "radio_get_error_text", TypeRaw, 0}, + {28, 10, "radio_get_status_text", TypeRaw, 0}, + {28, 11, "radio_error_action", TypeDword, 0}, + {28, 12, "radio_status_action", TypeDword, 0}, + {28, 13, "radio_splash_artid", TypeString, 0}, + {28, 14, "radio_radmic_status", TypeRaw, 0}, + {28, 15, "radio_start_play", TypeString, 0}, + {28, 16, "radio_stop_play", TypeRaw, 0}, + {28, 17, "radio_start_action", TypeDword, 0}, + {28, 18, "radio_ready_go_live_action", TypeDword, 0}, + {28, 19, "radio_go_live_action", TypeDword, 0}, + {28, 20, "radio_go_live_request", TypeDword, 0}, + {28, 21, "radio_atr_channel", TypeString, 0}, + {28, 22, "radio_go_live_status", TypeRaw, 0}, + {28, 23, "radio_ready_go_live_status", TypeRaw, 0}, + {28, 24, "radio_play_name_action", TypeDword, 0}, + {28, 25, "radio_play_name_text", TypeRaw, 0}, + {28, 26, "radio_play_desc_action", TypeDword, 0}, + {28, 27, "radio_play_desc_text", TypeRaw, 0}, + {28, 28, "radio_play_caption_action", TypeDword, 0}, + {28, 29, "radio_play_caption_text", TypeRaw, 0}, + {28, 30, "radio_atr_caption", TypeString, 0}, + {28, 31, "radio_droppoint_object", TypeDword, 0}, + {28, 32, "radio_form_is_closing", TypeRaw, 0}, + {28, 33, "radio_pause_play", TypeRaw, 0}, + {28, 34, "radio_resume_play", TypeRaw, 0}, + {29, 0, "pictalk_manage", TypeRaw, 0}, + {29, 1, "pictalk_open_file", TypeString, 0}, + {29, 2, "pictalk_control", TypeRaw, 0}, + {29, 3, "pictalk_get_attr_style", TypeRaw, 0}, + {29, 4, "pictalk_attr_style", TypeRaw, 0}, + {29, 5, "pictalk_timeline_action", TypeRaw, 0}, + {29, 6, "pictalk_delete_timeline", TypeRaw, 0}, + {29, 7, "pictalk_attr_intl", TypeRaw, 0}, + {29, 8, "pictalk_attr_ctrl_id", TypeRaw, 0}, + {29, 9, "pictalk_attr_art_id", TypeRaw, 0}, + {29, 10, "pictalk_update_art", TypeRaw, 0}, + {29, 11, "pictalk_reset_styles", TypeRaw, 0}, + {29, 12, "pictalk_ad_manage", TypeRaw, 0}, + {30, 0, "irc_manage", TypeRaw, 0}, + {30, 1, "irc_enter", TypeDword, 0}, + {30, 2, "irc_join", TypeDword, 0}, + {30, 3, "irc_create", TypeDword, 0}, + {30, 4, "irc_user_info", TypeDword, 0}, + {31, 0, "doc_manage", TypeRaw, 0}, + {31, 1, "doc_edit_action", TypeDword, 0}, + {31, 2, "doc_add_url", TypeString, 0}, + {31, 3, "doc_set_color_item", TypeDword, 0}, + {31, 4, "doc_bool_read_only", TypeBool, 0}, + {31, 5, "doc_open_file", TypeString, 0}, + {31, 6, "doc_remove_url", TypeString, 0}, + {31, 7, "doc_get_current_url", TypeRaw, 0}, + {31, 8, "doc_get_current_link", TypeRaw, 0}, + {31, 9, "doc_set_font_name", TypeString, 0}, + {31, 10, "doc_set_font_size", TypeDword, 0}, + {31, 11, "doc_set_font_style", TypeDword, 0}, + {31, 12, "doc_clear_font_style", TypeDword, 0}, + {31, 14, "doc_set_text_alignment", TypeDword, 0}, + {31, 15, "doc_get_font_name", TypeRaw, 0}, + {31, 16, "doc_get_font_size", TypeRaw, 0}, + {31, 17, "doc_get_font_style", TypeRaw, 0}, + {31, 18, "doc_get_text_alignment", TypeRaw, 0}, + {34, 0, "ccl_dial", TypeRaw, 0}, + {34, 1, "ccl_hang_up", TypeRaw, 0}, + {34, 2, "ccl_install_modem_driver", TypeRaw, 0}, + {34, 3, "ccl_update_locality", TypeRaw, 0}, + {34, 4, "ccl_get_locality", TypeRaw, 0}, + {34, 5, "ccl_new_location", TypeRaw, 0}, + {34, 6, "ccl_translate_com_port", TypeRaw, 0}, + {34, 7, "ccl_translate_baud_rate", TypeRaw, 0}, + {34, 8, "ccl_translate_network", TypeRaw, 0}, + {34, 9, "ccl_translate_locality", TypeRaw, 0}, + {34, 10, "ccl_check_hang_up", TypeRaw, 0}, + {34, 11, "ccl_is_modem", TypeRaw, 0}, + {34, 12, "ccl_add_net_choices", TypeRaw, 0}, + {34, 14, "ccl_list_set_net", TypeDword, 0}, + {34, 15, "ccl_list_get_net", TypeRaw, 0}, + {34, 16, "ccl_reload_networks", TypeRaw, 0}, + {34, 17, "ccl_enum_com_devices", TypeRaw, 0}, + {34, 18, "ccl_cancel_enum_devices", TypeRaw, 0}, + {34, 19, "ccl_select_com_device", TypeType15, 0}, + {35, 0, "p3_start", TypeRaw, 0}, + {35, 1, "p3_stop", TypeRaw, 0}, + {35, 3, "p3_write", TypeRaw, 0}, + {35, 4, "p3_interleaved_mode", TypeRaw, 0}, + {35, 5, "p3_debug_disable_outbound", TypeDword, 0}, + {35, 6, "p3_debug_get_outbound_state", TypeRaw, 0}, + {39, 0, "ad_add", TypeRaw, 0}, + {39, 1, "ad_store", TypeRaw, 0}, + {39, 2, "ad_modify", TypeRaw, 0}, + {39, 3, "ad_set_caller", TypeRaw, 0}, + {39, 4, "ad_to", TypeRaw, 0}, + {39, 5, "ad_cc", TypeRaw, 0}, + {40, 4, "app_command", TypeDword, 0}, + {42, 0, "mt_manage_tools", TypeRaw, 0}, + {42, 1, "mt_bounce_tool", TypeDword, 0}, + {42, 2, "mt_kill_tool", TypeDword, 0}, + {42, 3, "mt_display_tool_info", TypeDword, 0}, + {42, 4, "mt_load_tool", TypeString, 0}, + {42, 5, "mt_browse_tree", TypeRaw, 0}, + {42, 6, "mt_flip_value", TypeDword, 0}, + {42, 7, "mt_test_crash", TypeDword, 0}, + {42, 8, "mt_gid_to_string", TypeGID, 0}, + {42, 9, "mt_string_to_gid", TypeString, 0}, + {42, 10, "mt_waolsock_debug", TypeDword, 0}, + {42, 11, "mt_break", TypeRaw, 0}, + {42, 12, "mt_set_spy_mode", TypeRaw, 0}, + {42, 14, "mt_set_timeout_mode", TypeRaw, 0}, + {42, 15, "mt_start_atomdebug", TypeRaw, 0}, + {42, 16, "mt_end_atomdebug", TypeRaw, 0}, + {42, 17, "mt_open_diag", TypeRaw, 0}, + {42, 18, "mt_delete_art_in_top_form", TypeRaw, 0}, + {42, 19, "mt_hilight_groups_in_top_form", TypeRaw, 0}, + {42, 20, "mt_play_text", TypeRaw, 0}, + {42, 21, "mt_play_binary", TypeRaw, 0}, + {42, 22, "mt_database", TypeRaw, 0}, + {42, 23, "mt_start_edit_text", TypeRaw, 0}, + {42, 24, "mt_super_snoop", TypeRaw, 0}, + {47, 0, "vrm_start_form", TypeDword, 0}, + {47, 1, "vrm_send_form", TypeRaw, 0}, + {47, 2, "vrm_save_form", TypeRaw, 0}, + {47, 3, "vrm_action_command", TypeDword, 0}, + {47, 4, "vrm_start_html_form", TypeGID, 0}, + {47, 5, "vrm_form_up", TypeDword, 0}, + {47, 6, "vrm_html_get_wiz", TypeRaw, 0}, + {47, 7, "vrm_html_start_wiz", TypeDword, 0}, + {47, 8, "vrm_html_finish_wiz", TypeDword, 0}, + {47, 9, "vrm_am_get_spawn_path", TypeDword, 0}, + {47, 10, "vrm_html_get_spawn_path", TypeDword, 0}, + {47, 11, "vrm_html_get_spawn_file", TypeDword, 0}, + {47, 12, "vrm_html_form_up", TypeGID, 0}, + {47, 13, "vrm_aat_art_start_result", TypeRaw, FlagIndent}, + {47, 14, "vrm_aat_art_end_result", TypeRaw, FlagOutdent}, + {47, 15, "vrm_aat_art_gid", TypeGID, 0}, + {47, 16, "vrm_aat_art_name", TypeString, 0}, + {47, 17, "vrm_aat_art_return_code", TypeEnum, 0}, + {47, 18, "vrm_aat_art_image_id", TypeDword, 0}, + {47, 19, "vrm_aat_art_size_x", TypeDword, 0}, + {47, 20, "vrm_aat_art_size_y", TypeDword, 0}, + {47, 21, "vrm_aat_art_length", TypeDword, 0}, + {47, 22, "vrm_aat_art_modified_by", TypeString, 0}, + {47, 23, "vrm_aat_art_modified_date", TypeString, 0}, + {47, 24, "vrm_aat_art_format", TypeEnum, 0}, + {47, 25, "vrm_aat_art_type", TypeEnum, 0}, + {47, 26, "vrm_aat_art_plus_group", TypeDword, 0}, + {47, 27, "vrm_aat_art_dest_gid", TypeGID, 0}, + {47, 28, "vrm_aat_art_trigger_form_id", TypeGID, 0}, + {47, 29, "vrm_aat_art_exit_free_pay_curtain", TypeEnum, 0}, + {47, 30, "vrm_aat_art_repository", TypeEnum, 0}, + {47, 31, "vrm_set_context", TypeDword, 0}, + {47, 32, "vrm_aat_query_start_result", TypeDword, FlagIndent}, + {47, 33, "vrm_aat_query_end_result", TypeDword, FlagOutdent}, + {47, 34, "vrm_aat_art_exp_date", TypeString, 0}, + {47, 35, "vrm_aat_set_obj_context", TypeDword, 0}, + {47, 36, "vrm_aat_start_record", TypeDword, 0}, + {47, 37, "vrm_aat_end_record", TypeDword, 0}, + {47, 38, "vrm_aat_art_ownership", TypeEnum, 0}, + {47, 60, "vrm_generic_query", TypeDword, 0}, + {47, 61, "vrm_html_preset_miniicon", TypeGID, 0}, + {47, 62, "vrm_html_preset_editform", TypeGID, 0}, + {47, 63, "vrm_choose_art_id", TypeGID, 0}, + {47, 64, "vrm_bool_object_needs_update", TypeBool, 0}, + {47, 65, "vrm_finalize_objects", TypeDword, 0}, + {47, 66, "vrm_start_form_info", TypeString, 0}, + {47, 67, "vrm_html_set_domain", TypeString, 0}, + {47, 68, "vrm_extract_result", TypeDword, 0}, + {47, 69, "vrm_extract_saved_result", TypeDword, 0}, + {47, 70, "vrm_rainman_host_min", TypeRaw, 0}, + {47, 72, "vrm_start_rainman", TypeRaw, 0}, + {47, 73, "vrm_end_rainman", TypeRaw, 0}, + {47, 74, "vrm_rainman_error_code", TypeRaw, 0}, + {47, 75, "vrm_rainman_data", TypeRaw, 0}, + {47, 76, "vrm_fdo_datablock", TypeStream, FlagIndent | FlagOutdent}, + {48, 0, "www_load_url", TypeString, 0}, + {48, 1, "www_go_back", TypeRaw, 0}, + {48, 2, "www_go_forward", TypeRaw, 0}, + {48, 3, "www_reload", TypeRaw, 0}, + {48, 4, "www_stop", TypeRaw, 0}, + {48, 5, "www_get_current_url", TypeRaw, 0}, + {48, 6, "www_get_current_link", TypeRaw, 0}, + {48, 7, "www_get_parts_complete", TypeRaw, 0}, + {48, 8, "www_can_go_back", TypeRaw, 0}, + {48, 9, "www_can_go_forward", TypeRaw, 0}, + {48, 14, "www_get_current_title", TypeRaw, 0}, + {48, 15, "www_browse", TypeString, 0}, + {48, 16, "www_manage", TypeRaw, 0}, + {48, 20, "www_refresh_prefs", TypeRaw, 0}, + {48, 21, "www_purge_cache", TypeRaw, 0}, + {48, 22, "www_get_status_msg", TypeRaw, 0}, + {48, 23, "www_bool_suppress_errors", TypeRaw, 0}, + {48, 24, "www_invoke_options", TypeRaw, 0}, + {48, 25, "www_get_current_full_url", TypeRaw, 0}, + {48, 26, "www_display_3dbevel", TypeBool, 0}, + {51, 0, "hfs_attr_field_mapping", TypeList, 0}, + {51, 1, "hfs_cmd_form_gid", TypeGID, 0}, + {51, 2, "hfs_cmd_form_name", TypeString, 0}, + {51, 3, "hfs_attr_preset_global_id", TypeGID, 0}, + {51, 4, "hfs_attr_style_id", TypeGID, 0}, + {51, 5, "hfs_attr_cluster_id", TypeGID, 0}, + {51, 6, "hfs_attr_flags", TypeEnum, 0}, + {51, 7, "hfs_cmd_fdo", TypeStream, 0}, + {51, 8, "hfs_cmd_tag", TypeDword, 0}, + {51, 9, "hfs_cmd_database_id", TypeEnum, 0}, + {51, 10, "hfs_cmd_result_code", TypeDword, 0}, + {51, 11, "hfs_cmd_save_as", TypeRaw, 0}, + {51, 12, "hfs_attr_start_pre_stream", TypeRaw, FlagIndent}, + {51, 13, "hfs_attr_end_pre_stream", TypeRaw, FlagOutdent}, + {51, 14, "hfs_attr_start_in_stream", TypeRaw, FlagIndent}, + {51, 15, "hfs_attr_end_in_stream", TypeRaw, FlagOutdent}, + {51, 16, "hfs_attr_start_post_stream", TypeRaw, FlagIndent}, + {51, 17, "hfs_attr_end_post_stream", TypeRaw, FlagOutdent}, + {51, 18, "hfs_cmd_start_form_data", TypeRaw, 0}, + {51, 19, "hfs_cmd_end_form_data", TypeRaw, 0}, + {51, 20, "hfs_cmd_start_save_result", TypeRaw, 0}, + {51, 21, "hfs_cmd_end_save_result", TypeRaw, 0}, + {51, 22, "hfs_cmd_start_get_fdo", TypeRaw, 0}, + {51, 23, "hfs_cmd_end_get_fdo", TypeRaw, FlagIndent}, + {51, 24, "hfs_cmd_start_install_result", TypeRaw, FlagOutdent}, + {51, 25, "hfs_cmd_end_install_result", TypeRaw, 0}, + {51, 26, "hfs_cmd_result_message", TypeRaw, 0}, + {51, 27, "hfs_cmd_response_id", TypeDword, 0}, + {51, 28, "hfs_attr_variable_mapping", TypeList, 0}, + {51, 29, "hfs_attr_dispatch_mapping", TypeList, 0}, + {51, 30, "hfs_attr_checkbox_mapping", TypeList, 0}, + {51, 31, "hfs_attr_database_type", TypeEnum, 0}, + {51, 32, "hfs_cmd_reference_id", TypeDword, 0}, + {51, 33, "hfs_cmd_template_name", TypeString, 0}, + {51, 34, "hfs_attr_object_comment", TypeString, 0}, + {51, 35, "hfs_attr_object_name", TypeString, 0}, + {51, 36, "hfs_attr_fdo_comment", TypeString, 0}, + {51, 37, "hfs_attr_plus_group_number", TypeDword, 0}, + {51, 38, "hfs_attr_plus_group_type", TypeEnum, 0}, + {51, 39, "hfs_attr_layer_name", TypeString, 0}, + {51, 40, "hfs_cmd_read_only_form", TypeBool, 0}, + {51, 41, "hfs_attr_server_name", TypeString, 0}, + {51, 42, "hfs_cmd_access_rights", TypeRaw, 0}, + {51, 43, "hfs_attr_end_object", TypeRaw, FlagOutdent}, + {51, 44, "hfs_attr_object_flags", TypeEnum, 0}, + {51, 45, "hfs_cmd_command", TypeEnum, 0}, + {51, 46, "hfs_cmd_position", TypeEnum, 0}, + {51, 47, "hfs_cmd_platform", TypeString, 0}, + {51, 48, "hfs_cmd_view_rule", TypeString, 0}, + {51, 49, "hfs_cmd_language", TypeString, 0}, + {51, 50, "hfs_cmd_start_result", TypeEnum, 0}, + {51, 51, "hfs_cmd_end_result", TypeEnum, 0}, + {51, 52, "hfs_cmd_process_mode", TypeEnum, 0}, + {51, 53, "hfs_cmd_start_atoms", TypeList, 0}, + {51, 54, "hfs_cmd_atoms", TypeRaw, 0}, + {51, 55, "hfs_cmd_end_atoms", TypeRaw, 0}, + {51, 56, "hfs_attr_start_raw_display", TypeRaw, 0}, + {51, 57, "hfs_attr_end_raw_display", TypeRaw, 0}, + {52, 0, "blank_test", TypeRaw, 0}, + {52, 1, "blank_get_form", TypeGID, 0}, + {52, 2, "blank_get_ver", TypeRaw, 0}, + {53, 0, "vid_capture", TypeRaw, 0}, + {53, 1, "vid_send", TypeRaw, 0}, + {53, 2, "vid_manage", TypeRaw, 0}, + {53, 3, "vid_preview", TypeDword, 0}, + {53, 4, "vid_repeat_send", TypeDword, 0}, + {53, 5, "vid_set_token", TypeRaw, 0}, + {53, 6, "vid_set_udp", TypeRaw, 0}, + {53, 7, "vid_set_tcp", TypeRaw, 0}, + {53, 8, "vid_receive", TypeDword, 0}, + {53, 9, "vid_activate_capture", TypeRaw, 0}, + {53, 10, "vid_can_preview", TypeRaw, 0}, + {53, 11, "vid_set_format", TypeRaw, 0}, + {53, 12, "vid_receive_enable", TypeDword, 0}, + {53, 13, "vid_is_available", TypeRaw, 0}, + {53, 14, "vid_prev_count", TypeRaw, 0}, + {53, 15, "vid_next_count", TypeRaw, 0}, + {53, 16, "vid_show_prev", TypeRaw, 0}, + {53, 17, "vid_show_next", TypeRaw, 0}, + {53, 18, "vid_show_oldest", TypeRaw, 0}, + {53, 19, "vid_show_newest", TypeRaw, 0}, + {53, 20, "vid_flag_setup", TypeRaw, 0}, + {53, 21, "vid_setup", TypeRaw, 0}, + {53, 22, "vid_open", TypeRaw, 0}, + {53, 23, "vid_save_as", TypeRaw, 0}, + {53, 24, "vid_setup_popup", TypeDword, 0}, + {53, 25, "vid_get_data", TypeDword, 0}, + {53, 26, "vid_enable_extract", TypeBool, 0}, + {53, 27, "vid_query_setup", TypeDword, 0}, + {53, 28, "vid_store_setup", TypeDword, 0}, +} diff --git a/internal/aol/fdo/compile.go b/internal/aol/fdo/compile.go new file mode 100644 index 0000000..b5bfee9 --- /dev/null +++ b/internal/aol/fdo/compile.go @@ -0,0 +1,244 @@ +package fdo + +import ( + "fmt" + "strings" +) + +// CompileError is an atom the compiler couldn't encode. +type CompileError struct { + Line int + Atom string + Msg string +} + +func (e *CompileError) Error() string { + return fmt.Sprintf("fdo: line %d: %s: %s", e.Line, e.Atom, e.Msg) +} + +// Compile compiles FDO91 source to an atom stream, byte for byte as AOL's +// Ada32.dll does. +func Compile(src string) ([]byte, error) { + frames, err := CompileFrames(src) + if err != nil { + return nil, err + } + return Encode(frames), nil +} + +// MustCompile is Compile for source known when the program is written. +func MustCompile(src string) []byte { + b, err := Compile(src) + if err != nil { + panic(err) + } + return b +} + +// CompileFrames compiles source to its atoms, not yet encoded. +func CompileFrames(src string) ([]Frame, error) { + nodes, err := Parse(src) + if err != nil { + return nil, err + } + return NodesFrames(nodes) +} + +// NodesFrames compiles parsed atoms. +func NodesFrames(nodes []*Node) ([]Frame, error) { + out := make([]Frame, 0, len(nodes)) + for _, n := range nodes { + f, err := nodeFrame(n) + if err != nil { + return nil, err + } + out = append(out, f) + } + return out, nil +} + +func nodeFrame(n *Node) (Frame, error) { + fail := func(format string, a ...any) (Frame, error) { + return Frame{}, &CompileError{n.Line, n.Name, fmt.Sprintf(format, a...)} + } + if n.Name == "the_unknown" { + args := n.Args + if len(args) < 2 || args[0].Kind != KindNum || args[1].Kind != KindNum || + args[0].Num < 0 || args[0].Num > 127 || args[1].Num < 0 || args[1].Num > 255 { + return fail("needs ") + } + var d []byte + for _, v := range args[2:] { + b, err := rawValue(v) + if err != nil { + return fail("%v", err) + } + d = append(d, b...) + } + return Frame{uint8(args[0].Num), uint8(args[1].Num), nonNil(d)}, nil + } + a, ok := Lookup(n.Name) + if !ok { + return fail("unrecognized atom") + } + d, err := encodeArgs(a, n.Args) + if err != nil { + return fail("%v", err) + } + if len(d) > 0xFFFF { + return fail("argument is %d bytes; the most is 65535", len(d)) + } + return Frame{a.Proto, a.Num, nonNil(d)}, nil +} + +func nonNil(b []byte) []byte { + if b == nil { + return []byte{} + } + return b +} + +// rawValue is a the_unknown byte: hex, a number (one byte) or a string. +func rawValue(v Value) ([]byte, error) { + switch v.Kind { + case KindHex, KindString: + return v.Bytes, nil + case KindNum: + return []byte{byte(v.Num)}, nil + } + return nil, fmt.Errorf("the_unknown data must be hex, numbers or strings") +} + +// number is n big-endian in as few bytes as it needs (at least one). +func number(n int64) []byte { + u := uint32(n) + if n < 0 { + u = uint32(int32(n)) + } + switch { + case u <= 0xFF: + return []byte{byte(u)} + case u <= 0xFFFF: + return []byte{byte(u >> 8), byte(u)} + case u <= 0xFFFFFF: + return []byte{byte(u >> 16), byte(u >> 8), byte(u)} + } + return []byte{byte(u >> 24), byte(u >> 16), byte(u >> 8), byte(u)} +} + +// fixed is n big-endian in w bytes. +func fixed(n int64, w int) []byte { + b := make([]byte, w) + for i := w - 1; i >= 0; i-- { + b[i] = byte(n) + n >>= 8 + } + return b +} + +// gidNumber is a global id as a number: a-b is a<<16|b, a-b-c a<<24|b<<16|c. +func gidNumber(g []int64) int64 { + if len(g) == 2 { + return g[0]<<16 | g[1]&0xFFFF + } + return g[0]<<24 | (g[1]&0xFF)<<16 | g[2]&0xFFFF +} + +// encodeArgs encodes an atom's argument. +func encodeArgs(a *Atom, args []Value) ([]byte, error) { + if len(args) == 0 { + return nil, nil + } + var out []byte + for i, v := range args { + b, err := encodeValue(a, i, v) + if err != nil { + return nil, err + } + out = append(out, b...) + } + return out, nil +} + +// encodeValue encodes the i'th value of an atom's argument. +func encodeValue(a *Atom, i int, v Value) ([]byte, error) { + switch v.Kind { + case KindHex, KindString: + return v.Bytes, nil + case KindNum: + if w := numWidth(a, i); w > 0 { + return fixed(v.Num, w), nil + } + n := v.Num + if n > 0x7FFFFFFF { + n = 0x7FFFFFFF + } + return number(n), nil + case KindGID: + if len(v.GID) == 2 && v.GID[0] == 0 && isTokenType(a) { + return fixed(v.GID[1], 2), nil + } + return number(gidNumber(v.GID)), nil + case KindWord: + return encodeWord(a, i, v.Text) + case KindPipe: + var or uint64 + width := 0 + for _, p := range v.Parts { + var b []byte + var err error + switch p.Kind { + case KindWord: + b, err = encodeWord(a, i, p.Text) + case KindNum, KindHex: + b, err = encodeValue(a, i, p) + default: + err = fmt.Errorf("only words and numbers can be or'd") + } + if err != nil { + return nil, err + } + var n uint64 + for _, c := range b { + n = n<<8 | uint64(c) + } + or |= n + width = max(width, len(b)) + } + if w := pipeWidth(a); w > 0 { + width = w + } + return fixed(int64(or), width), nil + case KindStream: + frames, err := NodesFrames(v.Stream) + if err != nil { + return nil, err + } + return Encode(frames), nil + } + return nil, fmt.Errorf("bad value") +} + +func isTokenType(a *Atom) bool { return a.Type == TypeToken } + +// encodeWord encodes a word: one of the atom's named values, yes or no, a +// variable letter, or an atom's name. +func encodeWord(a *Atom, i int, w string) ([]byte, error) { + lw := strings.ToLower(w) + if b, ok := enumValue(a, i, lw); ok { + return b, nil + } + switch lw { + case "yes", "true": + return []byte{1}, nil + case "no", "false": + return []byte{0}, nil + } + if len(w) == 1 && w[0] >= 'A' && w[0] <= 'Z' { + return []byte{w[0] - 'A'}, nil + } + if r, ok := Lookup(lw); ok { + return []byte{r.Proto, r.Num}, nil + } + return nil, fmt.Errorf("unknown word %q", w) +} diff --git a/internal/aol/fdo/corpus_test.go b/internal/aol/fdo/corpus_test.go new file mode 100644 index 0000000..2c1ab48 --- /dev/null +++ b/internal/aol/fdo/corpus_test.go @@ -0,0 +1,239 @@ +package fdo + +import ( + "bufio" + "bytes" + "fmt" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "testing" +) + +// The corpus tests run against AtomForge's golden files (MIT License: +// LICENSE.atomforge): FDO91 source and what Ada32.dll compiled it to. +// testdata/golden holds 93 of its 1,889 forms, chosen to have as many +// different atoms as they can, and testdata/livecapture 44 streams captured +// from a live client; FDO_CORPUS names the directory with all of them +// (atomforge-fdo-java/src/test/resources/golden), and the master list of +// 74,369 single atoms that is there too. +func corpusDir() string { + if d := os.Getenv("FDO_CORPUS"); d != "" { + return d + } + return "testdata/golden" +} + +func corpusPairs(t *testing.T) []string { + files, _ := filepath.Glob(filepath.Join(corpusDir(), "*.txt")) + live, _ := filepath.Glob("testdata/livecapture/*.txt") + files = append(files, live...) + var out []string + for _, f := range files { + base := strings.TrimSuffix(f, ".txt") + if _, err := os.Stat(base + ".bin"); err == nil { + out = append(out, base) + } + } + if len(out) == 0 { + t.Skip("no corpus") + } + return out +} + +func firstDiff(a, b []byte) int { + for i := 0; i < len(a) && i < len(b); i++ { + if a[i] != b[i] { + return i + } + } + return min(len(a), len(b)) +} + +// TestCorpusCompile compiles each source and checks it against Ada32's bytes. +func TestCorpusCompile(t *testing.T) { + bad := 0 + for _, base := range corpusPairs(t) { + src, _ := os.ReadFile(base + ".txt") + want, _ := os.ReadFile(base + ".bin") + got, err := Compile(string(src)) + if err != nil { + bad++ + if bad <= 20 { + t.Errorf("%s: %v", filepath.Base(base), err) + } + continue + } + if !bytes.Equal(got, want) { + bad++ + if bad <= 20 { + i := firstDiff(got, want) + t.Errorf("%s: differs at %d: got % x, want % x", filepath.Base(base), i, + got[max(0, i-8):min(len(got), i+16)], want[max(0, i-8):min(len(want), i+16)]) + } + } + } + if bad > 0 { + t.Errorf("%d files differ", bad) + } +} + +// TestCorpusRoundTrip decodes each binary, decompiles it and compiles the +// text again: the bytes must come back the same. +func TestCorpusRoundTrip(t *testing.T) { + bad := 0 + for _, base := range corpusPairs(t) { + want, _ := os.ReadFile(base + ".bin") + src, err := Decompile(want) + if err == nil { + var got []byte + got, err = Compile(src) + if err == nil && !bytes.Equal(got, want) { + i := firstDiff(got, want) + err = fmt.Errorf("differs at %d: got % x, want % x", i, + got[max(0, i-8):min(len(got), i+16)], want[max(0, i-8):min(len(want), i+16)]) + } + } + if err != nil { + bad++ + if bad <= 20 { + t.Errorf("%s: %v", filepath.Base(base), err) + } + } + } + if bad > 0 { + t.Errorf("%d files don't round-trip", bad) + } +} + +// TestCorpusDecompile counts how many decompiled files read as their +// source does (the text, not just the bytes), indentation aside. +func TestCorpusDecompile(t *testing.T) { + same, n := 0, 0 + lines, sameLines := 0, 0 + diffs := map[string]int{} + ex := map[string]string{} + for _, base := range corpusPairs(t) { + bin, _ := os.ReadFile(base + ".bin") + want, _ := os.ReadFile(base + ".txt") + got, err := Decompile(bin) + if err != nil { + continue + } + n++ + if trimLines(got) == trimLines(string(want)) { + same++ + } + g := strings.Split(strings.TrimRight(got, "\n"), "\n") + w := strings.Split(strings.TrimRight(string(want), "\n"), "\n") + if len(g) != len(w) { + continue + } + for i := range w { + lines++ + g[i], w[i] = strings.TrimSpace(g[i]), strings.TrimSpace(w[i]) + if g[i] == w[i] { + sameLines++ + continue + } + name := strings.Fields(w[i])[0] + diffs[name]++ + ex[name] = fmt.Sprintf("got %q want %q", strings.TrimSpace(g[i]), strings.TrimSpace(w[i])) + } + } + t.Logf("%d of %d files, %d of %d lines read as their source", same, n, sameLines, lines) + type kv struct { + k string + v int + } + var kvs []kv + for k, v := range diffs { + kvs = append(kvs, kv{k, v}) + } + sort.Slice(kvs, func(i, j int) bool { return kvs[i].v > kvs[j].v }) + for i, e := range kvs { + if i >= 25 || !testing.Verbose() { + break + } + t.Logf("%6d %s: %s", e.v, e.k, ex[e.k]) + } +} + +// TestMasterAtomList compiles AtomForge's list of 74,000 single atoms, +// each as Ada32 compiled it (or refused to). +func TestMasterAtomList(t *testing.T) { + dir := corpusDir() + src, err := os.ReadFile(filepath.Join(dir, "master_atom_list.fdo")) + if err != nil { + t.Skip("no master_atom_list") + } + bin, _ := os.ReadFile(filepath.Join(dir, "master_atom_list.bin")) + idx, _ := os.Open(filepath.Join(dir, "master_atom_list.idx")) + defer idx.Close() + lines := strings.Split(string(src), "\n") + sc := bufio.NewScanner(idx) + sc.Buffer(nil, 1<<20) + bad, n, refused := 0, 0, 0 + perAtom := map[string]int{} + ex := map[string]string{} + for sc.Scan() { + l := sc.Text() + if strings.HasPrefix(l, "#") || l == "" { + continue + } + f := strings.SplitN(l, ",", 3) + if f[0] == "E" { + refused++ + continue + } + ln, _ := strconv.Atoi(f[0]) + off, _ := strconv.Atoi(f[1]) + size, _ := strconv.Atoi(f[2]) + want := bin[off : off+size] + line := lines[ln-1] + n++ + got, err := Compile(line) + if err == nil && !bytes.Equal(got, want) { + err = fmt.Errorf("got % x, want % x", got, want) + } + if err != nil { + bad++ + name := strings.Fields(line)[0] + perAtom[name]++ + if _, ok := ex[name]; !ok { + ex[name] = fmt.Sprintf("%.120s: %.200v", strings.TrimSpace(line), err) + } + } + } + type kv struct { + k string + v int + } + var kvs []kv + for k, v := range perAtom { + kvs = append(kvs, kv{k, v}) + } + sort.Slice(kvs, func(i, j int) bool { return kvs[i].v > kvs[j].v }) + for i, e := range kvs { + if i >= 60 { + break + } + t.Errorf("%5d %s", e.v, ex[e.k]) + } + if bad > 0 { + t.Errorf("%d of %d atoms differ (%d refused by Ada32, skipped)", bad, n, refused) + } + t.Logf("%d atoms compiled (%d refused by Ada32, skipped)", n, refused) +} + +// trimLines is s without its indentation, which Ada32's disassembler +// doesn't keep consistently. +func trimLines(s string) string { + l := strings.Split(strings.TrimSpace(s), "\n") + for i := range l { + l[i] = strings.TrimSpace(l[i]) + } + return strings.Join(l, "\n") +} diff --git a/internal/aol/fdo/decompile.go b/internal/aol/fdo/decompile.go new file mode 100644 index 0000000..6d59ae6 --- /dev/null +++ b/internal/aol/fdo/decompile.go @@ -0,0 +1,174 @@ +package fdo + +import ( + "bytes" + "fmt" + "strconv" + "strings" +) + +// Decompile turns an atom stream back into FDO91 source. Compiling the +// text gives the same bytes back: where an argument has no nicer form that +// does, it is shown as hex. +func Decompile(b []byte) (string, error) { + frames, err := Decode(b) + if err != nil { + return "", err + } + var sb strings.Builder + writeFrames(&sb, frames, 0) + return sb.String(), nil +} + +// DecompileFrames is Decompile for frames already decoded. +func DecompileFrames(frames []Frame) string { + var sb strings.Builder + writeFrames(&sb, frames, 0) + return sb.String() +} + +func writeFrames(sb *strings.Builder, frames []Frame, depth int) { + writeStream(sb, frames, depth, false) +} + +// writeStream writes atoms a line each, indented by objects and streams as +// Ada32 lays them out; a nested stream goes in < and >, four spaces in. +func writeStream(sb *strings.Builder, frames []Frame, depth int, nested bool) { + for _, f := range frames { + a, known := f.Atom() + var fl Flags + if known && a.Type != TypeStream && (a.Proto == ProtoUNI || a.Flags&FlagEOS == 0) && + !(nested && a.Proto == ProtoUNI) { + fl = a.Flags + } + if fl&FlagOutdent != 0 && depth > 0 { + depth-- + } + indent := strings.Repeat(" ", depth) + sb.WriteString(indent) + vals := frameValues(f) + if !known { + sb.WriteString("the_unknown") + } else { + sb.WriteString(a.Name) + } + if len(vals) == 1 && vals[0].Kind == KindStream { + inner := strings.Repeat(" ", depth+2) + sb.WriteString("\n" + inner + "<\n") + writeStream(sb, vals[0].streamFrames, depth+2, true) + sb.WriteString(inner + ">\n") + } else { + if len(vals) > 0 { + sb.WriteString(" <") + if known && a.Type == TypeVarString && len(vals) == 2 { + // as Ada32 writes it: + writeValue(sb, vals[0]) + sb.WriteString(",") + writeValue(sb, vals[1]) + } else { + writeValues(sb, vals) + } + sb.WriteString(">") + } + sb.WriteString("\n") + } + if fl&FlagIndent != 0 { + depth++ + } + } +} + +func writeValues(sb *strings.Builder, vals []Value) { + for i, v := range vals { + if i > 0 { + sb.WriteString(", ") + } + writeValue(sb, v) + } +} + +func writeValue(sb *strings.Builder, v Value) { + switch v.Kind { + case KindNum: + sb.WriteString(strconv.FormatInt(v.Num, 10)) + case KindHex: + for i, c := range v.Bytes { + if i > 0 { + sb.WriteString(", ") + } + fmt.Fprintf(sb, "%02xx", c) + } + case KindString: + sb.WriteString(quote(v.Bytes)) + case KindWord: + sb.WriteString(v.Text) + case KindGID: + for i, n := range v.GID { + if i > 0 { + sb.WriteByte('-') + } + sb.WriteString(strconv.FormatInt(n, 10)) + } + case KindPipe: + for i, p := range v.Parts { + if i > 0 { + sb.WriteString(" | ") + } + writeValue(sb, p) + } + } +} + +// quote writes b as a string: printable ASCII as it is, the rest escaped. +func quote(b []byte) string { + var sb strings.Builder + sb.WriteByte('"') + for _, c := range b { + switch { + case c == '\\': + sb.WriteString(`\\`) + case c == '"': + sb.WriteString(`\"`) + case c == '\r': + sb.WriteString(`\r`) + case c == '\n': + sb.WriteString(`\n`) + case c == '\t': + sb.WriteString(`\t`) + case c >= 0x20 && c < 0x7F: + sb.WriteByte(c) + default: + fmt.Fprintf(&sb, `\x%02x`, c) + } + } + sb.WriteByte('"') + return sb.String() +} + +// hexValue is data as hex bytes, which always compile back to themselves. +func hexValue(d []byte) []Value { return []Value{{Kind: KindHex, Bytes: d}} } + +// frameValues is the argument the decompiler shows for f: its nicest form +// that compiles back to f's data. +func frameValues(f Frame) []Value { + a, ok := f.Atom() + if !ok { + vals := []Value{{Kind: KindNum, Num: int64(f.Proto)}, {Kind: KindNum, Num: int64(f.Num)}} + if len(f.Data) > 0 { + vals = append(vals, Value{Kind: KindHex, Bytes: f.Data}) + } + return vals + } + if len(f.Data) == 0 { + return nil + } + for _, vals := range candidates(a, f.Data) { + if len(vals) == 1 && vals[0].Kind == KindStream { + return vals + } + if b, err := encodeArgs(a, vals); err == nil && bytes.Equal(b, f.Data) { + return vals + } + } + return hexValue(f.Data) +} diff --git a/internal/aol/fdo/enums.go b/internal/aol/fdo/enums.go new file mode 100644 index 0000000..ea9a9e3 --- /dev/null +++ b/internal/aol/fdo/enums.go @@ -0,0 +1,333 @@ +package fdo + +import ( + "fmt" + "strings" +) + +// The named values atoms take: mat_position's center_center, a +// man_start_object's trigger. From the FDO91 manual where it gives them, +// AtomForge's compiler (MIT License: LICENSE.atomforge) for the rest, and +// all checked against what Ada32.dll compiles them to (the corpus tests). + +type namedValue struct { + name string + val uint32 +} + +// enum is a set of named values: their width in bytes, and whether they +// are flags to be or'd together. The first name of a value is the one the +// decompiler writes. +type enum struct { + width int + flags bool // or'd together + desc bool // the decompiler writes the biggest first + vals []namedValue +} + +func (e *enum) value(w string) (uint32, bool) { + for _, v := range e.vals { + if strings.TrimPrefix(v.name, "~") == w { + return v.val, true + } + } + return 0, false +} + +// name is the name the decompiler writes for v; a name written ~name is +// one the compiler takes but Ada32's disassembler doesn't write. +func (e *enum) name(v uint32) (string, bool) { + for _, nv := range e.vals { + if nv.val == v && nv.name[0] != '~' { + return nv.name, true + } + } + return "", false +} + +func nv(pairs ...any) []namedValue { + out := make([]namedValue, 0, len(pairs)/2) + for i := 0; i < len(pairs); i += 2 { + out = append(out, namedValue{pairs[i].(string), uint32(pairs[i+1].(int))}) + } + return out +} + +var ( + // object types (FDO91 manual, man_start_object) + enumObject = &enum{width: 1, vals: nv( + "org_group", 0, "ind_group", 1, "dms_list", 2, "sms_list", 3, + "dss_list", 4, "sss_list", 5, "trigger", 6, "ornament", 7, + "view", 8, "edit_view", 9, "boolean", 10, "select_boolean", 11, + "range", 12, "select_range", 13, "variable", 14, "bad_object", 15, + "root", 16, "tool_group", 17, "tab_group", 18, "tab_page", 19, + "pictalk", 20, "www", 21, "split", 22, "organizer", 23, "tree", 24, + "tab", 25, "progress", 26, "toolbar", 27, "slider", 28, + // other names for the same + "group", 0, "independent", 1, "dynamic_multi_list", 2, + "static_multi_list", 3, "dynamic_list", 4, "static_list", 5, + "editable_view", 9, "selectable_boolean", 11, "selectable_range", 13, + "ruler", 15, "popup_menu", 16, "rich_text", 17, "multimedia", 18, + "chart", 19)} + + // action criteria (FDO91 manual, act_set_criterion) + enumCriterion = &enum{width: 1, vals: nv( + "void", 0, "select", 1, "close", 2, "~open", 3, "gain_focus", 4, + "lose_focus", 5, "~cancel", 6, "~enter_free", 7, "~enter_paid", 8, + "~create", 9, "~set_online", 10, "~set_offline", 11, "~restore", 12, + "~minimize", 14, "~restore_from_maximize", 15, "~restore_from_minimize", 16, + "~timeout", 17, "~screen_name_changed", 18, "~movie_over", 19, "~drop", 20, + "~url_drop", 21, "~user_delete", 22, "~toggle_up", 23, "~activated", 24, + "~deactivated", 25, "~popupmenu", 26, "~destroyed", 27, + "~selection", 1)} + + enumAlert = &enum{width: 1, vals: nv( + "info", 1, "error", 2, "pop_info", 3, "pop_error", 4, "warning", 5, + "pop_warning", 6, "yes_no", 7, "yes_no_cancel", 8)} + + enumPosition = &enum{width: 1, vals: nv( + "cascade", 0, "top_left", 1, "top_center", 2, "top_right", 3, + "center_left", 4, "center_center", 5, "center_right", 6, + "bottom_left", 7, "bottom_center", 8, "bottom_right", 9)} + + enumLogObject = &enum{width: 1, vals: nv( + "session_log", 0, "chat_log", 1, "im_log", 2, "no_log", 3)} + + enumSortOrder = &enum{width: 1, vals: nv("normal", 0, "reverse", 1, "alphabetical", 2)} + + enumFrameStyle = &enum{width: 2, vals: nv( + "none", 0, "single_line_pop_out", 1, "single_line_pop_in", 2, + "pop_in", 3, "pop_out", 4, "double_line", 5, "shadow", 6, "highlight", 7)} + + enumTriggerStyle = &enum{width: 2, vals: nv( + "default", 0, "place", 1, "rectangle", 2, "picture", 3, "framed", 4, + "bottom_tab", 5, "plain_picture", 6, "group_state", 7)} + + enumFont = &enum{width: 1, vals: nv( + "arial", 0, "courier", 1, "times_roman", 2, "system", 3, + "fixed_system", 4, "ms_serif", 5, "ms_sans_serif", 6, "small_fonts", 7, + "courier_new", 8, "script", 9, "ms_mincho", 10, "ms_gothic", 11, + "xi_ming_ti", 12, "biao_kai_ti", 13, "ming_lui_fixed", 15, + "ming_lui_variable", 16, "ms_hei", 17, "ms_song", 18, "fixedsys", 4)} + + enumFontStyle = &enum{width: 1, flags: true, vals: nv( + "normal", 0, "bold", 1, "italic", 2, "underline", 4, "strikeout", 8)} + + enumFieldScript = &enum{width: 1, vals: nv( + "latin", 0, "japanese", 1, "chinesetr", 2, "chineses", 0x19, + "ascii", 0x7F, "any", 0x80, "default", 0xFF, "latin1", 0)} + + enumScreenName = &enum{width: 1, vals: nv("append_with_for", 2, "prepend_with_s", 0x10)} + + // mat_title_pos: where (bits 7-6) or'd with how it's justified (bits 1-0) + enumTitlePos = &enum{width: 1, flags: true, vals: nv( + "left", 0, "above", 0x40, "right", 0x80, "below", 0xC0, + "center", 0, "top_or_left", 1, "bottom_or_right", 2)} + + enumTextOnPicture = &enum{width: 1, flags: true, desc: true, vals: nv( + "art_middle_center", 0, "title_middle_center", 0, + "title_upper_center", 2, "title_middle_left", 4, "title_middle_right", 5, + "title_lower_center", 7, "art_middle_left", 0x40, "art_middle_right", 0x50)} + + enumFmItem = &enum{width: 1, vals: nv( + "file_type_id", 1, "file_group_id", 2, "file_type_ext", 3, + "file_type_desc", 4, "file_type_flags", 5, "filename", 6, "path", 7, + "filespec", 8, "handle", 9, "error_code", 10, "custom_data", 11, + "text_width", 12, "text_indent", 13, "text_sub_indent", 14, + "text_flags", 15, "dialog_flags", 16, "and_mask", 17, "xor_mask", 18, + "file_size", 19, "free_disk_space", 20, "broadcast_return_value", 21, + "file_type_list_size", 22, "print_from_page", 23, "print_to_page", 24, + "print_min_page", 25, "print_max_page", 26, "print_copies", 27, + "hdc", 28, "print_job_name", 29, "date", 30, "time", 31, + "text_mode", 32, "ini_string_length", 33, "ini_file", 34, + "ini_group", 35, "ini_key", 36, "ini_data_type", 37, "thumbnail", 38, + "persistent_path", 40, "ini_section_size", 41)} + + enumErrorFlags = &enum{width: 1, flags: true, vals: nv( + "display_msg", 1, "terminate", 2, "broadcast", 4)} + + enumValidate = &enum{width: 1, flags: true, vals: nv("display_msg", 1, "terminate", 2)} + + enumDataType = &enum{width: 1, vals: nv( + "default", 0, "text", 1, "var", 2, "boolean", 3, "global_id", 4, + "relative_id", 5, "index", 6, "child_count", 7, "objptr", 8, + "value", 9, "raw", 10, "length", 11, "selected", 12, "lengh", 11)} + + enumExtraction = &enum{width: 1, vals: nv( + "default", 0, "current_object", 1, "selected_children", 2, + "cur_obj_selected_children", 3, "all_children", 4, + "cur_obj_all_children", 5)} + + enumBufFlags = &enum{width: 4, flags: true, vals: nv( + "token_header", 0x1, "stream_id_header", 0x2, "host_bound", 0x4, + "start_stream_header", 0x8, "end_stream_trailer", 0x10, + "data_included", 0x20, "leave_buffer_open", 0x40, + "response_id_header", 0x80, "pointer_included", 0x100, + "clear_buffer", 0x200)} + + enumHfsFlags = &enum{width: 4, flags: true, vals: nv( + "insert_global_id", 0x2, "update_display", 0x40)} + + enumHfsDatabase = &enum{width: 4, vals: nv("client", 0, "host", 1)} + + enumDisplay = &enum{width: 1, vals: nv("width", 0, "height", 1, "horzres", 2, "vertres", 3)} + + enumTypedData = &enum{width: 2, vals: nv("ascii", 0, "latin1", 0x0104)} + + enumAutoComplete = &enum{width: 1, vals: nv( + "web_list", 0, "address_list", 1, "other_list", 2, "std_sort_search", 1)} +) + +// atomEnums gives, per atom, the named values of each place in its +// argument (nil where it has none); the last applies to the places after. +var atomEnums = map[string][]*enum{ + "man_start_object": {enumObject}, + "man_start_sibling": {enumObject}, + "man_start_first": {enumObject}, + "man_start_alpha": {enumObject}, + "man_start_last": {enumObject}, + "mat_object_type": {enumObject}, + "act_set_criterion": {enumCriterion}, + "act_do_action": {enumCriterion}, + "async_alert": {enumAlert}, + "mat_position": {enumPosition}, + "mat_log_object": {enumLogObject}, + "mat_sort_order": {enumSortOrder}, + "mat_frame_style": {enumFrameStyle}, + "mat_trigger_style": {enumTriggerStyle}, + "mat_font_id": {enumFont}, + "mat_font_style": {enumFontStyle}, + "mat_font_sis": {enumFont, nil, enumFontStyle}, + "mat_intl_font_sis": {enumFont, nil, enumFontStyle}, + "mat_field_script": {enumFieldScript}, + "mat_title_pos": {enumTitlePos}, + "mat_text_on_picture_pos": {enumTextOnPicture}, + "mat_title_append_screen_name": {enumScreenName}, + "mat_auto_complete": {enumAutoComplete}, + "fm_item_type": {enumFmItem}, + "fm_item_get": {enumFmItem}, + "fm_handle_error": {enumErrorFlags}, + "de_validate": {enumValidate}, + "de_set_data_type": {enumDataType}, + "de_set_extraction_type": {enumExtraction}, + "de_get_data": {enumExtraction}, + "de_get_data_value": {enumExtraction}, + "de_get_data_pointer": {enumExtraction}, + "de_start_extraction": {enumBufFlags}, + "buf_start_buffer": {enumBufFlags}, + "buf_use_buffer": {enumBufFlags}, + "buf_set_flags": {enumBufFlags}, + "buf_get_flags": {enumBufFlags}, + "hfs_attr_flags": {enumHfsFlags}, + "hfs_attr_database_type": {enumHfsDatabase}, + "man_get_display_characteristics": {enumDisplay}, + "uni_start_typed_data": {enumTypedData}, + "uni_next_atom_typed": {enumTypedData}, +} + +func init() { + for _, n := range []string{"chart_title_font_sis", "chart_right_font_sis", + "chart_left_font_sis", "chart_bottom_font_sis", "chart_xlegend_font_sis", + "chart_ylegend_font_sis", "chart_constant_font_sis", "chart_legend_font_sis"} { + atomEnums[n] = atomEnums["mat_font_sis"] + } +} + +// enumAt is the named values of the i'th place of an atom's argument. +func enumAt(a *Atom, i int) *enum { + es := atomEnums[a.Name] + if len(es) == 0 { + return nil + } + if i >= len(es) { + i = len(es) - 1 + } + return es[i] +} + +// enumValue is one of an atom's named values. +func enumValue(a *Atom, i int, w string) ([]byte, bool) { + if a.Type == TypeOrient { + if v, ok := orientValue(w); ok { + return []byte{v}, true + } + return nil, false + } + e := enumAt(a, i) + if e == nil { + return nil, false + } + v, ok := e.value(w) + if !ok { + return nil, false + } + return fixed(int64(v), e.width), true +} + +// numWidth is the fixed width of the i'th number in an atom's argument, +// or 0 for "as few bytes as it needs". +func numWidth(a *Atom, i int) int { + switch a.Name { + case "mat_size": + if i == 2 { + return 2 // the text field's length + } + case "hfs_attr_field_mapping", "hfs_attr_variable_mapping", "hfs_attr_dispatch_mapping": + return 4 + case "hfs_attr_checkbox_mapping": + if i == 0 { + return 4 + } + } + return 0 +} + +// pipeWidth is the width of an or'd value for an atom, or 0 for the +// widest of its parts. +func pipeWidth(a *Atom) int { + if e := enumAt(a, 0); e != nil && e.flags { + return e.width + } + return 0 +} + +// orientation: h or v, how the objects are justified across (c l r f e), +// and along (c t b f e). +const ( + orientAcross = "clrfe" + orientAlong = "ctbfe" +) + +func orientValue(w string) (byte, bool) { + if len(w) != 3 || (w[0] != 'h' && w[0] != 'v') { + return 0, false + } + x := strings.IndexByte(orientAcross, w[1]) + if x < 0 && (w[1] == 't' || w[1] == 'b') { + x = strings.IndexByte(orientAlong, w[1]) // the manual's t/b for l/r + } + y := strings.IndexByte(orientAlong, w[2]) + if y < 0 && (w[2] == 'l' || w[2] == 'r') { + y = strings.IndexByte(orientAcross, w[2]) + } + if x < 0 || y < 0 { + return 0, false + } + v := byte(x<<3 | y) + if w[0] == 'v' { + v |= 0x40 + } + return v, true +} + +func orientName(v byte) (string, bool) { + x, y := int(v>>3&7), int(v&7) + if v&^0x7F != 0 || x >= len(orientAcross) || y >= len(orientAlong) { + return "", false + } + d := "h" + if v&0x40 != 0 { + d = "v" + } + return fmt.Sprintf("%s%c%c", d, orientAcross[x], orientAlong[y]), true +} diff --git a/internal/aol/fdo/fdo.go b/internal/aol/fdo/fdo.go new file mode 100644 index 0000000..5afc9a3 --- /dev/null +++ b/internal/aol/fdo/fdo.go @@ -0,0 +1,143 @@ +// Package fdo is FDO91, the forms language of the classic AOL client (2.5 +// to 4.0 and on): the atom streams the host sends to draw windows and run +// actions, and the client sends back with what a form holds. +// +// An atom stream is a run of atoms, each a protocol (man, mat, act...), an +// atom number and an argument of up to 32K bytes. Ada32.dll, AOL's own +// compiler, writes every atom in the "full" style; the client also reads +// seven compact ones, and atoms too big for one packet as a large atom in +// pieces. This package reads all of them (Decode, Decoder), writes them as +// Ada32 does (Encode, Packets), compiles FDO91 source to atom streams +// byte for byte as Ada32 does (Compile), and turns streams back into +// source that compiles to the same bytes (Decompile). +// +// The atom table is ADA.BIN's, the compiler's own list, as AtomForge +// dumped it, and the compiler is checked against AtomForge's corpus of what +// Ada32 made of 1,889 forms and 74,369 single atoms, and of 44 streams +// captured from a live client (see the tests). +// +// Strings are bytes: the client is a Windows program of the 1990s and +// reads Windows-1252. Latin1 and Quote turn Go strings into those bytes +// and into source text. +package fdo + +import ( + "fmt" + "strings" + "unicode/utf8" +) + +// Latin1 is s as the client's bytes: Windows-1252, with '?' for what it +// can't show. +func Latin1(s string) []byte { + b := make([]byte, 0, len(s)) + for _, r := range s { + switch { + case r < 0x80 || r >= 0xA0 && r <= 0xFF: + b = append(b, byte(r)) + default: + if c, ok := cp1252[r]; ok { + b = append(b, c) + } else { + b = append(b, '?') + } + } + } + return b +} + +// FromLatin1 is the client's Windows-1252 bytes as a Go string. +func FromLatin1(b []byte) string { + var sb strings.Builder + for _, c := range b { + switch { + case c < 0x80 || c >= 0xA0: + sb.WriteRune(rune(c)) + default: + if r := cp1252Runes[c-0x80]; r != 0 { + sb.WriteRune(r) + } else { + sb.WriteRune(utf8.RuneError) + } + } + } + return sb.String() +} + +// cp1252Runes are Windows-1252's characters at 0x80-0x9F. +var cp1252Runes = [32]rune{ + '€', 0, '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', 0, 'Ž', 0, + 0, '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', 0, 'ž', 'Ÿ', +} + +var cp1252 = func() map[rune]byte { + m := map[rune]byte{} + for i, r := range cp1252Runes { + if r != 0 { + m[r] = byte(0x80 + i) + } + } + return m +}() + +// Quote is s as an FDO91 string, "..." with escapes, its text in the +// client's Windows-1252: for putting text that isn't known in advance (a +// screen name, a message) into source. +func Quote(s string) string { return quote(Latin1(s)) } + +// QuoteBytes is b, the client's bytes, as an FDO91 string. +func QuoteBytes(b []byte) string { return quote(b) } + +// Find is the first frame of the named atom, at the top level of frames. +func Find(frames []Frame, name string) (Frame, bool) { + a, ok := Lookup(name) + if !ok { + return Frame{}, false + } + for _, f := range frames { + if f.Proto == a.Proto && f.Num == a.Num { + return f, true + } + } + return Frame{}, false +} + +// FindAll is every frame of the named atom, at the top level of frames: +// FindAll(frames, "de_data") is the fields a form sent, in order. +func FindAll(frames []Frame, name string) []Frame { + a, ok := Lookup(name) + if !ok { + return nil + } + var out []Frame + for _, f := range frames { + if f.Proto == a.Proto && f.Num == a.Num { + out = append(out, f) + } + } + return out +} + +// F makes a frame from an atom's name and its argument bytes; it panics on +// a name not in the table, so it is for names known when the program is +// written. +func F(name string, data ...byte) Frame { + a := MustLookup(name) + if data == nil { + data = []byte{} + } + return Frame{a.Proto, a.Num, data} +} + +// Number is n as an atom's argument: big-endian in as few bytes as it +// needs, as the compiler writes numbers. +func Number(n int64) []byte { return number(n) } + +// GID is a global id as an atom's argument: 32-105 is GID(32, 105) and +// 1-0-1329 GID(1, 0, 1329). +func GID(parts ...int64) []byte { + if len(parts) != 2 && len(parts) != 3 { + panic(fmt.Sprintf("fdo: a global id has 2 or 3 parts, not %d", len(parts))) + } + return number(gidNumber(parts)) +} diff --git a/internal/aol/fdo/fdo_test.go b/internal/aol/fdo/fdo_test.go new file mode 100644 index 0000000..a1a2a7a --- /dev/null +++ b/internal/aol/fdo/fdo_test.go @@ -0,0 +1,377 @@ +package fdo + +import ( + "bytes" + "errors" + "math/rand" + "strings" + "testing" +) + +// The sign-on form as an AOL 3.0 client sends it (token Dd, stream 0x15), +// from "The AOL Protocol" captures: screen name and password as de_data, +// numbers in four bytes where Ada32 would write one. +var signOn = []byte{ + 0x00, 0x01, 0x00, + 0x01, 0x0A, 0x04, 0, 0, 0, 1, + 0x01, 0x0B, 0x04, 0, 0, 0, 1, + 0x03, 0x01, 0x0A, 'h', 'o', 'l', 'y', 't', 'a', 'b', 'l', 'e', ' ', + 0x01, 0x1D, 0x00, 0x01, 0x1D, 0x00, + 0x01, 0x0A, 0x04, 0, 0, 0, 2, + 0x03, 0x01, 0x08, '*', '*', '*', '*', '*', '*', '*', '*', + 0x01, 0x1D, 0x00, + 0x00, 0x02, 0x00, +} + +func TestSignOn(t *testing.T) { + frames, err := Decode(signOn) + if err != nil { + t.Fatal(err) + } + var names []string + for _, f := range frames { + names = append(names, f.Name()) + } + want := "uni_start_stream man_set_context_relative man_set_context_index de_data " + + "man_end_context man_end_context man_set_context_relative de_data man_end_context uni_end_stream" + if got := strings.Join(names, " "); got != want { + t.Errorf("atoms\n got %s\nwant %s", got, want) + } + de := FindAll(frames, "de_data") + if len(de) != 2 || string(de[0].Data) != "holytable " || string(de[1].Data) != "********" { + t.Errorf("de_data: %v", de) + } + if !bytes.Equal(Encode(frames), signOn) { + t.Error("Encode doesn't give the packet back") + } + src, err := Decompile(signOn) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(src, "man_set_context_relative <00x, 00x, 00x, 01x>") || + !strings.Contains(src, `de_data <"holytable ">`) { + t.Errorf("decompiled:\n%s", src) + } + if b, err := Compile(src); err != nil || !bytes.Equal(b, signOn) { + t.Errorf("recompiled: % x, %v", b, err) + } +} + +// The sign-off confirmation from the FDO91 manual's introduction. +const signOff = ` +atom$uni_start_stream +atom$man_start_object +atom$mat_orientation +atom$mat_position <5> +atom$man_start_object +atom$man_start_sibling +atom$mat_orientation +atom$man_start_object +atom$mat_bool_default +atom$man_start_sibling +atom$man_end_object +atom$man_update_display +atom$uni_wait_off +atom$uni_end_stream +` + +func TestManualExample(t *testing.T) { + b, err := Compile(signOff) + if err != nil { + t.Fatal(err) + } + want := []byte{0x00, 0x01, 0x00, 0x01, 0x00, 0x0D, 0x01} + want = append(want, "Exit Gateway"...) + want = append(want, 0x10, 0x08, 0x01, 0x5B, 0x10, 0x40, 0x01, 0x05) + if !bytes.HasPrefix(b, want) { + t.Errorf("got % x\nwant prefix % x", b, want) + } + src, err := Decompile(b) + if err != nil { + t.Fatal(err) + } + for _, s := range []string{`man_start_object `, "mat_orientation ", + "mat_position ", `man_start_sibling `, "mat_bool_default "} { + if !strings.Contains(src, s) { + t.Errorf("decompiled source lacks %s:\n%s", s, src) + } + } + if b2, err := Compile(src); err != nil || !bytes.Equal(b, b2) { + t.Errorf("round trip: %v", err) + } +} + +func TestNestedStream(t *testing.T) { + src := `uni_start_stream + man_start_object + act_replace_select_action + < + uni_start_stream + sm_send_token_raw <"pE"> + uni_end_stream + > + man_end_object +uni_end_stream +` + b, err := Compile(src) + if err != nil { + t.Fatal(err) + } + inner := []byte{0x00, 0x01, 0x00, 0x0E, 0x10, 0x02, 'p', 'E', 0x00, 0x02, 0x00} + if !bytes.Contains(b, append([]byte{0x02, 0x04, byte(len(inner))}, inner...)) { + t.Errorf("nested stream not found in % x", b) + } + got, err := Decompile(b) + if err != nil || got != src { + t.Errorf("decompiled:\n%s\nwant:\n%s (%v)", got, src, err) + } +} + +func TestValues(t *testing.T) { + for _, c := range []struct { + src string + want []byte + }{ + {"mat_object_id <32-105>", []byte{0x10, 0x0C, 3, 0x20, 0x00, 0x69}}, + {"mat_art_id <1-0-1329>", []byte{0x10, 0x0E, 4, 1, 0, 0x05, 0x31}}, + {"uni_sync_skip <0>", []byte{0x00, 0x07, 1, 0}}, + {"uni_sync_skip <300>", []byte{0x00, 0x07, 2, 0x01, 0x2C}}, + {"uni_sync_skip <4000000000>", []byte{0x00, 0x07, 4, 0x7F, 0xFF, 0xFF, 0xFF}}, + {"mat_size <25, 1, 32>", []byte{0x10, 0x17, 4, 25, 1, 0, 32}}, + {"mat_title_pos ", []byte{0x10, 0x11, 1, 0x40}}, + {"mat_font_sis ", []byte{0x10, 0x0A, 3, 0, 10, 3}}, + {"var_string_set ", []byte{0x0C, 0x05, 5, 0, 'x', '\r', '\n', 0x80}}, + {"buf_set_data_atom ", []byte{0x04, 0x12, 2, 0x03, 0x01}}, + {"async_alert ", []byte{0x0D, 0x07, 6, 1, 'D', 'o', 'n', 'e', '.'}}, + {"buf_start_buffer ", []byte{0x04, 0x00, 4, 0, 0, 0, 5}}, + {"the_unknown <99, 7, 01x, 02x>", []byte{0xE0 | 0x60>>2, 0x03, 7, 2, 1, 2}}, + {"www_load_url <\"x\">", nil}, + } { + got, err := Compile(c.src) + if err != nil { + t.Errorf("%s: %v", c.src, err) + continue + } + if c.want != nil && !bytes.Equal(got, c.want) { + t.Errorf("%s: got % x, want % x", c.src, got, c.want) + } + back, err := Decompile(got) + if err != nil { + t.Errorf("%s: %v", c.src, err) + continue + } + if again, err := Compile(back); err != nil || !bytes.Equal(again, got) { + t.Errorf("%s: decompiled as %q, which compiles to % x (%v)", c.src, back, again, err) + } + } +} + +func TestErrors(t *testing.T) { + for _, c := range []struct{ src, msg string }{ + {"uni_start_stream\nnot_an_atom <1>", "line 2: not_an_atom: unrecognized atom"}, + {`man_append_data <"no end>`, "line 1: string not closed"}, + {"act_replace_action\n<\nuni_start_stream\n", "nested stream not closed"}, + {"mat_position ", `unknown word "sideways"`}, + {"uni_start_stream <1, >", "expected a value"}, + {"the_unknown <1>", "needs "}, + } { + _, err := Compile(c.src) + if err == nil || !strings.Contains(err.Error(), c.msg) { + t.Errorf("%q: got %v, want %q", c.src, err, c.msg) + } + } + var ce *CompileError + if _, err := Compile("uni_start_stream\n\nbogus"); !errors.As(err, &ce) || ce.Line != 3 { + t.Errorf("CompileError line: %v", err) + } +} + +// TestStyles decodes each of the eight styles. +func TestStyles(t *testing.T) { + b := []byte{ + 0x10, 0x08, 0x01, 0x5B, // full: mat_orientation + 0x30 | 0x00, 0x08, // atom: mat 8, no data (protocol carried over) + 0x80 | 0x0C, 0x02, 0xAA, 0xBB, // current: mat 12, two bytes + 0xA0 | 0x07, // zero: mat 7 <0> + 0xC0 | 0x07, // one: mat 7 <1> + 0x40 | 0x0D, 0x60 | 0x07, // data: async 7, value 3 + 0x20 | 0x0D, 0x40 | 0x07, 'h', 'i', // length: async 7, two bytes + 0xE0 | 0x08, 0x10, 0x05, 0x01, 'x', // prefix: www (48) atom 5, full + 0xE0 | 0x08 | 0x02, 0xA0 | 0x10, 0x01, // prefix, zero: proto 48, atom 0x41 + } + frames, err := Decode(b) + if err != nil { + t.Fatal(err) + } + want := []Frame{ + {16, 8, []byte{0x5B}}, {16, 8, []byte{}}, {16, 12, []byte{0xAA, 0xBB}}, + {16, 7, []byte{0}}, {16, 7, []byte{1}}, {13, 7, []byte{3}}, + {13, 7, []byte("hi")}, {48, 5, []byte("x")}, {48, 0x41, []byte{0}}, + } + if len(frames) != len(want) { + t.Fatalf("got %d frames: %v", len(frames), frames) + } + for i := range want { + if frames[i].Proto != want[i].Proto || frames[i].Num != want[i].Num || !bytes.Equal(frames[i].Data, want[i].Data) { + t.Errorf("frame %d: got %v, want %v", i, frames[i], want[i]) + } + } + if _, err := Decode([]byte{0x10, 0x08, 0x05, 1}); !errors.Is(err, ErrShort) { + t.Errorf("short atom: %v", err) + } +} + +func randomFrames(r *rand.Rand, n int) []Frame { + var out []Frame + for i := 0; i < n; i++ { + f := Frame{Proto: uint8(r.Intn(128)), Num: uint8(r.Intn(256))} + if r.Intn(3) == 0 { + f.Proto = uint8(r.Intn(3)) // runs of one protocol, for the compact styles + } + if f.Proto == ProtoUNI && f.Num >= atomStartLarge && f.Num <= atomEndLarge { + f.Num = 1 // not the large-atom atoms + } + switch r.Intn(5) { + case 0: + f.Data = []byte{} + case 1: + f.Data = []byte{byte(r.Intn(9))} + case 2: + f.Data = make([]byte, 1+r.Intn(200)) + default: + f.Data = make([]byte, r.Intn(8)) + } + r.Read(f.Data) + out = append(out, f) + } + return out +} + +func sameFrames(a, b []Frame) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i].Proto != b[i].Proto || a[i].Num != b[i].Num || !bytes.Equal(a[i].Data, b[i].Data) { + return false + } + } + return true +} + +func TestEncodeDecode(t *testing.T) { + r := rand.New(rand.NewSource(1)) + for i := 0; i < 200; i++ { + frames := randomFrames(r, 30) + for name, enc := range map[string]func([]Frame) []byte{"full": Encode, "compact": EncodeCompact} { + got, err := Decode(enc(frames)) + if err != nil || !sameFrames(got, frames) { + t.Fatalf("%s: %v", name, err) + } + } + if c, f := len(EncodeCompact(frames)), len(Encode(frames)); c > f { + t.Errorf("compact %d bytes, full %d", c, f) + } + } +} + +func TestLargeAtoms(t *testing.T) { + big := make([]byte, 1000) + for i := range big { + big[i] = byte(i) + } + frames := []Frame{F("uni_start_stream", 0), F("man_append_data", big...), F("man_update_display"), F("uni_end_stream", 0)} + packets := Packets(frames, 115) + var d Decoder + var got []Frame + for _, p := range packets { + if len(p) > 115 { + t.Errorf("packet of %d bytes", len(p)) + } + f, err := d.Feed(p) + if err != nil { + t.Fatal(err) + } + got = append(got, f...) + } + if !sameFrames(got, frames) { + t.Errorf("got %v", got) + } + // the start says which atom and how long + if p := packets[1]; !bytes.Equal(p, []byte{0x00, 0x04, 0x04, 0x01, 0x14, 0x03, 0xE8}) { + t.Errorf("start of the large atom: % x", p) + } + // and an atom over MaxData goes as one in Encode too + huge := Frame{1, 4, make([]byte, MaxData+10)} + if got, err := Decode(Encode([]Frame{huge})); err != nil || !sameFrames(got, []Frame{huge}) { + t.Errorf("huge atom: %v", err) + } + if _, err := Decode([]byte{0x00, 0x05, 0x01, 'x'}); !errors.Is(err, ErrLargeAtom) { + t.Errorf("segment without a start: %v", err) + } +} + +func TestOrientation(t *testing.T) { + n := 0 + for _, d := range "hv" { + for _, x := range orientAcross { + for _, y := range orientAlong { + w := string([]rune{d, x, y}) + v, ok := orientValue(w) + if !ok { + t.Fatalf("%s: no value", w) + } + if back, _ := orientName(v); back != w { + t.Errorf("%s: %#x reads %s", w, v, back) + } + n++ + } + } + } + if v, _ := orientValue("vff"); v != 0x5B { + t.Errorf("vff is %#x", v) + } + if v, _ := orientValue("hec"); v != 0x20 { + t.Errorf("hec is %#x", v) + } +} + +func TestLatin1(t *testing.T) { + s := "Café “quoted” – 50€ 日本" + b := Latin1(s) + want := []byte("Caf\xe9 \x93quoted\x94 \x96 50\x80 ??") + if !bytes.Equal(b, want) { + t.Errorf("Latin1: % x", b) + } + if got := FromLatin1(b); got != "Café “quoted” – 50€ ??" { + t.Errorf("FromLatin1: %q", got) + } + src := "man_append_data <" + Quote(`say "hi" \ `+s) + ">" + got, err := Compile(src) + if err != nil { + t.Fatal(err) + } + if f, _ := Decode(got); !bytes.Equal(f[0].Data, append([]byte(`say "hi" \ `), want...)) { + t.Errorf("quoted: % x", f[0].Data) + } +} + +func TestTable(t *testing.T) { + if n := len(Atoms()); n < 1600 { + t.Errorf("%d atoms", n) + } + seen := map[uint16]string{} + for _, a := range Atoms() { + k := uint16(a.Proto)<<8 | uint16(a.Num) + if s, dup := seen[k]; dup { + t.Errorf("%s and %s are both %d:%d", s, a.Name, a.Proto, a.Num) + } + seen[k] = a.Name + if p := ProtocolName(a.Proto); p == "" || !strings.HasPrefix(a.Name, p+"_") { + t.Errorf("%s is protocol %d (%q)", a.Name, a.Proto, p) + } + } + if a, ok := Lookup("ATOM$MAN_START_OBJECT"); !ok || a.Proto != ProtoMAN || a.Num != 0 { + t.Errorf("Lookup: %v", a) + } +} diff --git a/internal/aol/fdo/gen/main.go b/internal/aol/fdo/gen/main.go new file mode 100644 index 0000000..eab03fa --- /dev/null +++ b/internal/aol/fdo/gen/main.go @@ -0,0 +1,109 @@ +// Command gen makes the fdo package's atom table (atomtable.go) from +// AtomForge's dump of AOL's ADA.BIN, the atom list that ships with the +// FDO91 compiler (Ada32.dll): every atom's protocol, number, name, +// argument type and indent flags. +// +// git clone --depth 1 https://github.com/iconidentify/atomforge-fdo-java +// go run ./internal/aol/fdo/gen -src atomforge-fdo-java +package main + +import ( + "bytes" + "encoding/json" + "flag" + "fmt" + "go/format" + "log" + "os" + "os/exec" + "path/filepath" + "sort" + "strings" +) + +type atomJSON struct { + Name string `json:"name"` + Protocol int `json:"protocol"` + Atom int `json:"atom"` + Type string `json:"type"` + Flags []string `json:"flags"` +} + +// typeNames are the fdo package's names for ADA.BIN's argument types, +// keyed by AtomForge's names for them (some of which are guesses that +// don't fit the atoms that have them: "STREAM_LEGACY" is the named-value +// type of mat_position, "BOOL_LEGACY" a variable letter). +var typeNames = map[string]string{ + "RAW": "TypeRaw", "DWORD": "TypeDword", "STRING": "TypeString", + "BOOL": "TypeBool", "GID": "TypeGID", "STREAM": "TypeStream", + "OBJSTART": "TypeObject", "ORIENT": "TypeOrient", "TOKEN": "TypeToken", + "TOKENARG": "TypeCriterion", "ALERT": "TypeAlert", "ATOM": "TypeAtom", + "COLORDATA": "TypeByteList", "IGNORE": "TypeIgnore", + "VARLOOKUP": "TypeVarNumber", "CRITERION": "TypeVarString", + "BOOL_LEGACY": "TypeVar", "CRITERION_LEGACY": "TypeList", + "STREAM_LEGACY": "TypeEnum", "VAR": "TypeType14", + "VARDWORD": "TypeType15", +} + +var flagNames = map[string]string{"INDENT": "FlagIndent", "OUTDENT": "FlagOutdent", "EOS": "FlagEOS"} + +func main() { + src := flag.String("src", "atomforge-fdo-java", "a checkout of atomforge-fdo-java") + out := flag.String("out", "internal/aol/fdo/atomtable.go", "the file to write") + flag.Parse() + + raw, err := os.ReadFile(filepath.Join(*src, "src/test/resources/ada-bin-baseline.json")) + if err != nil { + log.Fatal(err) + } + var doc struct { + Generated string `json:"generated"` + Atoms []atomJSON `json:"atoms"` + } + if err := json.Unmarshal(raw, &doc); err != nil { + log.Fatal(err) + } + sort.Slice(doc.Atoms, func(i, j int) bool { + a, b := doc.Atoms[i], doc.Atoms[j] + if a.Protocol != b.Protocol { + return a.Protocol < b.Protocol + } + return a.Atom < b.Atom + }) + rev := "unknown" + if b, err := exec.Command("git", "-C", *src, "rev-parse", "HEAD").Output(); err == nil { + rev = strings.TrimSpace(string(b)) + } + + var w bytes.Buffer + fmt.Fprintf(&w, "// Code generated by go run ./internal/aol/fdo/gen; DO NOT EDIT.\n\n") + fmt.Fprintf(&w, "// From AtomForge's dump of ADA.BIN (src/test/resources/ada-bin-baseline.json,\n") + fmt.Fprintf(&w, "// generated %s), atomforge-fdo-java at %s\n", doc.Generated, rev) + fmt.Fprintf(&w, "// (Copyright AtomForge Contributors, MIT License: LICENSE.atomforge).\n\n") + fmt.Fprintf(&w, "package fdo\n\n") + fmt.Fprintf(&w, "var atomTable = [...]Atom{\n") + for _, a := range doc.Atoms { + t, ok := typeNames[a.Type] + if !ok { + log.Fatalf("%s: unknown type %s", a.Name, a.Type) + } + var fl []string + for _, f := range a.Flags { + fl = append(fl, flagNames[f]) + } + flags := "0" + if len(fl) > 0 { + flags = strings.Join(fl, "|") + } + fmt.Fprintf(&w, "\t{%d, %d, %q, %s, %s},\n", a.Protocol, a.Atom, strings.ToLower(a.Name), t, flags) + } + fmt.Fprintf(&w, "}\n") + b, err := format.Source(w.Bytes()) + if err != nil { + log.Fatal(err) + } + if err := os.WriteFile(*out, b, 0o644); err != nil { + log.Fatal(err) + } + log.Printf("%d atoms", len(doc.Atoms)) +} diff --git a/internal/aol/fdo/parse.go b/internal/aol/fdo/parse.go new file mode 100644 index 0000000..e719897 --- /dev/null +++ b/internal/aol/fdo/parse.go @@ -0,0 +1,451 @@ +package fdo + +import ( + "fmt" + "strconv" + "strings" +) + +// The source language is the one AOL's tools and the FDO91 manual use, as +// Ada32.dll compiles it and disassembles it: +// +// uni_start_stream <00x> +// man_start_object +// mat_orientation +// mat_object_id <32-105> +// act_replace_select_action +// < +// uni_start_stream +// sm_send_token_raw <"pE"> +// uni_end_stream +// > +// man_end_object +// uni_end_stream +// +// One atom a line; its argument in angle brackets: numbers (123), hex bytes +// (0dx), global ids (32-105, 1-0-1329), "strings" (with \r \n \t \\ \" +// \xNN), words (yes, vff, select, A, an atom's name), words or numbers or'd +// together (left | center), or several of these separated by commas. An +// argument of a < alone on its line, then atoms, then a > alone on its line, +// is a nested stream. A ; starts a comment. Indentation doesn't matter. +// "atom$" before a name, as the manual writes them, is allowed. +// the_unknown is an atom by number. + +// Kind is the kind of an argument value. +type Kind uint8 + +const ( + KindNum Kind = iota + 1 // Num + KindHex // Bytes, written 0dx or 0d0ax + KindString // Bytes + KindWord // Text + KindGID // GID + KindPipe // Parts, or'd together + KindStream // Stream +) + +// Value is one argument value. +type Value struct { + Kind Kind + Num int64 + Bytes []byte + Text string + GID []int64 + Parts []Value + Stream []*Node + + streamFrames []Frame // a decompiled nested stream +} + +// Node is one atom of source: its name and its arguments. +type Node struct { + Name string + Args []Value + Line int +} + +// ParseError is a line the parser couldn't read. +type ParseError struct { + Line int + Msg string +} + +func (e *ParseError) Error() string { return fmt.Sprintf("fdo: line %d: %s", e.Line, e.Msg) } + +type tokKind uint8 + +const ( + tEOF tokKind = iota + tNL + tLT + tGT + tComma + tPipe + tWord + tNum + tHex + tGID + tString +) + +type token struct { + kind tokKind + text string + line int +} + +type lexer struct { + src string + pos int + line int +} + +func isDigit(c byte) bool { return c >= '0' && c <= '9' } +func isHex(c byte) bool { + return isDigit(c) || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' +} +func isWord(c byte) bool { + return c == '_' || c == '$' || isDigit(c) || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' +} + +func (l *lexer) next() (token, error) { + for l.pos < len(l.src) { + c := l.src[l.pos] + if c == ' ' || c == '\t' || c == '\f' || c == '\v' { + l.pos++ + continue + } + if c == ';' { + for l.pos < len(l.src) && l.src[l.pos] != '\n' && l.src[l.pos] != '\r' { + l.pos++ + } + continue + } + break + } + if l.pos >= len(l.src) { + return token{tEOF, "", l.line}, nil + } + start, line := l.pos, l.line + c := l.src[l.pos] + l.pos++ + switch c { + case '\r': + if l.pos < len(l.src) && l.src[l.pos] == '\n' { + l.pos++ + } + l.line++ + return token{tNL, "", line}, nil + case '\n': + l.line++ + return token{tNL, "", line}, nil + case '<': + return token{tLT, "<", line}, nil + case '>': + return token{tGT, ">", line}, nil + case ',': + return token{tComma, ",", line}, nil + case '|': + return token{tPipe, "|", line}, nil + case '"': + var sb strings.Builder + for { + if l.pos >= len(l.src) || l.src[l.pos] == '\n' || l.src[l.pos] == '\r' { + return token{}, &ParseError{line, "string not closed"} + } + c := l.src[l.pos] + l.pos++ + if c == '"' { + break + } + sb.WriteByte(c) + if c == '\\' && l.pos < len(l.src) && l.src[l.pos] != '\n' && l.src[l.pos] != '\r' { + sb.WriteByte(l.src[l.pos]) + l.pos++ + } + } + return token{tString, sb.String(), line}, nil + } + if !isWord(c) && c != '-' { + return token{}, &ParseError{line, fmt.Sprintf("unexpected %q", c)} + } + for l.pos < len(l.src) && (isWord(l.src[l.pos]) || l.src[l.pos] == '-') { + l.pos++ + } + text := l.src[start:l.pos] + return token{classify(text), text, line}, nil +} + +// classify sorts a run of word characters into a number, hex bytes, a +// global id or a word. +func classify(s string) tokKind { + if n := len(s); n > 1 && (s[n-1] == 'x' || s[n-1] == 'X') && allHex(s[:n-1]) { + return tHex + } + digits := strings.TrimPrefix(s, "-") + if digits != "" && allDigits(digits) { + return tNum + } + if parts := strings.Split(s, "-"); len(parts) == 2 || len(parts) == 3 { + ok := true + for _, p := range parts { + ok = ok && p != "" && allDigits(p) + } + if ok { + return tGID + } + } + return tWord +} + +func allHex(s string) bool { + for i := 0; i < len(s); i++ { + if !isHex(s[i]) { + return false + } + } + return s != "" +} + +func allDigits(s string) bool { + for i := 0; i < len(s); i++ { + if !isDigit(s[i]) { + return false + } + } + return s != "" +} + +type parser struct { + lx lexer + tok token + peek *token +} + +func (p *parser) advance() error { + if p.peek != nil { + p.tok, p.peek = *p.peek, nil + return nil + } + t, err := p.lx.next() + p.tok = t + return err +} + +func (p *parser) lookahead() (token, error) { + if p.peek == nil { + t, err := p.lx.next() + if err != nil { + return t, err + } + p.peek = &t + } + return *p.peek, nil +} + +// Parse reads FDO91 source into its atoms. It checks the syntax only: +// Compile checks the names and arguments. +func Parse(src string) ([]*Node, error) { + p := &parser{lx: lexer{src: src, line: 1}} + if err := p.advance(); err != nil { + return nil, err + } + nodes, err := p.atoms(false) + if err != nil { + return nil, err + } + return nodes, nil +} + +// atoms reads atoms to the end, or to a > alone on its line if nested. +func (p *parser) atoms(nested bool) ([]*Node, error) { + var out []*Node + for { + switch p.tok.kind { + case tNL: + if err := p.advance(); err != nil { + return nil, err + } + continue + case tEOF: + if nested { + return nil, &ParseError{p.tok.line, "nested stream not closed with >"} + } + return out, nil + case tGT: + if !nested { + return nil, &ParseError{p.tok.line, "> without a nested stream"} + } + return out, p.advance() + case tWord: + default: + return nil, &ParseError{p.tok.line, fmt.Sprintf("expected an atom name, found %q", p.tok.text)} + } + n := &Node{Name: strings.TrimPrefix(strings.ToLower(p.tok.text), "atom$"), Line: p.tok.line} + if err := p.advance(); err != nil { + return nil, err + } + // the argument may be on the next line, as a nested stream's < is + if p.tok.kind == tNL { + if t, err := p.lookahead(); err != nil { + return nil, err + } else if t.kind == tLT { + if err := p.advance(); err != nil { + return nil, err + } + } + } + if p.tok.kind == tLT { + args, err := p.args() + if err != nil { + return nil, err + } + n.Args = args + } + switch p.tok.kind { + case tNL, tEOF, tGT: + default: + return nil, &ParseError{p.tok.line, fmt.Sprintf("unexpected %q after %s", p.tok.text, n.Name)} + } + out = append(out, n) + } +} + +// args reads <...>, p.tok being the <. +func (p *parser) args() ([]Value, error) { + line := p.tok.line + if err := p.advance(); err != nil { + return nil, err + } + if p.tok.kind == tNL { + // a nested stream + if err := p.advance(); err != nil { + return nil, err + } + s, err := p.atoms(true) + if err != nil { + return nil, err + } + return []Value{{Kind: KindStream, Stream: s}}, nil + } + var out []Value + if p.tok.kind == tGT { + return out, p.advance() + } + for { + v, err := p.value() + if err != nil { + return nil, err + } + out = append(out, v) + switch p.tok.kind { + case tComma: + if err := p.advance(); err != nil { + return nil, err + } + case tGT: + return out, p.advance() + default: + return nil, &ParseError{line, fmt.Sprintf("expected , or > in the argument, found %q", p.tok.text)} + } + } +} + +// value reads one value, or values or'd together. +func (p *parser) value() (Value, error) { + v, err := p.term() + if err != nil || p.tok.kind != tPipe { + return v, err + } + pipe := Value{Kind: KindPipe, Parts: []Value{v}} + for p.tok.kind == tPipe { + if err := p.advance(); err != nil { + return v, err + } + t, err := p.term() + if err != nil { + return v, err + } + pipe.Parts = append(pipe.Parts, t) + } + return pipe, nil +} + +func (p *parser) term() (Value, error) { + t := p.tok + var v Value + switch t.kind { + case tNum: + n, err := strconv.ParseInt(t.text, 10, 64) + if err != nil { + return v, &ParseError{t.line, "number out of range: " + t.text} + } + v = Value{Kind: KindNum, Num: n} + case tHex: + h := t.text[:len(t.text)-1] + if len(h)%2 == 1 { + h = "0" + h + } + b := make([]byte, len(h)/2) + for i := range b { + x, _ := strconv.ParseUint(h[2*i:2*i+2], 16, 8) + b[i] = byte(x) + } + v = Value{Kind: KindHex, Bytes: b} + case tGID: + var g []int64 + for _, s := range strings.Split(t.text, "-") { + n, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return v, &ParseError{t.line, "bad global id " + t.text} + } + g = append(g, n) + } + v = Value{Kind: KindGID, GID: g} + case tString: + v = Value{Kind: KindString, Bytes: unescape(t.text)} + case tWord: + v = Value{Kind: KindWord, Text: t.text} + default: + return v, &ParseError{t.line, fmt.Sprintf("expected a value, found %q", t.text)} + } + return v, p.advance() +} + +// unescape turns a string's escapes into bytes. The rest of the string +// is taken byte for byte, as Ada32 does: write Latin-1 text with \xNN, or +// give the compiler the bytes the client should get. +func unescape(s string) []byte { + b := make([]byte, 0, len(s)) + for i := 0; i < len(s); i++ { + c := s[i] + if c != '\\' || i+1 >= len(s) { + b = append(b, c) + continue + } + i++ + switch s[i] { + case 'n': + b = append(b, '\n') + case 'r': + b = append(b, '\r') + case 't': + b = append(b, '\t') + case '\\': + b = append(b, '\\') + case '"': + b = append(b, '"') + case 'x': + if i+2 < len(s) && isHex(s[i+1]) && isHex(s[i+2]) { + x, _ := strconv.ParseUint(s[i+1:i+3], 16, 8) + b = append(b, byte(x)) + i += 2 + } else { + b = append(b, '\\', 'x') + } + default: + b = append(b, '\\', s[i]) + } + } + return b +} diff --git a/internal/aol/fdo/render.go b/internal/aol/fdo/render.go new file mode 100644 index 0000000..6f5e14b --- /dev/null +++ b/internal/aol/fdo/render.go @@ -0,0 +1,285 @@ +package fdo + +import ( + "bytes" + "sort" +) + +// candidates are the forms the decompiler tries for an atom's data, best +// first; the first that compiles back to the data wins, and hex is the +// last resort. +func candidates(a *Atom, d []byte) [][]Value { + var out [][]Value + add := func(v ...Value) { out = append(out, v) } + word := func(s string) Value { return Value{Kind: KindWord, Text: s} } + num := func(n int64) Value { return Value{Kind: KindNum, Num: n} } + str := func(b []byte) Value { return Value{Kind: KindString, Bytes: b} } + + if a.Type != TypeObject && a.Type != TypeAlert && a.Name != "mat_title_pos" && a.Name != "mat_text_on_picture_pos" { + if v, ok := enumRender(a, 0, d); ok { + add(v) + } + } + switch a.Name { + case "man_get_display_characteristics": + if len(d) >= 2 { + if v, ok := enumRender(a, 0, d[:1]); ok { + add(v, num(beNumber(d[1:]))) + } + } + case "mat_auto_complete": + var vals []Value + for _, c := range d { + vals = append(vals, word(map[byte]string{0: "web_list", 1: "address_list", 2: "other_list"}[c])) + } + if len(d) == 2 && d[1] == 1 { + vals[1] = word("std_sort_search") + } + add(vals...) + case "mat_title_pos": + if len(d) == 1 && d[0]&3 != 3 { + // always where and how it's justified: + p := []Value{ + word([]string{"left", "above", "right", "below"}[d[0]>>6]), + word([]string{"center", "top_or_left", "bottom_or_right"}[d[0]&3])} + if r := d[0] & 0x3C; r != 0 { + p = append(p, num(int64(r))) + } + add(Value{Kind: KindPipe, Parts: p}) + } + case "mat_text_on_picture_pos": + if len(d) == 1 { + art, title := map[byte]string{0: "art_middle_center", 0x40: "art_middle_left", 0x50: "art_middle_right"}[d[0]&0xF0], + map[byte]string{0: "title_middle_center", 2: "title_upper_center", 4: "title_middle_left", + 5: "title_middle_right", 7: "title_lower_center"}[d[0]&0x0F] + if art != "" && title != "" { + add(Value{Kind: KindPipe, Parts: []Value{word(art), word(title)}}) + } + } + case "mat_size": + switch len(d) { + case 2: + add(num(int64(d[0])), num(int64(d[1]))) + case 4: + add(num(int64(d[0])), num(int64(d[1])), num(beNumber(d[2:]))) + } + case "hfs_attr_field_mapping", "hfs_attr_variable_mapping", "hfs_attr_dispatch_mapping": + if len(d) == 8 { + add(num(beNumber(d[:4])), num(beNumber(d[4:]))) + } + case "hfs_attr_checkbox_mapping": + if len(d) >= 4 { + add(num(beNumber(d[:4])), str(d[4:])) + } + } + if es := atomEnums[a.Name]; len(es) > 1 && len(d) <= len(es) { + // one byte a place: mat_font_sis + var vals []Value + for i := range d { + if v, ok := enumRender(a, i, d[i:i+1]); ok { + vals = append(vals, v) + } else { + vals = append(vals, num(int64(d[i]))) + } + } + add(vals...) + } + switch a.Type { + case TypeStream: + if frames, err := Decode(d); err == nil && bytes.Equal(Encode(frames), d) { + add(Value{Kind: KindStream, streamFrames: frames}) + } + case TypeDword, TypeCriterion: + add(num(beNumber(d))) + case TypeString: + if textual(d) { + add(str(d)) + } + case TypeBool: + if len(d) == 1 && d[0] <= 1 { + add(word(map[byte]string{0: "no", 1: "yes"}[d[0]])) + } + case TypeGID: + if g := gidValue(d); g != nil { + add(*g) + } + add(num(beNumber(d))) + case TypeAtom, TypeList: + if len(d) == 2 { + if r, ok := LookupNum(d[0], d[1]); ok { + add(word(r.Name)) + } + } + if a.Type == TypeList && len(d) > 1 && textual(d[1:]) { + add(num(int64(d[0])), str(d[1:])) + } + if len(d) > 2 { + if r, ok := LookupNum(d[0], d[1]); ok { + add(word(r.Name), Value{Kind: KindHex, Bytes: d[2:]}) + } + } + case TypeObject, TypeAlert: + if len(d) >= 1 { + if v, ok := enumRender(a, 0, d[:1]); ok && v.Kind == KindWord { + add(v, str(d[1:])) + } + add(Value{Kind: KindHex, Bytes: d[:1]}, str(d[1:])) + } + case TypeVar: + var vals []Value + for _, c := range d { + if c >= 26 { + vals = nil + break + } + vals = append(vals, word(string(rune('A'+c)))) + } + if vals != nil { + add(vals...) + } + case TypeVarNumber: + if len(d) == 1 && d[0] < 26 { + add(word(string(rune('A' + d[0])))) + } + if len(d) >= 2 && d[0] < 26 { + add(word(string(rune('A'+d[0]))), num(beNumber(d[1:]))) + } + case TypeVarString: + if len(d) >= 1 && d[0] < 26 { + add(word(string(rune('A'+d[0]))), str(d[1:])) + } + case TypeByteList: + var vals []Value + for _, c := range d { + vals = append(vals, num(int64(c))) + } + add(vals...) + case TypeToken: + // a token, then (usually) a global id or a number + if len(d) > 2 && printable(d[:2]) { + if len(d) == 3 && d[2] < 10 { + add(str(d[:2]), num(int64(d[2]))) + } + if g := tokenGID(a, d[2:]); g != nil { + add(str(d[:2]), *g) + } + } + if len(d) >= 2 && printable(d) { + add(str(d)) + } else if len(d) > 2 && printable(d[:2]) { + add(str(d[:2]), Value{Kind: KindHex, Bytes: d[2:]}) + } + } + if len(d) >= 1 && len(d) <= 4 && a.Type != TypeRaw && a.Type != TypeString { + add(num(beNumber(d))) + } + return out +} + +// textual is whether Ada32's disassembler writes b as a string: no +// control characters but tab, CR and LF. +func textual(b []byte) bool { + for _, c := range b { + if c < 0x20 && c != '\t' && c != '\r' && c != '\n' { + return false + } + } + return true +} + +// gid3 are the token atoms whose global ids Ada32 writes in three parts, +// 0-36-7232 where the others write 36-7232. +var gid3 = map[string]bool{"sm_m_send_token_arg": true, "de_ez_send_form": true, "sm_send_token_arg": true} + +// tokenGID shows the bytes after a token as a global id. +func tokenGID(a *Atom, d []byte) *Value { + switch { + case len(d) == 1: + return &Value{Kind: KindGID, GID: []int64{0, 0, beNumber(d)}} + case len(d) == 2 && gid3[a.Name]: + return &Value{Kind: KindGID, GID: []int64{0, 0, beNumber(d)}} + case len(d) == 2: + return &Value{Kind: KindGID, GID: []int64{0, beNumber(d)}} + case len(d) == 3 && gid3[a.Name]: + return &Value{Kind: KindGID, GID: []int64{0, int64(d[0]), beNumber(d[1:])}} + case len(d) == 3 || len(d) == 4: + return gidValue(d) + } + return nil +} + +func printable(b []byte) bool { + for _, c := range b { + if c < 0x20 || c >= 0x7F { + return false + } + } + return true +} + +// enumRender shows d as the i'th place's named value, or flags or'd. +func enumRender(a *Atom, i int, d []byte) (Value, bool) { + if a.Type == TypeOrient && i == 0 { + if len(d) == 1 { + if w, ok := orientName(d[0]); ok { + return Value{Kind: KindWord, Text: w}, true + } + } + return Value{}, false + } + e := enumAt(a, i) + if e == nil || len(d) != e.width { + return Value{}, false + } + v := uint32(beNumber(d)) + if w, ok := e.name(v); ok { + return Value{Kind: KindWord, Text: w}, true + } + if !e.flags { + return Value{}, false + } + // flags: the biggest named values that fit, then what's left as a number + vals := append([]namedValue(nil), e.vals...) + sort.SliceStable(vals, func(i, j int) bool { return vals[i].val > vals[j].val }) + var named []namedValue + rest := v + for _, f := range vals { + if f.val != 0 && f.name[0] != '~' && rest&f.val == f.val { + named = append(named, f) + rest &^= f.val + } + } + if !e.desc { + sort.SliceStable(named, func(i, j int) bool { return named[i].val < named[j].val }) + } + var parts []Value + for _, f := range named { + parts = append(parts, Value{Kind: KindWord, Text: f.name}) + } + if rest != 0 { + parts = append(parts, Value{Kind: KindNum, Num: int64(rest)}) + } + if len(parts) < 2 { + return Value{}, false + } + return Value{Kind: KindPipe, Parts: parts}, true +} + +func beNumber(d []byte) int64 { + var n int64 + for _, c := range d { + n = n<<8 | int64(c) + } + return n +} + +// gidValue reads 3 bytes as a-b and 4 as a-b-c. +func gidValue(d []byte) *Value { + switch len(d) { + case 3: + return &Value{Kind: KindGID, GID: []int64{int64(d[0]), int64(d[1])<<8 | int64(d[2])}} + case 4: + return &Value{Kind: KindGID, GID: []int64{int64(d[0]), int64(d[1]), int64(d[2])<<8 | int64(d[3])}} + } + return nil +} diff --git a/internal/aol/fdo/testdata/README.md b/internal/aol/fdo/testdata/README.md new file mode 100644 index 0000000..a01439c --- /dev/null +++ b/internal/aol/fdo/testdata/README.md @@ -0,0 +1,8 @@ +From AtomForge's test corpus (atomforge-fdo-java, src/test/resources; +Copyright AtomForge Contributors, MIT License: ../LICENSE.atomforge): + +- golden: 93 of its golden files, FDO91 source (.txt) and the atom + stream Ada32.dll compiled it to (.bin), picked to have as many + different atoms as they can. +- livecapture: its 44 streams captured from a live AOL client, as + source and bytes. diff --git a/internal/aol/fdo/testdata/golden/test_0011.bin b/internal/aol/fdo/testdata/golden/test_0011.bin new file mode 100755 index 0000000..713d94c Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0011.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0011.txt b/internal/aol/fdo/testdata/golden/test_0011.txt new file mode 100755 index 0000000..3c6a5f8 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0011.txt @@ -0,0 +1,55 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-118> + mat_orientation + mat_position + man_start_object + mat_orientation + mat_size <15, 11> + mat_relative_tag <1> + mat_bool_resize_horizontal + mat_bool_default_send + act_replace_select_action + < + uni_start_stream_wait_on <00x> + de_ez_send_list_text <"id", 01x, 00x, 00x, 00x, 01x> + > + man_start_sibling + mat_orientation + man_start_object + mat_art_id <1-0-1333> + mat_bool_disabled + man_start_sibling + mat_bool_default + act_replace_select_action + < + uni_start_stream + uni_wait_on + de_start_extraction <0> + man_set_context_relative <1> + de_get_data_pointer + uni_save_result + de_end_extraction + uni_invoke_no_context <32-225> + man_set_context_globalid <32-225> + man_place_cursor <2> + man_set_context_relative <1> + uni_get_result + uni_use_last_atom_string + uni_use_last_atom_string + man_end_context + man_update_display + buf_close_buffer + uni_wait_off + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream_wait_on <00x> + de_ez_send_list_text <"id", 01x, 00x, 00x, 00x, 01x> + > + man_end_object + man_end_object + man_update_display + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0021.bin b/internal/aol/fdo/testdata/golden/test_0021.bin new file mode 100755 index 0000000..fdb0226 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0021.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0021.txt b/internal/aol/fdo/testdata/golden/test_0021.txt new file mode 100755 index 0000000..9b9cca1 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0021.txt @@ -0,0 +1,46 @@ +uni_start_stream + idb_set_context <20-0-258> + idb_atr_offset <0> + idb_get_value <04x> + var_number_set_from_atom + idb_end_context + var_number_get + uni_use_last_atom_value + idb_atr_offset <0> + idb_get_value <04x> + var_number_set_from_atom + var_number_set + uni_start_loop + var_number_get + uni_use_last_atom_value + idb_get_value <04x> + var_number_set_from_atom + if_numa_neq_numb_then <1> + var_number_get + var_number_set_from_atom + var_number_add <8> + var_number_get + var_number_set_from_atom + var_number_decrement + var_number_get + var_number_set_from_atom + if_numa_true_then <2> + uni_end_loop + uni_sync_skip <1> + var_number_get + var_number_set_from_atom + var_number_add <4> + var_number_get + uni_use_last_atom_value + idb_get_value <04x> + uni_use_last_atom_value + idb_end_context + var_number_set + if_numa_true_then <3> + uni_sync_skip <2> + idb_atr_offset <8> + idb_get_value <04x> + uni_use_last_atom_value + idb_end_context + uni_sync_skip <3> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0038.bin b/internal/aol/fdo/testdata/golden/test_0038.bin new file mode 100755 index 0000000..c71c0dd Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0038.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0038.txt b/internal/aol/fdo/testdata/golden/test_0038.txt new file mode 100755 index 0000000..1f70e80 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0038.txt @@ -0,0 +1,238 @@ +uni_start_stream + idb_set_context <20-0-16> + idb_atr_offset <1> + idb_get_string + var_string_set_from_atom + var_string_set + idb_end_context + if_stra_eq_strb_then <10, 99> + async_error_box <"Complex Window Region"> + uni_sync_skip <10> + lm_table_use_table <20-0-65> + man_start_object + mat_bool_modal + mat_orientation + mat_object_id <32-2164> + mat_title <"Default West Screen"> + man_start_object + mat_orientation + man_start_object + mat_title <"Special Epsilon"> + man_end_object + man_start_object + mat_title <"Previous Theta"> + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + man_start_object + mat_bool_hidden + mat_relative_tag <1> + man_end_object + man_end_object + man_start_object + mat_height <1> + mat_width <10> + mat_capacity <8> + mat_bool_protected_input + mat_bool_hidden + mat_relative_tag <2> + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + man_start_object + mat_bool_hidden + mat_relative_tag <3> + man_end_object + man_end_object + man_start_object + mat_height <1> + mat_width <10> + mat_relative_tag <4> + mat_capacity <8> + mat_bool_protected_input + mat_bool_hidden + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + man_start_object + mat_bool_hidden + mat_relative_tag <5> + man_end_object + man_end_object + man_start_object + mat_height <1> + mat_width <10> + mat_capacity <8> + mat_bool_protected_input + mat_relative_tag <6> + mat_bool_hidden + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + man_start_object + mat_bool_hidden + mat_relative_tag <7> + man_end_object + man_end_object + man_start_object + mat_height <1> + mat_width <10> + mat_capacity <8> + mat_bool_protected_input + mat_relative_tag <8> + mat_bool_hidden + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + man_start_object + mat_bool_hidden + mat_relative_tag <9> + man_end_object + man_end_object + man_start_object + mat_height <1> + mat_width <10> + mat_capacity <8> + mat_bool_protected_input + mat_relative_tag <10> + mat_bool_hidden + man_end_object + man_end_object + man_start_object + mat_orientation + man_start_object + mat_height <4> + mat_width <30> + mat_font_sis + man_append_data <"old delete handle sub create north invoke create. north open simple unit save top invoke east. zone process simple first"> + man_end_object + man_start_object + mat_orientation + man_start_object + mat_bool_default + mat_title <"OK"> + act_set_criterion + act_append_action + < + uni_start_stream + man_close_update + uni_end_stream + > + man_end_object + man_end_object + man_update_display + man_end_object + man_set_context_globalid <32-2164> + var_number_set + idb_set_context <20-0-16> + idb_atr_offset <0> + idb_get_value + var_number_set_from_atom + if_numa_lte_numb_then <1> + var_number_set + uni_sync_skip <1> + var_number_set + var_number_set + var_string_set + var_number_set + uni_start_loop + uni_use_last_atom_value + var_number_increment + var_number_get + uni_use_last_atom_value + idb_get_string + var_string_set_from_atom + if_stra_eq_strb_then <5> + var_number_set + uni_sync_skip <5> + var_string_get + uni_use_last_atom_string + var_string_get + uni_use_last_atom_string + uni_use_last_atom_value + var_number_get + uni_use_last_atom_value + man_end_context + var_number_increment + var_number_get + uni_use_last_atom_value + var_string_get + uni_use_last_atom_string + uni_save_result + if_last_return_true_then <15> + uni_get_result + uni_use_last_atom_string + uni_sync_skip <15> + var_number_get + uni_use_last_atom_value + man_end_context + var_number_decrement + if_numb_true_then <2> + var_number_add <22> + uni_end_loop + uni_sync_skip <2> + idb_end_context + man_update_display + uni_sync_skip <99> + uni_wait_off + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0054.bin b/internal/aol/fdo/testdata/golden/test_0054.bin new file mode 100755 index 0000000..a8c2c48 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0054.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0054.txt b/internal/aol/fdo/testdata/golden/test_0054.txt new file mode 100755 index 0000000..76db4e5 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0054.txt @@ -0,0 +1,156 @@ +uni_start_stream + uni_wait_off + man_start_object + mat_object_id <32-234> + mat_title <"Complex Thing North"> + man_start_object + mat_orientation + man_start_object + mat_title <"Fourth Button Epsilon"> + mat_relative_tag <1> + mat_width <72> + mat_height <10> + mat_ruler <22> + mat_ruler <56> + act_replace_select_action + < + uni_start_stream + man_set_context_relative <4> + man_get_attribute + if_last_return_false_then <1> + act_do_action + act_append_action + < + uni_start_stream + uni_wait_on + xfer_show_file_description <00x, 20x, 00x, eax> + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1469> + mat_title <"Special Sigma\x7fsub"> + mat_relative_tag <5> + act_set_criterion + act_append_action + < + uni_start_stream + lm_open_window <32-235> + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1468> + mat_title <"Simple Bottom\x7fSub Theta"> + mat_relative_tag <7> + act_set_criterion + act_append_action + < + uni_start_stream + xfer_start_download + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1309> + mat_title <"Active Dialog\x7fActive Unit"> + mat_relative_tag <10> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + man_preset_gid <32-280> + if_last_return_true_then <1, 2> + man_make_focus + man_update_display + uni_sync_skip <1> + uni_invoke_no_context <32-280> + uni_sync_skip <2> + uni_wait_off_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1325> + mat_title <"righ"> + mat_relative_tag <9> + act_replace_select_action + < + uni_start_stream_wait_on + async_exec_context_help <44x, 6fx, 77x, 6ex, 6cx, 6fx, 61x, 64x> + uni_wait_off_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display + man_end_object + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0056.bin b/internal/aol/fdo/testdata/golden/test_0056.bin new file mode 100755 index 0000000..a924513 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0056.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0056.txt b/internal/aol/fdo/testdata/golden/test_0056.txt new file mode 100755 index 0000000..d57db21 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0056.txt @@ -0,0 +1,123 @@ +uni_start_stream + uni_wait_off + man_start_object + mat_object_id <32-235> + mat_title <"Third Right Component"> + man_start_object + mat_orientation + man_start_object + mat_title <"Advanced Corner South"> + mat_relative_tag <1> + mat_width <71> + mat_height <10> + mat_ruler <22> + mat_ruler <52> + act_replace_select_action + < + uni_start_stream + man_set_context_relative <2> + man_get_attribute + if_last_return_false_then <1> + act_do_action + act_append_action + < + uni_start_stream + uni_wait_on + xfer_show_file_description <00x, 20x, 00x, ebx> + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1469> + mat_title <"Special Sigma\x7fsub"> + mat_relative_tag <3> + act_set_criterion + act_append_action + < + uni_start_stream + xfer_show_file_status <00x, 20x, 00x, ebx> + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1292> + mat_title <"New Delta"> + mat_relative_tag <5> + act_set_criterion + act_append_action + < + uni_start_stream + sm_enter_paid + lm_open_window <32-234> + uni_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1309> + mat_title <"Active Dialog\x7fActive Unit"> + mat_relative_tag <8> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + man_preset_gid <32-280> + if_last_return_true_then <1, 2> + man_make_focus + man_update_display + uni_sync_skip <1> + uni_invoke_no_context <32-280> + uni_sync_skip <2> + uni_wait_off_end_stream + > + man_end_object + man_start_object + mat_art_id <1-0-1325> + mat_title <"righ"> + mat_relative_tag <7> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + async_exec_context_help <44x, 6fx, 77x, 6ex, 6cx, 6fx, 61x, 64x> + uni_wait_off_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display + man_end_object + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0062.bin b/internal/aol/fdo/testdata/golden/test_0062.bin new file mode 100755 index 0000000..0e4bf06 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0062.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0062.txt b/internal/aol/fdo/testdata/golden/test_0062.txt new file mode 100755 index 0000000..06cfe73 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0062.txt @@ -0,0 +1,19 @@ +uni_start_stream + var_number_set + man_item_get <3> + if_last_return_true_then <1> + fm_start + man_logging_command <3> + man_logging_command <2> + fm_end + var_numa_increment + uni_sync_skip <1> + man_item_get <2> + if_last_return_true_then <1> + fm_start + man_logging_command <4> + man_logging_command <2> + fm_end + var_numa_increment + uni_sync_skip <1> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0068.bin b/internal/aol/fdo/testdata/golden/test_0068.bin new file mode 100755 index 0000000..2b32740 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0068.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0068.txt b/internal/aol/fdo/testdata/golden/test_0068.txt new file mode 100755 index 0000000..ec955d9 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0068.txt @@ -0,0 +1,34 @@ +uni_start_stream + man_set_response_id <8436> + man_start_object + mat_position + mat_object_id <32-244> + mat_title <"Main Alpha"> + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_art_id <1-0-1331> + mat_title <"form"> + mat_command_key <43x, 00x> + act_set_criterion + act_append_action + < + uni_start_stream + man_close <32-220> + uni_invoke_no_context <32-221> + man_set_context_globalid <32-221> + mat_bool_invisible + man_update_display <32-221> + man_end_context + man_update_display <32-220> + ccl_hang_up + mip_action_command <0ax> + uni_end_stream + > + man_end_object + man_end_object + man_update_display + man_end_object + ccl_dial + man_end_context +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0117.bin b/internal/aol/fdo/testdata/golden/test_0117.bin new file mode 100755 index 0000000..441d519 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0117.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0117.txt b/internal/aol/fdo/testdata/golden/test_0117.txt new file mode 100755 index 0000000..3827bfe --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0117.txt @@ -0,0 +1,14 @@ +uni_start_stream + man_close <32-220> + uni_invoke_no_context <32-221> + man_set_context_globalid <32-221> + act_set_index <01x> + if_test_index_false_then + act_clr_test_index + mat_bool_invisible + man_update_display + man_end_context + uni_sync_skip <1> + ccl_hang_up + man_update_display <32-220> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0120.bin b/internal/aol/fdo/testdata/golden/test_0120.bin new file mode 100755 index 0000000..12febac Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0120.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0120.txt b/internal/aol/fdo/testdata/golden/test_0120.txt new file mode 100755 index 0000000..b12dbaa --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0120.txt @@ -0,0 +1,6 @@ +uni_start_stream + act_get_db_value <14x, 00x, 00x, 29x> + if_last_return_true_then <1> + man_response_pop + uni_sync_skip <1> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0122.bin b/internal/aol/fdo/testdata/golden/test_0122.bin new file mode 100755 index 0000000..3c8768f Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0122.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0122.txt b/internal/aol/fdo/testdata/golden/test_0122.txt new file mode 100755 index 0000000..ad0c3ad --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0122.txt @@ -0,0 +1,105 @@ +uni_start_stream <00x> + man_start_object + mat_style_id <32-425> + mat_orientation + mat_object_id <32-425> + mat_position + mat_bool_resize_vertical + mat_bool_modal + man_start_object + mat_orientation + mat_size <40, 8> + mat_relative_tag <1> + mat_title_pos + mat_bool_resize_vertical + mat_bool_resize_horizontal + act_replace_select_action + < + uni_start_stream + man_set_context_relative <5> + man_get_attribute + uni_save_result + man_end_context + uni_get_result + if_last_return_false_then <1, 2> + ad_to + uni_sync_skip <1> + ad_modify + man_set_context_globalid <32-427> + man_set_context_relative <2> + man_make_focus + man_end_context + man_update_display + man_end_context + uni_sync_skip <2> + uni_end_stream + > + man_start_sibling + mat_orientation + man_start_object + mat_title_width <6> + mat_relative_tag <5> + mat_bool_default + act_replace_select_action + < + uni_start_stream + ad_to + uni_end_stream + > + man_start_sibling + mat_title_width <6> + mat_relative_tag <6> + act_replace_select_action + < + uni_start_stream + ad_cc + uni_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_title_width <6> + mat_relative_tag <2> + act_replace_select_action + < + uni_start_stream + ad_add + uni_end_stream + > + man_start_sibling + mat_relative_tag <3> + act_replace_select_action + < + uni_start_stream + ad_modify + man_set_context_globalid <32-427> + man_set_context_relative <2> + man_make_focus + man_end_context + man_update_display + man_end_context + uni_end_stream + > + man_start_sibling + mat_title_width <6> + mat_relative_tag <4> + mat_command_key <91x, 00x> + act_replace_select_action + < + uni_start_stream + lm_user_delete_item <2097577> + uni_end_stream + > + man_start_sibling + mat_title_width <6> + act_replace_select_action + < + uni_start_stream + man_close_update + uni_end_stream + > + man_end_object + man_end_object + man_update_display + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0123.bin b/internal/aol/fdo/testdata/golden/test_0123.bin new file mode 100755 index 0000000..c385cb3 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0123.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0123.txt b/internal/aol/fdo/testdata/golden/test_0123.txt new file mode 100755 index 0000000..4289662 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0123.txt @@ -0,0 +1,64 @@ +uni_start_stream <00x> + man_preset_gid <32-427> + if_last_return_true_then <1> + man_make_focus + man_update_display +uni_abort_stream +uni_sync_skip <1> +man_start_object + mat_object_id <32-427> + mat_style_id <32-427> + mat_orientation + mat_position + mat_bool_resize_vertical + mat_bool_modal + man_start_object + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_size <35, 1, 35> + mat_font_id + man_start_sibling + mat_size <32, 1, 31> + mat_relative_tag <1> + mat_capacity <31> + mat_title_pos + mat_validation <128> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_size <30, 1, 40> + mat_font_id + man_start_sibling + mat_size <50, 3, 256> + mat_relative_tag <2> + mat_bool_writeable + mat_validation <128> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_bool_default + act_replace_select_action + < + uni_start_stream + de_validate + ad_store + man_close_update + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream + man_close_update + uni_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0126.bin b/internal/aol/fdo/testdata/golden/test_0126.bin new file mode 100755 index 0000000..4da1a24 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0126.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0126.txt b/internal/aol/fdo/testdata/golden/test_0126.txt new file mode 100755 index 0000000..0164173 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0126.txt @@ -0,0 +1,21 @@ +uni_start_stream <00x> + man_use_default_title + man_start_object + mat_object_id <32-4589> + mat_orientation + mat_position + mat_style_id <32-4589> + mat_dirty_query + man_start_object + mat_size <60, 14> + mat_relative_tag <1> + mat_bool_vertical_scroll + mat_bool_writeable + mat_managed_by <63> + chart_bool_show_tools + mat_width <570> + mat_height <350> + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0146.bin b/internal/aol/fdo/testdata/golden/test_0146.bin new file mode 100755 index 0000000..50990ee Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0146.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0146.txt b/internal/aol/fdo/testdata/golden/test_0146.txt new file mode 100755 index 0000000..933aa74 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0146.txt @@ -0,0 +1,170 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-4645> + mat_orientation + mat_position + mat_style_id <32-44> + act_set_criterion + act_replace_action + < + uni_start_stream + morg_obj_destroy_children <"New Top"> + uni_end_stream + > + man_start_object + mat_size <63, 10> + mat_relative_tag <1> + mat_bool_writeable + mat_size <63, 10> + mat_managed_by <70> + mat_font_sis + morg_view_path <"New Top"> + uni_sync_skip <101> + morg_view_highlight_full_line + uni_sync_skip <101> + morg_view_allow_delete_key + act_set_criterion <128> + act_replace_action + < + uni_start_stream + man_set_context_relative <1> + morg_view_has_mult_selections + var_number_set_from_atom + morg_obj_count_children + uni_save_result + man_end_context + uni_get_result + if_last_return_false_then <10, 20> + man_set_context_relative <17> + mat_bool_disabled + man_change_context_relative <2> + mat_bool_disabled + man_change_context_relative <6> + mat_bool_disabled + man_change_context_relative <8> + mat_bool_disabled + man_end_context + uni_sync_skip <10> + man_set_context_relative <17> + mat_bool_disabled + man_end_context + if_numb_false_then <171, 177> + man_set_context_relative <2> + mat_bool_disabled + man_change_context_relative <6> + mat_bool_disabled + man_change_context_relative <8> + mat_bool_disabled + man_end_context + uni_sync_skip <171> + man_set_context_relative <2> + mat_bool_disabled + man_change_context_relative <6> + mat_bool_disabled + man_change_context_relative <8> + mat_bool_disabled + man_end_context + uni_sync_skip <177> + uni_sync_skip <20> + man_update_display + uni_end_stream + > + act_set_criterion <130> + act_replace_action + < + uni_start_stream + man_set_context_relative <1> + act_do_action <128> + man_end_context + uni_end_stream + > + act_set_criterion <22> + act_replace_action + < + uni_start_stream + man_set_context_relative <1> + buf_start_buffer + buf_set_token <"m2"> + lm_get_first_selection + uni_save_result + uni_start_loop + uni_get_result + if_last_return_true_then <1> + uni_get_result + uni_use_last_atom_value + buf_set_data_atom + uni_get_result + uni_use_last_atom_value + buf_set_data_atom + buf_add_atom_data <6> + lm_get_next_selection + uni_save_result + uni_end_loop + uni_sync_skip <1> + buf_close_buffer + man_end_context + uni_end_stream + > + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <2> + mat_bool_default + act_replace_select_action + < + uni_start_stream + man_set_context_relative <1> + morg_view_select_object + man_end_context + uni_end_stream + > + man_start_sibling + mat_relative_tag <6> + act_replace_select_action + < + uni_start_stream_wait_on + man_set_context_relative <1> + lm_get_selected_item_id + uni_save_result + man_end_context + buf_start_buffer + buf_set_token <"oS"> + uni_get_result + uni_use_last_atom_value + buf_close_buffer + uni_end_stream + > + man_start_sibling + mat_relative_tag <8> + act_replace_select_action + < + uni_start_stream_wait_on + man_set_context_relative <1> + lm_get_selected_item_id + uni_save_result + man_end_context + buf_start_buffer + buf_set_token <"oR"> + uni_get_result + uni_use_last_atom_value + buf_close_buffer + uni_end_stream + > + man_start_sibling + mat_relative_tag <17> + act_replace_select_action + < + uni_start_stream + man_set_context_relative <1> + act_do_action <22> + man_end_context + uni_end_stream + > + mat_command_key <91x, 00x> + man_end_object + man_end_object + man_update_display + man_set_context_relative <1> + act_do_action <128> + man_end_context + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0151.bin b/internal/aol/fdo/testdata/golden/test_0151.bin new file mode 100755 index 0000000..04dc993 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0151.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0151.txt b/internal/aol/fdo/testdata/golden/test_0151.txt new file mode 100755 index 0000000..f47e295 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0151.txt @@ -0,0 +1,149 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-4653> + mat_orientation + mat_position + act_set_criterion <128> + act_replace_action + < + uni_start_stream + man_set_context_relative <1> + man_close_children + fm_start + fm_item_type + fm_item_set <"VIEWERS.INI"> + fm_item_type + fm_item_set <"VIEWERS"> + fm_item_type + fm_item_set <"@\x00"> + fm_ini_get_section + uni_start_loop + fm_ini_get_next_line + var_string_set_from_atom + if_stra_neq_null_then <1> + fm_item_type + var_string_get + uni_use_last_atom_string + fm_ini_read_data <00x> + uni_use_last_atom_string + man_start_object + act_set_inheritance <02x> + var_string_save + man_end_object + uni_end_loop + uni_sync_skip <1> + fm_end + man_is_rendered + if_last_return_true_then <1> + man_update_display + man_end_context + uni_end_stream + > + man_start_object + mat_orientation + man_start_object + mat_orientation + mat_size <40, 10> + mat_relative_tag <1> + mat_sort_order + act_replace_select_action + < + uni_start_stream + man_set_context_relative <2> + act_do_action + man_end_context + uni_sync_skip <2> + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0167.bin b/internal/aol/fdo/testdata/golden/test_0167.bin new file mode 100755 index 0000000..349ead1 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0167.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0167.txt b/internal/aol/fdo/testdata/golden/test_0167.txt new file mode 100755 index 0000000..560ce06 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0167.txt @@ -0,0 +1,44 @@ +uni_start_stream + if_offline_then <1> + var_number_set +uni_abort_stream +uni_sync_skip <1> +man_set_context_globalid <1> +var_lookup_by_id +if_numa_true_then <1> +var_number_set +uni_abort_stream +uni_sync_skip <1> +man_end_context +async_alert +var_number_set_from_atom +var_number_set +if_numa_neq_numb_then <1> +var_number_set +uni_abort_stream +uni_sync_skip <1> +xfer_finish_later +uni_wait_on +man_get_first_window +uni_save_result +uni_start_loop +uni_get_result +if_last_return_true_then <1> +uni_get_result +uni_use_last_atom_value +act_do_action <67108871> +man_end_context +uni_get_result +uni_use_last_atom_value +man_get_next_window +uni_save_result +uni_end_loop +uni_sync_skip <1> +uni_invoke_no_context <32-481> +uni_invoke_no_context <32-483> +man_set_context_globalid <1> +var_number_set +var_number_save +man_end_context +var_number_set +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0172.bin b/internal/aol/fdo/testdata/golden/test_0172.bin new file mode 100755 index 0000000..3642324 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0172.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0172.txt b/internal/aol/fdo/testdata/golden/test_0172.txt new file mode 100755 index 0000000..30f8a60 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0172.txt @@ -0,0 +1,3 @@ +uni_start_stream + man_close_update <32-5831> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0174.bin b/internal/aol/fdo/testdata/golden/test_0174.bin new file mode 100755 index 0000000..b371829 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0174.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0174.txt b/internal/aol/fdo/testdata/golden/test_0174.txt new file mode 100755 index 0000000..8b6a115 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0174.txt @@ -0,0 +1,38 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-488> + mat_orientation + man_start_object + mat_orientation + mat_size <70> + mat_relative_tag <200> + mat_ruler <8, 50, 60> + man_start_sibling + mat_orientation + man_start_object + mat_bool_default + act_replace_select_action + < + uni_start_stream + mt_load_tool + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream + mt_bounce_tool + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream + mt_kill_tool + uni_end_stream + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0177.bin b/internal/aol/fdo/testdata/golden/test_0177.bin new file mode 100755 index 0000000..3d66f5b Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0177.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0177.txt b/internal/aol/fdo/testdata/golden/test_0177.txt new file mode 100755 index 0000000..9e1480b --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0177.txt @@ -0,0 +1,20 @@ +uni_start_stream <00x> + man_use_default_title + man_start_object + mat_orientation + mat_position + mat_style_id <32-493> + man_start_object + mat_orientation + mat_size <36, 12> + mat_relative_tag <1> + mat_bool_list_icons + man_start_sibling + mat_bool_default + act_replace_select_action + < + uni_start_stream <00x> + sm_do_list_action <1> + > + man_end_object + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0179.bin b/internal/aol/fdo/testdata/golden/test_0179.bin new file mode 100755 index 0000000..7421648 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0179.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0179.txt b/internal/aol/fdo/testdata/golden/test_0179.txt new file mode 100755 index 0000000..01b66f4 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0179.txt @@ -0,0 +1,21 @@ +uni_start_stream + man_use_default_title + man_set_context_globalid <1> + man_start_object + mat_form_icon <1-0-1290> + var_number_set + var_number_save + mat_dirty_query + mat_object_id <32-4941> + mat_style_id <32-233> + mat_orientation + man_start_object + mat_size <64, 22, 32000> + rich_manage + mat_bool_writeable + mat_log_object + mat_relative_tag <1> + man_end_object + man_update_end_object + man_end_context +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0180.bin b/internal/aol/fdo/testdata/golden/test_0180.bin new file mode 100755 index 0000000..23e1b58 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0180.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0180.txt b/internal/aol/fdo/testdata/golden/test_0180.txt new file mode 100755 index 0000000..c329912 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0180.txt @@ -0,0 +1,136 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-498> + mat_orientation + mat_bool_modal + man_start_object + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_orientation + mat_height <11> + mat_relative_tag <1> + mat_sort_order + fm_start + fm_item_type + fm_item_set <"\x00"> + fm_item_type + fm_item_set <"ID"> + fm_item_type + fm_item_set <"TITLE"> + fm_set_relative_path <"cen"> + fm_get_first_file <"Second Region"> + uni_save_result + uni_start_loop + uni_get_result + if_last_return_true_then <1> + man_start_object + uni_get_result + var_string_set_from_atom + var_string_save + fm_item_type + uni_get_result + uni_use_last_atom_string + fm_item_get + fm_item_type + uni_use_last_atom_string + fm_ini_read_data + uni_use_last_atom_string + man_end_object + fm_get_next_file + uni_save_result + uni_end_loop + uni_sync_skip <1> + fm_end + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_title_width <17> + mat_bool_default + act_replace_select_action + < + uni_start_stream + uni_single_step + de_start_extraction <0> + man_set_context_relative <1> + de_set_data_type + de_set_variable_id <10> + de_get_data_pointer + uni_use_last_atom_string + man_end_context + de_end_extraction + man_close_update + uni_end_stream + > + man_start_sibling + mat_title_width <17> + mat_bool_default + act_replace_select_action + < + uni_start_stream <00x> + uni_wait_on + uni_invoke_no_context <32-476> + uni_end_stream <00x> + > + man_start_sibling + mat_title_width <17> + act_replace_select_action + < + uni_start_stream <00x> + uni_wait_on + uni_invoke_no_context <32-477> + uni_end_stream <00x> + > + man_start_sibling + mat_title_width <17> + act_replace_select_action + < + uni_start_stream <00x> + uni_wait_on + uni_invoke_no_context <32-492> + uni_end_stream <00x> + > + man_start_sibling + mat_title_width <17> + mat_bool_disabled + man_start_sibling + act_replace_select_action + < + uni_start_stream <00x> + man_close_update + uni_end_stream <00x> + > + man_end_object + man_end_object + man_end_object + man_update_display + idb_set_context <20-0-45> + idb_atr_offset <0> + idb_get_string + uni_save_result + man_set_context_relative <1> + fm_start + fm_item_type + fm_item_set <"\x00"> + fm_item_type + fm_item_set <"ID"> + fm_item_type + fm_item_set <"TITLE"> + fm_set_relative_path <"cen"> + fm_item_type + uni_get_result + uni_use_last_atom_string + fm_item_get + fm_item_type + uni_use_last_atom_string + fm_ini_read_data + uni_use_last_atom_string + uni_use_last_atom_value + man_end_context + idb_end_context + man_update_display + fm_end + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0186.bin b/internal/aol/fdo/testdata/golden/test_0186.bin new file mode 100755 index 0000000..8962f1f Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0186.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0186.txt b/internal/aol/fdo/testdata/golden/test_0186.txt new file mode 100755 index 0000000..ce3eb75 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0186.txt @@ -0,0 +1,5 @@ +uni_start_stream + idb_set_context <32-539> + idb_atr_globalid <32-229> + idb_end_context +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0195.bin b/internal/aol/fdo/testdata/golden/test_0195.bin new file mode 100755 index 0000000..52efe8d Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0195.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0195.txt b/internal/aol/fdo/testdata/golden/test_0195.txt new file mode 100755 index 0000000..e8b5c3e --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0195.txt @@ -0,0 +1,30 @@ +uni_start_stream <00x> + man_start_object + mat_orientation + mat_bool_modal + man_start_object + mat_size <35, 1, 30> + mat_relative_tag <1> + man_start_sibling + mat_size <35, 1, 30> + man_append_data <"Advanced Form Gadget"> + man_start_sibling + mat_orientation + man_start_object + mat_bool_default + act_replace_select_action + < + uni_start_stream <00x> + sm_p_send_token_arg <"mV", 1> + > + man_start_sibling + act_replace_select_action + < + uni_start_stream <00x> + sm_p_send_token_arg <"mV", 0> + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0197.bin b/internal/aol/fdo/testdata/golden/test_0197.bin new file mode 100755 index 0000000..ff577df Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0197.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0197.txt b/internal/aol/fdo/testdata/golden/test_0197.txt new file mode 100755 index 0000000..15d618a --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0197.txt @@ -0,0 +1,47 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-566> + mat_orientation + mat_bool_modal + man_start_object + mat_size <30, 3> + man_append_data <"Current Corner Screen\x7fBasic Top Button\x7fBasic North Zone\x7f"> + man_start_sibling + mat_size <30, 1> + mat_relative_tag <1> + mat_bool_vertical_scroll + mat_bool_resize_horizontal + mat_bool_writeable + mat_validation <128> + man_start_sibling + mat_orientation + man_start_object + mat_bool_default + act_replace_select_action + < + uni_start_stream + man_set_context_relative <1> + de_start_extraction <0> + de_validate + de_get_data_pointer + uni_use_last_atom_string + de_end_extraction + man_end_context + man_close_update + uni_invoke_local <32-570> + ccl_update_locality + man_close_update + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream <00x> + man_close_update + uni_end_stream <00x> + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0201.bin b/internal/aol/fdo/testdata/golden/test_0201.bin new file mode 100755 index 0000000..bb88efe Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0201.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0201.txt b/internal/aol/fdo/testdata/golden/test_0201.txt new file mode 100755 index 0000000..7cfe593 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0201.txt @@ -0,0 +1,3 @@ +uni_start_stream + async_play_sound_dammit <"Previous Region Side"> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0203.bin b/internal/aol/fdo/testdata/golden/test_0203.bin new file mode 100755 index 0000000..06618fc Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0203.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0203.txt b/internal/aol/fdo/testdata/golden/test_0203.txt new file mode 100755 index 0000000..90209b6 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0203.txt @@ -0,0 +1,28 @@ +uni_start_stream + man_set_context_globalid <32-666> + man_set_context_relative <16> + man_replace_data <"Simple Form"> + man_set_context_relative <1> + mat_value <1> + man_set_context_relative <3> + man_replace_data + man_set_context_relative <4> + mat_value <3> + man_set_context_relative <5> + mat_value <1> + man_set_context_relative <6> + man_replace_data + man_set_context_relative <7> + mat_value <3> + man_set_context_relative <8> + mat_value <1> + man_set_context_relative <11> + mat_value <0> + man_set_context_relative <12> + mat_bool_disabled + man_set_context_relative <13> + mat_value <0> + man_set_context_relative <14> + mat_bool_disabled + man_update_display +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0207.bin b/internal/aol/fdo/testdata/golden/test_0207.bin new file mode 100755 index 0000000..d4339cb Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0207.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0207.txt b/internal/aol/fdo/testdata/golden/test_0207.txt new file mode 100755 index 0000000..4a3503c --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0207.txt @@ -0,0 +1,17 @@ +uni_start_stream + man_insert_object_after <335544371> + mat_object_type + mat_object_id <32-5831> + mat_title <"Custom Sub Bottom"> + man_start_object + mat_relative_tag <1> + act_replace_select_action + < + uni_start_stream_wait_on + sm_enter_paid + uni_wait_off_end_stream + > + man_end_object + man_end_object + man_update_display +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0208.bin b/internal/aol/fdo/testdata/golden/test_0208.bin new file mode 100755 index 0000000..6a4017c Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0208.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0208.txt b/internal/aol/fdo/testdata/golden/test_0208.txt new file mode 100755 index 0000000..806ba47 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0208.txt @@ -0,0 +1,6 @@ +uni_start_stream + man_set_context_globalid <32-5831> + man_close_children + man_end_context + man_close_update <32-5831> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0211.bin b/internal/aol/fdo/testdata/golden/test_0211.bin new file mode 100755 index 0000000..496d372 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0211.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0211.txt b/internal/aol/fdo/testdata/golden/test_0211.txt new file mode 100755 index 0000000..d503f33 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0211.txt @@ -0,0 +1,175 @@ +uni_start_stream <00x> + man_start_object + mat_style_id <32-6024> + mat_orientation + mat_precise_width <455> + mat_precise_height <280> + mat_style_id <32-5472> + act_set_criterion <7> + act_replace_action + < + uni_start_stream + man_close_update + uni_end_stream + > + act_set_criterion <8> + act_replace_action + < + uni_start_stream + man_close_update + uni_end_stream + > + mat_art_id <1-0-21743> + mat_position + mat_bool_resize_vertical + mat_bool_precise + mat_bool_background_tile + man_start_object + man_force_old_style_dod + mat_art_id <1-0-35535> + mat_bool_disabled + mat_bool_invert + man_start_sibling + mat_precise_x <110> + mat_precise_y <10> + mat_art_id <1-0-29737> + mat_bool_disabled + man_start_sibling + mat_relative_tag <6> + mat_bool_invisible + man_start_sibling + rich_manage + rich_set_static + mat_precise_x <200> + mat_precise_y <10> + mat_precise_width <230> + mat_precise_height <72> + mat_relative_tag <3> + rich_set_static + mat_font_id + mat_font_size <12> + mat_font_style + man_start_sibling + mat_precise_x <120> + mat_precise_y <90> + mat_relative_tag <4> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + mat_bool_gradual_shadow + man_start_sibling + rich_manage + mat_precise_x <200> + mat_precise_y <90> + mat_precise_width <210> + mat_precise_height <60> + mat_relative_tag <1> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + mat_precise_x <120> + mat_precise_y <175> + mat_relative_tag <5> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + mat_bool_gradual_shadow + man_start_sibling + rich_manage + mat_precise_x <200> + mat_precise_y <175> + mat_precise_width <210> + mat_precise_height <60> + mat_relative_tag <2> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + mat_title_width <8> + mat_precise_x <120> + mat_precise_y <245> + mat_color_face <100, 100, 178> + mat_color_text <240, 240, 240> + mat_color_top_edge <150, 200, 255> + mat_color_bottom_edge <1, 1, 1> + mat_trigger_style + mat_font_id + mat_font_size <10> + mat_font_style + act_replace_select_action + < + uni_start_stream <00x> + man_close_update + man_preset_gid <32-5483> + if_last_return_true_then <1, 2> + man_make_focus + man_update_display + uni_sync_skip <1> + uni_invoke_no_context <32-5483> + uni_sync_skip <2> + uni_end_stream + > + man_start_sibling + mat_title_width <8> + mat_precise_x <230> + mat_precise_y <245> + mat_relative_tag <7> + mat_color_face <100, 100, 178> + mat_color_text <240, 240, 240> + mat_color_top_edge <150, 200, 255> + mat_color_bottom_edge <1, 1, 1> + mat_trigger_style + mat_bool_default + mat_font_id + mat_font_size <10> + mat_font_style + act_replace_select_action + < + uni_start_stream + man_close_update + uni_wait_on + async_exit_aux <00x> + uni_end_stream + > + man_start_sibling + mat_title_width <8> + mat_precise_x <340> + mat_precise_y <245> + mat_color_face <100, 100, 178> + mat_color_text <240, 240, 240> + mat_color_top_edge <150, 200, 255> + mat_color_bottom_edge <1, 1, 1> + mat_trigger_style + mat_font_id + mat_font_size <10> + mat_font_style + act_replace_select_action + < + uni_start_stream + man_close_update + uni_wait_on + async_exit_aux <01x> + uni_end_stream + > + man_start_sibling + mat_precise_x <120> + mat_precise_y <163> + mat_precise_width <310> + mat_precise_height <1> + mat_color_face <1, 1, 1> + mat_color_text <1, 1, 1> + man_append_data <"\x7f"> + man_end_object + man_place_cursor <7> + async_playsound <"Complex Delta"> + async_playsound <"..\\Main Omega\\Special View\\Active Bottom"> + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0215.bin b/internal/aol/fdo/testdata/golden/test_0215.bin new file mode 100755 index 0000000..0b82c92 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0215.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0215.txt b/internal/aol/fdo/testdata/golden/test_0215.txt new file mode 100755 index 0000000..00d9c6d --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0215.txt @@ -0,0 +1,9 @@ +uni_start_stream + de_start_extraction + buf_set_token <"eT"> + man_set_context_relative <12> + de_get_data + man_end_context + de_end_extraction + buf_close_buffer +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0228.bin b/internal/aol/fdo/testdata/golden/test_0228.bin new file mode 100755 index 0000000..b100c56 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0228.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0228.txt b/internal/aol/fdo/testdata/golden/test_0228.txt new file mode 100755 index 0000000..4ec19a3 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0228.txt @@ -0,0 +1,264 @@ +uni_start_stream <00x> + man_set_response_id <2622599> + var_number_set + var_number_save + man_set_context_globalid <1> + man_start_object + mat_object_id <40-1159> + mat_orientation + mat_position + mat_bool_invisible + mat_position + mat_bool_palette + var_number_set + var_number_save + man_start_object + mat_orientation + man_start_object + mat_relative_tag <1> + mat_art_id <1-0-1634> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + uni_wait_on + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + man_set_context_relative <1> + var_number_set + image_get_attr <16x, 01x> + var_number_set_from_atom + if_numa_gte_numb_then <1, 2> + var_number_set + uni_sync_skip <1> + var_number_add <90> + uni_sync_skip <2> + var_number_get + uni_use_last_atom_value + man_end_context + uni_wait_off_end_stream + > + man_start_sibling + mat_relative_tag <2> + mat_art_id <1-0-1633> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + async_alert + async_get_alert_result + var_number_set_from_atom + var_number_set + if_numa_neq_numb_then <1> + uni_abort_stream + uni_sync_skip <1> + uni_wait_on + man_set_context_relative <1> + image_revert + man_end_context + uni_wait_off_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <3> + mat_art_id <1-0-1629> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + image_flip_horizontal + man_end_context + uni_wait_off_end_stream + > + man_start_sibling + mat_relative_tag <4> + mat_art_id <1-0-1630> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + image_flip_vertical + man_end_context + uni_wait_off_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <5> + mat_art_id <1-0-1625> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + var_number_set + image_get_attr <16x, 06x> + var_number_set_from_atom + if_numa_gte_numb_then <1, 2> + var_number_set + uni_sync_skip <1> + var_number_add <5> + uni_sync_skip <2> + var_number_get + uni_use_last_atom_value + man_end_context + uni_wait_off_end_stream + > + man_start_sibling + mat_relative_tag <6> + mat_art_id <1-0-1628> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + var_number_set + image_get_attr <16x, 06x> + var_number_set_from_atom + if_numa_lte_numb_then <1, 2> + var_number_set + uni_sync_skip <1> + var_number_sub <5> + uni_sync_skip <2> + var_number_get + uni_use_last_atom_value + man_end_context + uni_wait_off_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <7> + mat_art_id <1-0-1626> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + var_number_set + image_get_attr <16x, 07x> + var_number_set_from_atom + if_numa_gte_numb_then <1, 2> + var_number_set + uni_sync_skip <1> + var_number_add <5> + uni_sync_skip <2> + var_number_get + uni_use_last_atom_value + man_end_context + uni_wait_off_end_stream + > + man_start_sibling + mat_relative_tag <8> + mat_art_id <1-0-1627> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + var_number_set + image_get_attr <16x, 07x> + var_number_set_from_atom + if_numa_lte_numb_then <1, 2> + var_number_set + uni_sync_skip <1> + var_number_sub <5> + uni_sync_skip <2> + var_number_get + uni_use_last_atom_value + man_end_context + uni_wait_off_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <9> + mat_art_id <1-0-1631> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + async_alert + async_get_alert_result + var_number_set_from_atom + var_number_set + if_numa_neq_numb_then <1> + uni_abort_stream + uni_sync_skip <1> + uni_wait_on + man_set_context_relative <1> + image_make_gray_scale + uni_wait_off + man_update_display + man_end_context + uni_end_stream + > + man_start_sibling + mat_relative_tag <10> + mat_art_id <1-0-1632> + mat_horizontal_spacing <0> + mat_vertical_spacing <0> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + uni_wait_on + man_set_context_relative <1> + image_invert + man_end_context + uni_wait_off_end_stream + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0229.bin b/internal/aol/fdo/testdata/golden/test_0229.bin new file mode 100755 index 0000000..3be9787 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0229.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0229.txt b/internal/aol/fdo/testdata/golden/test_0229.txt new file mode 100755 index 0000000..586a501 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0229.txt @@ -0,0 +1,81 @@ +uni_start_stream + man_preset_gid <0> + man_set_context_globalid <31> + man_insert_object_before + mat_object_type + mat_object_id <40-1231> + mat_title <"Default Bottom"> + mat_shortcut_key <"X"> + man_start_object + mat_title <"Previous Main"> + mat_shortcut_key <"S"> + mat_relative_tag <1> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <40-1159> + man_get_attribute + if_last_return_true_then <1, 2> + var_number_set + var_number_save + mat_bool_invisible + man_update_display + man_end_context + man_set_context_globalid <40-1231> + man_set_context_relative <1> + mat_title <"Third Sigma"> + mat_shortcut_key <"H"> + uni_sync_skip <1> + var_number_set + var_number_save + mat_bool_invisible + man_update_display + man_end_context + man_set_context_globalid <40-1231> + man_set_context_relative <1> + mat_title <"Previous Main"> + mat_shortcut_key <"S"> + uni_sync_skip <2> + man_update_display + man_end_context + uni_end_stream + > + man_end_object + man_start_object + mat_title <"Dynamic Dialog Edge"> + mat_shortcut_key <"F"> + mat_relative_tag <2> + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + man_set_context_relative <1> + image_get_attr <16x, 1ex> + if_last_return_false_then <3, 4> + image_attr_fit_to_view + man_end_context + man_end_context + man_set_context_globalid <40-1231> + man_set_context_relative <2> + mat_title <"Advanced Beta Right"> + mat_shortcut_key <"O"> + uni_sync_skip <3> + image_attr_fit_to_view + man_end_context + man_end_context + man_set_context_globalid <40-1231> + man_set_context_relative <2> + mat_title <"Dynamic Dialog Edge"> + mat_shortcut_key <"F"> + uni_sync_skip <4> + man_end_context + man_update_display + man_end_context + uni_end_stream + > + man_end_object + man_end_object + man_end_context + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0230.bin b/internal/aol/fdo/testdata/golden/test_0230.bin new file mode 100755 index 0000000..b6021d7 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0230.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0230.txt b/internal/aol/fdo/testdata/golden/test_0230.txt new file mode 100755 index 0000000..d7f06dd --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0230.txt @@ -0,0 +1,51 @@ +uni_start_stream + man_preset_gid <40-1256> + man_start_object + mat_position + mat_title <"Primary Delta"> + mat_bool_modal + mat_orientation + man_start_object + mat_relative_tag <2> + mat_width <20> + mat_height <1> + mat_horizontal_spacing <3> + man_end_object + man_start_object + mat_orientation + man_end_object + man_start_object + mat_orientation + man_start_object + mat_title <"Active Widget"> + mat_font_id + mat_font_size <9> + mat_font_style + mat_relative_tag <6> + act_set_criterion + act_append_action + < + uni_start_stream + xfer_abort + uni_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display +man_end_object +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0232.bin b/internal/aol/fdo/testdata/golden/test_0232.bin new file mode 100755 index 0000000..c177e22 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0232.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0232.txt b/internal/aol/fdo/testdata/golden/test_0232.txt new file mode 100755 index 0000000..3656d33 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0232.txt @@ -0,0 +1,41 @@ +uni_start_stream <00x> + man_use_default_title + man_set_context_globalid <1> + man_start_object + mat_object_id <40-2517> + mat_orientation + mat_position + mat_bool_invisible + var_number_set + var_number_save + act_set_criterion + act_replace_action + < + uni_start_stream + man_set_context_globalid <57> + man_set_context_relative <11> + mat_bool_disabled + man_change_context_relative <12> + mat_bool_disabled + man_end_context + man_update_display + man_end_context + man_set_context_globalid <40-1159> + mat_bool_invisible + man_update_display + man_end_context + uni_end_stream + > + man_start_object + mat_relative_tag <1> + mat_bool_horizontal_scroll + mat_bool_importable + mat_bool_writeable + mat_bool_exportable + image_attr_image_cropable <01x> + mat_size <0, 0> + mat_bool_graphic_view + image_attr_dynamic_display <01x> + man_end_object + man_end_object + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0233.bin b/internal/aol/fdo/testdata/golden/test_0233.bin new file mode 100755 index 0000000..5015b7f Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0233.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0233.txt b/internal/aol/fdo/testdata/golden/test_0233.txt new file mode 100755 index 0000000..1d48638 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0233.txt @@ -0,0 +1,78 @@ +uni_start_stream + man_start_object + mat_object_id <40-2533> + mat_title <"Default Area"> + mat_bool_modal + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_relative_tag <3> + mat_bool_graphic_view + image_attr_thumbnail + mat_width <72> + mat_height <72> + mat_bool_no_border + image_attr_image_type <517> + man_end_object + man_start_object + mat_relative_tag <1> + mat_width <35> + mat_height <1> + man_end_object + man_end_object + man_start_object + mat_relative_tag <2> + mat_width <35> + mat_object_color <144, 255, 255, 255, 128, 0, 0> + man_end_object + man_start_object + mat_relative_tag <4> + mat_width <35> + mat_height <1> + man_end_object + man_start_object + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_title <"Sub Top Gadget"> + mat_relative_tag <5> + act_set_criterion + act_append_action + < + uni_start_stream + xfer_finish_later + uni_end_stream + > + man_end_object + man_start_object + mat_title <"Third East"> + mat_relative_tag <7> + act_set_criterion + act_append_action + < + uni_start_stream + xfer_abort + uni_end_stream + > + man_end_object + man_update_display + man_end_object + uni_wait_off +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0237.bin b/internal/aol/fdo/testdata/golden/test_0237.bin new file mode 100755 index 0000000..e570c90 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0237.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0237.txt b/internal/aol/fdo/testdata/golden/test_0237.txt new file mode 100755 index 0000000..57aeb75 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0237.txt @@ -0,0 +1,16 @@ +uni_start_stream <00x> + man_use_default_title + man_start_object + mat_object_id <40-28006> + mat_style_id <40-28006> + mat_orientation + mat_position + man_start_object + mat_relative_tag <1> + pictalk_manage + mat_width <300> + mat_height <400> + mat_bool_writeable + man_end_object + man_end_object +uni_wait_off_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0242.bin b/internal/aol/fdo/testdata/golden/test_0242.bin new file mode 100755 index 0000000..45d6882 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0242.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0242.txt b/internal/aol/fdo/testdata/golden/test_0242.txt new file mode 100755 index 0000000..733ee85 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0242.txt @@ -0,0 +1,118 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <40-40454> + mat_style_id <40-40454> + mat_orientation + mat_position + man_start_object + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_size <20, 1> + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <1> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <5> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <2> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <3> + man_end_object + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_relative_tag <4> + mat_bool_default + act_replace_select_action + < + uni_start_stream + de_start_extraction <0> + lm_table_use_table <20-0-202> + lm_table_use_key <"Default Label"> + man_set_context_relative <1> + de_get_data_value + if_last_return_false_then <10, 11> + lm_table_set_item <"0"> + uni_sync_skip <10> + lm_table_set_item <"1"> + uni_sync_skip <11> + man_end_context + lm_table_use_key <"Special Form"> + man_set_context_relative <5> + de_get_data_value + if_last_return_false_then <50, 51> + lm_table_set_item <"0"> + uni_sync_skip <50> + lm_table_set_item <"1"> + uni_sync_skip <51> + man_end_context + lm_table_use_key <"Sub Form"> + man_set_context_relative <2> + de_get_data_value + if_last_return_false_then <20, 21> + lm_table_set_item <"0"> + uni_sync_skip <20> + lm_table_set_item <"1"> + uni_sync_skip <21> + man_end_context + lm_table_use_key <"Standard Back"> + man_set_context_relative <3> + de_get_data_value + if_last_return_false_then <30, 31> + lm_table_set_item <"0"> + uni_sync_skip <30> + lm_table_set_item <"1"> + uni_sync_skip <31> + man_end_context + de_end_extraction + man_close_update + uni_end_stream + > + man_start_sibling + act_replace_select_action + < + uni_start_stream + man_close_update + uni_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display + lm_table_use_table <20-0-202> + man_set_context_relative <1> + lm_table_use_key <"Default Label"> + lm_table_get_item_value + uni_use_last_atom_value + man_end_context + man_set_context_relative <5> + lm_table_use_key <"Special Form"> + lm_table_get_item_value + uni_use_last_atom_value + man_end_context + man_set_context_relative <2> + lm_table_use_key <"Sub Form"> + lm_table_get_item_value + uni_use_last_atom_value + man_end_context + man_set_context_relative <3> + lm_table_use_key <"Standard Back"> + lm_table_get_item_value + uni_use_last_atom_value + man_end_context + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0246.bin b/internal/aol/fdo/testdata/golden/test_0246.bin new file mode 100755 index 0000000..2bd88b6 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0246.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0246.txt b/internal/aol/fdo/testdata/golden/test_0246.txt new file mode 100755 index 0000000..b3e1f39 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0246.txt @@ -0,0 +1,24 @@ +uni_start_stream + man_set_context_globalid <57> + man_set_context_relative <10> + man_insert_object_after + mat_object_type + mat_title <"Basic Corner"> + mat_relative_tag <1000> + mat_bool_disabled + act_replace_select_action + < + uni_start_stream + man_set_context_globalid <1> + var_lookup_by_id + uni_use_last_atom_value + man_set_context_relative <1> + image_crop_image + man_end_context + man_end_context + uni_end_stream + > + man_end_context + man_update_display + man_end_context + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0251.bin b/internal/aol/fdo/testdata/golden/test_0251.bin new file mode 100755 index 0000000..a9a7a8a Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0251.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0251.txt b/internal/aol/fdo/testdata/golden/test_0251.txt new file mode 100755 index 0000000..e7813f2 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0251.txt @@ -0,0 +1,23 @@ +uni_start_stream + pictalk_attr_ctrl_id <07x, d3x> + pictalk_attr_art_id <14x, 00x, 01x, 8ex> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d5x> + pictalk_attr_art_id <14x, 00x, 01x, 88x> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d4x> + pictalk_attr_art_id <14x, 00x, 01x, 89x> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d2x> + pictalk_attr_art_id <14x, 00x, 01x, 8ax> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d2x> + pictalk_attr_art_id <14x, 00x, 01x, 8ax> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d0x> + pictalk_attr_art_id <14x, 00x, 01x, 8bx> + pictalk_update_art + pictalk_attr_ctrl_id <07x, d1x> + pictalk_attr_art_id <14x, 00x, 01x, 8cx> + pictalk_update_art +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0354.bin b/internal/aol/fdo/testdata/golden/test_0354.bin new file mode 100755 index 0000000..b50ef99 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0354.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0354.txt b/internal/aol/fdo/testdata/golden/test_0354.txt new file mode 100755 index 0000000..74057b4 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0354.txt @@ -0,0 +1,53 @@ +uni_start_stream <00x> + man_start_object + mat_orientation + mat_position + mat_style_id <32-160> + man_start_object + mat_size <40, 1, 40> + man_append_data <"Old Frame Box"> + man_start_sibling + mat_orientation + man_start_object + mat_size <7, 1, 7> + mat_title_pos + man_append_data <"Simple Region"> + man_start_sibling + mat_size <4, 1, 2> + mat_relative_tag <12> + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_bool_importable + mat_validation <128> + man_append_data <"1"> + man_start_sibling + mat_size <8, 1, 8> + man_append_data <"Fourth Block"> + man_end_object + man_end_object + uni_invoke_local_preserve <32-190> + man_start_object + mat_size <1, 1, 1> + man_start_sibling + mat_orientation + man_start_object + mat_art_id <1-0-1324> + mat_bool_default + act_replace_select_action + < + uni_start_stream <00x> + de_ez_send_form <"bs"> + > + man_start_sibling + mat_art_id <1-0-1325> + act_replace_select_action + < + uni_start_stream <00x> + sm_send_k1 <8-49074> + > + man_end_object + man_end_object + man_update_display + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0358.bin b/internal/aol/fdo/testdata/golden/test_0358.bin new file mode 100755 index 0000000..1b5bd2e Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0358.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0358.txt b/internal/aol/fdo/testdata/golden/test_0358.txt new file mode 100755 index 0000000..b97b247 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0358.txt @@ -0,0 +1,47 @@ +uni_start_stream <00x> + man_start_object + mat_object_id <32-1640> + mat_orientation + mat_position + man_start_object + mat_size <30, 1> + mat_relative_tag <1> + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_exportable + mat_bool_importable + idb_set_context <20-0-258> + idb_atr_offset <0> + idb_get_value <04x> + uni_convert_last_atom_data + uni_use_last_atom_string + idb_end_context + man_start_sibling + mat_bool_default + act_replace_select_action + < + uni_start_stream + de_start_extraction <0> + man_set_context_relative <1> + de_get_data_pointer + uni_convert_last_atom_string + mt_flip_value + uni_save_result + idb_set_context <20-0-258> + idb_atr_offset <0> + idb_append_data <00x, 00x, 00x, 00x> + idb_atr_offset <0> + idb_atr_length <4> + uni_get_result + uni_use_last_atom_value + idb_end_context + man_end_context + de_end_extraction + man_close_update + async_alert + uni_end_stream + > + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0474.bin b/internal/aol/fdo/testdata/golden/test_0474.bin new file mode 100755 index 0000000..ec69f7e Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0474.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0474.txt b/internal/aol/fdo/testdata/golden/test_0474.txt new file mode 100755 index 0000000..d23fd01 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0474.txt @@ -0,0 +1,60 @@ +uni_start_stream + idb_set_context <20-0-10> + idb_atr_offset <0> + idb_get_string + var_string_set_from_atom + idb_end_context + if_stra_eq_null_then <1> + ccl_is_modem + if_last_return_true_then <1> + async_alert + mip_action_command <0ax> +uni_abort_stream +uni_sync_skip <1> +man_set_context_globalid <32-221> +var_number_clear_id +de_start_extraction <0> +man_set_context_relative <2> +de_get_data_pointer +uni_save_result +man_change_context_relative <1> +de_get_data_pointer +var_string_set_from_atom +man_end_context +de_end_extraction +buf_close_buffer +var_string_set +if_stra_eq_strb_then <10> +async_alert +mip_action_command <0ax> +uni_abort_stream +uni_sync_skip <10> +var_string_set +if_stra_eq_strb_then <10> +async_alert +mip_action_command <0ax> +uni_abort_stream +uni_sync_skip <10> +var_string_set +if_stra_eq_strb_then <10> +async_alert +mip_action_command <0ax> +uni_abort_stream +uni_sync_skip <10> +uni_get_result +var_string_set_from_atom +if_stra_neq_null_then <1, 2> +mat_bool_invisible +man_update_display +idb_start_obj <"t"> +idb_atr_globalid <20-3-26> +var_string_get +uni_use_last_atom_string +idb_end_obj +var_string_null +uni_invoke_no_context <32-220> +uni_sync_skip <1> +async_alert +mip_action_command <0ax> +uni_sync_skip <2> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0508.bin b/internal/aol/fdo/testdata/golden/test_0508.bin new file mode 100755 index 0000000..d6b5178 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0508.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0508.txt b/internal/aol/fdo/testdata/golden/test_0508.txt new file mode 100755 index 0000000..2b70127 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0508.txt @@ -0,0 +1,12 @@ +uni_start_stream + cm_is_tool_loaded <230> + if_last_return_false_then <1> + async_exit + uni_sync_skip <1> + cm_tool_verify_set_tid + cm_tool_verify <03x, 00x, 00x, 29x> + if_last_return_false_then <1> + async_exit + uni_sync_skip <1> + uni_invoke_local <32-5448> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0509.bin b/internal/aol/fdo/testdata/golden/test_0509.bin new file mode 100755 index 0000000..5db1c83 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0509.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0509.txt b/internal/aol/fdo/testdata/golden/test_0509.txt new file mode 100755 index 0000000..52673f2 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0509.txt @@ -0,0 +1,7 @@ +uni_start_stream + cm_is_tool_loaded <230> + if_last_return_false_then <1> + async_exit + uni_sync_skip <1> + uni_invoke_local <32-5448> +uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0531.bin b/internal/aol/fdo/testdata/golden/test_0531.bin new file mode 100755 index 0000000..b1976fd Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0531.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0531.txt b/internal/aol/fdo/testdata/golden/test_0531.txt new file mode 100755 index 0000000..1a21229 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0531.txt @@ -0,0 +1,54 @@ +uni_start_stream <00x> + man_preset_gid <32-224> + if_last_return_true_then <1> + man_make_focus <32-224> + man_update_display <32-224> +uni_abort_stream +uni_sync_skip <1> +man_start_object + mat_object_id <32-224> + mat_style_id <32-224> + mat_orientation + mat_color_face <255, 255, 255> + mat_position + mat_bool_resize_vertical + mat_bool_background_flood + man_start_object + mat_orientation + man_start_object + mat_size <30, 3> + mat_horizontal_spacing <0> + mat_vertical_spacing <3> + man_append_data <"Previous Dialog Zone\x7fsecondary current secondary execute frame west\x7fCurrent Back"> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_size <25, 1, 16> + mat_relative_tag <1> + mat_vertical_spacing <3> + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_validation <128> + man_start_sibling + mat_trigger_style + mat_font_sis + mat_color_face <0, 51, 153> + mat_color_text <255, 255, 255> + mat_color_top_edge <102, 153, 204> + mat_color_bottom_edge <0, 0, 102> + mat_horizontal_spacing <0> + mat_precise_width <70> + mat_precise_height <24> + mat_bool_default + act_replace_select_action + < + uni_start_stream_wait_on <00x> + de_ez_send_form <"Ln"> + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0532.bin b/internal/aol/fdo/testdata/golden/test_0532.bin new file mode 100755 index 0000000..460fb4d Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0532.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0532.txt b/internal/aol/fdo/testdata/golden/test_0532.txt new file mode 100755 index 0000000..83870e3 --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0532.txt @@ -0,0 +1,56 @@ +uni_start_stream <00x> + man_preset_gid <32-224> + if_last_return_true_then <1> + man_make_focus <32-224> + man_set_context_globalid <32-224> + man_set_context_relative <1> + man_do_edit_menu <4> + man_end_context + man_update_display <32-224> +uni_abort_stream +uni_sync_skip <1> +man_start_object + mat_style_id <32-8456> + mat_orientation + mat_color_face <255, 255, 255> + mat_position + mat_bool_resize_vertical + mat_bool_background_flood + man_start_object + mat_orientation + man_start_object + mat_art_id <1-5-21197> + mat_horizontal_spacing <5> + mat_vertical_spacing <3> + mat_bool_disabled + man_start_sibling + mat_size <30, 3> + mat_horizontal_spacing <0> + mat_vertical_spacing <3> + man_append_data <"Previous Button Main\x7fSimple Left Dialog\x7fCurrent Omega Right"> + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_size <25, 1, 16> + mat_relative_tag <1> + mat_vertical_spacing <3> + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_validation <128> + man_start_sibling + mat_trigger_style + mat_art_id <1-5-21175> + mat_bool_default + mat_bool_gradual_shadow + act_replace_select_action + < + uni_start_stream_wait_on <00x> + de_ez_send_form <"Ln"> + > + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/golden/test_0541.bin b/internal/aol/fdo/testdata/golden/test_0541.bin new file mode 100755 index 0000000..3613054 Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0541.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0541.txt b/internal/aol/fdo/testdata/golden/test_0541.txt new file mode 100755 index 0000000..f25a01f --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0541.txt @@ -0,0 +1,304 @@ +uni_start_stream + man_start_object + mat_orientation + mat_object_id <32-225> + mat_title <"Current Beta North"> + mat_style_id <32-225> + mat_bool_background_flood + mat_color_face <255, 255, 255> + act_set_criterion <353> + act_replace_action + < + uni_start_stream + de_start_extraction <0> + man_set_context_relative <1> + de_get_data_pointer + uni_save_result + man_end_context + de_end_extraction + async_alert_start <01x> + uni_get_result + uni_use_last_atom_string + async_alert_add_text <"Basic View Edge"> + async_alert_end + uni_end_stream + > + act_set_criterion <354> + act_replace_action + < + uni_start_stream + man_close_update + uni_end_stream + > + act_set_criterion <210> + act_replace_action + < + uni_start_stream + man_set_context_relative <2> + rich_get_text_style + var_number_set_from_atom + man_change_context_relative <42> + var_number_get + var_number_set + if_numa_and_numb_then <1, 2> + mat_value <1> + uni_sync_skip <1> + mat_value <0> + uni_sync_skip <2> + man_change_context_relative <43> + var_number_get + var_number_set + if_numa_and_numb_then <1, 2> + mat_value <1> + uni_sync_skip <1> + mat_value <0> + uni_sync_skip <2> + man_change_context_relative <44> + var_number_get + var_number_set + if_numa_and_numb_then <1, 2> + mat_value <1> + uni_sync_skip <1> + mat_value <0> + uni_sync_skip <2> + man_end_context + man_update_display + uni_end_stream + > + man_start_object + mat_height <1> + mat_width <24> + mat_capacity <20> + mat_validation <128> + mat_relative_tag <1> + mat_title <"Static Gadget"> + mat_title_pos + man_start_sibling + mat_orientation + man_start_object + mat_orientation + mat_bool_tool_group + mat_bool_resize_horizontal + mat_bool_resize_vertical + man_start_object + mat_orientation + man_start_object + mat_context_help <"Custom Center Beta"> + mat_relative_tag <60> + mat_horizontal_spacing <0> + mat_vertical_spacing <2> + mat_art_id <1-0-31462> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_text_color + uni_end_stream + > + man_start_sibling + mat_context_help <"Simple Theta Delta"> + mat_relative_tag <61> + mat_horizontal_spacing <3> + mat_art_id <1-0-31463> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_background_color + uni_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_context_help <"New Object Area"> + mat_art_id <1-0-31459> + mat_bool_small_icon + mat_relative_tag <41> + mat_horizontal_spacing <0> + act_replace_select_action + < + uni_start_stream + rich_font_size <1> + uni_end_stream + > + man_start_sibling + mat_context_help <"Sub Sigma"> + mat_relative_tag <64> + mat_horizontal_spacing <0> + mat_art_id <1-0-31460> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_font_size <3> + uni_end_stream + > + man_start_sibling + mat_context_help <"Old Element Unit"> + mat_relative_tag <65> + mat_horizontal_spacing <3> + mat_art_id <1-0-31461> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_font_size <7> + uni_end_stream + > + man_end_object + man_start_sibling + mat_orientation + mat_bool_list_icons + man_start_object + mat_context_help <"view"> + mat_relative_tag <42> + mat_horizontal_spacing <0> + mat_trigger_style + mat_art_id <1-0-39886> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_font_attribute <1> + uni_end_stream + > + act_set_criterion <23> + act_replace_action + < + uni_start_stream + rich_font_attribute <1> + uni_end_stream + > + man_start_sibling + mat_context_help <"Fourth Item"> + mat_relative_tag <43> + mat_horizontal_spacing <0> + mat_trigger_style + mat_art_id <1-0-31465> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_font_attribute <2> + uni_end_stream + > + act_set_criterion <23> + act_replace_action + < + uni_start_stream + rich_font_attribute <2> + uni_end_stream + > + man_start_sibling + mat_context_help <"Fourth Delta"> + mat_relative_tag <44> + mat_horizontal_spacing <3> + mat_trigger_style + mat_art_id <1-0-39884> + mat_bool_small_icon + act_replace_select_action + < + uni_start_stream + rich_font_attribute <4> + uni_end_stream + > + act_set_criterion <23> + act_replace_action + < + uni_start_stream + rich_font_attribute <4> + uni_end_stream + > + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_context_help <"Advanced Area Right"> + mat_precise_width <24> + mat_precise_height <19> + mat_art_id <1-4-54274> + mat_bool_small_icon + mat_relative_tag <47> + mat_horizontal_spacing <0> + mat_bool_dropdown_button + act_replace_popup_menu_action + < + uni_start_stream + rich_insert_smilie + uni_end_stream + > + man_end_object + man_end_object + man_start_sibling + mat_relative_tag <2> + mat_field_script + mat_encode_type <00x> + mat_bool_first_script + mat_precise_height <80> + mat_precise_width <320> + mat_validation <128> + mat_font_sis + rich_manage + rich_allow_embeds + rich_ignore_tabs + mat_capacity <512> + mat_bool_writeable + rich_enable_smilie + man_end_object + man_start_sibling + mat_orientation + man_start_object + mat_context_help <"Secondary Box Delta\x7fCustom Top Panel"> + mat_command_key <0dx> + mat_trigger_style + mat_bool_precise + mat_precise_width <90> + mat_precise_height <24> + mat_font_sis + mat_color_face <204, 204, 255> + mat_color_text <0, 0, 0> + mat_color_top_edge <255, 255, 255> + mat_color_bottom_edge <153, 153, 204> + mat_horizontal_spacing <3> + act_set_criterion + act_append_action + < + uni_start_stream + uni_wait_on + buf_start_buffer + de_start_extraction + buf_set_token <"iO"> + man_set_context_relative <1> + de_get_data + man_end_context + de_end_extraction + buf_close_buffer + uni_end_stream + > + man_end_object + man_end_object + man_update_display + uni_end_stream diff --git a/internal/aol/fdo/testdata/golden/test_0580.bin b/internal/aol/fdo/testdata/golden/test_0580.bin new file mode 100755 index 0000000..1172afe Binary files /dev/null and b/internal/aol/fdo/testdata/golden/test_0580.bin differ diff --git a/internal/aol/fdo/testdata/golden/test_0580.txt b/internal/aol/fdo/testdata/golden/test_0580.txt new file mode 100755 index 0000000..ba251cb --- /dev/null +++ b/internal/aol/fdo/testdata/golden/test_0580.txt @@ -0,0 +1,44 @@ +uni_start_stream + man_get_top_window + uni_use_last_atom_value + man_get_attribute + var_string_set_from_atom + man_end_context + man_start_object + mat_bool_modal + mat_position + mat_object_id <32-232> + mat_title <"New Button"> + mat_orientation + man_start_object + mat_orientation + man_start_object + mat_art_id <1-0-1408> + man_end_object + man_start_object + mat_title <"Simple Right West"> + man_end_object + man_start_object + mat_relative_tag <1> + mat_height <1> + var_string_get + uni_use_last_atom_string + man_end_object + man_end_object + man_start_object + mat_title <"Old Dialog"> + act_set_criterion + act_append_action + < + uni_start_stream <01x> + man_close + man_update_display + uni_end_stream + > + man_end_object + man_start_object + mat_title <"Secondary Omega Gamma"> + act_set_criterion + act_replace_action + < + uni_start_stream + ccl_hang_up + man_close + man_update_display + uni_end_stream + > + man_end_object + man_end_object + man_end_object + man_update_display + uni_wait_off + uni_end_stream <00x> diff --git a/internal/aol/fdo/testdata/livecapture/capture_033.bin b/internal/aol/fdo/testdata/livecapture/capture_033.bin new file mode 100755 index 0000000..f489eda Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_033.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_033.txt b/internal/aol/fdo/testdata/livecapture/capture_033.txt new file mode 100755 index 0000000..6b0ad1b --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_033.txt @@ -0,0 +1,18 @@ +uni_start_stream + uni_start_stream + idb_start_obj <"a"> + idb_dod_progress_gauge <"close open process active start main refresh"> + idb_atr_globalid <32-117> + idb_atr_length <996> + idb_atr_dod <01x> + idb_append_data <00x,01x,01x,00x,01x,00x,01x,01x,10x,08x,01x,5bx,10x,40x,01x,05x,10x,3ax,03x,20x,00x,75x,10x,5dx,01x,00x,10x,65x,01x,01x,10x,0ex,04x,01x,45x,6ax,78x,01x,00x,01x,00x,10x,08x,01x,5bx,01x,00x,01x,00x,10x,08x,01x,23x,01x,00x,01x,00x,10x,08x,01x,0cx,01x,00x,0bx,06x,4cx,69x,73x,74x,20x,52x,6fx,6fx,6dx,73x,10x,19x,01x,08x,10x,0ex,04x,01x,45x,05x,31x,02x,04x,09x,00x,01x,01x,00x,0ex,0cx,02x,4cx,50x,01x,01x,0dx,06x,43x,65x,6ex,74x,65x,72x,20x,53x,74x,61x,67x,65x,10x,19x,01x,08x,10x,0bx,02x,01x,04x,10x,0ex,04x,01x,45x,05x,37x,02x,04x,0ax,00x,01x,01x,00x,0ex,03x,03x,08x,00x,3ex,01x,01x,0ax,06x,50x,43x,20x> + idb_append_data <53x,74x,75x,64x,69x,6fx,10x,19x,01x,08x,10x,0bx,02x,01x,03x,10x,0ex,04x,01x,45x,05x,34x,02x,04x,0ax,00x,01x,01x,00x,0ex,03x,03x,08x,00x,14x,01x,01x,0cx,06x,50x,72x,65x,66x,65x,72x,65x,6ex,63x,65x,73x,10x,19x,01x,08x,10x,0ex,04x,01x,45x,05x,15x,02x,04x,2ax,00x,01x,01x,00x,01x,16x,03x,20x,00x,f5x,0fx,13x,02x,01x,02x,01x,35x,00x,01x,11x,00x,00x,07x,01x,01x,00x,0fx,00x,00x,13x,03x,20x,00x,f5x,00x,07x,01x,02x,00x,02x,01x,00x,01x,02x,00x,01x,01x,01x,00x,10x,08x,01x,41x,01x,00x,01x,07x,10x,17x,04x,0cx,01x,00x,0cx,10x,31x,01x,09x,10x,32x,01x,01x,01x,14x,0cx,50x,65x,6fx,70x,6cx,65x,20x,48x,65x,72x,65x> + idb_append_data <3ax,01x,01x,01x,07x,10x,17x,04x,02x,01x,00x,02x,10x,0bx,02x,01x,05x,10x,31x,01x,09x,01x,02x,00x,01x,01x,01x,04x,10x,08x,01x,5bx,10x,17x,02x,0cx,05x,10x,0bx,02x,01x,01x,10x,11x,01x,01x,10x,04x,01x,00x,10x,2bx,01x,00x,10x,30x,01x,00x,10x,31x,01x,09x,02x,04x,80x,e5x,00x,01x,00x,03x,02x,01x,00x,03x,03x,01x,04x,03x,08x,01x,01x,0cx,02x,01x,00x,01x,0ax,02x,01x,01x,03x,03x,01x,05x,03x,08x,00x,0cx,02x,01x,01x,03x,07x,00x,04x,07x,00x,04x,08x,00x,01x,1dx,00x,01x,16x,03x,20x,00x,a8x,0fx,13x,02x,01x,02x,01x,35x,00x,01x,10x,00x,00x,0ax,02x,10x,18x,01x,0ax,01x,01x,01x,10x,00x,00x,0ax,02x,01x,15x,01x,42x,00x> + idb_append_data <01x,10x,00x,01x,1dx,00x,00x,07x,01x,01x,00x,14x,03x,20x,00x,a8x,00x,07x,01x,02x,0cx,00x,02x,00x,01x,0cx,00x,02x,01x,02x,0cx,03x,01x,00x,00x,0bx,02x,01x,09x,0cx,13x,04x,02x,01x,00x,01x,0cx,03x,01x,01x,00x,0bx,02x,01x,0ax,0cx,14x,00x,0cx,13x,04x,00x,01x,00x,00x,01x,1dx,00x,01x,1dx,00x,0cx,00x,02x,00x,03x,0cx,00x,02x,02x,05x,01x,0ax,01x,67x,0cx,03x,01x,00x,00x,0bx,02x,10x,33x,01x,1dx,00x,0cx,13x,02x,00x,02x,0cx,13x,02x,01x,05x,0fx,20x,02x,01x,02x,01x,0ax,01x,67x,10x,01x,01x,01x,01x,1dx,00x,00x,07x,01x,01x,01x,0ax,01x,67x,10x,01x,01x,00x,01x,1dx,00x,00x,07x,01x,02x,01x,12x,00x,01x,02x,00x,02x,04x> + idb_append_data <13x,00x,01x,01x,00x,00x,0fx,00x,00x,13x,03x,20x,00x,f5x,00x,10x,00x,00x,02x,00x,01x,01x,01x,00x,10x,08x,01x,49x,01x,00x,01x,08x,10x,17x,04x,43x,0bx,20x,00x,10x,0bx,02x,01x,00x,10x,12x,01x,0ax,10x,27x,01x,01x,10x,43x,02x,10x,00x,10x,21x,01x,01x,10x,42x,01x,01x,10x,41x,01x,01x,01x,02x,00x,02x,04x,41x,00x,01x,00x,01x,06x,03x,20x,00x,a8x,03x,02x,01x,00x,03x,03x,01x,04x,03x,08x,01x,01x,0cx,02x,01x,00x,01x,0ax,02x,01x,01x,03x,03x,01x,05x,04x,07x,00x,03x,08x,00x,0cx,02x,01x,01x,03x,07x,00x,04x,08x,00x,01x,1dx,00x,00x,14x,03x,20x,00x,a8x,00x,10x,00x,00x,02x,00x,01x,00x,01x,00x,10x,08x,01x,0bx,01x,00x> + idb_append_data <01x,09x,10x,17x,04x,3dx,01x,00x,5cx,10x,0bx,02x,01x,02x,10x,11x,01x,00x,10x,00x,01x,00x,10x,03x,01x,00x,10x,04x,01x,00x,10x,25x,01x,00x,10x,27x,01x,01x,10x,38x,01x,80x,01x,01x,05x,06x,53x,65x,6ex,64x,10x,02x,01x,01x,10x,52x,03x,fcx,9dx,2cx,10x,53x,03x,00x,1ex,37x,10x,54x,03x,ffx,c8x,64x,10x,55x,03x,96x,5ax,14x,10x,58x,02x,00x,01x,10x,30x,01x,00x,10x,31x,01x,0ax,10x,32x,01x,01x,02x,04x,2cx,00x,01x,00x,03x,02x,00x,03x,10x,01x,03x,04x,06x,02x,41x,61x,01x,0ax,02x,01x,02x,03x,06x,00x,01x,0fx,00x,01x,35x,00x,01x,11x,00x,03x,07x,00x,04x,08x,00x,01x,1dx,00x,00x,02x,00x,01x,02x,00x,01x,02x,00x,01x,02x> + idb_append_data <00x,01x,02x,00x,01x,11x,00x,e8x,03x,04x,01x,01x,02x,00x,01x,82x,02x,03x,27x,00x,01x,00x,01x,0ax,02x,01x,01x,01x,43x,00x,00x,2dx,00x,00x,0cx,00x,01x,0cx,02x,01x,05x,00x,15x,00x,00x,0ax,02x,01x,15x,01x,1dx,00x,01x,11x,00x,00x,02x,00x,02x,00x,01x,07x,02x,03x,1bx,00x,01x,00x,01x,09x,04x,13x,00x,00x,00x,02x,01x,01x,02x,01x,1dx,00x,01x,03x,04x,13x,00x,00x,00x,00x,02x,00x,00x,02x,01x,00x> + + idb_end_obj + uni_end_stream +man_update_woff_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_034.bin b/internal/aol/fdo/testdata/livecapture/capture_034.bin new file mode 100755 index 0000000..aa8a7a7 Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_034.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_034.txt b/internal/aol/fdo/testdata/livecapture/capture_034.txt new file mode 100755 index 0000000..9f20017 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_034.txt @@ -0,0 +1,25 @@ +uni_start_stream + dod_start + uni_transaction_id <21300529> + dod_no_hints + dod_form_id <19-0-0> + dod_gid <1-69-1329> + dod_type <2> + dod_data <01x,00x,01x,00x,01x,00x,0cx,07x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,e8x,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,34x,33x,2ax,9ex,9ex,95x,8fx,82x,57x,e7x,cbx,82x,5bx,58x,40x,e9x,e1x,d2x,c4x,bfx,b2x,98x,79x,53x,56x,57x,4fx,bax,a8x,6fx,2fx,47x,5ax,b5x,b1x,a5x,6cx,6bx,51x,b3x,87x,58x,d2x,cdx,bfx,85x,89x,82x,d3x,bdx,7cx,69x,50x,30x,2dx,44x,54x,a3x,96x,67x,59x,56x,3ex,3fx,3ax,2ex,bcx,bax,aex,52x,44x,2dx,d2x,d2x,cfx,74x,56x,34x,b7x,8dx,5ex,abx,7ex,4dx,44x,44x,3fx,5dx,5dx,59x,76x,7bx,76x,6ex,5dx,45x,bdx> + dod_data <93x,65x,49x,4ax,44x,6cx,68x,62x,efx,d1x,85x,4dx,3ex,28x,39x,58x,72x,4fx,52x,4fx,cbx,c7x,bax,2bx,3bx,43x,92x,94x,8cx,45x,45x,40x,40x,41x,3cx,a2x,74x,44x,64x,65x,5cx,78x,75x,6ex,c6x,b1x,75x,d3x,d4x,d1x,c1x,bdx,b2x,e2x,c5x,7dx,7cx,64x,45x,50x,50x,49x,57x,46x,2ex,efx,e7x,d7x,61x,62x,59x,b5x,8ax,5bx,9fx,a1x,9fx,bax,90x,61x,6dx,6ax,63x,7bx,80x,7ax,49x,43x,35x,61x,5dx,42x,77x,59x,37x,afx,82x,52x,bex,bfx,bcx,6bx,58x,3ex,b5x,a0x,67x,dcx,d6x,c7x,d7x,d1x,c3x,52x,49x,37x,3dx,4ax,4fx,56x,59x,56x,f4x,ebx,dbx,77x,62x,46x,acx,99x,63x,eex,cex,81x,45x,40x,34x,b7x,b8x,b5x,a6x,79x,49x,b3x,b4x,b2x,6fx,6cx,65x,5fx> + dod_data <57x,45x,6cx,63x,43x,50x,54x,51x,68x,67x,5dx,d3x,d3x,d0x,44x,3bx,2bx,46x,42x,35x,4dx,4dx,47x,d4x,d4x,d1x,6cx,53x,33x,dcx,c1x,7dx,51x,49x,3bx,f3x,d4x,86x,9dx,9fx,9cx,acx,9cx,67x,5fx,5fx,5bx,34x,45x,4ex,7bx,5bx,36x,44x,48x,44x,50x,41x,2bx,d4x,d5x,d2x,b8x,8ex,60x,4fx,4ex,48x,4dx,48x,38x,acx,84x,59x,42x,43x,3ex,f3x,e9x,d9x,8ax,8dx,86x,b7x,8cx,5dx,bbx,91x,63x,35x,49x,56x,76x,5dx,3dx,6ax,61x,41x,72x,59x,39x,41x,3cx,2fx,d2x,d3x,d0x,52x,52x,4bx,45x,44x,39x,35x,38x,2dx,b4x,89x,5ax,71x,53x,31x,bcx,abx,73x,b0x,83x,54x,6cx,69x,62x,f4x,ecx,dbx,66x,5fx,40x,e5x,c7x,7dx,bax,bbx,b9x,adx,80x,51x,dbx,d4x,c6x,62x> + dod_data <58x,47x,a1x,a3x,a0x,d3x,d3x,d1x,4fx,4dx,3ax,4dx,50x,4dx,6ex,6bx,64x,4ax,4dx,49x,63x,64x,5bx,47x,45x,3cx,75x,57x,35x,53x,57x,53x,47x,48x,42x,6bx,51x,32x,47x,3fx,32x,47x,3ex,2dx,4bx,44x,37x,51x,55x,52x,c0x,c1x,bex,aax,9cx,6bx,d5x,cfx,c1x,5ex,5ex,5ax,b6x,8bx,5cx,9dx,a0x,9dx,a9x,7bx,4bx,f4x,d5x,87x,57x,5bx,58x,f3x,eax,d9x,d4x,d4x,d2x,4dx,51x,4dx,b5x,b3x,a8x,46x,46x,41x,49x,46x,3ex,68x,68x,5ex,46x,44x,3bx,b1x,85x,56x,49x,42x,35x,b9x,8fx,60x,c9x,b3x,76x,b4x,88x,59x,6dx,65x,45x,6ax,67x,60x,cex,c9x,bcx,79x,5bx,38x,e8x,cdx,84x,47x,41x,34x,e8x,c8x,7bx,bex,95x,67x,c3x,bex,b1x,63x,5ex,43x,52x,56x,52x,d5x> + dod_data + dod_data + dod_data <39x,f3x,53x,45x,83x,21x,49x,1ax,5ax,58x,49x,98x,d1x,1cx,39x,8cx,0ax,2bx,54x,48x,58x,52x,a7x,dbx,8cx,6ex,8bx,2ax,2cx,08x,42x,94x,26x,9dx,38x,c2x,14x,06x,13x,a6x,68x,1dx,3ax,70x,15x,ebx,35x,5ax,98x,30x,62x,c5x,76x,45x,02x,c5x,a3x,32x,94x,86x,28x,b9x,60x,86x,26x,1fx,1ax,1ax,59x,b2x,a0x,c9x,9bx,efx,d6x,2dx,1ax,c4x,f2x,11x,bbx,35x,38x,8bx,1dx,73x,88x,04x,d6x,21x,49x,29x,0ax,00x,3dx,19x,32x,fcx,88x,fcx,a3x,91x,e4x,70x,aex,7ex,c8x,1bx,c6x,d9x,95x,2bx,79x,c8x,fax,80x,b2x,79x,15x,03x,95x,1dx,15x,f2x,e4x,41x,e5x,26x,93x,1ax,42x,1fx,80x,a1x,cax,74x,26x,53x,26x,55x,6ex,dcx,c8x,d2x,51x,acx,5ax,1fx,44x,56x> + dod_data <0cx,39x,44x,49x,25x,57x,bbx,3cx,e2x,96x,35x,6bx,76x,a7x,44x,39x,6bx,52x,08x,2dx,13x,a2x,0ax,08x,90x,3cx,99x,50x,e1x,b0x,87x,f8x,a2x,c0x,e0x,54x,fax,74x,ffx,7bx,c2x,2fx,99x,b6x,24x,0bx,c4x,1cx,41x,97x,e4x,d7x,2fx,23x,99x,d8x,f1x,29x,96x,a9x,81x,2ax,5ex,3bx,40x,69x,19x,dex,f1x,34x,1dx,16x,d2x,68x,f3x,cbx,38x,49x,9cx,10x,83x,0dx,6cx,24x,91x,8cx,11x,3ax,a4x,73x,8cx,31x,e9x,b8x,91x,07x,2fx,fbx,bcx,e3x,11x,4ax,0fx,51x,92x,48x,37x,82x,54x,f1x,4bx,1bx,3cx,acx,13x,e2x,3ax,ebx,b4x,e2x,49x,37x,71x,28x,01x,87x,02x,69x,ccx,70x,00x,7ex,efx,e8x,04x,92x,47x,1ax,76x,63x,0ax,29x,49x,10x,38x,8ex,1fx,49x,24x,a1x> + dod_data <8dx,27x,9ex,1cx,32x,04x,18x,28x,48x,d0x,cbx,12x,17x,34x,91x,dfx,43x,41x,69x,a1x,21x,16x,a8x,90x,a2x,cdx,03x,1ex,78x,e0x,ccx,95x,1ex,9cx,c0x,06x,2dx,4cx,d4x,93x,8ax,00x,b1x,0cx,40x,42x,24x,3bx,20x,12x,52x,49x,19x,26x,d2x,04x,3bx,2dx,78x,e2x,c7x,9bx,9ex,b0x,f1x,cbx,8fx,9ex,d0x,22x,03x,3cx,96x,58x,f2x,02x,3ex,d8x,c0x,92x,48x,8cx,07x,ddx,e4x,48x,14x,edx,e8x,d0x,82x,36x,01x,40x,a3x,68x,0ax,29x,40x,73x,c9x,38x,3ex,00x,b2x,47x,02x,09x,40x,80x,cfx,05x,a7x,24x,62x,26x,42x,09x,59x,d1x,c9x,0ex,58x,9cx,b1x,c8x,2fx,45x,38x,e0x,cdx,a9x,a6x,16x,c0x,86x,0fx,5cx,e0x,82x,0bx,03x,13x,0cx,ffx,50x,06x,99x,efx,2cx> + dod_data <76x,15x,0cx,9dx,ecx,03x,8bx,0ex,8bx,24x,61x,41x,30x,a1x,04x,13x,ccx,20x,73x,6ax,43x,00x,13x,bex,f8x,32x,82x,2fx,afx,94x,41x,cfx,6fx,70x,71x,dax,49x,14x,f4x,e0x,b0x,88x,36x,16x,84x,12x,6cx,28x,44x,ccx,e9x,09x,05x,4cx,78x,21x,2ex,27x,03x,f4x,f9x,dbx,43x,e8x,7ax,9ax,48x,0fx,aax,dcx,00x,a4x,36x,c9x,78x,32x,4ex,32x,bfx,f8x,e1x,09x,1ex,72x,acx,a2x,efx,14x,7fx,d4x,00x,4bx,7ex,1ex,d5x,61x,50x,1dx,e7x,24x,52x,edx,3fx,9ex,fcx,c2x,86x,36x,02x,bax,f7x,8bx,27x,57x,ecx,92x,cdx,06x,eax,64x,b3x,c9x,06x,93x,f4x,41x,85x,32x,e8x,6ax,81x,41x,27x,b9x,c0x,c2x,0ex,02x,b3x,94x,7cx,4dx,3fx,06x,ccx,62x,40x,3fx,d7x,48x> + dod_data <02x,84x,06x,99x,a4x,23x,4bx,31x,3ax,74x,b1x,8fx,23x,09x,bdx,e5x,d1x,39x,51x,c0x,52x,ccx,1cx,90x,40x,12x,c1x,16x,5bx,3cx,23x,f4x,d0x,63x,34x,80x,0ax,2ax,c5x,bcx,01x,82x,2cx,d6x,f4x,41x,09x,4fx,08x,69x,d1x,49x,22x,a7x,a8x,c6x,47x,1ex,40x,d4x,c6x,07x,1fx,aax,e4x,e1x,86x,20x,62x,bfx,a1x,43x,26x,6ex,68x,30x,89x,39x,54x,30x,c9x,e9x,39x,3bx,c0x,f2x,46x,7dx,6ex,b0x,c3x,0ex,2ax,ecx,b8x,a1x,0ax,2ax,1ax,a8x,cdx,c2x,4ex,dfx,38x,b0x,23x,08x,1fx,a7x,f4x,61x,82x,41x,cax,d8x,82x,01x,06x,e7x,e4x,b2x,c2x,3dx,f7x,7cx,53x,0ax,23x,93x,33x,42x,f9x,28x,94x,53x,7ex,0fx,23x,dfx,40x,bex,06x,2bx,88x,c0x,80x,81x,45x,28x> + dod_data <91x,33x,4dx,3cx,dcx,ecx,c0x,0dx,2bx,7dx,f4x,a1x,7ax,1fx,dcx,88x,00x,3bx,37x,b4x,8bx,c0x,0ax,37x,7dx,c4x,a3x,0bx,28x,66x,98x,91x,51x,70x,81x,90x,c1x,01x,38x,8fx,84x,40x,0dx,f1x,c7x,ebx,f3x,88x,3ex,c4x,3fx,22x,cax,f2x,2ax,88x,22x,8ax,3ex,8ax,58x,25x,b0x,4ex,18x,68x,11x,c8x,3cx,dcx,fbx,c3x,bdx,26x,fex,7cx,e1x,8fx,f7x,5fx,ccx,53x,7ex,f9x,f3x,80x,afx,89x,55x,c1x,55x,64x,11x,0cx,0bx,01x,35x,d3x,47x,18x,e9x,d4x,91x,70x,3ex,5dx,a8x,85x,2dx,14x,a5x,a4x,8cx,cex,56x,50x,8cx,15x,06x,a6x,33x,9dx,18x,e4x,13x,9fx,10x,d8x,70x,82x,73x,bfx,a1x,60x,05x,2bx,15x,c1x,40x,1dx,94x,91x,3dx,d2x,ecx,a7x,22x,c1x,b1x,49x> + dod_data <06x,b5x,a0x,8cx,80x,00x,00x,3bx> + + dod_end_data + dod_close_form + dod_end +uni_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_035.bin b/internal/aol/fdo/testdata/livecapture/capture_035.bin new file mode 100755 index 0000000..81e872e Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_035.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_035.txt b/internal/aol/fdo/testdata/livecapture/capture_035.txt new file mode 100755 index 0000000..211324c --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_035.txt @@ -0,0 +1,24 @@ +uni_start_stream + uni_start_stream + idb_start_obj <"p"> + idb_dod_progress_gauge <"close open process active start main refresh"> + idb_atr_globalid <1-69-1329> + idb_atr_length <1808> + idb_atr_dod <01x> + idb_append_data <01x,00x,01x,00x,01x,00x,0cx,07x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,e8x,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,34x,33x,2ax,9ex,9ex,95x,8fx,82x,57x,e7x,cbx,82x,5bx,58x,40x,e9x,e1x,d2x,c4x,bfx,b2x,98x,79x,53x,56x,57x,4fx,bax,a8x,6fx,2fx,47x,5ax,b5x,b1x,a5x,6cx,6bx,51x,b3x,87x,58x,d2x,cdx,bfx,85x,89x,82x,d3x,bdx,7cx,69x,50x,30x,2dx,44x,54x,a3x,96x,67x,59x,56x,3ex,3fx,3ax,2ex,bcx,bax,aex,52x,44x,2dx,d2x,d2x,cfx,74x,56x,34x,b7x,8dx,5ex,abx,7ex,4dx,44x,44x,3fx,5dx,5dx,59x,76x,7bx,76x,6ex,5dx,45x,bdx> + idb_append_data <93x,65x,49x,4ax,44x,6cx,68x,62x,efx,d1x,85x,4dx,3ex,28x,39x,58x,72x,4fx,52x,4fx,cbx,c7x,bax,2bx,3bx,43x,92x,94x,8cx,45x,45x,40x,40x,41x,3cx,a2x,74x,44x,64x,65x,5cx,78x,75x,6ex,c6x,b1x,75x,d3x,d4x,d1x,c1x,bdx,b2x,e2x,c5x,7dx,7cx,64x,45x,50x,50x,49x,57x,46x,2ex,efx,e7x,d7x,61x,62x,59x,b5x,8ax,5bx,9fx,a1x,9fx,bax,90x,61x,6dx,6ax,63x,7bx,80x,7ax,49x,43x,35x,61x,5dx,42x,77x,59x,37x,afx,82x,52x,bex,bfx,bcx,6bx,58x,3ex,b5x,a0x,67x,dcx,d6x,c7x,d7x,d1x,c3x,52x,49x,37x,3dx,4ax,4fx,56x,59x,56x,f4x,ebx,dbx,77x,62x,46x,acx,99x,63x,eex,cex,81x,45x,40x,34x,b7x,b8x,b5x,a6x,79x,49x,b3x,b4x,b2x,6fx,6cx,65x,5fx> + idb_append_data <57x,45x,6cx,63x,43x,50x,54x,51x,68x,67x,5dx,d3x,d3x,d0x,44x,3bx,2bx,46x,42x,35x,4dx,4dx,47x,d4x,d4x,d1x,6cx,53x,33x,dcx,c1x,7dx,51x,49x,3bx,f3x,d4x,86x,9dx,9fx,9cx,acx,9cx,67x,5fx,5fx,5bx,34x,45x,4ex,7bx,5bx,36x,44x,48x,44x,50x,41x,2bx,d4x,d5x,d2x,b8x,8ex,60x,4fx,4ex,48x,4dx,48x,38x,acx,84x,59x,42x,43x,3ex,f3x,e9x,d9x,8ax,8dx,86x,b7x,8cx,5dx,bbx,91x,63x,35x,49x,56x,76x,5dx,3dx,6ax,61x,41x,72x,59x,39x,41x,3cx,2fx,d2x,d3x,d0x,52x,52x,4bx,45x,44x,39x,35x,38x,2dx,b4x,89x,5ax,71x,53x,31x,bcx,abx,73x,b0x,83x,54x,6cx,69x,62x,f4x,ecx,dbx,66x,5fx,40x,e5x,c7x,7dx,bax,bbx,b9x,adx,80x,51x,dbx,d4x,c6x,62x> + idb_append_data <58x,47x,a1x,a3x,a0x,d3x,d3x,d1x,4fx,4dx,3ax,4dx,50x,4dx,6ex,6bx,64x,4ax,4dx,49x,63x,64x,5bx,47x,45x,3cx,75x,57x,35x,53x,57x,53x,47x,48x,42x,6bx,51x,32x,47x,3fx,32x,47x,3ex,2dx,4bx,44x,37x,51x,55x,52x,c0x,c1x,bex,aax,9cx,6bx,d5x,cfx,c1x,5ex,5ex,5ax,b6x,8bx,5cx,9dx,a0x,9dx,a9x,7bx,4bx,f4x,d5x,87x,57x,5bx,58x,f3x,eax,d9x,d4x,d4x,d2x,4dx,51x,4dx,b5x,b3x,a8x,46x,46x,41x,49x,46x,3ex,68x,68x,5ex,46x,44x,3bx,b1x,85x,56x,49x,42x,35x,b9x,8fx,60x,c9x,b3x,76x,b4x,88x,59x,6dx,65x,45x,6ax,67x,60x,cex,c9x,bcx,79x,5bx,38x,e8x,cdx,84x,47x,41x,34x,e8x,c8x,7bx,bex,95x,67x,c3x,bex,b1x,63x,5ex,43x,52x,56x,52x,d5x> + idb_append_data + idb_append_data + idb_append_data <39x,f3x,53x,45x,83x,21x,49x,1ax,5ax,58x,49x,98x,d1x,1cx,39x,8cx,0ax,2bx,54x,48x,58x,52x,a7x,dbx,8cx,6ex,8bx,2ax,2cx,08x,42x,94x,26x,9dx,38x,c2x,14x,06x,13x,a6x,68x,1dx,3ax,70x,15x,ebx,35x,5ax,98x,30x,62x,c5x,76x,45x,02x,c5x,a3x,32x,94x,86x,28x,b9x,60x,86x,26x,1fx,1ax,1ax,59x,b2x,a0x,c9x,9bx,efx,d6x,2dx,1ax,c4x,f2x,11x,bbx,35x,38x,8bx,1dx,73x,88x,04x,d6x,21x,49x,29x,0ax,00x,3dx,19x,32x,fcx,88x,fcx,a3x,91x,e4x,70x,aex,7ex,c8x,1bx,c6x,d9x,95x,2bx,79x,c8x,fax,80x,b2x,79x,15x,03x,95x,1dx,15x,f2x,e4x,41x,e5x,26x,93x,1ax,42x,1fx,80x,a1x,cax,74x,26x,53x,26x,55x,6ex,dcx,c8x,d2x,51x,acx,5ax,1fx,44x,56x> + idb_append_data <0cx,39x,44x,49x,25x,57x,bbx,3cx,e2x,96x,35x,6bx,76x,a7x,44x,39x,6bx,52x,08x,2dx,13x,a2x,0ax,08x,90x,3cx,99x,50x,e1x,b0x,87x,f8x,a2x,c0x,e0x,54x,fax,74x,ffx,7bx,c2x,2fx,99x,b6x,24x,0bx,c4x,1cx,41x,97x,e4x,d7x,2fx,23x,99x,d8x,f1x,29x,96x,a9x,81x,2ax,5ex,3bx,40x,69x,19x,dex,f1x,34x,1dx,16x,d2x,68x,f3x,cbx,38x,49x,9cx,10x,83x,0dx,6cx,24x,91x,8cx,11x,3ax,a4x,73x,8cx,31x,e9x,b8x,91x,07x,2fx,fbx,bcx,e3x,11x,4ax,0fx,51x,92x,48x,37x,82x,54x,f1x,4bx,1bx,3cx,acx,13x,e2x,3ax,ebx,b4x,e2x,49x,37x,71x,28x,01x,87x,02x,69x,ccx,70x,00x,7ex,efx,e8x,04x,92x,47x,1ax,76x,63x,0ax,29x,49x,10x,38x,8ex,1fx,49x,24x,a1x> + idb_append_data <8dx,27x,9ex,1cx,32x,04x,18x,28x,48x,d0x,cbx,12x,17x,34x,91x,dfx,43x,41x,69x,a1x,21x,16x,a8x,90x,a2x,cdx,03x,1ex,78x,e0x,ccx,95x,1ex,9cx,c0x,06x,2dx,4cx,d4x,93x,8ax,00x,b1x,0cx,40x,42x,24x,3bx,20x,12x,52x,49x,19x,26x,d2x,04x,3bx,2dx,78x,e2x,c7x,9bx,9ex,b0x,f1x,cbx,8fx,9ex,d0x,22x,03x,3cx,96x,58x,f2x,02x,3ex,d8x,c0x,92x,48x,8cx,07x,ddx,e4x,48x,14x,edx,e8x,d0x,82x,36x,01x,40x,a3x,68x,0ax,29x,40x,73x,c9x,38x,3ex,00x,b2x,47x,02x,09x,40x,80x,cfx,05x,a7x,24x,62x,26x,42x,09x,59x,d1x,c9x,0ex,58x,9cx,b1x,c8x,2fx,45x,38x,e0x,cdx,a9x,a6x,16x,c0x,86x,0fx,5cx,e0x,82x,0bx,03x,13x,0cx,ffx,50x,06x,99x,efx,2cx> + idb_append_data <76x,15x,0cx,9dx,ecx,03x,8bx,0ex,8bx,24x,61x,41x,30x,a1x,04x,13x,ccx,20x,73x,6ax,43x,00x,13x,bex,f8x,32x,82x,2fx,afx,94x,41x,cfx,6fx,70x,71x,dax,49x,14x,f4x,e0x,b0x,88x,36x,16x,84x,12x,6cx,28x,44x,ccx,e9x,09x,05x,4cx,78x,21x,2ex,27x,03x,f4x,f9x,dbx,43x,e8x,7ax,9ax,48x,0fx,aax,dcx,00x,a4x,36x,c9x,78x,32x,4ex,32x,bfx,f8x,e1x,09x,1ex,72x,acx,a2x,efx,14x,7fx,d4x,00x,4bx,7ex,1ex,d5x,61x,50x,1dx,e7x,24x,52x,edx,3fx,9ex,fcx,c2x,86x,36x,02x,bax,f7x,8bx,27x,57x,ecx,92x,cdx,06x,eax,64x,b3x,c9x,06x,93x,f4x,41x,85x,32x,e8x,6ax,81x,41x,27x,b9x,c0x,c2x,0ex,02x,b3x,94x,7cx,4dx,3fx,06x,ccx,62x,40x,3fx,d7x,48x> + idb_append_data <02x,84x,06x,99x,a4x,23x,4bx,31x,3ax,74x,b1x,8fx,23x,09x,bdx,e5x,d1x,39x,51x,c0x,52x,ccx,1cx,90x,40x,12x,c1x,16x,5bx,3cx,23x,f4x,d0x,63x,34x,80x,0ax,2ax,c5x,bcx,01x,82x,2cx,d6x,f4x,41x,09x,4fx,08x,69x,d1x,49x,22x,a7x,a8x,c6x,47x,1ex,40x,d4x,c6x,07x,1fx,aax,e4x,e1x,86x,20x,62x,bfx,a1x,43x,26x,6ex,68x,30x,89x,39x,54x,30x,c9x,e9x,39x,3bx,c0x,f2x,46x,7dx,6ex,b0x,c3x,0ex,2ax,ecx,b8x,a1x,0ax,2ax,1ax,a8x,cdx,c2x,4ex,dfx,38x,b0x,23x,08x,1fx,a7x,f4x,61x,82x,41x,cax,d8x,82x,01x,06x,e7x,e4x,b2x,c2x,3dx,f7x,7cx,53x,0ax,23x,93x,33x,42x,f9x,28x,94x,53x,7ex,0fx,23x,dfx,40x,bex,06x,2bx,88x,c0x,80x,81x,45x,28x> + idb_append_data <91x,33x,4dx,3cx,dcx,ecx,c0x,0dx,2bx,7dx,f4x,a1x,7ax,1fx,dcx,88x,00x,3bx,37x,b4x,8bx,c0x,0ax,37x,7dx,c4x,a3x,0bx,28x,66x,98x,91x,51x,70x,81x,90x,c1x,01x,38x,8fx,84x,40x,0dx,f1x,c7x,ebx,f3x,88x,3ex,c4x,3fx,22x,cax,f2x,2ax,88x,22x,8ax,3ex,8ax,58x,25x,b0x,4ex,18x,68x,11x,c8x,3cx,dcx,fbx,c3x,bdx,26x,fex,7cx,e1x,8fx,f7x,5fx,ccx,53x,7ex,f9x,f3x,80x,afx,89x,55x,c1x,55x,64x,11x,0cx,0bx,01x,35x,d3x,47x,18x,e9x,d4x,91x,70x,3ex,5dx,a8x,85x,2dx,14x,a5x,a4x,8cx,cex,56x,50x,8cx,15x,06x,a6x,33x,9dx,18x,e4x,13x,9fx,10x,d8x,70x,82x,73x,bfx,a1x,60x,05x,2bx,15x,c1x,40x,1dx,94x,91x,3dx,d2x,ecx,a7x,22x,c1x,b1x,49x> + idb_append_data <06x,b5x,a0x,8cx,80x,00x,00x,3bx> + + idb_end_obj + uni_end_stream +man_update_woff_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_036.bin b/internal/aol/fdo/testdata/livecapture/capture_036.bin new file mode 100755 index 0000000..a626db1 Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_036.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_036.txt b/internal/aol/fdo/testdata/livecapture/capture_036.txt new file mode 100755 index 0000000..55d740c --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_036.txt @@ -0,0 +1,22 @@ +uni_start_stream + dod_start + uni_transaction_id <21300535> + dod_no_hints + dod_form_id <19-0-0> + dod_gid <1-69-1335> + dod_type <2> + dod_data <01x,00x,01x,00x,01x,00x,c7x,05x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,a3x,05x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,34x,2fx,33x,c8x,51x,47x,74x,36x,33x,69x,72x,7dx,ccx,aex,7ex,6bx,3dx,3bx,83x,83x,83x,93x,36x,32x,4bx,4fx,56x,80x,6bx,56x,a1x,7dx,61x,43x,47x,4fx,b3x,43x,3bx,48x,33x,34x,77x,5bx,49x,5ax,30x,30x,68x,68x,6ax,ecx,ccx,92x,a2x,3ex,38x,83x,30x,2ex,82x,42x,3ex,5cx,48x,3fx,6ex,6ex,6fx,91x,7fx,65x,5fx,5ex,60x,75x,74x,76x,6cx,54x,47x,40x,2fx,32x,67x,36x,34x,b9x,4ax,41x,46x,38x,3ax,afx,88x,66x,4cx> + dod_data <41x,3fx,dex,bex,88x,35x,36x,3bx,53x,44x,3fx,74x,3fx,3cx,54x,5cx,68x,9dx,3cx,37x,3cx,37x,3ax,8fx,6ex,59x,a7x,3cx,36x,8bx,8bx,8bx,40x,38x,3ax,99x,76x,5dx,8bx,44x,40x,f6x,d4x,97x,65x,52x,48x,55x,38x,38x,7bx,7ax,7bx,bfx,4cx,43x,62x,4cx,3fx,99x,48x,41x,41x,44x,4cx,9cx,37x,32x,3ax,3bx,41x,47x,4ax,51x,9ex,87x,69x,85x,37x,34x,a8x,41x,3ax,88x,77x,61x,94x,72x,5bx,8cx,8cx,8cx,9fx,38x,33x,47x,3ex,3fx,3ax,30x,33x,cex,54x,49x,a2x,3ax,34x,8fx,33x,2fx,adx,3fx,38x,9fx,7bx,60x,72x,57x,47x,87x,6dx,54x,76x,3ax,37x,44x,3dx,3fx,99x,3ax,35x,9fx,84x,63x,45x,31x,33x,65x,4dx,3fx,abx,3ex,37x,7cx,5fx,4bx,38x,35x,38x,49x> + dod_data <39x,3ax,4fx,34x,35x,7ax,3dx,3ax,93x,46x,41x,41x,3ax,3dx,8dx,38x,34x,32x,33x,37x,a7x,81x,63x,8cx,8bx,8bx,6dx,57x,4bx,39x,34x,35x,4fx,53x,5bx,c2x,4dx,44x,88x,30x,2dx,6ex,39x,37x,6bx,35x,34x,86x,71x,5ax,4fx,42x,3fx,79x,40x,3dx,8bx,71x,56x,e2x,c1x,8bx,97x,35x,31x,66x,4dx,3fx,33x,31x,35x,71x,3cx,39x,5fx,30x,30x,7dx,7dx,7ex,90x,6fx,59x,4dx,36x,37x,95x,80x,64x,43x,3cx,3ex,3cx,3ex,43x,afx,41x,39x,96x,38x,33x,c4x,4ex,44x,5fx,4ax,3fx,76x,36x,33x,36x,33x,36x,cfx,54x,49x,75x,75x,76x,6cx,35x,33x,a4x,3ax,34x,6ax,72x,7ex,3dx,38x,3ax,7ax,41x,3dx,8bx,8bx,8cx,41x,30x,32x,44x,48x,51x,bcx,4bx,42x,83x,43x,3fx,9dx> + dod_data <89x,6bx,9cx,39x,34x,c1x,4dx,43x,a1x,39x,33x,91x,70x,5ax,85x,84x,85x,48x,3fx,3ex,8cx,8bx,8cx,9fx,3cx,37x,40x,3ax,3cx,95x,35x,31x,eex,cdx,93x,98x,37x,32x,45x,3dx,3fx,35x,36x,3cx,3ax,36x,38x,8dx,45x,40x,55x,45x,3fx,8ax,30x,2dx,bbx,49x,41x,51x,43x,3fx,34x,32x,35x,9bx,3ax,35x,a8x,3dx,36x,3ax,3cx,43x,84x,42x,3ex,63x,4cx,3fx,76x,3bx,39x,afx,88x,67x,69x,68x,6ax,6fx,6ex,6fx,98x,36x,31x,3ex,38x,3bx,73x,58x,47x,92x,80x,66x,aex,40x,39x,41x,39x,3bx,9ax,77x,5ex,69x,72x,7ex,49x,3fx,3fx,84x,43x,3ex,96x,36x,31x,3bx,3cx,41x,5dx,49x,3fx,a9x,41x,3ax,56x,38x,38x,9dx,37x,32x,c2x,4ex,44x,6ex,3ax,38x,bfx,4dx,44x,a3x> + dod_data <3ax,34x,35x,32x,35x,7ax,40x,3dx,a0x,38x,33x,95x,72x,5bx,b0x,41x,3ax,a3x,3ex,38x,64x,4cx,3fx,84x,43x,3fx,6dx,35x,33x,77x,36x,33x,6bx,36x,34x,bbx,4ax,41x,42x,30x,32x,50x,42x,3fx,9ax,3ax,35x,4dx,41x,3fx,a8x,3dx,37x,a0x,84x,63x,90x,33x,2fx,3bx,30x,33x,48x,3ex,3fx,bax,4ax,41x,cdx,aex,7ex,c9x,51x,47x,35x,2fx,33x,48x,3fx,3fx,c1x,4dx,44x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x> + dod_data <00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,7dx,08x,1cx,48x,70x,91x,0fx,83x,06x,05x,22x,24x,78x,90x,a1x,43x,86x,5ax,1ax,2ex,5cx,f8x,b0x,a2x,42x,89x,18x,ffx,60x,b4x,28x,30x,51x,9ex,8fx,20x,43x,e6x,c9x,30x,b2x,a4x,c8x,8fx,89x,12x,aax,f0x,f1x,c7x,82x,2bx,1cx,30x,63x,cax,9cx,49x,13x,47x,9cx,50x,0dx,7dx,acx,b4x> + dod_data <80x,80x,8fx,cfx,9fx,aax,80x,f2x,19x,c0x,47x,95x,d1x,a2x,43x,f9x,74x,09x,b5x,52x,45x,53x,0bx,35x,4ax,48x,9dx,4ax,b5x,aax,d5x,12x,0bx,20x,e8x,24x,68x,41x,59x,93x,61x,1bx,86x,35x,79x,96x,26x,93x,59x,2ex,5cx,ccx,9ax,05x,f0x,75x,c3x,86x,26x,cax,70x,32x,14x,05x,86x,c1x,a8x,64x,90x,18x,4cx,81x,13x,a9x,6fx,9dx,19x,7dx,fbx,36x,60x,50x,88x,88x,23x,06x,49x,e4x,72x,f5x,83x,a7x,c8x,0fx,5ex,78x,62x,f1x,8dx,44x,6cx,86x,13x,4cx,81x,ddx,e0x,81x,f5x,63x,13x,1ex,56x,8ax,07x,5ax,60x,fcx,24x,97x,84x,c8x,93x,dfx,34x,6bx,96x,23x,f3x,66x,59x,9ex,41x,3bx,1cx,ddx,f8x,31x,eax,48x,3cx,1ex,b9x,70x,f1x,c8x,54x,5fx,cdx,3bx> + dod_data <3ax,7fx,56x,8cx,d0x,02x,2ex,3cx,a5x,4fx,c3x,e0x,6bx,6ax,f7x,6ex,42x,bfx,85x,c0x,b2x,b1x,49x,88x,ecx,81x,06x,69x,3bx,86x,2cx,79x,55x,02x,33x,bbx,cdx,88x,ffx,59x,15x,49x,33x,2cx,d8x,c3x,13x,2ax,34x,8ex,3cx,85x,20x,1ax,52x,94x,18x,73x,82x,04x,19x,93x,32x,4ex,88x,45x,f2x,50x,45x,c6x,b1x,eax,d7x,5dx,a4x,5dx,11x,78x,90x,60x,45x,24x,f3x,a1x,a1x,a0x,82x,fax,59x,51x,00x,1ex,bbx,c4x,16x,0ax,42x,c5x,1dx,27x,87x,33x,94x,acx,a0x,04x,10x,9ex,2cx,e8x,c4x,87x,bdx,acx,a2x,04x,2ax,bex,04x,70x,cax,70x,b3x,a9x,21x,8cx,30x,2dx,f4x,d1x,d7x,32x,0bx,2ax,e8x,04x,1ax,4ex,90x,17x,49x,1fx,bex,30x,23x,0cx,15x,13x,e6x,b4x> + dod_data <88x,05x,0fx,7cx,61x,c9x,2dx,81x,8dx,10x,23x,8dx,1fx,56x,12x,d8x,1dx,13x,7cx,b1x,46x,68x,02x,59x,40x,cbx,1cx,a3x,04x,43x,4ax,5fx,1dx,c6x,38x,e3x,8cx,7dx,91x,c2x,41x,2bx,07x,7cx,02x,e5x,8fx,7ex,30x,92x,cbx,15x,51x,f4x,d5x,cbx,87x,48x,7ex,f8x,61x,5fx,93x,e8x,70x,88x,26x,9dx,40x,e9x,c3x,68x,8cx,78x,61x,8bx,1dx,27x,bcx,b2x,a5x,87x,34x,a2x,f1x,0ax,29x,61x,ecx,e1x,85x,26x,bex,c8x,95x,d0x,8fx,b8x,30x,32x,cbx,1ex,c0x,28x,a2x,41x,29x,50x,54x,6ax,a9x,03x,47x,1cx,a1x,01x,08x,bfx,ecx,41x,47x,31x,89x,fax,78x,67x,99x,74x,40x,fax,42x,1bx,46x,80x,f2x,81x,aax,aax,66x,61x,84x,02x,28x,6cx,88x,d1x,29x,1dx,9ax,80x> + dod_data <46x,e1x,41x,78x,3ex,0ax,ccx,0bx,28x,a4x,92x,aax,aax,abx,82x,a2x,40x,2ax,6dx,c8x,eax,69x,adx,38x,25x,14x,91x,71x,26x,44x,33x,c4x,aex,88x,b4x,81x,48x,0fx,bax,50x,4bx,2dx,22x,d1x,6ex,a1x,87x,2dx,5ex,14x,43x,41x,8fx,eax,89x,82x,85x,24x,e4x,4ax,22x,c2x,b9x,e8x,a6x,9bx,aex,b9x,22x,48x,82x,85x,9dx,2ex,05x,22x,efx,bcx,f4x,d6x,6bx,6fx,20x,9cx,84x,a2x,11x,76x,6cx,60x,e0x,efx,bfx,00x,07x,2cx,f0x,bfx,31x,70x,b4x,90x,46x,1ax,adx,14x,11x,45x,39x,35x,ccx,d0x,44x,3ex,44x,b4x,92x,41x,08x,3fx,ecx,b0x,c1x,5bx,41x,acx,dex,c6x,07x,05x,04x,00x,3bx> + + dod_end_data + dod_close_form + dod_end +uni_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_037.bin b/internal/aol/fdo/testdata/livecapture/capture_037.bin new file mode 100755 index 0000000..1a2c0aa Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_037.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_037.txt b/internal/aol/fdo/testdata/livecapture/capture_037.txt new file mode 100755 index 0000000..9695a11 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_037.txt @@ -0,0 +1,21 @@ +uni_start_stream + uni_start_stream + idb_start_obj <"p"> + idb_dod_progress_gauge <"close open process active start main refresh"> + idb_atr_globalid <1-69-1335> + idb_atr_length <1483> + idb_atr_dod <01x> + idb_append_data <01x,00x,01x,00x,01x,00x,c7x,05x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,a3x,05x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,34x,2fx,33x,c8x,51x,47x,74x,36x,33x,69x,72x,7dx,ccx,aex,7ex,6bx,3dx,3bx,83x,83x,83x,93x,36x,32x,4bx,4fx,56x,80x,6bx,56x,a1x,7dx,61x,43x,47x,4fx,b3x,43x,3bx,48x,33x,34x,77x,5bx,49x,5ax,30x,30x,68x,68x,6ax,ecx,ccx,92x,a2x,3ex,38x,83x,30x,2ex,82x,42x,3ex,5cx,48x,3fx,6ex,6ex,6fx,91x,7fx,65x,5fx,5ex,60x,75x,74x,76x,6cx,54x,47x,40x,2fx,32x,67x,36x,34x,b9x,4ax,41x,46x,38x,3ax,afx,88x,66x,4cx> + idb_append_data <41x,3fx,dex,bex,88x,35x,36x,3bx,53x,44x,3fx,74x,3fx,3cx,54x,5cx,68x,9dx,3cx,37x,3cx,37x,3ax,8fx,6ex,59x,a7x,3cx,36x,8bx,8bx,8bx,40x,38x,3ax,99x,76x,5dx,8bx,44x,40x,f6x,d4x,97x,65x,52x,48x,55x,38x,38x,7bx,7ax,7bx,bfx,4cx,43x,62x,4cx,3fx,99x,48x,41x,41x,44x,4cx,9cx,37x,32x,3ax,3bx,41x,47x,4ax,51x,9ex,87x,69x,85x,37x,34x,a8x,41x,3ax,88x,77x,61x,94x,72x,5bx,8cx,8cx,8cx,9fx,38x,33x,47x,3ex,3fx,3ax,30x,33x,cex,54x,49x,a2x,3ax,34x,8fx,33x,2fx,adx,3fx,38x,9fx,7bx,60x,72x,57x,47x,87x,6dx,54x,76x,3ax,37x,44x,3dx,3fx,99x,3ax,35x,9fx,84x,63x,45x,31x,33x,65x,4dx,3fx,abx,3ex,37x,7cx,5fx,4bx,38x,35x,38x,49x> + idb_append_data <39x,3ax,4fx,34x,35x,7ax,3dx,3ax,93x,46x,41x,41x,3ax,3dx,8dx,38x,34x,32x,33x,37x,a7x,81x,63x,8cx,8bx,8bx,6dx,57x,4bx,39x,34x,35x,4fx,53x,5bx,c2x,4dx,44x,88x,30x,2dx,6ex,39x,37x,6bx,35x,34x,86x,71x,5ax,4fx,42x,3fx,79x,40x,3dx,8bx,71x,56x,e2x,c1x,8bx,97x,35x,31x,66x,4dx,3fx,33x,31x,35x,71x,3cx,39x,5fx,30x,30x,7dx,7dx,7ex,90x,6fx,59x,4dx,36x,37x,95x,80x,64x,43x,3cx,3ex,3cx,3ex,43x,afx,41x,39x,96x,38x,33x,c4x,4ex,44x,5fx,4ax,3fx,76x,36x,33x,36x,33x,36x,cfx,54x,49x,75x,75x,76x,6cx,35x,33x,a4x,3ax,34x,6ax,72x,7ex,3dx,38x,3ax,7ax,41x,3dx,8bx,8bx,8cx,41x,30x,32x,44x,48x,51x,bcx,4bx,42x,83x,43x,3fx,9dx> + idb_append_data <89x,6bx,9cx,39x,34x,c1x,4dx,43x,a1x,39x,33x,91x,70x,5ax,85x,84x,85x,48x,3fx,3ex,8cx,8bx,8cx,9fx,3cx,37x,40x,3ax,3cx,95x,35x,31x,eex,cdx,93x,98x,37x,32x,45x,3dx,3fx,35x,36x,3cx,3ax,36x,38x,8dx,45x,40x,55x,45x,3fx,8ax,30x,2dx,bbx,49x,41x,51x,43x,3fx,34x,32x,35x,9bx,3ax,35x,a8x,3dx,36x,3ax,3cx,43x,84x,42x,3ex,63x,4cx,3fx,76x,3bx,39x,afx,88x,67x,69x,68x,6ax,6fx,6ex,6fx,98x,36x,31x,3ex,38x,3bx,73x,58x,47x,92x,80x,66x,aex,40x,39x,41x,39x,3bx,9ax,77x,5ex,69x,72x,7ex,49x,3fx,3fx,84x,43x,3ex,96x,36x,31x,3bx,3cx,41x,5dx,49x,3fx,a9x,41x,3ax,56x,38x,38x,9dx,37x,32x,c2x,4ex,44x,6ex,3ax,38x,bfx,4dx,44x,a3x> + idb_append_data <3ax,34x,35x,32x,35x,7ax,40x,3dx,a0x,38x,33x,95x,72x,5bx,b0x,41x,3ax,a3x,3ex,38x,64x,4cx,3fx,84x,43x,3fx,6dx,35x,33x,77x,36x,33x,6bx,36x,34x,bbx,4ax,41x,42x,30x,32x,50x,42x,3fx,9ax,3ax,35x,4dx,41x,3fx,a8x,3dx,37x,a0x,84x,63x,90x,33x,2fx,3bx,30x,33x,48x,3ex,3fx,bax,4ax,41x,cdx,aex,7ex,c9x,51x,47x,35x,2fx,33x,48x,3fx,3fx,c1x,4dx,44x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x> + idb_append_data <00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,00x,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,7dx,08x,1cx,48x,70x,91x,0fx,83x,06x,05x,22x,24x,78x,90x,a1x,43x,86x,5ax,1ax,2ex,5cx,f8x,b0x,a2x,42x,89x,18x,ffx,60x,b4x,28x,30x,51x,9ex,8fx,20x,43x,e6x,c9x,30x,b2x,a4x,c8x,8fx,89x,12x,aax,f0x,f1x,c7x,82x,2bx,1cx,30x,63x,cax,9cx,49x,13x,47x,9cx,50x,0dx,7dx,acx,b4x> + idb_append_data <80x,80x,8fx,cfx,9fx,aax,80x,f2x,19x,c0x,47x,95x,d1x,a2x,43x,f9x,74x,09x,b5x,52x,45x,53x,0bx,35x,4ax,48x,9dx,4ax,b5x,aax,d5x,12x,0bx,20x,e8x,24x,68x,41x,59x,93x,61x,1bx,86x,35x,79x,96x,26x,93x,59x,2ex,5cx,ccx,9ax,05x,f0x,75x,c3x,86x,26x,cax,70x,32x,14x,05x,86x,c1x,a8x,64x,90x,18x,4cx,81x,13x,a9x,6fx,9dx,19x,7dx,fbx,36x,60x,50x,88x,88x,23x,06x,49x,e4x,72x,f5x,83x,a7x,c8x,0fx,5ex,78x,62x,f1x,8dx,44x,6cx,86x,13x,4cx,81x,ddx,e0x,81x,f5x,63x,13x,1ex,56x,8ax,07x,5ax,60x,fcx,24x,97x,84x,c8x,93x,dfx,34x,6bx,96x,23x,f3x,66x,59x,9ex,41x,3bx,1cx,ddx,f8x,31x,eax,48x,3cx,1ex,b9x,70x,f1x,c8x,54x,5fx,cdx,3bx> + idb_append_data <3ax,7fx,56x,8cx,d0x,02x,2ex,3cx,a5x,4fx,c3x,e0x,6bx,6ax,f7x,6ex,42x,bfx,85x,c0x,b2x,b1x,49x,88x,ecx,81x,06x,69x,3bx,86x,2cx,79x,55x,02x,33x,bbx,cdx,88x,ffx,59x,15x,49x,33x,2cx,d8x,c3x,13x,2ax,34x,8ex,3cx,85x,20x,1ax,52x,94x,18x,73x,82x,04x,19x,93x,32x,4ex,88x,45x,f2x,50x,45x,c6x,b1x,eax,d7x,5dx,a4x,5dx,11x,78x,90x,60x,45x,24x,f3x,a1x,a1x,a0x,82x,fax,59x,51x,00x,1ex,bbx,c4x,16x,0ax,42x,c5x,1dx,27x,87x,33x,94x,acx,a0x,04x,10x,9ex,2cx,e8x,c4x,87x,bdx,acx,a2x,04x,2ax,bex,04x,70x,cax,70x,b3x,a9x,21x,8cx,30x,2dx,f4x,d1x,d7x,32x,0bx,2ax,e8x,04x,1ax,4ex,90x,17x,49x,1fx,bex,30x,23x,0cx,15x,13x,e6x,b4x> + idb_append_data <88x,05x,0fx,7cx,61x,c9x,2dx,81x,8dx,10x,23x,8dx,1fx,56x,12x,d8x,1dx,13x,7cx,b1x,46x,68x,02x,59x,40x,cbx,1cx,a3x,04x,43x,4ax,5fx,1dx,c6x,38x,e3x,8cx,7dx,91x,c2x,41x,2bx,07x,7cx,02x,e5x,8fx,7ex,30x,92x,cbx,15x,51x,f4x,d5x,cbx,87x,48x,7ex,f8x,61x,5fx,93x,e8x,70x,88x,26x,9dx,40x,e9x,c3x,68x,8cx,78x,61x,8bx,1dx,27x,bcx,b2x,a5x,87x,34x,a2x,f1x,0ax,29x,61x,ecx,e1x,85x,26x,bex,c8x,95x,d0x,8fx,b8x,30x,32x,cbx,1ex,c0x,28x,a2x,41x,29x,50x,54x,6ax,a9x,03x,47x,1cx,a1x,01x,08x,bfx,ecx,41x,47x,31x,89x,fax,78x,67x,99x,74x,40x,fax,42x,1bx,46x,80x,f2x,81x,aax,aax,66x,61x,84x,02x,28x,6cx,88x,d1x,29x,1dx,9ax,80x> + idb_append_data <46x,e1x,41x,78x,3ex,0ax,ccx,0bx,28x,a4x,92x,aax,aax,abx,82x,a2x,40x,2ax,6dx,c8x,eax,69x,adx,38x,25x,14x,91x,71x,26x,44x,33x,c4x,aex,88x,b4x,81x,48x,0fx,bax,50x,4bx,2dx,22x,d1x,6ex,a1x,87x,2dx,5ex,14x,43x,41x,8fx,eax,89x,82x,85x,24x,e4x,4ax,22x,c2x,b9x,e8x,a6x,9bx,aex,b9x,22x,48x,82x,85x,9dx,2ex,05x,22x,efx,bcx,f4x,d6x,6bx,6fx,20x,9cx,84x,a2x,11x,76x,6cx,60x,e0x,efx,bfx,00x,07x,2cx,f0x,bfx,31x,70x,b4x,90x,46x,1ax,adx,14x,11x,45x,39x,35x,ccx,d0x,44x,3ex,44x,b4x,92x,41x,08x,3fx,ecx,b0x,c1x,5bx,41x,acx,dex,c6x,07x,05x,04x,00x,3bx> + + idb_end_obj + uni_end_stream +man_update_woff_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_038.bin b/internal/aol/fdo/testdata/livecapture/capture_038.bin new file mode 100755 index 0000000..b03ccb4 Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_038.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_038.txt b/internal/aol/fdo/testdata/livecapture/capture_038.txt new file mode 100755 index 0000000..4fe34c9 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_038.txt @@ -0,0 +1,24 @@ +uni_start_stream + dod_start + uni_transaction_id <21300532> + dod_no_hints + dod_form_id <19-0-0> + dod_gid <1-69-1332> + dod_type <2> + dod_data <01x,00x,01x,00x,01x,00x,e8x,06x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,c4x,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,1ex,1ex,27x,90x,acx,b1x,63x,50x,45x,d7x,d3x,cdx,7ax,76x,76x,29x,3bx,4ex,8ex,5bx,37x,bex,78x,42x,3fx,66x,79x,30x,46x,54x,8ex,8bx,89x,46x,50x,56x,80x,74x,63x,45x,3fx,41x,26x,2ex,37x,37x,55x,65x,5ex,6cx,72x,3dx,34x,32x,81x,55x,36x,a5x,a1x,9ex,93x,74x,5cx,20x,26x,36x,edx,e8x,e1x,35x,2cx,2cx,6cx,83x,89x,80x,67x,54x,d7x,86x,46x,7ex,52x,34x,3cx,5ex,71x,50x,62x,6dx,4cx,3fx,39x,c5x,c1x,bcx,28x> + dod_data <25x,2ax,59x,55x,57x,45x,3ax,36x,78x,60x,4fx,28x,33x,3ex,97x,78x,5fx,47x,4ex,54x,51x,43x,44x,6ax,55x,47x,b2x,aex,aax,71x,5cx,4dx,61x,75x,7bx,48x,44x,47x,9fx,65x,3bx,87x,6dx,59x,40x,3bx,3dx,34x,4cx,5ax,20x,24x,30x,6bx,82x,88x,99x,95x,93x,2ax,3ax,46x,96x,b2x,b7x,43x,38x,34x,21x,29x,3bx,50x,4dx,4fx,56x,3dx,2fx,59x,49x,41x,51x,6ax,73x,6ex,59x,4bx,20x,21x,2bx,38x,32x,33x,31x,3ax,48x,96x,92x,90x,55x,51x,53x,2fx,33x,3ax,97x,7bx,5fx,47x,34x,2cx,5ex,5ax,5bx,6ex,86x,8cx,96x,76x,5dx,3ex,38x,39x,2dx,2bx,2fx,7bx,63x,51x,abx,a7x,a3x,4cx,49x,4bx,8dx,70x,5ax,21x,2ax,3cx,f1x,ecx,e5x,61x,70x,75x,36x,51x,61x,ddx> + dod_data <8ax,48x,3bx,35x,37x,74x,5dx,4dx,21x,27x,36x,3dx,63x,76x,67x,54x,48x,7fx,7cx,7bx,71x,89x,8fx,1fx,25x,33x,3ax,58x,68x,39x,34x,35x,f1x,edx,e5x,66x,76x,7bx,48x,3cx,38x,4ex,4bx,4dx,4ax,47x,49x,b6x,b1x,aex,32x,2ex,32x,f0x,ebx,e4x,23x,2cx,3dx,dcx,d8x,d2x,58x,6bx,70x,dcx,88x,46x,43x,3ex,3fx,1fx,23x,2fx,92x,73x,5cx,31x,48x,56x,24x,1fx,22x,41x,37x,39x,2ax,3ex,52x,93x,8fx,8dx,9bx,98x,96x,70x,5ax,4bx,5cx,40x,2ex,62x,5ex,5fx,6cx,57x,49x,43x,39x,3bx,29x,3bx,4dx,95x,75x,5cx,84x,6ax,55x,52x,4ex,51x,24x,2cx,39x,33x,2cx,2dx,91x,5dx,38x,46x,41x,43x,22x,26x,32x,9ax,7bx,62x,53x,45x,45x,98x,b4x,b9x,1fx,27x,38x,24x> + dod_data <29x,34x,98x,79x,60x,3cx,5bx,6bx,79x,61x,50x,c3x,7ax,42x,62x,72x,77x,64x,73x,79x,5dx,4cx,42x,6fx,88x,8dx,4bx,46x,47x,8ax,6ex,58x,22x,2bx,3cx,3dx,34x,36x,40x,36x,33x,91x,77x,5dx,f0x,ecx,e5x,8dx,71x,5bx,acx,a8x,a4x,4ax,52x,58x,3ex,64x,77x,75x,5ex,4ex,dfx,8dx,4bx,7dx,64x,52x,1ex,21x,2dx,2bx,26x,2bx,27x,33x,42x,31x,3cx,4cx,56x,53x,55x,1fx,26x,34x,36x,30x,32x,6cx,58x,4ax,99x,79x,61x,4cx,47x,49x,3ex,37x,38x,46x,3bx,36x,20x,28x,39x,39x,56x,66x,54x,6cx,74x,96x,77x,5fx,70x,5bx,4cx,65x,52x,46x,20x,28x,3bx,21x,23x,2dx,40x,67x,7ax,97x,b3x,b8x,3cx,33x,35x,42x,38x,3ax,44x,41x,44x,43x,3fx,41x,22x,28x,37x,20x> + dod_data <20x,29x,67x,77x,7cx,21x,24x,31x,38x,2cx,2ax,40x,3ax,3ax,6fx,58x,49x,48x,42x,44x,38x,30x,33x,97x,93x,91x,1ex,22x,2fx,20x,23x,30x,94x,75x,5dx,f0x,ecx,e4x,4dx,4ax,4cx,44x,39x,35x,50x,4cx,4ex,23x,2dx,3fx,20x,29x,3bx,1ex,24x,32x,9ax,96x,94x,72x,5bx,4bx,51x,4ex,50x,8fx,71x,5ax,51x,63x,6ex,3fx,62x,74x,3ex,35x,37x,22x,2ax,3dx,46x,41x,42x,70x,88x,8ex,f1x,edx,e6x,7ax,62x,50x,99x,7ax,62x,93x,5ex,38x,6dx,56x,48x,29x,33x,44x,34x,2ex,30x,32x,49x,57x,dcx,89x,47x,98x,78x,5fx,8cx,6fx,59x,21x,26x,34x,6dx,58x,4ax,2fx,2ax,2ex,97x,78x,5ex,95x,76x,5ex,99x,79x,60x,64x,51x,45x,6ax,56x,49x,2ax,3cx,50x,76x,5fx,4ex,63x> + dod_data <73x,78x,3fx,35x,32x,82x,75x,63x,4ax,3dx,37x,65x,74x,79x,31x,47x,55x,dex,8bx,4ax,73x,5cx,4cx,9bx,7cx,63x,4ax,46x,48x,99x,7ax,61x,8cx,70x,5ax,20x,24x,32x,d8x,87x,48x,4dx,40x,3bx,adx,a9x,a6x,71x,8ax,8fx,97x,77x,5ex,22x,2bx,3dx,4cx,48x,4ax,53x,4fx,52x,4dx,49x,4bx,21x,2ax,3dx,6fx,87x,8dx,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,9fx,3cx,e9x,42x,50x,20x,c1x,49x,5dx,04x,2ax,ecx,32x,6dx,5ax,c2x,86x,03x,13x,26x,54x,68x,90x,e2x,c4x,27x,93x,26x,2dx,24x,28x,71x,dax,c0x,81x,1ax,23x,0ax,1cx,10x,82x,dfx,32x,26x,c5x,96x,2dx,0bx,f2x,49x,e5x,27x,1cx,7ax,f8x,0dx,0bx,d2x,0fx,47x,3fx,7ex,fdx,86x,15x,2bx> + dod_data <46x,c7x,4cx,42x,61x,93x,42x,88x,72x,e4x,68x,1ex,a5x,6ex,44x,9bx,ccx,33x,dax,a4x,29x,33x,66x,4dx,28x,3dx,6dx,4ax,a9x,89x,9cx,22x,14x,69x,55x,0bx,36x,e2x,90x,57x,25x,23x,bax,2ax,39x,77x,88x,9ax,12x,4dx,9ax,94x,28x,a1x,36x,42x,adx,a6x,60x,78x,e2x,2dx,8cx,26x,4fx,8ex,2dx,7ax,9bx,80x,c5x,f8x,05x,acx,efx,2fx,35x,6ax,7ex,e1x,8ax,01x,0cx,97x,dex,18x,9bx,00x,9cx,0bx,c6x,e2x,62x,1ax,6ex,3cx,62x,b4x,1ax,74x,ccx,dfx,a9x,0ax,15x,b4x,54x,70x,72x,a3x,d5x,b1x,41x,a7x,6ex,9cx,d2x,a7x,efx,86x,1ax,2ax,aax,fax,51x,7cx,81x,47x,8ex,1ax,cfx,c7x,9cx,00x,23x,41x,83x,86x,03x,50x,d0x,6ex,58x,3ex,f6x,d9x,89x,3fx,27x,a7x> + dod_data <55x,f9x,f1x,28x,30x,5ax,3ex,39x,c0x,62x,dfx,d0x,87x,2bx,8ax,15x,04x,dax,b4x,90x,2ex,7dx,eax,d8x,8dx,1bx,bcx,7fx,bdx,53x,15x,26x,a1x,c6x,06x,f9x,76x,fdx,ffx,1ax,84x,4cx,0bx,28x,57x,0fx,cex,ecx,48x,e0x,4dx,9fx,13x,68x,d0x,b0x,75x,68x,d6x,0cx,fbx,2fx,d4x,61x,14x,4ex,e2x,15x,fex,97x,16x,13x,ecx,78x,61x,c9x,03x,43x,30x,c0x,46x,1bx,3dx,9cx,02x,8dx,3ex,9ex,e0x,23x,8dx,34x,65x,38x,f1x,8bx,32x,f9x,c4x,e3x,ddx,24x,2cx,70x,b3x,4ax,0cx,dex,78x,01x,4bx,0dx,e8x,a0x,22x,89x,3ax,09x,18x,d0x,42x,2ex,dex,dcx,e0x,89x,34x,8cx,e0x,f3x,c8x,0dx,f4x,60x,22x,4ex,3fx,0cx,65x,14x,0dx,37x,aex,55x,e1x,85x,20x,82x,b0x,63x> + dod_data + dod_data + dod_data <53x,c2x,c9x,2ex,e4x,d1x,44x,38x,25x,ccx,82x,91x,40x,a4x,88x,03x,72x,3ex,25x,54x,93x,4fx,21x,2ex,9fx,9cx,cfx,11x,dcx,70x,23x,4fx,35x,40x,17x,b2x,88x,0ex,87x,e4x,43x,01x,2dx,fax,61x,e1x,c1x,2ax,2ax,c8x,71x,0dx,0fx,a2x,d4x,a1x,c2x,2ax,dfx,d4x,51x,47x,39x,e5x,f0x,d0x,f5x,37x,3cx,d4x,21x,0ax,0fx,28x,c8x,b1x,0ex,01x,14x,59x,50x,49x,1cx,c9x,c0x,9dx,0cx,10x,33x,80x,d1x,0bx,24x,cfx,3cx,13x,0bx,24x,90x,f4x,a9x,b2x,8cx,2fx,74x,03x,0ex,87x,2fx,4bx,90x,81x,eex,adx,6ax,a2x,abx,f8x,24x,b4x,9cx,70x,42x,20x,8fx,07x,22x,f9x,3ex,c2x,48x,99x,aex,94x,21x,ddx,acx,11x,19x,29x,4cx,00x,04x,27x,76x,b8x,21x,8bx,2cx,a2x> + dod_data <93x,cex,c9x,0cx,4bx,88x,91x,91x,94x,13x,55x,2ex,90x,e2x,04x,d8x,c3x,0ax,39x,acx,5cx,21x,40x,edx,e4x,90x,73x,c5x,15x,b3x,93x,93x,8ex,02x,1ax,65x,fex,7ax,f0x,c2x,88x,61x,0ax,20x,48x,a3x,7cx,34x,3cx,80x,14x,32x,cax,d1x,3fx,8bx,13x,c1x,07x,14x,85x,84x,50x,48x,f7x,80x,93x,8dx,0fx,5cx,84x,a2x,0bx,12x,bax,94x,12x,fex,14x,53x,74x,efx,43x,28x,63x,a4x,80x,d1x,45x,4fx,5cx,9ex,11x,50x,c2x,08x,43x,46x,fcx,e9x,2ex,fex,3ax,50x,afx,6bx,fex,3ex,e6x,c4x,abx,b9x,7ex,fex,89x,5bx,ddx,ebx,02x,02x,00x,3bx> + + dod_end_data + dod_close_form + dod_end +uni_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_039.bin b/internal/aol/fdo/testdata/livecapture/capture_039.bin new file mode 100755 index 0000000..e5229fa Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_039.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_039.txt b/internal/aol/fdo/testdata/livecapture/capture_039.txt new file mode 100755 index 0000000..30c5f10 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_039.txt @@ -0,0 +1,23 @@ +uni_start_stream + uni_start_stream + idb_start_obj <"p"> + idb_dod_progress_gauge <"close open process active start main refresh"> + idb_atr_globalid <1-69-1332> + idb_atr_length <1772> + idb_atr_dod <01x> + idb_append_data <01x,00x,01x,00x,01x,00x,e8x,06x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,c4x,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,1ex,1ex,27x,90x,acx,b1x,63x,50x,45x,d7x,d3x,cdx,7ax,76x,76x,29x,3bx,4ex,8ex,5bx,37x,bex,78x,42x,3fx,66x,79x,30x,46x,54x,8ex,8bx,89x,46x,50x,56x,80x,74x,63x,45x,3fx,41x,26x,2ex,37x,37x,55x,65x,5ex,6cx,72x,3dx,34x,32x,81x,55x,36x,a5x,a1x,9ex,93x,74x,5cx,20x,26x,36x,edx,e8x,e1x,35x,2cx,2cx,6cx,83x,89x,80x,67x,54x,d7x,86x,46x,7ex,52x,34x,3cx,5ex,71x,50x,62x,6dx,4cx,3fx,39x,c5x,c1x,bcx,28x> + idb_append_data <25x,2ax,59x,55x,57x,45x,3ax,36x,78x,60x,4fx,28x,33x,3ex,97x,78x,5fx,47x,4ex,54x,51x,43x,44x,6ax,55x,47x,b2x,aex,aax,71x,5cx,4dx,61x,75x,7bx,48x,44x,47x,9fx,65x,3bx,87x,6dx,59x,40x,3bx,3dx,34x,4cx,5ax,20x,24x,30x,6bx,82x,88x,99x,95x,93x,2ax,3ax,46x,96x,b2x,b7x,43x,38x,34x,21x,29x,3bx,50x,4dx,4fx,56x,3dx,2fx,59x,49x,41x,51x,6ax,73x,6ex,59x,4bx,20x,21x,2bx,38x,32x,33x,31x,3ax,48x,96x,92x,90x,55x,51x,53x,2fx,33x,3ax,97x,7bx,5fx,47x,34x,2cx,5ex,5ax,5bx,6ex,86x,8cx,96x,76x,5dx,3ex,38x,39x,2dx,2bx,2fx,7bx,63x,51x,abx,a7x,a3x,4cx,49x,4bx,8dx,70x,5ax,21x,2ax,3cx,f1x,ecx,e5x,61x,70x,75x,36x,51x,61x,ddx> + idb_append_data <8ax,48x,3bx,35x,37x,74x,5dx,4dx,21x,27x,36x,3dx,63x,76x,67x,54x,48x,7fx,7cx,7bx,71x,89x,8fx,1fx,25x,33x,3ax,58x,68x,39x,34x,35x,f1x,edx,e5x,66x,76x,7bx,48x,3cx,38x,4ex,4bx,4dx,4ax,47x,49x,b6x,b1x,aex,32x,2ex,32x,f0x,ebx,e4x,23x,2cx,3dx,dcx,d8x,d2x,58x,6bx,70x,dcx,88x,46x,43x,3ex,3fx,1fx,23x,2fx,92x,73x,5cx,31x,48x,56x,24x,1fx,22x,41x,37x,39x,2ax,3ex,52x,93x,8fx,8dx,9bx,98x,96x,70x,5ax,4bx,5cx,40x,2ex,62x,5ex,5fx,6cx,57x,49x,43x,39x,3bx,29x,3bx,4dx,95x,75x,5cx,84x,6ax,55x,52x,4ex,51x,24x,2cx,39x,33x,2cx,2dx,91x,5dx,38x,46x,41x,43x,22x,26x,32x,9ax,7bx,62x,53x,45x,45x,98x,b4x,b9x,1fx,27x,38x,24x> + idb_append_data <29x,34x,98x,79x,60x,3cx,5bx,6bx,79x,61x,50x,c3x,7ax,42x,62x,72x,77x,64x,73x,79x,5dx,4cx,42x,6fx,88x,8dx,4bx,46x,47x,8ax,6ex,58x,22x,2bx,3cx,3dx,34x,36x,40x,36x,33x,91x,77x,5dx,f0x,ecx,e5x,8dx,71x,5bx,acx,a8x,a4x,4ax,52x,58x,3ex,64x,77x,75x,5ex,4ex,dfx,8dx,4bx,7dx,64x,52x,1ex,21x,2dx,2bx,26x,2bx,27x,33x,42x,31x,3cx,4cx,56x,53x,55x,1fx,26x,34x,36x,30x,32x,6cx,58x,4ax,99x,79x,61x,4cx,47x,49x,3ex,37x,38x,46x,3bx,36x,20x,28x,39x,39x,56x,66x,54x,6cx,74x,96x,77x,5fx,70x,5bx,4cx,65x,52x,46x,20x,28x,3bx,21x,23x,2dx,40x,67x,7ax,97x,b3x,b8x,3cx,33x,35x,42x,38x,3ax,44x,41x,44x,43x,3fx,41x,22x,28x,37x,20x> + idb_append_data <20x,29x,67x,77x,7cx,21x,24x,31x,38x,2cx,2ax,40x,3ax,3ax,6fx,58x,49x,48x,42x,44x,38x,30x,33x,97x,93x,91x,1ex,22x,2fx,20x,23x,30x,94x,75x,5dx,f0x,ecx,e4x,4dx,4ax,4cx,44x,39x,35x,50x,4cx,4ex,23x,2dx,3fx,20x,29x,3bx,1ex,24x,32x,9ax,96x,94x,72x,5bx,4bx,51x,4ex,50x,8fx,71x,5ax,51x,63x,6ex,3fx,62x,74x,3ex,35x,37x,22x,2ax,3dx,46x,41x,42x,70x,88x,8ex,f1x,edx,e6x,7ax,62x,50x,99x,7ax,62x,93x,5ex,38x,6dx,56x,48x,29x,33x,44x,34x,2ex,30x,32x,49x,57x,dcx,89x,47x,98x,78x,5fx,8cx,6fx,59x,21x,26x,34x,6dx,58x,4ax,2fx,2ax,2ex,97x,78x,5ex,95x,76x,5ex,99x,79x,60x,64x,51x,45x,6ax,56x,49x,2ax,3cx,50x,76x,5fx,4ex,63x> + idb_append_data <73x,78x,3fx,35x,32x,82x,75x,63x,4ax,3dx,37x,65x,74x,79x,31x,47x,55x,dex,8bx,4ax,73x,5cx,4cx,9bx,7cx,63x,4ax,46x,48x,99x,7ax,61x,8cx,70x,5ax,20x,24x,32x,d8x,87x,48x,4dx,40x,3bx,adx,a9x,a6x,71x,8ax,8fx,97x,77x,5ex,22x,2bx,3dx,4cx,48x,4ax,53x,4fx,52x,4dx,49x,4bx,21x,2ax,3dx,6fx,87x,8dx,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,9fx,3cx,e9x,42x,50x,20x,c1x,49x,5dx,04x,2ax,ecx,32x,6dx,5ax,c2x,86x,03x,13x,26x,54x,68x,90x,e2x,c4x,27x,93x,26x,2dx,24x,28x,71x,dax,c0x,81x,1ax,23x,0ax,1cx,10x,82x,dfx,32x,26x,c5x,96x,2dx,0bx,f2x,49x,e5x,27x,1cx,7ax,f8x,0dx,0bx,d2x,0fx,47x,3fx,7ex,fdx,86x,15x,2bx> + idb_append_data <46x,c7x,4cx,42x,61x,93x,42x,88x,72x,e4x,68x,1ex,a5x,6ex,44x,9bx,ccx,33x,dax,a4x,29x,33x,66x,4dx,28x,3dx,6dx,4ax,a9x,89x,9cx,22x,14x,69x,55x,0bx,36x,e2x,90x,57x,25x,23x,bax,2ax,39x,77x,88x,9ax,12x,4dx,9ax,94x,28x,a1x,36x,42x,adx,a6x,60x,78x,e2x,2dx,8cx,26x,4fx,8ex,2dx,7ax,9bx,80x,c5x,f8x,05x,acx,efx,2fx,35x,6ax,7ex,e1x,8ax,01x,0cx,97x,dex,18x,9bx,00x,9cx,0bx,c6x,e2x,62x,1ax,6ex,3cx,62x,b4x,1ax,74x,ccx,dfx,a9x,0ax,15x,b4x,54x,70x,72x,a3x,d5x,b1x,41x,a7x,6ex,9cx,d2x,a7x,efx,86x,1ax,2ax,aax,fax,51x,7cx,81x,47x,8ex,1ax,cfx,c7x,9cx,00x,23x,41x,83x,86x,03x,50x,d0x,6ex,58x,3ex,f6x,d9x,89x,3fx,27x,a7x> + idb_append_data <55x,f9x,f1x,28x,30x,5ax,3ex,39x,c0x,62x,dfx,d0x,87x,2bx,8ax,15x,04x,dax,b4x,90x,2ex,7dx,eax,d8x,8dx,1bx,bcx,7fx,bdx,53x,15x,26x,a1x,c6x,06x,f9x,76x,fdx,ffx,1ax,84x,4cx,0bx,28x,57x,0fx,cex,ecx,48x,e0x,4dx,9fx,13x,68x,d0x,b0x,75x,68x,d6x,0cx,fbx,2fx,d4x,61x,14x,4ex,e2x,15x,fex,97x,16x,13x,ecx,78x,61x,c9x,03x,43x,30x,c0x,46x,1bx,3dx,9cx,02x,8dx,3ex,9ex,e0x,23x,8dx,34x,65x,38x,f1x,8bx,32x,f9x,c4x,e3x,ddx,24x,2cx,70x,b3x,4ax,0cx,dex,78x,01x,4bx,0dx,e8x,a0x,22x,89x,3ax,09x,18x,d0x,42x,2ex,dex,dcx,e0x,89x,34x,8cx,e0x,f3x,c8x,0dx,f4x,60x,22x,4ex,3fx,0cx,65x,14x,0dx,37x,aex,55x,e1x,85x,20x,82x,b0x,63x> + idb_append_data + idb_append_data + idb_append_data <53x,c2x,c9x,2ex,e4x,d1x,44x,38x,25x,ccx,82x,91x,40x,a4x,88x,03x,72x,3ex,25x,54x,93x,4fx,21x,2ex,9fx,9cx,cfx,11x,dcx,70x,23x,4fx,35x,40x,17x,b2x,88x,0ex,87x,e4x,43x,01x,2dx,fax,61x,e1x,c1x,2ax,2ax,c8x,71x,0dx,0fx,a2x,d4x,a1x,c2x,2ax,dfx,d4x,51x,47x,39x,e5x,f0x,d0x,f5x,37x,3cx,d4x,21x,0ax,0fx,28x,c8x,b1x,0ex,01x,14x,59x,50x,49x,1cx,c9x,c0x,9dx,0cx,10x,33x,80x,d1x,0bx,24x,cfx,3cx,13x,0bx,24x,90x,f4x,a9x,b2x,8cx,2fx,74x,03x,0ex,87x,2fx,4bx,90x,81x,eex,adx,6ax,a2x,abx,f8x,24x,b4x,9cx,70x,42x,20x,8fx,07x,22x,f9x,3ex,c2x,48x,99x,aex,94x,21x,ddx,acx,11x,19x,29x,4cx,00x,04x,27x,76x,b8x,21x,8bx,2cx,a2x> + idb_append_data <93x,cex,c9x,0cx,4bx,88x,91x,91x,94x,13x,55x,2ex,90x,e2x,04x,d8x,c3x,0ax,39x,acx,5cx,21x,40x,edx,e4x,90x,73x,c5x,15x,b3x,93x,93x,8ex,02x,1ax,65x,fex,7ax,f0x,c2x,88x,61x,0ax,20x,48x,a3x,7cx,34x,3cx,80x,14x,32x,cax,d1x,3fx,8bx,13x,c1x,07x,14x,85x,84x,50x,48x,f7x,80x,93x,8dx,0fx,5cx,84x,a2x,0bx,12x,bax,94x,12x,fex,14x,53x,74x,efx,43x,28x,63x,a4x,80x,d1x,45x,4fx,5cx,9ex,11x,50x,c2x,08x,43x,46x,fcx,e9x,2ex,fex,3ax,50x,afx,6bx,fex,3ex,e6x,c4x,abx,b9x,7ex,fex,89x,5bx,ddx,ebx,02x,02x,00x,3bx> + + idb_end_obj + uni_end_stream +man_update_woff_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_040.bin b/internal/aol/fdo/testdata/livecapture/capture_040.bin new file mode 100755 index 0000000..d23020b Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_040.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_040.txt b/internal/aol/fdo/testdata/livecapture/capture_040.txt new file mode 100755 index 0000000..befeb7e --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_040.txt @@ -0,0 +1,24 @@ +uni_start_stream + dod_start + uni_transaction_id <21300501> + dod_no_hints + dod_form_id <19-0-0> + dod_gid <1-69-1301> + dod_type <2> + dod_data <01x,00x,01x,00x,01x,00x,7ex,06x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,5ax,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,21x,1fx,17x,b9x,92x,34x,eex,ccx,50x,5dx,58x,4ax,e4x,ddx,b8x,97x,91x,73x,58x,55x,4dx,37x,33x,1ex,90x,71x,21x,aax,a2x,81x,ddx,d9x,a7x,7ax,74x,59x,6ax,56x,1dx,c9x,c2x,a0x,f1x,e9x,c3x,8fx,8cx,86x,d9x,a9x,33x,b0x,8ex,30x,95x,8ax,65x,d2x,cbx,a8x,4fx,43x,1fx,49x,7bx,93x,81x,6cx,32x,68x,a3x,c1x,b1x,aex,a4x,e2x,dfx,cex,7dx,79x,6cx,f3x,eex,d6x,8dx,70x,31x,39x,4ax,46x,c4x,bex,9cx,3ex,6ex,82x,54x> + dod_data <4dx,36x,e5x,b8x,40x,c4x,95x,27x,95x,8bx,64x,81x,5ax,17x,b8x,b1x,91x,97x,a4x,a2x,69x,62x,49x,8ax,9fx,a1x,41x,3cx,27x,c4x,c1x,b5x,6dx,6bx,62x,5fx,7ex,8ax,d3x,a2x,2dx,a1x,9dx,75x,a1x,6dx,16x,94x,90x,8ax,64x,52x,1ex,53x,89x,a3x,48x,3ex,1fx,84x,73x,42x,d7x,d4x,c5x,ebx,e5x,bcx,aax,a7x,a0x,81x,65x,1dx,8bx,87x,7bx,b0x,86x,24x,dex,c2x,50x,bex,bcx,b3x,23x,21x,19x,dbx,aex,40x,c0x,b9x,98x,d1x,cdx,bbx,c6x,c4x,b6x,acx,9bx,44x,8ax,7ex,3ax,7ax,77x,6ax,46x,4fx,47x,a2x,a1x,9ax,5ax,42x,19x,dcx,d5x,b1x,6ex,5cx,27x,bfx,8dx,24x,70x,70x,71x,aax,76x,19x,9bx,77x,20x,48x,42x,2ax,81x,7dx,71x,63x,5dx,44x,d0x,c9x,a6x,7cx> + dod_data <6dx,4bx,cdx,9cx,27x,ccx,c9x,bbx,acx,a7x,91x,e2x,dbx,b5x,5ax,92x,adx,e7x,bfx,49x,3fx,38x,20x,d5x,d0x,bcx,43x,3ex,29x,71x,6ax,50x,66x,86x,92x,80x,7ax,5ex,f4x,edx,c6x,8ex,8ax,7dx,c9x,c6x,b7x,dbx,b6x,3dx,a1x,9ax,7cx,e8x,c8x,4fx,c2x,c0x,b4x,b4x,8cx,2ax,e7x,dfx,bax,4cx,80x,98x,d4x,cfx,bcx,d7x,a7x,32x,68x,56x,29x,9cx,96x,79x,dfx,dbx,c9x,c4x,c2x,b5x,50x,4dx,49x,7ax,7ax,78x,9cx,7cx,29x,a6x,a3x,9cx,b0x,a9x,8ax,d4x,d0x,bcx,83x,7fx,72x,b2x,a0x,46x,b8x,87x,28x,86x,71x,30x,cbx,c4x,a1x,72x,61x,2cx,80x,69x,26x,e2x,bax,48x,adx,a6x,85x,e0x,b1x,40x,25x,22x,19x,cax,9ax,2ex,d5x,d1x,bdx,91x,8dx,88x,3bx,34x,1ex,6cx> + dod_data <66x,4cx,8bx,74x,31x,94x,73x,20x,b2x,90x,37x,87x,6cx,30x,5ex,44x,19x,dcx,b5x,45x,c2x,bbx,9ax,d4x,a6x,37x,dbx,acx,34x,96x,92x,8cx,f3x,efx,d9x,4bx,40x,1fx,7dx,77x,5cx,dbx,d7x,c7x,f5x,edx,c5x,ecx,c0x,49x,6ex,58x,20x,eex,d0x,52x,25x,23x,1ax,d4x,d0x,bdx,8cx,88x,7bx,a4x,70x,16x,abx,a5x,8ax,dfx,dax,a9x,c7x,c5x,b7x,cbx,c8x,bax,4fx,82x,9bx,83x,67x,23x,bfx,bdx,b4x,44x,3ex,29x,84x,80x,73x,22x,20x,17x,cdx,9cx,30x,83x,5cx,18x,3ex,39x,24x,f5x,edx,c6x,99x,92x,75x,a7x,a4x,9dx,bbx,89x,29x,95x,91x,8bx,96x,75x,21x,c6x,c3x,b5x,8ex,8bx,7ex,5dx,59x,49x,5dx,45x,1cx,b2x,abx,8cx,acx,78x,1bx,c1x,8fx,26x,91x,8ex,88x,f5x> + dod_data + dod_data <58x,49x,7bx,75x,5ax,8fx,8bx,7ex,d9x,aax,35x,25x,22x,1ax,abx,a9x,a1x,f5x,edx,c7x,e3x,dbx,b7x,83x,73x,44x,7dx,6dx,4dx,82x,7ex,72x,93x,91x,8ax,aax,a8x,a0x,dfx,dax,aax,22x,20x,18x,95x,91x,8cx,cax,c3x,a0x,c3x,c1x,b4x,90x,8cx,86x,4cx,41x,1ex,dcx,adx,35x,c3x,bcx,9bx,6ex,6cx,63x,e6x,b9x,41x,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,03x,09x,0bx,24x,50x,98x,c1x,83x,5ax,0cx,62x,5ax,78x,b0x,e1x,c0x,83x,04x,1fx,16x,6cx,88x,89x,8ex,c5x,34x,74x,d2x,60x,c4x,74x,cbx,a2x,16x,2dx,05x,13x,0ex,2cx,88x,49x,d8x,13x,79x,75x,52x,d6x,99x,56x,47x,9ex,cbx,97x,2ex,ebx,8cx,9ax,49x,73x,94x,c0x,88x,1cx,89x,f8x,cbx> + dod_data <91x,a9x,a7x,37x,30x,eax,82x,bex,02x,43x,f4x,95x,51x,a3x,60x,bcx,79x,cbx,f1x,06x,99x,43x,0dx,2bx,24x,65x,30x,f7x,ecx,59x,86x,abx,58x,b3x,5ax,bdx,6ax,b5x,aax,11x,03x,c8x,4ax,0ax,c3x,d4x,a3x,46x,1bx,14x,68x,4dx,60x,58x,cbx,b6x,adx,5bx,b6x,61x,04x,01x,10x,8bx,09x,57x,33x,2ax,bex,64x,a0x,a9x,76x,e3x,06x,3dx,7ax,b9x,a2x,b5x,8bx,96x,abx,5dx,aex,c3x,81x,a3x,d1x,73x,04x,a4x,d6x,b8x,5bx,63x,31x,b1x,7bx,e4x,c9x,d7x,85x,2bx,5dx,78x,90x,dbx,4cx,2ex,94x,b1x,cfx,c6x,42x,89x,f6x,1cx,3ax,58x,63x,00x,b7x,4ax,d2x,61x,d7x,ccx,d3x,87x,4fx,15x,58x,c8x,99x,adx,aax,b6x,2ax,60x,b8x,81x,d5x,96x,73x,5bx,95x,b8x,c6x,e3x> + dod_data + dod_data <09x,08x,1ex,54x,68x,61x,3ex,2fx,0ax,b3x,8bx,64x,1bx,ccx,b8x,e2x,0fx,31x,1cx,e3x,c3x,0ex,64x,60x,a1x,88x,0fx,22x,30x,50x,c2x,24x,58x,a2x,22x,4ax,19x,c5x,d8x,c3x,90x,64x,efx,15x,c8x,22x,2ax,0ex,f4x,01x,8dx,00x,10x,ccx,c2x,84x,1ax,94x,fcx,92x,80x,03x,a8x,8cx,e9x,5fx,86x,1bx,8ex,c5x,cex,7bx,e0x,7cx,b8x,8cx,35x,59x,0cx,21x,86x,26x,b1x,c4x,f2x,c2x,3ax,85x,58x,33x,48x,03x,72x,12x,39x,0ex,1dx,09x,61x,f2x,07x,9ex,7ax,aex,c1x,87x,25x,abx,24x,52x,c5x,26x,47x,dcx,e1x,c7x,14x,bcx,34x,50x,a1x,7fx,c5x,60x,b7x,21x,1dx,7fx,78x,c8x,e0x,32x,14x,80x,72x,48x,29x,a6x,c4x,23x,05x,09x,80x,44x,ffx,80x,03x,35x,f8x,7cx> + dod_data <9ax,4fx,97x,c2x,09x,43x,07x,2ex,49x,a6x,70x,0dx,83x,efx,8cx,11x,09x,1ex,21x,d0x,62x,0ax,36x,4ax,34x,b2x,47x,3ax,bdx,58x,61x,6bx,31x,c1x,a9x,c6x,6bx,27x,bex,56x,38x,01x,3cx,66x,48x,f3x,0fx,23x,8cx,f0x,d3x,82x,0ex,34x,2cx,13x,67x,8bx,8ax,0ax,17x,08x,59x,1bx,50x,fbx,21x,2ax,3fx,64x,83x,40x,1cx,7ax,24x,13x,40x,12x,86x,b4x,02x,49x,09x,e3x,0ex,a9x,8fx,86x,06x,69x,81x,4bx,38x,eax,96x,f3x,c5x,17x,c4x,14x,30x,c3x,08x,5cx,18x,d2x,04x,21x,12x,64x,53x,c0x,19x,15x,7ex,e1x,dfx,bex,75x,92x,e5x,61x,39x,a8x,60x,4cx,4cx,14x,04x,78x,01x,c9x,3ex,0bx,10x,c0x,0dx,31x,0cx,0ex,2cx,71x,3ex,0fx,2cx,3ax,10x,59x,8fx,50x> + dod_data + dod_data <65x,cex,d1x,42x,b7x,80x,aex,7ax,45x,9ax,67x,dex,50x,40x,00x,3bx> + + dod_end_data + dod_close_form + dod_end +uni_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_041.bin b/internal/aol/fdo/testdata/livecapture/capture_041.bin new file mode 100755 index 0000000..bc4d99f Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_041.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_041.txt b/internal/aol/fdo/testdata/livecapture/capture_041.txt new file mode 100755 index 0000000..c3fda18 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_041.txt @@ -0,0 +1,23 @@ +uni_start_stream + uni_start_stream + idb_start_obj <"p"> + idb_dod_progress_gauge <"close open process active start main refresh"> + idb_atr_globalid <1-69-1301> + idb_atr_length <1666> + idb_atr_dod <01x> + idb_append_data <01x,00x,01x,00x,01x,00x,7ex,06x,00x,00x,01x,00x,00x,00x,05x,02x,20x,00x,20x,00x,00x,00x,5ax,06x,00x,00x,24x,00x,00x,00x,00x,00x,00x,00x,00x,00x,80x,fdx,00x,00x,47x,49x,46x,38x,37x,61x,20x,00x,20x,00x,f7x,00x,00x,21x,1fx,17x,b9x,92x,34x,eex,ccx,50x,5dx,58x,4ax,e4x,ddx,b8x,97x,91x,73x,58x,55x,4dx,37x,33x,1ex,90x,71x,21x,aax,a2x,81x,ddx,d9x,a7x,7ax,74x,59x,6ax,56x,1dx,c9x,c2x,a0x,f1x,e9x,c3x,8fx,8cx,86x,d9x,a9x,33x,b0x,8ex,30x,95x,8ax,65x,d2x,cbx,a8x,4fx,43x,1fx,49x,7bx,93x,81x,6cx,32x,68x,a3x,c1x,b1x,aex,a4x,e2x,dfx,cex,7dx,79x,6cx,f3x,eex,d6x,8dx,70x,31x,39x,4ax,46x,c4x,bex,9cx,3ex,6ex,82x,54x> + idb_append_data <4dx,36x,e5x,b8x,40x,c4x,95x,27x,95x,8bx,64x,81x,5ax,17x,b8x,b1x,91x,97x,a4x,a2x,69x,62x,49x,8ax,9fx,a1x,41x,3cx,27x,c4x,c1x,b5x,6dx,6bx,62x,5fx,7ex,8ax,d3x,a2x,2dx,a1x,9dx,75x,a1x,6dx,16x,94x,90x,8ax,64x,52x,1ex,53x,89x,a3x,48x,3ex,1fx,84x,73x,42x,d7x,d4x,c5x,ebx,e5x,bcx,aax,a7x,a0x,81x,65x,1dx,8bx,87x,7bx,b0x,86x,24x,dex,c2x,50x,bex,bcx,b3x,23x,21x,19x,dbx,aex,40x,c0x,b9x,98x,d1x,cdx,bbx,c6x,c4x,b6x,acx,9bx,44x,8ax,7ex,3ax,7ax,77x,6ax,46x,4fx,47x,a2x,a1x,9ax,5ax,42x,19x,dcx,d5x,b1x,6ex,5cx,27x,bfx,8dx,24x,70x,70x,71x,aax,76x,19x,9bx,77x,20x,48x,42x,2ax,81x,7dx,71x,63x,5dx,44x,d0x,c9x,a6x,7cx> + idb_append_data <6dx,4bx,cdx,9cx,27x,ccx,c9x,bbx,acx,a7x,91x,e2x,dbx,b5x,5ax,92x,adx,e7x,bfx,49x,3fx,38x,20x,d5x,d0x,bcx,43x,3ex,29x,71x,6ax,50x,66x,86x,92x,80x,7ax,5ex,f4x,edx,c6x,8ex,8ax,7dx,c9x,c6x,b7x,dbx,b6x,3dx,a1x,9ax,7cx,e8x,c8x,4fx,c2x,c0x,b4x,b4x,8cx,2ax,e7x,dfx,bax,4cx,80x,98x,d4x,cfx,bcx,d7x,a7x,32x,68x,56x,29x,9cx,96x,79x,dfx,dbx,c9x,c4x,c2x,b5x,50x,4dx,49x,7ax,7ax,78x,9cx,7cx,29x,a6x,a3x,9cx,b0x,a9x,8ax,d4x,d0x,bcx,83x,7fx,72x,b2x,a0x,46x,b8x,87x,28x,86x,71x,30x,cbx,c4x,a1x,72x,61x,2cx,80x,69x,26x,e2x,bax,48x,adx,a6x,85x,e0x,b1x,40x,25x,22x,19x,cax,9ax,2ex,d5x,d1x,bdx,91x,8dx,88x,3bx,34x,1ex,6cx> + idb_append_data <66x,4cx,8bx,74x,31x,94x,73x,20x,b2x,90x,37x,87x,6cx,30x,5ex,44x,19x,dcx,b5x,45x,c2x,bbx,9ax,d4x,a6x,37x,dbx,acx,34x,96x,92x,8cx,f3x,efx,d9x,4bx,40x,1fx,7dx,77x,5cx,dbx,d7x,c7x,f5x,edx,c5x,ecx,c0x,49x,6ex,58x,20x,eex,d0x,52x,25x,23x,1ax,d4x,d0x,bdx,8cx,88x,7bx,a4x,70x,16x,abx,a5x,8ax,dfx,dax,a9x,c7x,c5x,b7x,cbx,c8x,bax,4fx,82x,9bx,83x,67x,23x,bfx,bdx,b4x,44x,3ex,29x,84x,80x,73x,22x,20x,17x,cdx,9cx,30x,83x,5cx,18x,3ex,39x,24x,f5x,edx,c6x,99x,92x,75x,a7x,a4x,9dx,bbx,89x,29x,95x,91x,8bx,96x,75x,21x,c6x,c3x,b5x,8ex,8bx,7ex,5dx,59x,49x,5dx,45x,1cx,b2x,abx,8cx,acx,78x,1bx,c1x,8fx,26x,91x,8ex,88x,f5x> + idb_append_data + idb_append_data <58x,49x,7bx,75x,5ax,8fx,8bx,7ex,d9x,aax,35x,25x,22x,1ax,abx,a9x,a1x,f5x,edx,c7x,e3x,dbx,b7x,83x,73x,44x,7dx,6dx,4dx,82x,7ex,72x,93x,91x,8ax,aax,a8x,a0x,dfx,dax,aax,22x,20x,18x,95x,91x,8cx,cax,c3x,a0x,c3x,c1x,b4x,90x,8cx,86x,4cx,41x,1ex,dcx,adx,35x,c3x,bcx,9bx,6ex,6cx,63x,e6x,b9x,41x,2cx,00x,00x,00x,00x,20x,00x,20x,00x,00x,08x,ffx,00x,03x,09x,0bx,24x,50x,98x,c1x,83x,5ax,0cx,62x,5ax,78x,b0x,e1x,c0x,83x,04x,1fx,16x,6cx,88x,89x,8ex,c5x,34x,74x,d2x,60x,c4x,74x,cbx,a2x,16x,2dx,05x,13x,0ex,2cx,88x,49x,d8x,13x,79x,75x,52x,d6x,99x,56x,47x,9ex,cbx,97x,2ex,ebx,8cx,9ax,49x,73x,94x,c0x,88x,1cx,89x,f8x,cbx> + idb_append_data <91x,a9x,a7x,37x,30x,eax,82x,bex,02x,43x,f4x,95x,51x,a3x,60x,bcx,79x,cbx,f1x,06x,99x,43x,0dx,2bx,24x,65x,30x,f7x,ecx,59x,86x,abx,58x,b3x,5ax,bdx,6ax,b5x,aax,11x,03x,c8x,4ax,0ax,c3x,d4x,a3x,46x,1bx,14x,68x,4dx,60x,58x,cbx,b6x,adx,5bx,b6x,61x,04x,01x,10x,8bx,09x,57x,33x,2ax,bex,64x,a0x,a9x,76x,e3x,06x,3dx,7ax,b9x,a2x,b5x,8bx,96x,abx,5dx,aex,c3x,81x,a3x,d1x,73x,04x,a4x,d6x,b8x,5bx,63x,31x,b1x,7bx,e4x,c9x,d7x,85x,2bx,5dx,78x,90x,dbx,4cx,2ex,94x,b1x,cfx,c6x,42x,89x,f6x,1cx,3ax,58x,63x,00x,b7x,4ax,d2x,61x,d7x,ccx,d3x,87x,4fx,15x,58x,c8x,99x,adx,aax,b6x,2ax,60x,b8x,81x,d5x,96x,73x,5bx,95x,b8x,c6x,e3x> + idb_append_data + idb_append_data <09x,08x,1ex,54x,68x,61x,3ex,2fx,0ax,b3x,8bx,64x,1bx,ccx,b8x,e2x,0fx,31x,1cx,e3x,c3x,0ex,64x,60x,a1x,88x,0fx,22x,30x,50x,c2x,24x,58x,a2x,22x,4ax,19x,c5x,d8x,c3x,90x,64x,efx,15x,c8x,22x,2ax,0ex,f4x,01x,8dx,00x,10x,ccx,c2x,84x,1ax,94x,fcx,92x,80x,03x,a8x,8cx,e9x,5fx,86x,1bx,8ex,c5x,cex,7bx,e0x,7cx,b8x,8cx,35x,59x,0cx,21x,86x,26x,b1x,c4x,f2x,c2x,3ax,85x,58x,33x,48x,03x,72x,12x,39x,0ex,1dx,09x,61x,f2x,07x,9ex,7ax,aex,c1x,87x,25x,abx,24x,52x,c5x,26x,47x,dcx,e1x,c7x,14x,bcx,34x,50x,a1x,7fx,c5x,60x,b7x,21x,1dx,7fx,78x,c8x,e0x,32x,14x,80x,72x,48x,29x,a6x,c4x,23x,05x,09x,80x,44x,ffx,80x,03x,35x,f8x,7cx> + idb_append_data <9ax,4fx,97x,c2x,09x,43x,07x,2ex,49x,a6x,70x,0dx,83x,efx,8cx,11x,09x,1ex,21x,d0x,62x,0ax,36x,4ax,34x,b2x,47x,3ax,bdx,58x,61x,6bx,31x,c1x,a9x,c6x,6bx,27x,bex,56x,38x,01x,3cx,66x,48x,f3x,0fx,23x,8cx,f0x,d3x,82x,0ex,34x,2cx,13x,67x,8bx,8ax,0ax,17x,08x,59x,1bx,50x,fbx,21x,2ax,3fx,64x,83x,40x,1cx,7ax,24x,13x,40x,12x,86x,b4x,02x,49x,09x,e3x,0ex,a9x,8fx,86x,06x,69x,81x,4bx,38x,eax,96x,f3x,c5x,17x,c4x,14x,30x,c3x,08x,5cx,18x,d2x,04x,21x,12x,64x,53x,c0x,19x,15x,7ex,e1x,dfx,bex,75x,92x,e5x,61x,39x,a8x,60x,4cx,4cx,14x,04x,78x,01x,c9x,3ex,0bx,10x,c0x,0dx,31x,0cx,0ex,2cx,71x,3ex,0fx,2cx,3ax,10x,59x,8fx,50x> + idb_append_data + idb_append_data <65x,cex,d1x,42x,b7x,80x,aex,7ax,45x,9ax,67x,dex,50x,40x,00x,3bx> + + idb_end_obj + uni_end_stream +man_update_woff_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_042.bin b/internal/aol/fdo/testdata/livecapture/capture_042.bin new file mode 100755 index 0000000..14cb088 Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_042.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_042.txt b/internal/aol/fdo/testdata/livecapture/capture_042.txt new file mode 100755 index 0000000..429bb1b --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_042.txt @@ -0,0 +1,3 @@ +uni_start_stream + uni_wait_off +uni_end_stream diff --git a/internal/aol/fdo/testdata/livecapture/capture_043.bin b/internal/aol/fdo/testdata/livecapture/capture_043.bin new file mode 100755 index 0000000..2da66df Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_043.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_043.txt b/internal/aol/fdo/testdata/livecapture/capture_043.txt new file mode 100755 index 0000000..3f043c1 --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_043.txt @@ -0,0 +1,46 @@ +uni_start_stream <> + man_preset_gid <19-0-0> + if_last_return_false_then <1> +uni_start_stream <01x> + uni_invoke_no_context <32-256> + man_set_context_globalid <19-0-0> + act_set_criterion + act_replace_action + < + uni_start_stream + man_close <19-0-0> + sm_send_token_raw <"CL"> + uni_end_stream + > + man_replace_data <"Active Label Sigma"> + var_number_set + var_number_save + uni_end_stream <01x> + chat_room_open <> + chat_add_user <"left"> + mat_relative_tag <2> + act_set_inheritance <02x> + chat_end_object <> + chat_add_user <"Secondary Unit"> + mat_relative_tag <3> + act_set_inheritance <02x> + chat_end_object <> + uni_start_stream + man_set_context_relative <257> + man_get_child_count + uni_convert_last_atom_data + uni_save_result + man_change_context_relative <261> + uni_get_result + uni_use_last_atom_string + man_end_context + man_update_display + uni_end_stream + uni_start_stream + sm_send_token_raw <"CO"> + uni_end_stream + uni_sync_skip <1> + man_update_display + man_make_focus + uni_wait_off <> +uni_end_stream <> \ No newline at end of file diff --git a/internal/aol/fdo/testdata/livecapture/capture_044.bin b/internal/aol/fdo/testdata/livecapture/capture_044.bin new file mode 100755 index 0000000..2b414ca Binary files /dev/null and b/internal/aol/fdo/testdata/livecapture/capture_044.bin differ diff --git a/internal/aol/fdo/testdata/livecapture/capture_044.txt b/internal/aol/fdo/testdata/livecapture/capture_044.txt new file mode 100755 index 0000000..17b6bae --- /dev/null +++ b/internal/aol/fdo/testdata/livecapture/capture_044.txt @@ -0,0 +1,264 @@ +uni_start_stream <00x> + uni_wait_on + man_set_context_globalid <1> + var_number_set + var_number_save + man_end_context + man_set_context_globalid <53> + man_start_object + mat_bool_background_tile + mat_art_id <1-69-27256> + mat_style_id <32-5447> + mat_orientation + mat_precise_width <518> + mat_precise_height <300> + mat_object_id <32-30> + mat_style_id <32-5447> + mat_position + mat_bool_resize_vertical + mat_bool_non_closeable + mat_bool_precise + + man_start_object + mat_precise_x <8> + mat_precise_y <3> + mat_trigger_style + mat_precise_height <103> + mat_precise_width <115> + mat_art_id <1-69-21864> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + sm_send_k1 <17-35040> + > + man_start_sibling + mat_precise_x <1> + mat_precise_y <105> + mat_trigger_style + mat_art_id <1-69-27553> + act_replace_select_action + < + uni_start_stream <00x> + man_preset_gid <32-5483> + if_last_return_true_then <1, 2> + man_make_focus + man_update_display + uni_sync_skip <1> + uni_wait_on + uni_invoke_no_context <32-5483> + uni_sync_skip <2> + uni_end_stream <00x> + > + man_start_sibling + mat_precise_x <10> + mat_precise_y <162> + mat_trigger_style + mat_art_id <1-69-21191> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + sm_send_k1 <3-4604> + > + man_start_sibling + mat_precise_y <226> + mat_relative_tag <22> + mat_trigger_style + mat_art_id <1-69-21186> + mat_bool_default + act_replace_select_action + < + uni_start_stream_wait_on <00x> + sm_send_k1 <19-6341> + > + man_start_sibling + mat_precise_x <98> + mat_precise_y <226> + mat_trigger_style + mat_art_id <1-69-21188> + act_replace_select_action + < + uni_start_stream + sm_enter_paid + sm_send_token_arg <"CJ"> + > + man_start_sibling + mat_precise_x <196> + mat_precise_y <226> + mat_trigger_style + mat_art_id <1-69-21192> + act_replace_select_action + < + uni_start_stream_wait_on <00x> + sm_send_k1 <17-40338> + > + man_start_sibling + mat_precise_x <440> + mat_precise_y <9> + mat_relative_tag <17> + mat_trigger_style + mat_art_id <1-69-1307> + mat_bool_resize_horizontal + man_start_sibling + mat_precise_x <440> + mat_precise_y <82> + mat_relative_tag <18> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + man_start_sibling + mat_precise_x <440> + mat_precise_y <155> + mat_relative_tag <19> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + man_start_sibling + mat_precise_x <440> + mat_precise_y <228> + mat_relative_tag <20> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + man_start_sibling + mat_orientation + mat_precise_x <293> + mat_precise_y <10> + mat_precise_width <1> + mat_precise_height <210> + mat_color_face <1, 1, 1> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <294> + mat_precise_y <11> + mat_precise_width <1> + mat_precise_height <210> + mat_color_face <200, 200, 200> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <302> + mat_precise_y <76> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <1, 1, 1> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <303> + mat_precise_y <77> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <200, 200, 200> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <302> + mat_precise_y <149> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <1, 1, 1> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <303> + mat_precise_y <150> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <200, 200, 200> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <302> + mat_precise_y <222> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <1, 1, 1> + mat_bool_background_flood + man_start_sibling + mat_orientation + mat_precise_x <303> + mat_precise_y <223> + mat_precise_width <208> + mat_precise_height <1> + mat_color_face <200, 200, 200> + mat_bool_background_flood + man_start_sibling + mat_precise_x <190> + mat_precise_y <25> + mat_relative_tag <21> + mat_trigger_style + mat_art_id <1-0-1307> + mat_bool_resize_horizontal + man_start_sibling + rich_manage + mat_precise_x <185> + mat_precise_y <95> + mat_precise_width <85> + mat_precise_height <120> + mat_relative_tag <3> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + rich_manage + mat_precise_x <302> + mat_precise_y <9> + mat_precise_width <125> + mat_precise_height <60> + mat_relative_tag <10> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + rich_manage + mat_precise_x <302> + mat_precise_y <82> + mat_precise_width <125> + mat_precise_height <60> + mat_relative_tag <12> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + rich_manage + mat_precise_x <302> + mat_precise_y <155> + mat_precise_width <125> + mat_precise_height <60> + mat_relative_tag <14> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_start_sibling + rich_manage + mat_precise_x <302> + mat_precise_y <228> + mat_precise_width <125> + mat_precise_height <60> + mat_relative_tag <16> + rich_set_static + mat_bool_vertical_scroll + mat_bool_resize_vertical + mat_bool_resize_horizontal + mat_bool_exportable + mat_font_id + mat_font_size <9> + man_end_object + uni_end_stream <00x> \ No newline at end of file diff --git a/internal/aol/fdo/wire.go b/internal/aol/fdo/wire.go new file mode 100644 index 0000000..1927905 --- /dev/null +++ b/internal/aol/fdo/wire.go @@ -0,0 +1,362 @@ +package fdo + +import ( + "errors" + "fmt" +) + +// Frame is one atom as it travels: its protocol, number and argument bytes. +type Frame struct { + Proto uint8 + Num uint8 + Data []byte +} + +// Atom is the frame's table entry, if it has one. +func (f Frame) Atom() (*Atom, bool) { return LookupNum(f.Proto, f.Num) } + +// Name is the frame's atom name, or "proto:num" for one not in the table. +func (f Frame) Name() string { + if a, ok := f.Atom(); ok { + return a.Name + } + return fmt.Sprintf("%d:%d", f.Proto, f.Num) +} + +func (f Frame) String() string { return fmt.Sprintf("%s % x", f.Name(), f.Data) } + +// The eight encoding styles: the top three bits of an atom's first byte. +const ( + styleFull = 0 // [proto] [atom] [len] [data] + styleLength = 1 // [proto] [len<<5|atom] [data]: 0-7 bytes, atom < 32 + styleData = 2 // [proto] [value<<5|atom]: one byte of 0-7, atom < 32 + styleAtom = 3 // [atom]: no data, the last atom's protocol + styleCurrent = 4 // [atom] [len] [data]: the last atom's protocol + styleZero = 5 // [atom]: data is one 0 byte + styleOne = 6 // [atom]: data is one 1 byte + stylePrefix = 7 // [111PPAAS] then one of the others: protocols 32-127 +) + +// The universal protocol's large-atom atoms: an atom too big for one +// packet goes as uni_start_large_atom , zero or more +// uni_large_atom_segment , then uni_end_large_atom . +const ( + atomStartLarge = 4 + atomLargeSegment = 5 + atomEndLarge = 6 +) + +// MaxData is the most argument bytes one atom can carry (a two-byte length +// has 15 bits); a bigger atom must be sent as a large atom. +const MaxData = 0x7FFF + +var ( + // ErrShort is a stream that ends inside an atom. + ErrShort = errors.New("fdo: atom stream ends inside an atom") + // ErrLargeAtom is a large-atom segment with no uni_start_large_atom. + ErrLargeAtom = errors.New("fdo: large atom segment without a start") +) + +// Decoder reads atom streams, keeping what carries from one packet to the +// next: the protocol the compact styles assume and a large atom being +// collected. The zero value is ready; keep one per stream id. +type Decoder struct { + proto uint8 + large bool + lProto uint8 + lNum uint8 + lData []byte +} + +// Decode reads one whole atom stream. +func Decode(b []byte) ([]Frame, error) { + var d Decoder + f, err := d.Feed(b) + if err == nil && d.large { + err = fmt.Errorf("fdo: large atom %d:%d not ended", d.lProto, d.lNum) + } + return f, err +} + +// Feed decodes the atoms in b (a packet's worth: whole atoms) and returns +// them. A large atom comes back as one frame once its end arrives. +func (d *Decoder) Feed(b []byte) ([]Frame, error) { + var out []Frame + for len(b) > 0 { + f, n, err := d.next(b) + if err != nil { + return out, err + } + b = b[n:] + if f.Proto == ProtoUNI { + switch f.Num { + case atomStartLarge: + if len(f.Data) < 2 { + return out, fmt.Errorf("fdo: uni_start_large_atom needs a protocol and an atom") + } + d.large, d.lProto, d.lNum, d.lData = true, f.Data[0], f.Data[1], nil + continue + case atomLargeSegment, atomEndLarge: + if !d.large { + return out, ErrLargeAtom + } + d.lData = append(d.lData, f.Data...) + if f.Num == atomEndLarge { + out = append(out, Frame{d.lProto, d.lNum, d.lData}) + d.large, d.lData = false, nil + } + continue + } + } + out = append(out, f) + } + return out, nil +} + +// next decodes the atom at the start of b and returns it and its size. +func (d *Decoder) next(b []byte) (Frame, int, error) { + p := 0 + get := func() (byte, error) { + if p >= len(b) { + return 0, ErrShort + } + c := b[p] + p++ + return c, nil + } + length := func() (int, error) { + c, err := get() + if err != nil || c&0x80 == 0 { + return int(c), err + } + lo, err := get() + return int(c&0x7F)<<8 | int(lo), err + } + data := func(n int) ([]byte, error) { + if len(b)-p < n { + return nil, ErrShort + } + v := append([]byte(nil), b[p:p+n]...) + p += n + return v, nil + } + first, _ := get() + style, low := first>>5, first&0x1F + var f Frame + var err error + switch style { + case styleFull: + f.Proto = low + if f.Num, err = get(); err == nil { + var n int + if n, err = length(); err == nil { + f.Data, err = data(n) + } + } + case styleLength, styleData: + f.Proto = low + var c byte + if c, err = get(); err == nil { + f.Num = c & 0x1F + if style == styleData { + f.Data = []byte{c >> 5} + } else { + f.Data, err = data(int(c >> 5)) + } + } + case styleAtom, styleZero, styleOne, styleCurrent: + f.Proto, f.Num = d.proto, low + switch style { + case styleZero: + f.Data = []byte{0} + case styleOne: + f.Data = []byte{1} + case styleCurrent: + var n int + if n, err = length(); err == nil { + f.Data, err = data(n) + } + } + case stylePrefix: + // [111 PP AA S]: PP the protocol's bits 6-5, AA the atom's 7-6 + var c, a byte + if c, err = get(); err != nil { + break + } + if a, err = get(); err != nil { + break + } + f.Proto = (first>>3&3)<<5 | c&0x1F + hi := (first >> 1 & 3) << 6 + switch c >> 5 { + case styleFull, styleCurrent: + f.Num = a + var n int + if n, err = length(); err == nil { + f.Data, err = data(n) + } + case styleLength: + f.Num = hi | a&0x1F + f.Data, err = data(int(a >> 5)) + case styleData: + f.Num = hi | a&0x1F + f.Data = []byte{a >> 5} + case styleAtom: + f.Num = hi | a&0x3F + case styleZero: + f.Num, f.Data = hi|a&0x3F, []byte{0} + case styleOne: + f.Num, f.Data = hi|a&0x3F, []byte{1} + default: + err = fmt.Errorf("fdo: prefix byte %#02x then another prefix", first) + } + } + if err != nil { + return f, p, err + } + if f.Data == nil { + f.Data = []byte{} + } + d.proto = f.Proto + return f, p, nil +} + +// AppendFrame appends f in the full style, as AOL's compiler writes every +// atom. Its data must be at most MaxData bytes. +func AppendFrame(b []byte, f Frame) []byte { + if f.Proto >= 32 { + b = append(b, stylePrefix<<5|(f.Proto&0x60)>>2) + } + b = append(b, f.Proto&0x1F, f.Num) + b = appendLength(b, len(f.Data)) + return append(b, f.Data...) +} + +func appendLength(b []byte, n int) []byte { + if n < 0x80 { + return append(b, byte(n)) + } + return append(b, 0x80|byte(n>>8), byte(n)) +} + +// frameSize is f's size in the full style. +func frameSize(f Frame) int { + n := 3 + len(f.Data) + if len(f.Data) >= 0x80 { + n++ + } + if f.Proto >= 32 { + n++ + } + return n +} + +// Encode writes frames in the full style, byte for byte as Ada32.dll does. +// A frame bigger than MaxData goes as a large atom. +func Encode(frames []Frame) []byte { + var b []byte + for _, f := range frames { + if len(f.Data) > MaxData { + for _, s := range splitLarge(f, MaxData) { + b = AppendFrame(b, s) + } + continue + } + b = AppendFrame(b, f) + } + return b +} + +// EncodeCompact writes frames in the shortest styles. The client reads +// them, but AOL's tools wrote the full style; Encode is the one to match. +func EncodeCompact(frames []Frame) []byte { + var b []byte + cur := uint8(0) + for _, f := range frames { + n, d := f.Num, f.Data + switch { + case f.Proto >= 32 || len(d) > MaxData: + b = append(b, Encode([]Frame{f})...) + if len(d) > MaxData { + cur = ProtoUNI // the decoder last saw uni_end_large_atom + continue + } + case n < 32 && f.Proto == cur && len(d) == 0: + b = append(b, styleAtom<<5|n) + case n < 32 && f.Proto == cur && len(d) == 1 && d[0] == 0: + b = append(b, styleZero<<5|n) + case n < 32 && f.Proto == cur && len(d) == 1 && d[0] == 1: + b = append(b, styleOne<<5|n) + case n < 32 && len(d) == 1 && d[0] < 8: + b = append(b, styleData<<5|f.Proto, d[0]<<5|n) + case n < 32 && len(d) >= 1 && len(d) < 8: + b = append(b, styleLength<<5|f.Proto, byte(len(d))<<5|n) + b = append(b, d...) + case n < 32 && f.Proto == cur: + b = append(b, styleCurrent<<5|n) + b = appendLength(b, len(d)) + b = append(b, d...) + default: + b = AppendFrame(b, f) + } + cur = f.Proto + } + return b +} + +// splitLarge breaks f into uni_start_large_atom, segments and +// uni_end_large_atom, each segment's data at most seg bytes. +func splitLarge(f Frame, seg int) []Frame { + start := []byte{f.Proto, f.Num} + if n := len(f.Data); n < 0x80 { + start = append(start, byte(n)) + } else { + start = append(start, byte(n>>8), byte(n)) + } + out := []Frame{{ProtoUNI, atomStartLarge, start}} + d := f.Data + for len(d) > seg { + out = append(out, Frame{ProtoUNI, atomLargeSegment, d[:seg]}) + d = d[seg:] + } + return append(out, Frame{ProtoUNI, atomEndLarge, d}) +} + +// Packets encodes frames (full style) into pieces of at most max bytes, +// each holding whole atoms, for P3 data packets: the AOL 3.0 client's own +// limit is 119 bytes of packet data, and the stream's token and id take 4 +// of them. An atom that doesn't fit one piece goes as a large atom, its +// start and each segment in a piece of its own. max must be at least 8. +func Packets(frames []Frame, max int) [][]byte { + if max < 8 { + panic("fdo: packet size too small") + } + var out [][]byte + var cur []byte + flush := func() { + if len(cur) > 0 { + out = append(out, cur) + cur = nil + } + } + for _, f := range frames { + n := frameSize(f) + if n > max { + flush() + segs := splitLarge(f, max-4) + for i, s := range segs { + cur = AppendFrame(cur, s) + if i < len(segs)-1 { + flush() + } + } + continue + } + if len(cur)+n > max { + flush() + } + cur = AppendFrame(cur, f) + } + flush() + return out +} diff --git a/internal/aol/p3/init.go b/internal/aol/p3/init.go new file mode 100644 index 0000000..d007962 --- /dev/null +++ b/internal/aol/p3/init.go @@ -0,0 +1,85 @@ +package p3 + +import ( + "encoding/binary" + "fmt" +) + +// Init is what the client says of itself in its INIT packet: the layout of +// the 32-bit Windows client (3.0 and on); other clients' INITs are shorter +// or laid out otherwise, and only what they have is filled in. +type Init struct { + Platform uint8 // 3 Windows, 0x0C Macintosh + Version uint8 + SubVersion uint8 + MachineMemory uint8 + AppMemory uint8 + PCType uint16 + ReleaseMonth uint8 + ReleaseDay uint8 + CustomerClass uint16 + UDOTimestamp uint32 // when its forms database was made + DOSVersion uint16 + SessionFlags uint16 + VideoType uint8 + Processor uint8 + MediaType uint32 + WindowsVer uint32 + MemoryMode uint8 + Width, Height uint16 // the screen's + Colors uint16 + Region uint16 + Language [4]uint16 + ConnectSpeed uint8 + + Raw []byte // the INIT's data as it came +} + +// The platforms. +const ( + PlatformWindows = 0x03 + PlatformMac = 0x0C +) + +// ParseInit reads an INIT packet's data. +func ParseInit(d []byte) Init { + in := Init{Raw: append([]byte(nil), d...)} + b := make([]byte, 0x31) + copy(b, d) + be := binary.BigEndian + in.Platform, in.Version, in.SubVersion = b[0], b[1], b[2] + in.MachineMemory, in.AppMemory = b[4], b[5] + in.PCType = be.Uint16(b[6:]) + in.ReleaseMonth, in.ReleaseDay = b[8], b[9] + in.CustomerClass = be.Uint16(b[0x0A:]) + in.UDOTimestamp = be.Uint32(b[0x0C:]) + in.DOSVersion = be.Uint16(b[0x10:]) + in.SessionFlags = be.Uint16(b[0x12:]) + in.VideoType, in.Processor = b[0x14], b[0x15] + in.MediaType = be.Uint32(b[0x16:]) + in.WindowsVer = be.Uint32(b[0x1A:]) + in.MemoryMode = b[0x1E] + in.Width, in.Height = be.Uint16(b[0x1F:]), be.Uint16(b[0x21:]) + in.Colors = be.Uint16(b[0x23:]) + in.Region = be.Uint16(b[0x26:]) + for i := range in.Language { + in.Language[i] = be.Uint16(b[0x28+2*i:]) + } + in.ConnectSpeed = b[0x30] + return in +} + +func (in Init) String() string { + p := fmt.Sprintf("platform %d", in.Platform) + switch in.Platform { + case PlatformWindows: + p = "Windows" + case PlatformMac: + p = "Macintosh" + } + s := fmt.Sprintf("%s client, version %d/%d", p, in.Version, in.SubVersion) + if in.Width != 0 { + s += fmt.Sprintf(", %dx%d", in.Width, in.Height) + } + return s +} diff --git a/internal/aol/p3/link.go b/internal/aol/p3/link.go new file mode 100644 index 0000000..cb6a580 --- /dev/null +++ b/internal/aol/p3/link.go @@ -0,0 +1,499 @@ +package p3 + +import ( + "errors" + "fmt" + "io" + "sync" + "time" +) + +// Options tune a Link; the zero value is the client's own timings. +type Options struct { + // Timeout is how long DATA may go unacknowledged before a HEARTBEAT + // asks (12 seconds), and Retries how many are asked before the link is + // given up (10). + Timeout time.Duration + Retries int + + // Window is the most DATA unacknowledged at once (16); AckEvery the + // most DATA taken in before it is acknowledged (8), and AckDelay how + // long a lone DATA waits for an answer to carry its acknowledgement + // before an ACK is sent (200ms). + Window int + AckEvery int + AckDelay time.Duration + + // InitWait is how long Serve waits for the client's INIT (30 seconds). + InitWait time.Duration + + // Logf, if set, is told of what goes wrong on the link. + Logf func(format string, args ...any) + + // Trace, if set, is given every packet: in, true for one from the + // client. + Trace func(in bool, p Packet) +} + +func (o *Options) defaults() { + if o.Timeout <= 0 { + o.Timeout = 12 * time.Second + } + if o.Retries <= 0 { + o.Retries = 10 + } + if o.Window <= 0 || o.Window > seqRing/2 { + o.Window = 16 + } + if o.AckEvery <= 0 { + o.AckEvery = 8 + } + if o.AckDelay <= 0 { + o.AckDelay = 200 * time.Millisecond + } + if o.InitWait <= 0 { + o.InitWait = 30 * time.Second + } +} + +// Errors on a link. +var ( + ErrClosed = errors.New("p3: link closed") + ErrTimeout = errors.New("p3: the client stopped acknowledging") + ErrNoInit = errors.New("p3: the client sent no INIT") + ErrTooBig = fmt.Errorf("p3: more than %d bytes of data", MaxData) +) + +// Link is the host's end of a P3 link: DATA in order in, DATA out within +// the window, acknowledged, NAKed and resent as P3 does. +type Link struct { + conn io.ReadWriteCloser + r *Reader + opt Options + + mu sync.Mutex + room *sync.Cond // the window has room, or the link is down + init Init + tx uint8 // the last DATA sent + rx uint8 // the last DATA taken in + out []sent // DATA sent, not yet acknowledged + pending int // DATA taken in, not yet acknowledged + nakked bool // a NAK is out for the gap in what came in + hbTries int // HEARTBEATs since the last acknowledgement + ackDue bool // an ACK is to go if nothing else does first + resent time.Time + ackT *time.Timer + hbT *time.Timer + + err error // why the link is down: set before done closes + + wq chan []byte // packets to write, in order + in chan []byte // DATA come in, in order + done chan struct{} // closed when the link is down + closed sync.Once +} + +type sent struct { + seq uint8 + data []byte +} + +// Serve starts the host's end of a link on conn, a connection on which an +// AOL client has begun P3: it waits for the client's INIT, acknowledges +// it, and the link is up. Close the link to close conn. +func Serve(conn io.ReadWriteCloser, opt Options) (*Link, error) { + opt.defaults() + l := &Link{ + conn: conn, r: NewReader(conn), opt: opt, + tx: SeqInit, rx: SeqInit, + wq: make(chan []byte, 256), in: make(chan []byte, 64), done: make(chan struct{}), + } + l.room = sync.NewCond(&l.mu) + type deadliner interface{ SetReadDeadline(time.Time) error } + dl, _ := conn.(deadliner) + if dl != nil { + dl.SetReadDeadline(time.Now().Add(opt.InitWait)) + } + for { + p, err := l.r.Read() + if err == ErrCRC || err == ErrLength { + continue // the client sends its INIT again + } + if err != nil { + conn.Close() + if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { + return nil, ErrNoInit + } + return nil, fmt.Errorf("%w: %v", ErrNoInit, err) + } + l.trace(true, p) + if p.Kind() == INIT { + l.init = ParseInit(p.Data) + l.rx = p.TX + break + } + } + if dl != nil { + dl.SetReadDeadline(time.Time{}) + } + go l.writer() + l.mu.Lock() + l.send(ACK, nil) + l.mu.Unlock() + go l.reader() + return l, nil +} + +// Init is what the client said of itself. +func (l *Link) Init() Init { + l.mu.Lock() + defer l.mu.Unlock() + return l.init +} + +// Read gives the next DATA packet's data from the client. +func (l *Link) Read() ([]byte, error) { + select { + case d := <-l.in: + return d, nil + case <-l.done: + select { + case d := <-l.in: + return d, nil + default: + } + return nil, l.Err() + } +} + +// Write sends data to the client in one DATA packet, waiting while the +// window is full. +func (l *Link) Write(data []byte) error { + if len(data) > MaxData { + return ErrTooBig + } + data = append([]byte(nil), data...) + l.mu.Lock() + defer l.mu.Unlock() + for !l.down() && len(l.out) >= l.opt.Window { + l.room.Wait() + } + if l.down() { + return l.err + } + l.tx = next(l.tx) + l.out = append(l.out, sent{l.tx, data}) + if len(l.out) == 1 { + l.armHeartbeat() + } + l.send(DATA, data) + return nil +} + +// WriteToken sends a token and what follows it in one DATA packet. +func (l *Link) WriteToken(token string, data []byte) error { + if len(token) != 2 { + return fmt.Errorf("p3: token %q is not two letters", token) + } + return l.Write(append([]byte(token), data...)) +} + +// Unacked is how many DATA packets the client has yet to acknowledge. +func (l *Link) Unacked() int { + l.mu.Lock() + defer l.mu.Unlock() + return len(l.out) +} + +// Close takes the link down and closes its connection, once what has been +// written has gone (or a second has passed). +func (l *Link) Close() error { + select { + case l.wq <- nil: // the writer closes when it comes to it + select { + case <-l.done: + case <-time.After(time.Second): + } + case <-l.done: + case <-time.After(time.Second): + } + l.fail(ErrClosed) + return nil +} + +// Done is closed when the link is down. +func (l *Link) Done() <-chan struct{} { return l.done } + +// Err is why the link is down, or nil. +func (l *Link) Err() error { + if l.down() { + return l.err + } + return nil +} + +func (l *Link) down() bool { + select { + case <-l.done: + return true + default: + return false + } +} + +// fail takes the link down for err, the first time. It is called without +// l.mu: a sender holding it may be waiting on the writer. +func (l *Link) fail(err error) { + first := false + l.closed.Do(func() { + first = true + l.err = err + close(l.done) + l.conn.Close() + }) + if first { + if err != ErrClosed { + l.logf("link down: %v", err) + } + l.mu.Lock() + l.stopTimers() + l.room.Broadcast() + l.mu.Unlock() + } +} + +func (l *Link) stopTimers() { + if l.ackT != nil { + l.ackT.Stop() + } + if l.hbT != nil { + l.hbT.Stop() + } +} + +func (l *Link) logf(format string, args ...any) { + if l.opt.Logf != nil { + l.opt.Logf("p3: "+format, args...) + } +} + +func (l *Link) trace(in bool, p Packet) { + if l.opt.Trace != nil { + l.opt.Trace(in, p) + } +} + +// send numbers a packet and queues it to be written; l.mu is held. Every +// packet carries the acknowledgement of what has come in. +func (l *Link) send(kind uint8, data []byte) { + l.sendSeq(l.tx, kind, data) +} + +func (l *Link) sendSeq(tx, kind uint8, data []byte) { + if l.down() { + return + } + p := Packet{TX: tx, RX: l.rx, Type: kind, Data: data} + l.pending, l.ackDue = 0, false + l.trace(false, p) + select { + case l.wq <- Append(nil, p): + case <-l.done: + } +} + +func (l *Link) writer() { + type deadliner interface{ SetWriteDeadline(time.Time) error } + dl, _ := l.conn.(deadliner) + for { + select { + case b := <-l.wq: + if b == nil { + l.fail(ErrClosed) + return + } + if dl != nil { + dl.SetWriteDeadline(time.Now().Add(l.opt.Timeout * time.Duration(l.opt.Retries))) + } + if _, err := l.conn.Write(b); err != nil { + l.fail(err) + return + } + case <-l.done: + return + } + } +} + +func (l *Link) reader() { + for { + p, err := l.r.Read() + switch { + case err == ErrCRC: + l.trace(true, p) + l.nak(NakCRC) + continue + case err == ErrLength: + l.nak(NakLength) + continue + case err != nil: + l.fail(err) + return + } + l.trace(true, p) + if d := l.take(p); d != nil { + select { + case l.in <- d: + case <-l.done: + return + } + } + } +} + +// nak asks the client to resend from the first DATA after our rx, once +// for each gap in what came in. +func (l *Link) nak(reason uint8) { + l.mu.Lock() + defer l.mu.Unlock() + if !l.nakked { + l.nakked = true + l.send(NAK, []byte{reason}) + } +} + +// take handles a packet from the client, and gives DATA's data to be +// read. +func (l *Link) take(p Packet) []byte { + l.mu.Lock() + defer l.mu.Unlock() + if p.Kind() == INIT { + // the client has started again (or missed our ACK): so do we + if len(l.out) > 0 || l.rx != p.TX { + l.logf("INIT again, %d packets unsent", len(l.out)) + } + l.init = ParseInit(p.Data) + l.tx, l.rx, l.out, l.nakked, l.hbTries = SeqInit, p.TX, nil, false, 0 + l.stopTimers() + l.room.Broadcast() + l.send(ACK, nil) + return nil + } + heartbeat := l.hbTries > 0 + l.acked(p.RX) + switch p.Kind() { + case DATA: + switch { + case p.TX == next(l.rx): + l.rx = p.TX + l.nakked = false + l.pending++ + if l.pending >= l.opt.AckEvery { + l.send(ACK, nil) + } else { + l.armAck() + } + return p.Data + case behind(p.TX, l.rx) < seqRing/2: + // one we have: our acknowledgement went astray + l.armAck() + default: + if !l.nakked { + l.nakked = true + l.send(NAK, []byte{NakSequence}) + } + } + case ACK: + if heartbeat { + l.resend(p.RX) + } + case NAK: + if len(p.Data) > 0 && p.Data[0] != NakSequence { + l.logf("NAK %d from rx %02x", p.Data[0], p.RX) + } + l.resend(p.RX) + case HEARTBEAT: + l.send(ACK, nil) + case SS: + l.send(SSR, nil) + case SSR: + l.resend(p.RX) + default: + l.logf("packet type %02x", p.Type) + } + return nil +} + +// acked takes rx as the client's acknowledgement of our DATA up to it. +func (l *Link) acked(rx uint8) { + for i, s := range l.out { + if s.seq == rx { + l.out = l.out[i+1:] + l.hbTries = 0 + if len(l.out) > 0 { + l.armHeartbeat() + } else if l.hbT != nil { + l.hbT.Stop() + } + l.room.Broadcast() + return + } + } +} + +// resend sends again all the DATA not acknowledged (go back N), but not +// twice over for one loss. +func (l *Link) resend(rx uint8) { + if len(l.out) == 0 || time.Since(l.resent) < l.opt.AckDelay { + return + } + l.resent = time.Now() + for _, s := range l.out { + l.sendSeq(s.seq, DATA, s.data) + } + l.armHeartbeat() +} + +// armAck has an ACK sent soon, unless another packet carries the +// acknowledgement first. +func (l *Link) armAck() { + if l.ackDue { + return + } + l.ackDue = true + if l.ackT == nil { + l.ackT = time.AfterFunc(l.opt.AckDelay, func() { + l.mu.Lock() + defer l.mu.Unlock() + if l.ackDue { + l.send(ACK, nil) + } + }) + } else { + l.ackT.Reset(l.opt.AckDelay) + } +} +func (l *Link) armHeartbeat() { + if l.hbT == nil { + l.hbT = time.AfterFunc(l.opt.Timeout, l.heartbeat) + } else { + l.hbT.Reset(l.opt.Timeout) + } +} + +func (l *Link) heartbeat() { + l.mu.Lock() + if l.down() || len(l.out) == 0 { + l.mu.Unlock() + return + } + if l.hbTries >= l.opt.Retries { + l.mu.Unlock() + l.fail(ErrTimeout) + return + } + l.hbTries++ + l.send(HEARTBEAT, nil) + l.hbT.Reset(l.opt.Timeout) + l.mu.Unlock() +} diff --git a/internal/aol/p3/p3.go b/internal/aol/p3/p3.go new file mode 100644 index 0000000..ef31389 --- /dev/null +++ b/internal/aol/p3/p3.go @@ -0,0 +1,257 @@ +// Package p3 is P3, the link layer under the classic AOL client (3.0, 4.0 +// and on): the packets that carry its tokens and atom streams to the host, +// over a modem or inside TCP on port 5190, numbered, checked and +// acknowledged. +// +// A packet is +// +// 5A crc(2) length(2) tx rx type data... 0D +// +// the CRC a CRC-16/ARC of everything from the length to the last data byte, +// the length that of tx, rx, type and data. DATA packets are numbered by +// tx from 0x10 to 0x7F and round again, and each side's rx acknowledges +// every packet up to the one it names; the rest (ACK, NAK, HEARTBEAT, +// INIT, SS, SSR) repeat the last DATA number. A sender has at most 16 +// packets unacknowledged; a receiver acknowledges at least every 8th; 12 +// seconds without one and the sender asks with a HEARTBEAT, up to 10 times. +// The client sets the top bit of the type (A0, A3, A4...), so a packet +// echoed back by a line is told from the host's; the host sends types bare. +// +// The client opens with INIT (its version, its machine) at 7F/7F, and the +// link is up when the host acknowledges it. AOL 4.0 over TCP stops +// computing CRCs after that and sends "**" in their place. +// +// Reader and Append read and write packets; Link is the host's end of a +// link, which Serve starts on a connection. +// +// Sources: Deceptio's P3 pages (deceptio.org/re/p3), written with the +// help of P3's author; the FDO91 manual's chapter 27; and what Dialtone +// and others have learned serving live clients. +package p3 + +import ( + "bufio" + "errors" + "fmt" + "io" +) + +// Sync and End begin and end every packet. +const ( + Sync = 0x5A + End = 0x0D +) + +// The packet types. +const ( + DATA = 0x20 + SS = 0x21 // asks for an SSR + SSR = 0x22 // answers an SS: resend what follows my rx + INIT = 0x23 // the client's first packet + ACK = 0x24 + NAK = 0x25 // data: why (NakCRC, NakSequence, NakLength) + HEARTBEAT = 0x26 // asks for an ACK + + // FromClient is set in the type of every packet the client sends. + FromClient = 0x80 +) + +// A NAK's reason, its one byte of data. +const ( + NakCRC = 1 + NakSequence = 2 + NakLength = 3 +) + +// Sequence numbers. +const ( + SeqMin = 0x10 + SeqMax = 0x7F + SeqInit = 0x7F // both sides' tx and rx before any DATA + seqRing = SeqMax - SeqMin + 1 +) + +// Sizes. +const ( + // MaxLength is the largest length a packet may have (1,024 bytes in + // all); MaxData is the most data in one packet. + MaxLength = 0x3FA + MaxData = MaxLength - 3 + + // MaxClientData is the most the client puts in one packet. + MaxClientData = 0x77 + + headerSize = 8 +) + +// noCRC is what AOL 4.0 over TCP sends for a CRC. +const noCRC = 0x2A2A + +// Packet is a P3 packet. +type Packet struct { + TX, RX uint8 + Type uint8 // as sent: the client's have FromClient set + Data []byte + NoCRC bool // read: its CRC was "**", not checked +} + +// Kind is p's type without FromClient. +func (p Packet) Kind() uint8 { return p.Type &^ FromClient } + +// FromClient is whether the client sent p. +func (p Packet) FromClient() bool { return p.Type&FromClient != 0 } + +func (p Packet) String() string { + name, ok := typeNames[p.Kind()] + if !ok { + name = fmt.Sprintf("type %02x", p.Type) + } + s := fmt.Sprintf("%s tx=%02x rx=%02x", name, p.TX, p.RX) + if p.Kind() == DATA && len(p.Data) >= 2 { + s += fmt.Sprintf(" %q", p.Data[:2]) + } + if len(p.Data) > 0 { + s += fmt.Sprintf(" (%d bytes)", len(p.Data)) + } + return s +} + +var typeNames = map[uint8]string{ + DATA: "DATA", SS: "SS", SSR: "SSR", INIT: "INIT", ACK: "ACK", NAK: "NAK", HEARTBEAT: "HEARTBEAT", +} + +// CRC is P3's CRC: CRC-16/ARC (reflected 0x8005, from zero). +func CRC(b []byte) uint16 { + var c uint16 + for _, x := range b { + c = c>>8 ^ crcTable[byte(c)^x] + } + return c +} + +var crcTable = func() (t [256]uint16) { + for i := range t { + c := uint16(i) + for range 8 { + if c&1 != 0 { + c = c>>1 ^ 0xA001 + } else { + c >>= 1 + } + } + t[i] = c + } + return +}() + +// Append appends p as bytes to b, with its length and CRC. It panics on +// more than MaxData of data. +func Append(b []byte, p Packet) []byte { + if len(p.Data) > MaxData { + panic(fmt.Sprintf("p3: %d bytes of data in one packet", len(p.Data))) + } + n := len(p.Data) + 3 + start := len(b) + b = append(b, Sync, 0, 0, byte(n>>8), byte(n), p.TX, p.RX, p.Type) + b = append(b, p.Data...) + c := CRC(b[start+3:]) + b[start+1], b[start+2] = byte(c>>8), byte(c) + return append(b, End) +} + +// Errors reading packets. A packet with ErrCRC or ErrLength is to be +// NAKed; the Reader has passed over it and goes on with the next. +var ( + ErrCRC = errors.New("p3: bad CRC") + ErrLength = errors.New("p3: bad length") +) + +// Reader reads packets. +type Reader struct { + r *bufio.Reader + Skipped int // bytes passed over looking for a packet +} + +// NewReader reads packets from r. +func NewReader(r io.Reader) *Reader { + br, ok := r.(*bufio.Reader) + if !ok || br.Size() < MaxLength+6 { + br = bufio.NewReaderSize(r, 4096) + } + return &Reader{r: br} +} + +// Read reads the next packet. Bytes before a Sync are passed over; a +// packet whose CRC is wrong is ErrCRC, one too long or short ErrLength. +// A packet without its End is taken as it is. +func (r *Reader) Read() (Packet, error) { + for { + c, err := r.r.ReadByte() + if err != nil { + return Packet{}, err + } + if c == Sync { + break + } + r.Skipped++ + } + h, err := r.r.Peek(4) + if err != nil { + return Packet{}, unexpected(err) + } + n := int(h[2])<<8 | int(h[3]) + if n < 3 || n > MaxLength { + // line noise, most likely: look for the next Sync from here + return Packet{}, ErrLength + } + b, err := r.r.Peek(4 + n) + if err != nil { + return Packet{}, unexpected(err) + } + crc := uint16(b[0])<<8 | uint16(b[1]) + p := Packet{TX: b[4], RX: b[5], Type: b[6], NoCRC: crc == noCRC} + ok := p.NoCRC || CRC(b[2:]) == crc + p.Data = append([]byte(nil), b[7:]...) + r.r.Discard(4 + n) + if e, err := r.r.Peek(1); err == nil && e[0] == End { + r.r.Discard(1) + } + if !ok { + return p, ErrCRC + } + return p, nil +} + +func unexpected(err error) error { + if err == io.EOF { + return io.ErrUnexpectedEOF + } + return err +} + +// Sniff is whether b begins as a P3 client's first packet, an INIT. +func Sniff(b []byte) bool { + return len(b) >= headerSize && b[0] == Sync && b[7]&^FromClient == INIT +} + +// Token splits a DATA packet's data into its token (two letters, "Dd", +// "Aa"...) and what follows it. +func Token(data []byte) (string, []byte) { + if len(data) < 2 { + return "", data + } + return string(data[:2]), data[2:] +} + +// next is the sequence number after s. +func next(s uint8) uint8 { + if s >= SeqMax || s < SeqMin { + return SeqMin + } + return s + 1 +} + +// behind is how far s is behind t, round the ring: 0 if s is t. +func behind(s, t uint8) int { + return ((int(t)-int(s))%seqRing + seqRing) % seqRing +} diff --git a/internal/aol/p3/p3_test.go b/internal/aol/p3/p3_test.go new file mode 100644 index 0000000..22f6ded --- /dev/null +++ b/internal/aol/p3/p3_test.go @@ -0,0 +1,502 @@ +package p3 + +import ( + "bufio" + "bytes" + "encoding/hex" + "errors" + "fmt" + "io" + "net" + "strings" + "testing" + "time" +) + +func unhex(s string) []byte { + b, err := hex.DecodeString(strings.ReplaceAll(s, " ", "")) + if err != nil { + panic(err) + } + return b +} + +// Packets a host sends live clients (as Dialtone, which serves them, has +// them): the ACK of the client's INIT and the SD that follows it; and a +// sign-off (XS) with AOL 4.0's "**" for a CRC. +var ( + initACK = unhex("5ab71100037f7f240d") + sdData = unhex("5a88e9000b107f20534454d1f68b00000d") + xsBye = unhex("5a2a2a000d7f7f20585347 6f6f64627965210d") +) + +func TestPackets(t *testing.T) { + for _, c := range []struct { + raw []byte + p Packet + }{ + {initACK, Packet{TX: 0x7F, RX: 0x7F, Type: ACK}}, + {sdData, Packet{TX: 0x10, RX: 0x7F, Type: DATA, Data: unhex("5344 54d1f68b0000")}}, + } { + if got := Append(nil, c.p); !bytes.Equal(got, c.raw) { + t.Errorf("Append(%v) = %x, want %x", c.p, got, c.raw) + } + p, err := NewReader(bytes.NewReader(c.raw)).Read() + if err != nil || p.TX != c.p.TX || p.RX != c.p.RX || p.Type != c.p.Type || !bytes.Equal(p.Data, c.p.Data) || p.NoCRC { + t.Errorf("Read(%x) = %v, %v", c.raw, p, err) + } + } + p, err := NewReader(bytes.NewReader(xsBye)).Read() + if tok, rest := Token(p.Data); err != nil || !p.NoCRC || tok != "XS" || string(rest) != "Goodbye!" { + t.Errorf("Read(**) = %v, %v", p, err) + } + if CRC([]byte("123456789")) != 0xBB3D { // CRC-16/ARC's check value + t.Error("CRC") + } +} + +func TestReader(t *testing.T) { + bad := append([]byte(nil), sdData...) + bad[len(bad)-2] ^= 1 + noEnd := initACK[:len(initACK)-1] + var in []byte + in = append(in, "ATDT\r"...) // what isn't P3 is passed over + in = append(in, initACK...) + in = append(in, bad...) + in = append(in, 0x5A, 0x00, 0x00, 0xFF, 0xFF) // a length too long + in = append(in, noEnd...) + in = append(in, sdData...) + in = append(in, Append(nil, Packet{TX: 0x11, RX: 0x7F, Type: DATA, Data: bytes.Repeat([]byte{End}, 30)})...) + r := NewReader(bytes.NewReader(in)) + var got []string + for { + p, err := r.Read() + if err == io.EOF { + break + } + switch err { + case nil: + got = append(got, fmt.Sprintf("%02x/%d", p.Type, len(p.Data))) + case ErrCRC, ErrLength: + got = append(got, err.Error()) + default: + t.Fatal(err) + } + } + want := "24/0 p3: bad CRC p3: bad length 24/0 20/8 20/30" + if g := strings.Join(got, " "); g != want { + t.Errorf("got %s\nwant %s", g, want) + } + if r.Skipped != 5+4 { + t.Errorf("skipped %d", r.Skipped) + } +} + +func TestSeq(t *testing.T) { + if next(0x7F) != 0x10 || next(0x10) != 0x11 || next(0) != 0x10 { + t.Error("next") + } + if behind(0x7F, 0x10) != 1 || behind(0x10, 0x7F) != seqRing-1 || behind(0x20, 0x20) != 0 { + t.Error("behind") + } +} + +// initData is an INIT as the 32-bit Windows client lays it out. +func initData() []byte { + d := make([]byte, 0x34) + d[0], d[1], d[2] = PlatformWindows, 3, 0 + d[0x1F], d[0x20], d[0x21], d[0x22] = 0x03, 0x20, 0x02, 0x58 // 800x600 + d[0x30] = 5 + return d +} + +func TestInit(t *testing.T) { + in := ParseInit(initData()) + if in.Platform != PlatformWindows || in.Width != 800 || in.Height != 600 || in.ConnectSpeed != 5 { + t.Errorf("%+v", in) + } + if s := in.String(); s != "Windows client, version 3/0, 800x600" { + t.Error(s) + } + if in := ParseInit([]byte{PlatformMac, 2}); in.Platform != PlatformMac || in.Version != 2 { + t.Errorf("short: %+v", in) + } + if !Sniff(Append(nil, Packet{TX: 0x7F, RX: 0x7F, Type: INIT | FromClient, Data: initData()})) || Sniff(sdData) || Sniff([]byte("*\x01")) { + t.Error("Sniff") + } +} + +// client is the client's end of a link, scripted by a test. +type client struct { + t *testing.T + c net.Conn + pkts chan Packet + errs chan error +} + +func dial(t *testing.T, opt Options) (*client, *Link) { + t.Helper() + a, b := net.Pipe() + c := &client{t: t, c: a, pkts: make(chan Packet, 1024), errs: make(chan error, 64)} + go func() { + r := NewReader(bufio.NewReader(a)) + for { + p, err := r.Read() + if err == ErrCRC || err == ErrLength { + c.errs <- err + continue + } + if err != nil { + close(c.pkts) + return + } + c.pkts <- p + } + }() + var l *Link + done := make(chan error) + go func() { + var err error + l, err = Serve(b, opt) + done <- err + }() + c.send(Packet{TX: SeqInit, RX: SeqInit, Type: INIT, Data: initData()}) + if err := <-done; err != nil { + t.Fatal(err) + } + if p := c.expect(ACK); p.TX != 0x7F || p.RX != 0x7F { + t.Fatalf("INIT answered with %v", p) + } + t.Cleanup(func() { l.Close(); a.Close() }) + return c, l +} + +func (c *client) send(p Packet) { + p.Type |= FromClient + if _, err := c.c.Write(Append(nil, p)); err != nil { + c.t.Fatal(err) + } +} + +func (c *client) next() (Packet, bool) { + select { + case p, ok := <-c.pkts: + return p, ok + case <-time.After(2 * time.Second): + c.t.Fatal("nothing from the host") + return Packet{}, false + } +} + +func (c *client) expect(kind uint8) Packet { + c.t.Helper() + p, ok := c.next() + if !ok { + c.t.Fatalf("link closed, wanted %02x", kind) + } + if p.Type != kind { + c.t.Fatalf("got %v, wanted %02x", p, kind) + } + return p +} + +func (c *client) quiet(d time.Duration) { + c.t.Helper() + select { + case p := <-c.pkts: + c.t.Fatalf("unexpected %v", p) + case <-time.After(d): + } +} + +func read(t *testing.T, l *Link) []byte { + t.Helper() + got := make(chan []byte, 1) + go func() { + d, err := l.Read() + if err != nil { + t.Error(err) + } + got <- d + }() + select { + case d := <-got: + return d + case <-time.After(2 * time.Second): + t.Fatal("nothing read") + return nil + } +} + +func TestHandshake(t *testing.T) { + a, b := net.Pipe() + defer a.Close() + go a.Write(Append(nil, Packet{TX: SeqInit, RX: SeqInit, Type: INIT | FromClient, Data: initData()})) + got := make(chan []byte) + go func() { + buf := make([]byte, 64) + n, _ := a.Read(buf) + got <- buf[:n] + }() + l, err := Serve(b, Options{}) + if err != nil { + t.Fatal(err) + } + defer l.Close() + if g := <-got; !bytes.Equal(g, initACK) { + t.Errorf("INIT answered with %x, want %x", g, initACK) + } + if in := l.Init(); in.Width != 800 { + t.Errorf("Init: %+v", in) + } + + // no INIT: Serve gives up + a2, b2 := net.Pipe() + go func() { a2.Write([]byte("hello\r")); a2.Close() }() + if _, err := Serve(b2, Options{InitWait: time.Second}); !errors.Is(err, ErrNoInit) { + t.Errorf("no INIT: %v", err) + } +} + +func TestData(t *testing.T) { + c, l := dial(t, Options{AckDelay: 20 * time.Millisecond}) + + // the client's DATA is read, and acknowledged soon after + c.send(Packet{TX: 0x10, RX: 0x7F, Type: DATA, Data: []byte("Dd\x00\x15")}) + if d := read(t, l); string(d) != "Dd\x00\x15" { + t.Errorf("read %q", d) + } + if p := c.expect(ACK); p.RX != 0x10 || p.TX != 0x7F { + t.Errorf("ACK %v", p) + } + + // the host's DATA carries the acknowledgement: no ACK as well + c.send(Packet{TX: 0x11, RX: 0x7F, Type: DATA, Data: []byte("ya")}) + read(t, l) + if err := l.WriteToken("SD", nil); err != nil { + t.Fatal(err) + } + if p := c.expect(DATA); p.TX != 0x10 || p.RX != 0x11 || string(p.Data) != "SD" { + t.Errorf("DATA %v", p) + } + c.quiet(60 * time.Millisecond) + if l.Unacked() != 1 { + t.Errorf("unacked %d", l.Unacked()) + } + c.send(Packet{TX: 0x11, RX: 0x10, Type: ACK}) + time.Sleep(20 * time.Millisecond) + if l.Unacked() != 0 { + t.Errorf("unacked %d after ACK", l.Unacked()) + } + + // a DATA again (our ACK lost): acknowledged, not read twice + c.send(Packet{TX: 0x11, RX: 0x10, Type: DATA, Data: []byte("ya")}) + if p := c.expect(ACK); p.RX != 0x11 { + t.Errorf("ACK %v", p) + } + + // one missing: NAKed once, then taken when it comes + c.send(Packet{TX: 0x13, RX: 0x10, Type: DATA, Data: []byte("x3")}) + c.send(Packet{TX: 0x14, RX: 0x10, Type: DATA, Data: []byte("x4")}) + if p := c.expect(NAK); p.RX != 0x11 || !bytes.Equal(p.Data, []byte{NakSequence}) { + t.Errorf("NAK %v", p) + } + c.quiet(60 * time.Millisecond) + for i := uint8(0x12); i <= 0x14; i++ { + c.send(Packet{TX: i, RX: 0x10, Type: DATA, Data: []byte{'x', '0' + i - 0x10}}) + } + for _, w := range []string{"x2", "x3", "x4"} { + if d := read(t, l); string(d) != w { + t.Errorf("read %q, want %q", d, w) + } + } + if p := c.expect(ACK); p.RX != 0x14 { + t.Errorf("ACK %v", p) + } + + // a bad CRC: NAKed + b := Append(nil, Packet{TX: 0x15, RX: 0x10, Type: DATA | FromClient, Data: []byte("zz")}) + b[1] ^= 0xFF + c.c.Write(b) + if p := c.expect(NAK); p.RX != 0x14 || !bytes.Equal(p.Data, []byte{NakCRC}) { + t.Errorf("NAK %v", p) + } + + // a HEARTBEAT: ACKed at once + c.send(Packet{TX: 0x14, RX: 0x10, Type: HEARTBEAT}) + if p := c.expect(ACK); p.RX != 0x14 { + t.Errorf("ACK %v", p) + } + + // AOL 4.0's "**" CRC + b = Append(nil, Packet{TX: 0x15, RX: 0x10, Type: DATA | FromClient, Data: []byte("pE")}) + b[1], b[2] = '*', '*' + c.c.Write(b) + if d := read(t, l); string(d) != "pE" { + t.Errorf("read %q", d) + } +} + +func TestAckEvery(t *testing.T) { + c, l := dial(t, Options{AckDelay: time.Hour}) + seq := uint8(SeqInit) + for i := range 8 { + seq = next(seq) + c.send(Packet{TX: seq, RX: SeqInit, Type: DATA, Data: []byte{'a', byte(i)}}) + read(t, l) + } + if p := c.expect(ACK); p.RX != seq { + t.Errorf("ACK %v", p) + } +} + +func TestWindow(t *testing.T) { + c, l := dial(t, Options{}) + wrote := make(chan int, 32) + go func() { + for i := range 20 { + if err := l.Write([]byte{'w', byte(i)}); err != nil { + t.Error(err) + return + } + wrote <- i + } + }() + var last Packet + for range 16 { + last = c.expect(DATA) + } + c.quiet(50 * time.Millisecond) + if len(wrote) != 16 || last.TX != 0x1F { + t.Fatalf("%d written, last %v", len(wrote), last) + } + // acknowledging 3 lets 3 more go + c.send(Packet{TX: SeqInit, RX: 0x12, Type: ACK}) + for i := range 3 { + if p := c.expect(DATA); p.TX != uint8(0x20+i) { + t.Errorf("DATA %v", p) + } + } + c.quiet(50 * time.Millisecond) + + // a NAK has all the unacknowledged sent again, from after its rx + c.send(Packet{TX: SeqInit, RX: 0x15, Type: NAK, Data: []byte{NakSequence}}) + for i := 0x16; i <= 0x22; i++ { + if p := c.expect(DATA); p.TX != uint8(i) || p.Data[1] != byte(i-0x10) { + t.Fatalf("resent %v, want tx %02x", p, i) + } + } + c.send(Packet{TX: SeqInit, RX: 0x22, Type: ACK}) + if p := c.expect(DATA); p.TX != 0x23 { + t.Errorf("DATA %v", p) + } +} + +func TestWrap(t *testing.T) { + c, l := dial(t, Options{AckDelay: time.Millisecond}) + const n = 300 + go func() { + for i := range n { + if err := l.Write([]byte(fmt.Sprint(i))); err != nil { + t.Error(err) + return + } + } + }() + seq, rx := uint8(SeqInit), uint8(SeqInit) + for i := 0; i < n; { + p, _ := c.next() + if p.Type != DATA { + continue // its ACKs of ours + } + if p.TX != next(rx) || string(p.Data) != fmt.Sprint(i) { + t.Fatalf("%d: %v %q", i, p, p.Data) + } + rx = p.TX + i++ + // and the client talks back, acknowledging as it goes + seq = next(seq) + c.send(Packet{TX: seq, RX: rx, Type: DATA, Data: []byte(fmt.Sprint(i))}) + if d := read(t, l); string(d) != fmt.Sprint(i) { + t.Fatalf("read %q", d) + } + } +} + +func TestHeartbeat(t *testing.T) { + c, l := dial(t, Options{Timeout: 30 * time.Millisecond, Retries: 3}) + l.Write([]byte("aa")) + l.Write([]byte("ab")) + c.expect(DATA) + c.expect(DATA) + // no acknowledgement: HEARTBEATs, and the client's ACK of only the + // first has the second sent again + if p := c.expect(HEARTBEAT); p.TX != 0x11 { + t.Errorf("HEARTBEAT %v", p) + } + c.send(Packet{TX: SeqInit, RX: 0x10, Type: ACK}) + if p := c.expect(DATA); p.TX != 0x11 || string(p.Data) != "ab" { + t.Errorf("resent %v", p) + } + // then silence: three HEARTBEATs and the link is down + for range 3 { + c.expect(HEARTBEAT) + } + select { + case <-l.Done(): + case <-time.After(time.Second): + t.Fatal("link still up") + } + if l.Err() != ErrTimeout { + t.Errorf("Err %v", l.Err()) + } + if err := l.Write([]byte("x")); err != ErrTimeout { + t.Errorf("Write after: %v", err) + } + if _, err := l.Read(); err != ErrTimeout { + t.Errorf("Read after: %v", err) + } +} + +func TestReinit(t *testing.T) { + c, l := dial(t, Options{}) + l.Write([]byte("aa")) + c.expect(DATA) + // the client starts over: so does the host + c.send(Packet{TX: SeqInit, RX: SeqInit, Type: INIT, Data: initData()}) + if p := c.expect(ACK); p.TX != SeqInit || p.RX != SeqInit { + t.Errorf("ACK %v", p) + } + l.Write([]byte("ab")) + if p := c.expect(DATA); p.TX != 0x10 { + t.Errorf("DATA %v", p) + } +} + +func TestClose(t *testing.T) { + c, l := dial(t, Options{}) + c.c.Close() + select { + case <-l.Done(): + case <-time.After(time.Second): + t.Fatal("link still up") + } + if _, err := l.Read(); err == nil { + t.Error("Read after close") + } + if err := l.Write(make([]byte, MaxData+1)); err != ErrTooBig { + t.Error(err) + } +} + +func TestCloseSends(t *testing.T) { + c, l := dial(t, Options{}) + l.WriteToken("XS", []byte("Goodbye!")) + l.Close() + if p := c.expect(DATA); string(p.Data) != "XSGoodbye!" { + t.Errorf("DATA %v", p) + } + if _, ok := c.next(); ok { + t.Error("not closed") + } +} diff --git a/internal/bbs/bbs.go b/internal/bbs/bbs.go index 57ae18e..eae4ce9 100644 --- a/internal/bbs/bbs.go +++ b/internal/bbs/bbs.go @@ -184,17 +184,19 @@ type BBS struct { // sysopAway: the sysop is not to be paged (pages leave a message) sysopAway atomic.Bool - mu sync.Mutex - nodes map[int]*Node - failures map[string][]time.Time - hubOnce sync.Once - chat *hub - relay Relay // a chat network's rooms (MRC) - geoMu sync.Mutex - geo *geoip.File - presMu sync.Mutex - presence map[int]func(name string, online bool) // WatchPresence's - presNext int + mu sync.Mutex + nodes map[int]*Node + failures map[string][]time.Time + hubOnce sync.Once + chat *hub + relay Relay // a chat network's rooms (MRC) + geoMu sync.Mutex + geo *geoip.File + presMu sync.Mutex + presence map[int]func(name string, online bool) // WatchPresence's + presNext int + friendFns map[int]func(user int64) // WatchFriends' + friendNext int } // New makes the BBS of the settings and store. @@ -622,6 +624,7 @@ func (b *BBS) menuLogin(who, name, pw string) (*store.User, error) { b.Log.Printf("%s: %s's password by modemmenu (%s)", who, u.Name, backend) b.Store.KeepOSCARKeys(u.ID, pw) // for AIM's digest logins, if kept b.Store.KeepCISKey(u.ID, pw) // and CompuServe's + b.Store.KeepMSNKey(u.ID, pw) // and MSN's return u, nil } @@ -674,6 +677,7 @@ func (n *Node) loggedIn(u *store.User, how string) (*store.User, error) { return nil, err } n.SetUser(u) + n.DeliverKept() n.startClock(u) if err := n.b.Store.AddCall(&store.Call{UserID: u.ID, Name: u.Name, Location: u.Location, Via: n.Caller.Via, Node: n.Num}); err != nil { diff --git a/internal/bbs/chat.go b/internal/bbs/chat.go index 4294b81..4240f59 100644 --- a/internal/bbs/chat.go +++ b/internal/bbs/chat.go @@ -35,6 +35,7 @@ type Event struct { Node int Text string Time time.Time + Kept bool // a private message kept while its caller was away // the CB handle the sender goes by ("": none; From is still the // user's name, for those that do not show handles) Handle string @@ -52,6 +53,9 @@ func (e Event) String() string { case Left: return "<- " + e.From + " left" case Private: + if e.Kept { + return fmt.Sprintf("Message from %s (%s, while you were away): %s", e.From, e.Time.Format("Jan 2 15:04"), e.Text) + } return fmt.Sprintf("Message from %s (node %d): %s", e.From, e.Node, e.Text) case Mail: return "New mail from " + e.From + ": " + e.Text @@ -524,6 +528,9 @@ func (n *Node) Message(to int, text string) error { if o == nil || o.User() == nil || o == n { return ErrNoNode } + if from := n.User(); from != nil && n.b.Blocks(o.User(), from) { + return ErrBlocked + } if n.flood() { return ErrFlood } diff --git a/internal/bbs/chatcmd.go b/internal/bbs/chatcmd.go index b7332eb..edfb622 100644 --- a/internal/bbs/chatcmd.go +++ b/internal/bbs/chatcmd.go @@ -12,7 +12,10 @@ var ChatHelp = []string{ "Type to talk. Commands:", " /who who is in this room /rooms the rooms in use", " /join ROOM go to another room /me ACTION * you do something", - " /msg NODE TEXT a message to one node /topic this room's topic", + " /msg WHO TEXT to a user, kept if away /topic this room's topic", + " /history [WHO] your talks with a user /friends your friends list", + " /friend WHO put one on your list /unfriend WHO take one off it", + " /block WHO stop their messages /unblock WHO let them again", " /quit leave the chat", "Sysops: /pages callers paging /answer [NODE] answer one /busy pages on or off", " /topic TEXT set a permanent room's topic", @@ -87,16 +90,100 @@ func (n *Node) ChatCommand(line string) (out []string, leave bool, err error) { out = append(out, e.String()) } return append(out, "You are in "+n.Room()+"."), false, nil - case "msg", "m": + case "msg", "m", "tell": to, text, _ := strings.Cut(arg, " ") - num, err := strconv.Atoi(to) - if err != nil { - return nil, false, fmt.Errorf("/msg NODE TEXT: a node's number first") + if to == "" { + return nil, false, fmt.Errorf("/msg WHO TEXT: a user's name (or a node's number), then the message") } - if err := n.Message(num, text); err != nil { + if num, err := strconv.Atoi(to); err == nil { + if err := n.Message(num, text); err != nil { + return nil, false, err + } + if o := n.b.node(num); o != nil { + n.Keep(o.User(), text, true) + } + return []string{fmt.Sprintf("Sent to node %d.", num)}, false, nil + } + u, err := n.b.Store.UserByName(to) + if err != nil { + return nil, false, ErrNoUser + } + online, err := n.TellUser(u, text) + if err != nil { return nil, false, err } - return []string{fmt.Sprintf("Sent to node %d.", num)}, false, nil + if !online { + return []string{u.Name + " is away; they will have it when they next log in."}, false, nil + } + return []string{"Sent to " + u.Name + "."}, false, nil + case "history": + if arg == "" { + ps, err := n.Conversations() + if err != nil { + return nil, false, err + } + if len(ps) == 0 { + return []string{"You have no conversations yet (/msg WHO TEXT starts one)."}, false, nil + } + out = append(out, "Your conversations (/history WHO to read one):") + for _, p := range ps { + out = append(out, fmt.Sprintf(" %-20s %d lines, the last %s", p.Name, p.Lines, p.Last.Format("Jan 2 15:04"))) + } + return out, false, nil + } + u, err := n.b.Store.UserByName(arg) + if err != nil { + return nil, false, ErrNoUser + } + cs, err := n.History(u, 50) + if err != nil { + return nil, false, err + } + if len(cs) == 0 { + return []string{"You and " + u.Name + " have not talked yet."}, false, nil + } + return HistoryLines(cs), false, nil + case "friends": + u := n.User() + if u == nil { + return nil, false, ErrNoUser + } + lines, err := n.b.FriendLines(u) + return lines, false, err + case "friend", "unfriend": + u := n.User() + if u == nil || arg == "" { + return nil, false, fmt.Errorf("/%s WHO: a user's name", strings.ToLower(cmd)) + } + if strings.ToLower(cmd) == "friend" { + f, err := n.b.AddFriend(u, arg) + if err != nil { + return nil, false, err + } + return []string{f.Name + " is on your friends list."}, false, nil + } + f, err := n.b.RemoveFriend(u, arg) + if err != nil { + return nil, false, err + } + return []string{f.Name + " is off your friends list."}, false, nil + case "block", "unblock": + u := n.User() + if u == nil || arg == "" { + return nil, false, fmt.Errorf("/%s WHO: a user's name", strings.ToLower(cmd)) + } + if strings.ToLower(cmd) == "block" { + f, err := n.b.Block(u, arg) + if err != nil { + return nil, false, err + } + return []string{f.Name + " is blocked: you will not get their messages."}, false, nil + } + f, err := n.b.Unblock(u, arg) + if err != nil { + return nil, false, err + } + return []string{f.Name + " is no longer blocked."}, false, nil case "pages": ps := n.b.Pages() if len(ps) == 0 { diff --git a/internal/bbs/private.go b/internal/bbs/private.go new file mode 100644 index 0000000..fc52b11 --- /dev/null +++ b/internal/bbs/private.go @@ -0,0 +1,319 @@ +package bbs + +import ( + "errors" + "strings" + + "github.com/D-Modem/bbs/internal/store" +) + +// Private messages between users are kept, whatever way they come (IRC, +// AIM, ICQ, the BBS's chat): one away gets them on their next login, and +// either may read their conversation back. + +// historyLines are the lines of a conversation History gives at most. +const historyLines = 500 + +// ErrNoUser: there is no user of that name. +var ErrNoUser = errors.New("there is no user of that name") + +// ErrBlocked: the user blocks the sender. +var ErrBlocked = errors.New("that user is not taking your messages") + +// Keep keeps a private line from the node's user to another (delivered: +// they had it, on some node). +func (n *Node) Keep(to *store.User, text string, delivered bool) { + from := n.User() + text = Clean(text, MaxChatLine) + if from == nil || to == nil || text == "" { + return + } + if _, err := n.b.Store.AddChat(&store.Chat{FromID: from.ID, From: from.Name, ToID: to.ID, To: to.Name, + Text: text, Delivered: delivered}); err != nil { + n.b.Log.Printf("node %d: keeping a message: %v", n.Num, err) + } +} + +// nodesOfUser are the nodes a user is on. +func (b *BBS) nodesOfUser(id int64) []*Node { + b.mu.Lock() + defer b.mu.Unlock() + var out []*Node + for _, o := range b.nodes { + if o.user != nil && o.user.ID == id { + out = append(out, o) + } + } + return out +} + +// TellUser sends a private line to a user: to each node they are on +// (besides this one), or, if they are on none, kept for them. Online: it +// went to them now. +func (n *Node) TellUser(to *store.User, text string) (online bool, err error) { + text = Clean(text, MaxChatLine) + if text == "" { + return false, errors.New("say something") + } + if from := n.User(); from != nil && n.b.Blocks(to, from) { + return false, ErrBlocked + } + sent := false + var lastErr error + others := n.b.nodesOfUser(to.ID) + for _, o := range others { + if o == n { + continue + } + if err := n.Message(o.Num, text); err != nil { + lastErr = err + } else { + sent = true + } + } + if !sent && lastErr != nil { + return false, lastErr + } + if len(others) == 0 { + if n.flood() { + return false, ErrFlood + } + } + n.Keep(to, text, len(others) > 0) + return len(others) > 0, nil +} + +// Kept takes the private lines kept for the node's user while they were +// away, as events, and marks them had. +func (n *Node) Kept() []Event { + u := n.User() + if u == nil { + return nil + } + cs, err := n.b.Store.KeptChats(u.ID) + if err != nil { + n.b.Log.Printf("node %d: kept messages: %v", n.Num, err) + return nil + } + if len(cs) == 0 { + return nil + } + ids := make([]int64, len(cs)) + out := make([]Event, len(cs)) + for i, c := range cs { + ids[i] = c.ID + out[i] = Event{Kind: Private, From: c.From, Text: c.Text, Time: c.Sent, Kept: true} + } + if err := n.b.Store.ChatsDelivered(ids); err != nil { + n.b.Log.Printf("node %d: kept messages: %v", n.Num, err) + } + return out +} + +// DeliverKept gives the node the private lines kept for its user, as its +// events. +func (n *Node) DeliverKept() { + for _, e := range n.Kept() { + n.deliver(e) + } +} + +// History is the node's user's conversation with another user, oldest +// first (at most limit lines; 0: as many as History gives). +func (n *Node) History(with *store.User, limit int) ([]store.Chat, error) { + u := n.User() + if u == nil { + return nil, ErrNoUser + } + if limit <= 0 || limit > historyLines { + limit = historyLines + } + return n.b.Store.ChatsBetween(u.ID, with.ID, limit) +} + +// Conversations are those the node's user has talked with, the latest +// first. +func (n *Node) Conversations() ([]store.ChatPartner, error) { + u := n.User() + if u == nil { + return nil, ErrNoUser + } + return n.b.Store.ChatPartners(u.ID, 50) +} + +// HistoryLines is a conversation as lines to show. +func HistoryLines(cs []store.Chat) []string { + out := make([]string, 0, len(cs)) + day := "" + for _, c := range cs { + if d := c.Sent.Format("Monday, January 2, 2006"); d != day { + day = d + out = append(out, "-- "+d+" --") + } + out = append(out, c.Sent.Format("15:04")+" <"+c.From+"> "+c.Text) + } + return out +} + +// Friends is a user's friends list. +func (b *BBS) Friends(u *store.User) ([]store.Friend, error) { return b.Store.Friends(u.ID) } + +// AddFriend puts the user of that name on u's friends list; that user. +func (b *BBS) AddFriend(u *store.User, name string) (*store.User, error) { + f, err := b.Store.UserByName(strings.TrimSpace(name)) + if err != nil { + if errors.Is(err, store.ErrNotFound) { + return nil, ErrNoUser + } + return nil, err + } + if f.ID == u.ID { + return nil, errors.New("you are always your own friend") + } + if ok, err := b.Store.IsFriend(u.ID, f.ID); err != nil { + return nil, err + } else if ok { + return f, nil + } + if err := b.Store.PutFriend(u.ID, store.Friend{ID: f.ID}); err != nil { + return nil, err + } + b.FriendsChanged(u.ID) + return f, nil +} + +// RemoveFriend takes the user of that name off u's friends list; that +// user. +func (b *BBS) RemoveFriend(u *store.User, name string) (*store.User, error) { + f, err := b.Store.UserByName(strings.TrimSpace(name)) + if err != nil { + if errors.Is(err, store.ErrNotFound) { + return nil, ErrNoUser + } + return nil, err + } + if ok, err := b.Store.IsFriend(u.ID, f.ID); err != nil { + return nil, err + } else if !ok { + return nil, errors.New(f.Name + " is not on your friends list") + } + if err := b.Store.RemoveFriend(u.ID, f.ID); err != nil { + return nil, err + } + b.FriendsChanged(u.ID) + return f, nil +} + +// Blocks reports whether u blocks other. +func (b *BBS) Blocks(u, other *store.User) bool { + ok, err := b.Store.IsBlocked(u.ID, other.ID) + if err != nil { + b.Log.Printf("blocked list of %s: %v", u.Name, err) + } + return ok +} + +// Blocked is a user's blocked list. +func (b *BBS) Blocked(u *store.User) ([]store.Friend, error) { return b.Store.Blocked(u.ID) } + +// Block puts the user of that name on u's blocked list (they can no +// longer send u private messages, nor see u online where a front end +// shows it); that user. +func (b *BBS) Block(u *store.User, name string) (*store.User, error) { + f, err := b.userNamed(name) + if err != nil { + return nil, err + } + if f.ID == u.ID { + return nil, errors.New("you cannot block yourself") + } + if err := b.Store.Block(u.ID, f.ID); err != nil { + return nil, err + } + b.FriendsChanged(u.ID) + return f, nil +} + +// Unblock takes the user of that name off u's blocked list; that user. +func (b *BBS) Unblock(u *store.User, name string) (*store.User, error) { + f, err := b.userNamed(name) + if err != nil { + return nil, err + } + if ok, err := b.Store.IsBlocked(u.ID, f.ID); err != nil { + return nil, err + } else if !ok { + return nil, errors.New(f.Name + " is not on your blocked list") + } + if err := b.Store.Unblock(u.ID, f.ID); err != nil { + return nil, err + } + b.FriendsChanged(u.ID) + return f, nil +} + +// userNamed is the user of that name (ErrNoUser: none). +func (b *BBS) userNamed(name string) (*store.User, error) { + f, err := b.Store.UserByName(strings.TrimSpace(name)) + if errors.Is(err, store.ErrNotFound) { + return nil, ErrNoUser + } + return f, err +} + +// WatchFriends has fn told when a user's friends list (or blocked list) +// changes, until the returned func is called. fn must not block. +func (b *BBS) WatchFriends(fn func(user int64)) (stop func()) { + b.presMu.Lock() + defer b.presMu.Unlock() + if b.friendFns == nil { + b.friendFns = map[int]func(int64){} + } + b.friendNext++ + id := b.friendNext + b.friendFns[id] = fn + return func() { + b.presMu.Lock() + delete(b.friendFns, id) + b.presMu.Unlock() + } +} + +// FriendsChanged tells the watchers that a user's friends list changed. +func (b *BBS) FriendsChanged(user int64) { + b.presMu.Lock() + fns := make([]func(int64), 0, len(b.friendFns)) + for _, fn := range b.friendFns { + fns = append(fns, fn) + } + b.presMu.Unlock() + for _, fn := range fns { + fn(user) + } +} + +// FriendLines are a user's friends as lines to show: who is on, and how. +func (b *BBS) FriendLines(u *store.User) ([]string, error) { + fs, err := b.Friends(u) + if err != nil { + return nil, err + } + if len(fs) == 0 { + return []string{"Your friends list is empty."}, nil + } + out := []string{"Your friends:"} + for _, f := range fs { + var on []string + for _, n := range b.Nodes() { + if strings.EqualFold(n.User, f.Name) { + on = append(on, n.Via) + } + } + state := "away" + if len(on) > 0 { + state = "on (" + strings.Join(on, ", ") + ")" + } + out = append(out, " "+f.Name+" "+state) + } + return out, nil +} diff --git a/internal/cis/hmi.go b/internal/cis/hmi.go index 496ef80..fa53a28 100644 --- a/internal/cis/hmi.go +++ b/internal/cis/hmi.go @@ -18,8 +18,9 @@ package cis // dates. What this serves: the session's opening, the pages (menus as // 0x27, articles as 0x28 and their text in pieces), the rest of a menu's // items (0x34), Find (0x22), the directory lookup (0x0D), acks for the -// rest, and the logoff. Forums, Mail and the CB in CIM are still to come: -// their pages say so. +// rest, and the logoff. Forums, their libraries' lists and Mail to read +// are pages too (hmiforum.go); the CB in CIM, downloads and sending mail +// are still to come. import ( "errors" @@ -143,7 +144,7 @@ func (s *session) hmi() error { if err != nil { return fmt.Errorf("cis: CIM's Transport Layer: %w", err) } - h := &hmiSession{s: s, t: t, made: map[string]*Page{}} + h := &hmiSession{s: s, t: t} return h.run() } @@ -245,14 +246,12 @@ func paramsOK(line string) bool { return sum&0xFFFF == n } -// hmiSession is the HMI's state: the article being fetched, and the pages -// made for names that are no page of the service's. +// hmiSession is the HMI's state: the article being fetched. type hmiSession struct { s *session t *xfer.BTransport settled bool // the first message has gone (twice) text []byte - made map[string]*Page // delay is the wait before each answer, as the emulator that was // checked against WinCIM waits. delay time.Duration @@ -455,16 +454,14 @@ var hmiAliases = map[string]string{ } // lookup is the page a name stands for: "CIS:TOP", "HOM:FORUMS", a GO -// word. A name that is none gets a page saying so: the client must never -// be left without one. +// word, a forum's or the mailbox's own pages (hmiforum.go). A name that +// is none gets a page saying so: the client must never be left without +// one. Pages are made afresh each time, so they show what is there now. func (h *hmiSession) lookup(name string) *Page { name = strings.ToUpper(strings.TrimSpace(name)) if name == "" { name = "CIS:TOP" } - if p := h.made[name]; p != nil { - return p - } w := name if i := strings.IndexByte(w, ':'); i >= 0 && i <= 3 { w = w[i+1:] @@ -472,30 +469,8 @@ func (h *hmiSession) lookup(name string) *Page { if a, ok := hmiAliases[w]; ok && h.s.pages.Get(w) == nil { w = a } - s := h.s - var p *Page - if f := s.forum(w); f != nil && s.pages.Get(w) == nil { - p = &Page{ID: f.Go, Title: f.Name, Text: []string{ - " " + f.Name, - "", - " Forums are not in CIM here yet: a terminal program reaches", - " this one with GO " + f.Go + ".", - }} - } else if p = s.pages.Get(w); p != nil { - switch p.ID { - case "FORUMS": - p = s.forumsPage() - if !p.Menu() { - p.Text = []string{" There are no forums here yet."} - } - case "MAIL", "CB": - what := map[string]string{"MAIL": "CompuServe Mail", "CB": "The CB Simulator"}[p.ID] - p = &Page{ID: p.ID, Title: p.Title, Text: []string{ - " " + what + " is not in CIM here yet: a terminal program", - " reaches it with GO " + p.ID + ".", - }} - } - } else { + p := h.page(w) + if p == nil { p = &Page{ID: w, Title: "CompuServe", Text: []string{ " " + w + " is not a service here.", "", @@ -508,6 +483,39 @@ func (h *hmiSession) lookup(name string) *Page { if p.Title == "" { p.Title = "CompuServe" } - h.made[name] = p + return p +} + +// page is the page w names, or nil. +func (h *hmiSession) page(w string) *Page { + s := h.s + word, part, _ := strings.Cut(w, "/") + if word == "MAIL" || word == "EASYPLEX" { + return s.mailPage(part) + } + if f := s.forum(word); f != nil && s.pages.Get(word) == nil { + if part != "" { + return s.forumPart(f, part) + } + return s.forumPage(f) + } + if part != "" { + return nil + } + p := s.pages.Get(w) + if p == nil { + return nil + } + switch p.ID { + case "FORUMS": + p = s.forumsPage() + case "MAIL": + return s.mailPage("") + case "CB": + p = &Page{ID: p.ID, Title: p.Title, Text: []string{ + " The CB Simulator is not in CIM here yet: a terminal program", + " reaches it with GO CB.", + }} + } return p } diff --git a/internal/cis/hmiforum.go b/internal/cis/hmiforum.go new file mode 100644 index 0000000..89688c2 --- /dev/null +++ b/internal/cis/hmiforum.go @@ -0,0 +1,152 @@ +package cis + +// Forums, libraries and Mail in CIM, as pages: WinCIM 3.0.2 asks for them +// with ordinary page requests (CIS:FORUMS, HOM:MAILHMI) and shows menus +// and articles, as 24high/CompuServe-Emulator measured it (POST.md). The +// pages here: +// +// CIS:FORUMS the forums +// CIS: a forum: its sections and libraries +// CIS:/S a section's messages, newest first +// CIS:/M a message (read: it counts as read) +// CIS:/L a library's files +// CIS:MAIL the mailbox, newest first +// CIS:MAIL/ a letter (read: it is marked read) +// +// Item kind 0 is a selectable item; kind 1 is drawn as a label the client +// will not select, so every item here is kind 0. + +import ( + "fmt" + "strconv" + "strings" +) + +// hmiList is how many messages a section's page lists: the item count is +// a byte. +const hmiList = 200 + +// forumPage is a forum: one item for each section, then each library. +func (s *session) forumPage(f *Forum) *Page { + p := &Page{ID: f.Go, Title: f.Name} + for i, a := range f.Sections { + p.Items = append(p.Items, Item{ + Text: fmt.Sprintf("Messages: %s (%d)", sectionName(a), a.Messages), + Target: fmt.Sprintf("%s/S%d", f.Go, i), + }) + } + for i, l := range f.Libs { + p.Items = append(p.Items, Item{ + Text: "Library: " + l.Name, + Target: fmt.Sprintf("%s/L%d", f.Go, i), + }) + } + if len(p.Items) == 0 { + p.Text = []string{" " + f.Name + " has nothing in it yet."} + } + return p +} + +// forumPart is one of a forum's pages below it: "S0", "M1234", "L2". +func (s *session) forumPart(f *Forum, part string) *Page { + if len(part) < 2 { + return nil + } + n, err := strconv.ParseInt(part[1:], 10, 64) + if err != nil || n < 0 { + return nil + } + st := &forumState{f: f, read: map[int64]int64{}} + switch part[0] { + case 'S': + if n >= int64(len(f.Sections)) { + return nil + } + a := f.Sections[n] + p := &Page{ID: fmt.Sprintf("%s/S%d", f.Go, n), Title: f.Name} + ms, _ := s.b.Store.Messages(a.ID, 0, 5000) + for i := len(ms) - 1; i >= 0 && len(p.Items) < hmiList; i-- { + m := ms[i] + p.Items = append(p.Items, Item{ + Text: fmt.Sprintf("%s (%s) #%d", m.Subject, m.From, m.ID), + Target: fmt.Sprintf("%s/M%d", f.Go, m.ID), + }) + } + if len(p.Items) == 0 { + p.Text = []string{" There are no messages in " + sectionName(a) + "."} + } + return p + case 'M': + m, err := s.b.Store.Message(n) + if err != nil || f.section(m.AreaID) < 0 { + return nil + } + replies := s.replies(m) + lines := append(s.header(st, m, replies), "") + body := strings.Split(strings.TrimRight(strings.ReplaceAll(m.Body, "\r\n", "\n"), "\n"), "\n") + lines = append(lines, body...) + if r := replyLine(replies); r != nil { + lines = append(append(lines, ""), r...) + } + if lr, _ := s.b.Store.LastRead(s.user.ID, m.AreaID); m.ID > lr { + s.b.Store.SetLastRead(s.user.ID, m.AreaID, m.ID) + } + return &Page{ID: fmt.Sprintf("%s/M%d", f.Go, m.ID), Title: m.Subject, Text: lines} + case 'L': + if n >= int64(len(f.Libs)) { + return nil + } + l := f.Libs[n] + p := &Page{ID: fmt.Sprintf("%s/L%d", f.Go, n), Title: l.Name, + Text: []string{" " + l.Name, ""}} + fs := s.libFiles(l, libQuery{}) + for _, file := range fs { + p.Text = append(p.Text, fmt.Sprintf(" %-12s %8d %s %s", file.Name, file.Size, + file.Created.Format("02-Jan-06"), file.Description)) + } + if len(fs) == 0 { + p.Text = append(p.Text, " There are no files here.") + } + p.Text = append(p.Text, "", " Downloads are not in CIM here yet: a terminal program", + " downloads from this library with GO "+f.Go+", then LIB "+strconv.FormatInt(n, 10)+".") + return p + } + return nil +} + +// mailPage is the mailbox, or one letter of it ("MAIL/"). +func (s *session) mailPage(id string) *Page { + all, err := s.b.Store.Inbox(s.user.ID) + if err != nil { + s.b.Log.Printf("node %d: CompuServe: mail: %v", s.node.Num, err) + } + if id != "" { + n, err := strconv.ParseInt(id, 10, 64) + if err != nil { + return nil + } + for _, m := range all { + if m.ID == n { + s.b.Store.MarkMailRead(s.user.ID, m.ID) + return &Page{ID: "MAIL/" + id, Title: m.Subject, Text: mailText(m)} + } + } + return nil + } + p := &Page{ID: "MAIL", Title: "CompuServe Mail"} + for i := len(all) - 1; i >= 0 && len(p.Items) < hmiList; i-- { + m := all[i] + mark := "" + if !m.Read { + mark = "* " + } + p.Items = append(p.Items, Item{ + Text: fmt.Sprintf("%s%s (%s)", mark, m.Subject, fromLine(m)), + Target: "MAIL/" + strconv.FormatInt(m.ID, 10), + }) + } + if len(p.Items) == 0 { + p.Text = []string{" No messages pending."} + } + return p +} diff --git a/internal/ircd/bbsserv.go b/internal/ircd/bbsserv.go index 00da97c..9bdd7c0 100644 --- a/internal/ircd/bbsserv.go +++ b/internal/ircd/bbsserv.go @@ -117,6 +117,28 @@ DEL lets it go when its last caller leaves. ROOM TOPIC sets its topic maxParams: 3, unsplitFinalParam: true, } + svc.Commands["friends"] = &serviceCommand{ + handler: bsFriends, + help: `Syntax: $bFRIENDS [ADD|DEL ]$b + +FRIENDS lists your friends list, and who on it is on now. FRIENDS ADD +puts a BBS user on it, FRIENDS DEL takes one off. It is the same list +on the BBS, and your buddy list on AIM and ICQ.`, + helpShort: "$bFRIENDS$b lists, adds and removes your friends.", + maxParams: 2, + } + svc.Commands["history"] = &serviceCommand{ + handler: bsHistory, + help: `Syntax: $bHISTORY [nick] [lines]$b + +Private messages are kept. HISTORY alone lists those you have talked +with; HISTORY shows your last lines with them (50, or as many +as you ask, up to 500). A message to someone not on is kept for them, +and they have it when they next log in.`, + helpShort: "$bHISTORY$b shows your private conversations.", + maxParams: 2, + } + svc.Commands["friend"] = &serviceCommand{aliasOf: "friends"} svc.Commands["channel"] = &serviceCommand{aliasOf: "room"} svc.Commands["channels"] = &serviceCommand{aliasOf: "rooms"} svc.Commands["account"] = &serviceCommand{aliasOf: "info"} @@ -492,3 +514,87 @@ func bsRoom(svc *service, c *client, _ string, params []string) { svc.notice(c, capital(err.Error())+".") } } + +// bsFriends is FRIENDS: the friends list, ADD and DEL. +func bsFriends(svc *service, c *client, _ string, params []string) { + b := c.s.B + if len(params) == 0 { + lines, err := b.FriendLines(c.u) + if err != nil { + svc.notice(c, capital(err.Error())+".") + return + } + for _, l := range lines { + svc.notice(c, l) + } + return + } + if len(params) < 2 { + svc.notice(c, fmt.Sprintf("FRIENDS ADD or DEL a nick: /msg %s HELP FRIENDS", svc.Name)) + return + } + name := params[1] + if u := c.userOfNick(name); u != nil { + name = u.Name + } + switch strings.ToLower(params[0]) { + case "add": + f, err := b.AddFriend(c.u, name) + if err != nil { + svc.notice(c, capital(err.Error())+".") + return + } + svc.notice(c, Nick(f.Name)+" is on your friends list.") + case "del", "delete", "remove": + f, err := b.RemoveFriend(c.u, name) + if err != nil { + svc.notice(c, capital(err.Error())+".") + return + } + svc.notice(c, Nick(f.Name)+" is off your friends list.") + default: + svc.notice(c, fmt.Sprintf("FRIENDS ADD or DEL a nick: /msg %s HELP FRIENDS", svc.Name)) + } +} + +// bsHistory is HISTORY: those talked with, or the last lines with one. +func bsHistory(svc *service, c *client, _ string, params []string) { + if len(params) == 0 { + ps, err := c.n.Conversations() + if err != nil { + svc.notice(c, capital(err.Error())+".") + return + } + if len(ps) == 0 { + svc.notice(c, "You have no conversations yet.") + return + } + for _, p := range ps { + svc.notice(c, fmt.Sprintf("%-20s %d lines, the last %s", Nick(p.Name), p.Lines, p.Last.Format("Jan 2 15:04"))) + } + return + } + u := c.userOfNick(params[0]) + if u == nil { + svc.notice(c, "There is no user of that nick.") + return + } + limit := 50 + if len(params) > 1 { + if n, err := strconv.Atoi(params[1]); err == nil && n > 0 { + limit = n + } + } + cs, err := c.n.History(u, limit) + if err != nil { + svc.notice(c, capital(err.Error())+".") + return + } + if len(cs) == 0 { + svc.notice(c, "You and "+Nick(u.Name)+" have not talked yet.") + return + } + for _, l := range bbs.HistoryLines(cs) { + svc.notice(c, l) + } +} diff --git a/internal/ircd/client.go b/internal/ircd/client.go index abe0be1..9c4af15 100644 --- a/internal/ircd/client.go +++ b/internal/ircd/client.go @@ -427,6 +427,7 @@ func (c *client) login() bool { c.send(nil, asked+"!irc@"+c.s.S.ServerName, "NICK", c.nick) } c.welcome() + n.DeliverKept() // messages kept while they were away, with their times return true } diff --git a/internal/ircd/commands.go b/internal/ircd/commands.go index c2b7c92..6002acb 100644 --- a/internal/ircd/commands.go +++ b/internal/ircd/commands.go @@ -11,6 +11,7 @@ import ( "github.com/ergochat/irc-go/ircmsg" "github.com/D-Modem/bbs/internal/bbs" + "github.com/D-Modem/bbs/internal/store" ) // command handles a registered client's line. @@ -264,6 +265,26 @@ func (c *client) nodesOf(nick string) []bbs.NodeInfo { return out } +// userOfNick is the BBS user a nick is of, on or not (nil: none). +func (c *client) userOfNick(nick string) *store.User { + if fold(nick) == fold(c.s.svc.Name) { + return nil + } + if u, err := c.s.B.Store.UserByName(nick); err == nil { + return u + } + us, err := c.s.B.Store.Users() + if err != nil { + return nil + } + for _, u := range us { + if fold(Nick(u.Name)) == fold(nick) { + return u + } + } + return nil +} + // who is WHO: a channel's members (and the service, in a permanent room), // or a nick's nodes. func (c *client) who(mask string) { @@ -446,15 +467,32 @@ func (c *client) privmsg(command, target, text string) { return } ns := c.nodesOf(target) - if len(ns) == 0 { - if !notice { - c.reply(ERR_NOSUCHNICK, target, "No such nick") - } - return - } if emote { text = "* " + c.u.Name + " " + text } + if len(ns) == 0 { + // a user away: kept for them + u := c.userOfNick(target) + if u == nil { + if !notice { + c.reply(ERR_NOSUCHNICK, target, "No such nick") + } + return + } + if _, err := c.n.TellUser(u, text); err != nil { + if !notice { + c.reply(ERR_CANNOTSENDTOCHAN, target, "Cannot send: "+err.Error()) + } + return + } + if c.caps["echo-message"] { + c.send(map[string]string{"time": stamp(time.Now())}, c.source(), command, target, text) + } + if !notice { + c.reply(RPL_AWAY, Nick(u.Name), "Not on now; they will have your message when they next log in") + } + return + } sent := false var lastErr error for _, o := range ns { @@ -467,6 +505,11 @@ func (c *client) privmsg(command, target, text string) { sent = true } } + if sent { + if u, err := c.s.B.Store.UserByName(ns[0].User); err == nil { + c.n.Keep(u, text, true) + } + } switch { case sent && c.caps["echo-message"], !sent && lastErr == nil: // echoed, or to yourself with no other node: back it comes, as IRC @@ -533,7 +576,11 @@ func (c *client) event(e bbs.Event) { case bbs.Topic: c.send(tags, c.s.svc.source(c), "TOPIC", "#"+e.Room, e.Text) case bbs.Private: - c.send(tags, c.sourceOf(e.From, e.Node), "PRIVMSG", c.nick, e.Text) + text := e.Text + if e.Kept && !c.caps["server-time"] { + text = "[" + e.Time.Format("Jan 2 15:04") + "] " + text + } + c.send(tags, c.sourceOf(e.From, e.Node), "PRIVMSG", c.nick, text) case bbs.Paged: text := fmt.Sprintf("%s (node %d) is paging you", e.From, e.Node) if e.Text != "" { diff --git a/internal/ircd/ircd_test.go b/internal/ircd/ircd_test.go index 8c04cd0..a7d9e3f 100644 --- a/internal/ircd/ircd_test.go +++ b/internal/ircd/ircd_test.go @@ -464,3 +464,64 @@ func TestRelayedLines(t *testing.T) { e.b.RelayEvent(bbs.Event{Kind: bbs.Notice, Room: "mrc-lobby", Text: "- dave has arrived."}) c.expect(":irc.test NOTICE #mrc-lobby :- dave has arrived.") } + +// TestKeptMessages: a PRIVMSG to a user not on is kept (301 says so), and +// given them when they come, by IRC (its time as server-time) or the +// terminal; a terminal's /msg by name, and the conversation read back. +func TestKeptMessages(t *testing.T) { + e := start(t) + a := e.dial(t) + a.login("alice", "alice") + a.send("PRIVMSG bob :are you there?") + if l := a.expect(" 301 "); !strings.Contains(l, "bob") { + t.Errorf("301 %q", l) + } + a.send("PRIVMSG nobody :hello") + a.expect(" 401 ") + + // bob comes on a terminal, then talks back by /msg and his name + bob := e.caller(t, "bob") + bob.DeliverKept() + waitEvent(t, bob, "Message from alice") + if out, _, err := bob.ChatCommand("/msg alice yes, here"); err != nil || len(out) != 1 || out[0] != "Sent to alice." { + t.Errorf("/msg %q %v", out, err) + } + a.expect("PRIVMSG alice :yes, here") + if out, _, _ := bob.ChatCommand("/history alice"); len(out) != 3 || !strings.HasSuffix(out[1], " are you there?") { + t.Errorf("/history %q", out) + } + + // Carol Ann, on IRC later: a line kept for her has its time + a.send("PRIVMSG Carol_Ann :for later") + a.expect(" 301 ") + c := e.dial(t) + c.send("CAP REQ :server-time", "CAP END") + c.login("Carol Ann", "Carol_Ann") + if l := c.expect("PRIVMSG Carol_Ann :for later"); !strings.HasPrefix(l, "@time=") { + t.Errorf("kept line %q", l) + } +} + +// TestFriends: BBSServ FRIENDS adds, lists (who is on) and removes; the +// terminal's /friends shows the same list. +func TestFriends(t *testing.T) { + e := start(t) + a := e.dial(t) + a.login("alice", "alice") + a.send("PRIVMSG BBSServ :FRIENDS ADD bob") + a.expect("bob is on your friends list") + a.send("PRIVMSG BBSServ :FRIENDS ADD nobody") + a.expect("There is no user of that name") + e.caller(t, "bob") + a.send("PRIVMSG BBSServ :FRIENDS") + a.expect("bob on (telnet)") + n := e.caller(t, "alice") + if out, _, _ := n.ChatCommand("/friends"); len(out) != 2 || !strings.Contains(out[1], "bob") { + t.Errorf("/friends %q", out) + } + a.send("PRIVMSG BBSServ :FRIENDS DEL bob") + a.expect("bob is off your friends list") + if out, _, _ := n.ChatCommand("/friends"); out[0] != "Your friends list is empty." { + t.Errorf("/friends after %q", out) + } +} diff --git a/internal/msn/events.go b/internal/msn/events.go new file mode 100644 index 0000000..9e89a77 --- /dev/null +++ b/internal/msn/events.go @@ -0,0 +1,54 @@ +package msn + +import ( + "fmt" + + "github.com/D-Modem/bbs/internal/bbs" +) + +// event is something the node is told: a private message, as an IM from +// its sender; anything else as an IM from the BBS. +func (ns *nsSession) event(e bbs.Event) { + switch e.Kind { + case bbs.Private: + text := e.Text + if e.Kept { + text = "(" + e.Time.Format("Jan 2 15:04") + ", while you were away) " + text + } + u, err := ns.s.B.Store.UserByName(e.From) + if err != nil { + ns.s.deliverFrom(ns, nil, e.From+": "+text) + return + } + if ns.s.B.Blocks(ns.u, u) { + return + } + ns.s.deliverFrom(ns, u, text) + return + case bbs.Said, bbs.Emoted, bbs.Joined, bbs.Left, bbs.Topic: + return // no rooms on MSN + case bbs.Paged: + text := fmt.Sprintf("%s (node %d) is paging you", e.From, e.Node) + if e.Text != "" { + text += ": " + e.Text + } + ns.s.deliverFrom(ns, nil, text+fmt.Sprintf(" (join the chat room sysop-%d to answer)", e.Node)) + return + } + ns.s.deliverFrom(ns, nil, e.String()) +} + +// deliverKept gives the client the private messages kept for its user +// while they were away. +func (ns *nsSession) deliverKept() { + ns.mu.Lock() + sent := ns.keptSent + ns.keptSent = true + ns.mu.Unlock() + if sent { + return + } + for _, e := range ns.n.Kept() { + ns.event(e) + } +} diff --git a/internal/msn/lists.go b/internal/msn/lists.go new file mode 100644 index 0000000..74aded1 --- /dev/null +++ b/internal/msn/lists.go @@ -0,0 +1,598 @@ +package msn + +import ( + "sort" + "strconv" + "strings" + + "github.com/D-Modem/bbs/internal/store" +) + +// The contact lists: the Forward List (FL) is the user's friends list; the +// Block List (BL) their blocked list; the Reverse List (RL) those who have +// them as a friend; the Allow List (AL), those not blocked who are on +// either. A user who adds one is on their RL and not on their AL or BL, +// which a client asks about ("X has added you..."). + +const maxGroups = 30 // MSNP7's group ids are 0 to 29 + +// loadLists reads the lists from the store into the session. +func (ns *nsSession) loadLists() error { + st := ns.s.B.Store + fs, err := st.Friends(ns.u.ID) + if err != nil { + return err + } + bs, err := st.Blocked(ns.u.ID) + if err != nil { + return err + } + rs, err := st.FriendOf(ns.u.ID) + if err != nil { + return err + } + ns.mu.Lock() + defer ns.mu.Unlock() + ns.fl = map[int64]store.Friend{} + for _, f := range fs { + ns.fl[f.ID] = f + ns.groupIDLocked(f.Group) + } + ns.bl = map[int64]bool{} + for _, b := range bs { + ns.bl[b.ID] = true + } + ns.rl = map[int64]bool{} + for _, r := range rs { + ns.rl[r.ID] = true + } + return nil +} + +// groupIDLocked is a group's id, given one if it has none. ns.mu is +// held. +func (ns *nsSession) groupIDLocked(name string) int { + if name == "" { + return 0 + } + for id, g := range ns.groups { + if g == name { + return id + } + } + for id := 1; id < maxGroups; id++ { + if _, used := ns.groups[id]; !used { + ns.groups[id] = name + return id + } + } + return 0 +} + +// entry is one on a list, as LST gives it. +type entry struct { + handle, name string + group int +} + +// list is one of the lists, sorted by handle. +func (ns *nsSession) list(which string) []entry { + ns.mu.Lock() + defer ns.mu.Unlock() + var out []entry + add := func(id int64, name string, group int) { + out = append(out, entry{handle: ns.s.handleOfName(name), name: name, group: group}) + } + names := ns.namesLocked() + switch which { + case "FL": + for _, f := range ns.fl { + n := f.Name + if f.Alias != "" { + n = f.Alias + } + out = append(out, entry{handle: ns.s.handleOfName(f.Name), name: n, group: ns.groupIDLocked(f.Group)}) + } + case "AL": + seen := map[int64]bool{} + for id := range ns.fl { + if !ns.bl[id] { + seen[id] = true + } + } + for id := range ns.rl { + if !ns.bl[id] { + seen[id] = true + } + } + for id := range seen { + add(id, names[id], 0) + } + case "BL": + for id := range ns.bl { + add(id, names[id], 0) + } + case "RL": + for id := range ns.rl { + add(id, names[id], 0) + } + } + sort.Slice(out, func(i, j int) bool { return out[i].handle < out[j].handle }) + return out +} + +// namesLocked are the names of everyone on the lists, by id. ns.mu is +// held; the store is read for those not on the FL. +func (ns *nsSession) namesLocked() map[int64]string { + names := map[int64]string{} + for id, f := range ns.fl { + names[id] = f.Name + } + for _, m := range []map[int64]bool{ns.bl, ns.rl} { + for id := range m { + if _, ok := names[id]; ok { + continue + } + if u, err := ns.s.B.Store.UserByID(id); err == nil { + names[id] = u.Name + } + } + } + return names +} + +// handleOfName is the handle of a user of that name. +func (s *Server) handleOfName(name string) string { + return strings.ReplaceAll(name, " ", "") + "@" + s.S.Domain +} + +// syn sends the lists: the settings, the groups (MSNP7), each list. The +// list version is always new, so the client takes all of it. +func (ns *nsSession) syn(c *cmd) { + if err := ns.loadLists(); err != nil { + ns.s.B.Log.Printf("node %d: msn: lists: %v", ns.n.Num, err) + ns.k.sendErr(errInternal, c.trid) + return + } + have, _ := strconv.Atoi(c.arg(0)) + ns.mu.Lock() + if ns.listVer <= have { + ns.listVer = have + 1 + } + ns.synced = true + gtc, blp := ns.gtc, ns.blp + ns.mu.Unlock() + v := ns.verNow() + ns.k.send("SYN", c.trid, v) + ns.k.send("GTC", c.trid, v, gtc) + ns.k.send("BLP", c.trid, v, blp) + if ns.ver >= 7 { + ns.sendGroups(c.trid, v) + } + for _, l := range []string{"FL", "AL", "BL", "RL"} { + ns.sendList(c.trid, v, l) + } +} + +// sendList sends a list as LST lines. +func (ns *nsSession) sendList(trid, v, which string) { + es := ns.list(which) + if len(es) == 0 { + ns.k.send("LST", trid, which, v, "0", "0") + return + } + for i, e := range es { + w := []string{"LST", trid, which, v, strconv.Itoa(i + 1), strconv.Itoa(len(es)), e.handle, encode(e.name)} + if which == "FL" && ns.ver >= 7 { + w = append(w, strconv.Itoa(e.group)) + } + ns.k.send(w...) + } +} + +// sendGroups sends the groups as LSG lines (Other Contacts, 0, first). +func (ns *nsSession) sendGroups(trid, v string) { + ns.mu.Lock() + ids := make([]int, 0, len(ns.groups)) + for id := range ns.groups { + ids = append(ids, id) + } + sort.Ints(ids) + names := make([]string, len(ids)) + for i, id := range ids { + names[i] = ns.groups[id] + if id == 0 { + names[i] = "Other Contacts" + } + } + ns.mu.Unlock() + for i, id := range ids { + ns.k.send("LSG", trid, v, strconv.Itoa(i+1), strconv.Itoa(len(ids)), strconv.Itoa(id), encode(names[i]), "0") + } +} + +// lst answers LST: one list. +func (ns *nsSession) lst(c *cmd) { + which := strings.ToUpper(c.arg(0)) + switch which { + case "FL", "AL", "BL", "RL": + ns.sendList(c.trid, ns.verNow(), which) + default: + ns.k.sendErr(errBadParam, c.trid) + } +} + +// lsg answers LSG: the groups. +func (ns *nsSession) lsg(c *cmd) { + if ns.ver < 7 { + ns.k.sendErr(errSyntax, c.trid) + return + } + ns.sendGroups(c.trid, ns.verNow()) +} + +// add is ADD: a friend (FL), one allowed (AL), one blocked (BL). +func (ns *nsSession) add(c *cmd) { + which, handle := strings.ToUpper(c.arg(0)), c.arg(1) + k := ns.k + t := ns.s.resolve(handle) + switch { + case which != "FL" && which != "AL" && which != "BL": + k.sendErr(errBadParam, c.trid) + return + case !strings.Contains(handle, "@"): + k.sendErr(errBadHandle, c.trid) + return + case t == nil: + k.sendErr(errNoSuchUser, c.trid) + return + case t.ID == ns.u.ID: + k.sendErr(errBadParam, c.trid) + return + } + h := ns.s.handleOf(t) + ns.mu.Lock() + f, isFriend := ns.fl[t.ID] + blocked := ns.bl[t.ID] + ns.mu.Unlock() + switch which { + case "FL": + group := "" + gid := 0 + if ns.ver >= 7 && c.arg(3) != "" { + var err error + if gid, err = strconv.Atoi(c.arg(3)); err != nil { + k.sendErr(errBadGroup, c.trid) + return + } + ns.mu.Lock() + g, ok := ns.groups[gid] + ns.mu.Unlock() + if !ok { + k.sendErr(errBadGroup, c.trid) + return + } + group = g + } + if isFriend && (ns.ver < 7 || f.Group == group) { + k.sendErr(errAlreadyThere, c.trid) + return + } + nf := store.Friend{ID: t.ID, Name: t.Name, Group: group, Alias: f.Alias} + ns.mu.Lock() + ns.fl[t.ID] = nf // before the store tells of it, so it is not told twice + ns.mu.Unlock() + if err := ns.s.B.Store.PutFriend(ns.u.ID, nf); err != nil { + ns.s.B.Log.Printf("node %d: msn: adding a friend: %v", ns.n.Num, err) + k.sendErr(errInternal, c.trid) + return + } + w := []string{"ADD", c.trid, "FL", ns.bumpVer(), h, encode(t.Name)} + if ns.ver >= 7 { + w = append(w, strconv.Itoa(gid)) + } + k.send(w...) + ns.s.B.FriendsChanged(ns.u.ID) + if st := ns.s.statusFor(t, ns.u); st != "" { + ns.mu.Lock() + ns.told[t.ID] = st + ns.mu.Unlock() + k.send("ILN", c.trid, st, h, encode(ns.s.friendlyFor(t))) + } + case "AL": + if blocked { + k.sendErr(errInOpposite, c.trid) + return + } + k.send("ADD", c.trid, "AL", ns.bumpVer(), h, encode(t.Name)) + case "BL": + if blocked { + k.sendErr(errAlreadyThere, c.trid) + return + } + ns.mu.Lock() + ns.bl[t.ID] = true + ns.mu.Unlock() + if err := ns.s.B.Store.Block(ns.u.ID, t.ID); err != nil { + k.sendErr(errInternal, c.trid) + return + } + k.send("ADD", c.trid, "BL", ns.bumpVer(), h, encode(t.Name)) + ns.s.B.FriendsChanged(ns.u.ID) + ns.s.changed(ns.u) + } +} + +// rem is REM: off a list (or, MSNP7, out of a group). +func (ns *nsSession) rem(c *cmd) { + which, handle := strings.ToUpper(c.arg(0)), c.arg(1) + k := ns.k + t := ns.s.resolve(handle) + if which != "FL" && which != "AL" && which != "BL" { + k.sendErr(errBadParam, c.trid) + return + } + if t == nil { + k.sendErr(errNotOnList, c.trid) + return + } + h := ns.s.handleOf(t) + ns.mu.Lock() + f, isFriend := ns.fl[t.ID] + blocked := ns.bl[t.ID] + ns.mu.Unlock() + switch which { + case "FL": + if !isFriend { + k.sendErr(errNotOnList, c.trid) + return + } + if ns.ver >= 7 && c.arg(2) != "" { + gid, err := strconv.Atoi(c.arg(2)) + ns.mu.Lock() + g, ok := ns.groups[gid] + ns.mu.Unlock() + if err != nil || !ok { + k.sendErr(errBadGroup, c.trid) + return + } + if f.Group != g { + k.sendErr(errNotInGroup, c.trid) + return + } + if g != "" { // out of the group: into Other Contacts + f.Group = "" + ns.mu.Lock() + ns.fl[t.ID] = f + ns.mu.Unlock() + ns.s.B.Store.PutFriend(ns.u.ID, f) + ns.s.B.FriendsChanged(ns.u.ID) + } + k.send("REM", c.trid, "FL", ns.bumpVer(), h, c.arg(2)) + return + } + ns.mu.Lock() + delete(ns.fl, t.ID) + delete(ns.told, t.ID) + ns.mu.Unlock() + if err := ns.s.B.Store.RemoveFriend(ns.u.ID, t.ID); err != nil { + k.sendErr(errInternal, c.trid) + return + } + k.send("REM", c.trid, "FL", ns.bumpVer(), h) + ns.s.B.FriendsChanged(ns.u.ID) + case "AL": + k.send("REM", c.trid, "AL", ns.bumpVer(), h) + case "BL": + if !blocked { + k.sendErr(errNotOnList, c.trid) + return + } + ns.mu.Lock() + delete(ns.bl, t.ID) + ns.mu.Unlock() + ns.s.B.Store.Unblock(ns.u.ID, t.ID) + k.send("REM", c.trid, "BL", ns.bumpVer(), h) + ns.s.B.FriendsChanged(ns.u.ID) + ns.s.changed(ns.u) + } +} + +// rea is REA: its own display name, or one it keeps for a friend (the +// friend's alias on the friends list). +func (ns *nsSession) rea(c *cmd) { + handle, name := c.arg(0), strings.TrimSpace(decode(c.arg(1))) + k := ns.k + if name == "" || len(name) > 129 { + k.sendErr(errBadFriendly, c.trid) + return + } + t := ns.s.resolve(handle) + if t == nil { + k.sendErr(errNotOnList, c.trid) + return + } + if t.ID == ns.u.ID { + ns.mu.Lock() + ns.friendly = name + ns.mu.Unlock() + k.send("REA", c.trid, ns.bumpVer(), handle, encode(name)) + ns.s.renamed(ns.u) + return + } + ns.mu.Lock() + f, ok := ns.fl[t.ID] + if ok { + f.Alias = name + if name == t.Name { + f.Alias = "" + } + ns.fl[t.ID] = f + } + ns.mu.Unlock() + if !ok { + k.sendErr(errNotOnList, c.trid) + return + } + ns.s.B.Store.PutFriend(ns.u.ID, f) + k.send("REA", c.trid, ns.bumpVer(), handle, encode(name)) +} + +// group is ADG, RMG and REG (MSNP7): groups made, removed, renamed. A +// group is its friends': one with none is forgotten at the next sign-in. +func (ns *nsSession) group(c *cmd) { + k := ns.k + if ns.ver < 7 { + k.sendErr(errSyntax, c.trid) + return + } + st := ns.s.B.Store + switch c.name { + case "ADG": + name := strings.TrimSpace(decode(c.arg(0))) + if name == "" || len(name) > 61 || strings.EqualFold(name, "Other Contacts") { + k.sendErr(errGroupName, c.trid) + return + } + ns.mu.Lock() + for _, g := range ns.groups { + if strings.EqualFold(g, name) { + ns.mu.Unlock() + k.sendErr(errGroupName, c.trid) + return + } + } + n := len(ns.groups) + id := ns.groupIDLocked(name) + ns.mu.Unlock() + if n >= maxGroups || id == 0 { + k.sendErr(errListFull, c.trid) + return + } + k.send("ADG", c.trid, ns.bumpVer(), encode(name), strconv.Itoa(id), "0") + case "RMG", "REG": + id, err := strconv.Atoi(c.arg(0)) + ns.mu.Lock() + old, ok := ns.groups[id] + ns.mu.Unlock() + if err != nil || !ok || id == 0 { + k.sendErr(errBadGroup, c.trid) + return + } + to := "" + if c.name == "REG" { + to = strings.TrimSpace(decode(c.arg(1))) + if to == "" || len(to) > 61 { + k.sendErr(errGroupName, c.trid) + return + } + } + ns.mu.Lock() + var moved []store.Friend + for fid, f := range ns.fl { + if f.Group == old { + f.Group = to + ns.fl[fid] = f + moved = append(moved, f) + } + } + if c.name == "RMG" { + delete(ns.groups, id) + } else { + ns.groups[id] = to + } + ns.mu.Unlock() + for _, f := range moved { + st.PutFriend(ns.u.ID, f) + } + if len(moved) > 0 { + ns.s.B.FriendsChanged(ns.u.ID) + } + if c.name == "RMG" { + k.send("RMG", c.trid, ns.bumpVer(), strconv.Itoa(id)) + } else { + k.send("REG", c.trid, ns.bumpVer(), strconv.Itoa(id), encode(to), "0") + } + } +} + +// syncLists has the client told of changes made to its friends and +// blocked lists elsewhere (by AIM, IRC, the BBS). +func (ns *nsSession) syncLists() { + ns.mu.Lock() + synced := ns.synced + oldFL, oldBL := ns.fl, ns.bl + ns.mu.Unlock() + if !synced { + return + } + if err := ns.loadLists(); err != nil { + return + } + ns.mu.Lock() + newFL, newBL := ns.fl, ns.bl + ns.mu.Unlock() + for id, f := range newFL { + if _, ok := oldFL[id]; !ok { + w := []string{"ADD", "0", "FL", ns.bumpVer(), ns.s.handleOfName(f.Name), encode(f.Name)} + if ns.ver >= 7 { + ns.mu.Lock() + w = append(w, strconv.Itoa(ns.groupIDLocked(f.Group))) + ns.mu.Unlock() + } + ns.k.send(w...) + if u, err := ns.s.B.Store.UserByID(id); err == nil { + ns.contactChanged(u) + } + } + } + for id, f := range oldFL { + if _, ok := newFL[id]; !ok { + ns.k.send("REM", "0", "FL", ns.bumpVer(), ns.s.handleOfName(f.Name)) + ns.mu.Lock() + delete(ns.told, id) + ns.mu.Unlock() + } + } + for id := range newBL { + if !oldBL[id] { + if u, err := ns.s.B.Store.UserByID(id); err == nil { + ns.k.send("ADD", "0", "BL", ns.bumpVer(), ns.s.handleOf(u), encode(u.Name)) + } + } + } + for id := range oldBL { + if !newBL[id] { + if u, err := ns.s.B.Store.UserByID(id); err == nil { + ns.k.send("REM", "0", "BL", ns.bumpVer(), ns.s.handleOf(u)) + } + } + } +} + +// reverseChanged: another user's lists changed: whether they have this +// one as a friend (its RL), and what it sees of them. +func (ns *nsSession) reverseChanged(u *store.User) { + ns.mu.Lock() + synced := ns.synced + had := ns.rl[u.ID] + ns.mu.Unlock() + if synced { + has, err := ns.s.B.Store.IsFriend(u.ID, ns.u.ID) + if err == nil && has != had { + ns.mu.Lock() + if has { + ns.rl[u.ID] = true + } else { + delete(ns.rl, u.ID) + } + ns.mu.Unlock() + if has { + ns.k.send("ADD", "0", "RL", ns.bumpVer(), ns.s.handleOf(u), encode(u.Name)) + } else { + ns.k.send("REM", "0", "RL", ns.bumpVer(), ns.s.handleOf(u)) + } + } + } + ns.contactChanged(u) +} diff --git a/internal/msn/msn_test.go b/internal/msn/msn_test.go new file mode 100644 index 0000000..dc759f7 --- /dev/null +++ b/internal/msn/msn_test.go @@ -0,0 +1,604 @@ +package msn + +import ( + "bufio" + "bytes" + "context" + "crypto/md5" + "encoding/hex" + "fmt" + "log" + "net" + "path/filepath" + "strconv" + "strings" + "sync" + "testing" + "time" + + "github.com/D-Modem/bbs/internal/bbs" + "github.com/D-Modem/bbs/internal/ircd" + "github.com/D-Modem/bbs/internal/store" +) + +type syncBuf struct { + mu sync.Mutex + b bytes.Buffer +} + +func (s *syncBuf) Write(p []byte) (int, error) { + s.mu.Lock() + defer s.mu.Unlock() + return s.b.Write(p) +} + +func (s *syncBuf) String() string { + s.mu.Lock() + defer s.mu.Unlock() + return s.b.String() +} + +type env struct { + b *bbs.BBS + srv *Server + addr string // MSN's + ircAddr string +} + +// freeAddr is a loopback address free to listen on. +func freeAddr(t *testing.T) string { + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + defer ln.Close() + return ln.Addr().String() +} + +// start is a BBS (alice, bob, Carol Ann and sysop, all password1; old, +// made before MSN digests were kept) with MSN and IRC servers. +func start(t *testing.T) *env { + t.Helper() + store.BcryptCost = 4 + st, err := store.Open(filepath.Join(t.TempDir(), "bbs.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { st.Close() }) + if _, err := st.CreateUser("old", "password1", "", false); err != nil { + t.Fatal(err) + } + st.SetKeepMSN(true) + for _, name := range []string{"alice", "bob", "Carol Ann", "sysop"} { + if _, err := st.CreateUser(name, "password1", "Here", name == "sysop"); err != nil { + t.Fatal(err) + } + } + s := bbs.Defaults() + s.Name, s.FailDelay = "Test BBS", 0 + logs := &syncBuf{} + b := bbs.New(s, st, log.New(logs, "", 0)) + e := &env{b: b, addr: freeAddr(t), ircAddr: freeAddr(t)} + srv, err := New(b, Settings{Address: e.addr, Domain: "bbs.test", MaxPerIP: 50}) + if err != nil { + t.Fatal(err) + } + e.srv = srv + is, err := ircd.New(b, ircd.Settings{Address: e.ircAddr, ServerName: "irc.test", MaxClients: 10, MaxPerIP: 10}) + if err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithCancel(context.Background()) + var wg sync.WaitGroup + wg.Add(2) + go func() { srv.Run(ctx); wg.Done() }() + go func() { is.Run(ctx); wg.Done() }() + t.Cleanup(func() { + cancel() + wg.Wait() + if t.Failed() { + t.Log("log:\n" + logs.String()) + } + }) + for _, a := range []string{e.addr, e.ircAddr} { + for i := 0; ; i++ { + if c, err := net.Dial("tcp", a); err == nil { + c.Close() + break + } + if i > 100 { + t.Fatal("never listened") + } + time.Sleep(10 * time.Millisecond) + } + } + return e +} + +// client is a scripted MSN client's connection (to the notification +// server or a switchboard). +type client struct { + t *testing.T + c net.Conn + r *bufio.Reader + trid int +} + +func dial(t *testing.T, addr string) *client { + t.Helper() + c, err := net.Dial("tcp", addr) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { c.Close() }) + return &client{t: t, c: c, r: bufio.NewReader(c)} +} + +// cmd sends a command with the next transaction id, which it gives. +func (cl *client) cmd(name string, args ...string) string { + cl.trid++ + id := strconv.Itoa(cl.trid) + cl.c.Write([]byte(strings.Join(append([]string{name, id}, args...), " ") + "\r\n")) + return id +} + +// msg sends a MSG with a text payload. +func (cl *client) msg(ack, text string) string { + cl.trid++ + id := strconv.Itoa(cl.trid) + p := "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n" + text + fmt.Fprintf(cl.c, "MSG %s %s %d\r\n%s", id, ack, len(p), p) + return id +} + +// line is the next line the server sends (and its payload, for a MSG). +func (cl *client) line() (string, string, error) { + cl.c.SetReadDeadline(time.Now().Add(3 * time.Second)) + l, err := cl.r.ReadString('\n') + if err != nil { + return "", "", err + } + l = strings.TrimRight(l, "\r\n") + f := strings.Fields(l) + if len(f) > 0 && (f[0] == "MSG" || f[0] == "NOT") { + n, _ := strconv.Atoi(f[len(f)-1]) + p := make([]byte, n) + if _, err := readFull(cl.r, p); err != nil { + return "", "", err + } + return l, string(p), nil + } + return l, "", nil +} + +// expect reads lines until one beginning with want; it and its payload. +func (cl *client) expect(want string) (string, string) { + cl.t.Helper() + var seen []string + for { + l, p, err := cl.line() + if err != nil { + cl.t.Fatalf("waiting for %q: %v; saw %q", want, err, seen) + } + if strings.HasPrefix(l, want) { + return l, p + } + seen = append(seen, l) + } +} + +// quiet: nothing beginning with any of these comes for a moment. +func (cl *client) quiet(not ...string) { + cl.t.Helper() + cl.c.SetReadDeadline(time.Now().Add(300 * time.Millisecond)) + for { + l, _, err := cl.line() + if err != nil { + return + } + for _, n := range not { + if strings.HasPrefix(l, n) { + cl.t.Errorf("unwanted %q", l) + } + } + } +} + +func digest(salt, pw string) string { + h := md5.Sum([]byte(salt + pw)) + return hex.EncodeToString(h[:]) +} + +// signIn signs a client in by MD5 at MSNP ver; the USR's answer. +func signIn(t *testing.T, addr, handle, pw string, ver int) (*client, string) { + t.Helper() + cl := dial(t, addr) + cl.cmd("VER", fmt.Sprintf("MSNP%d", ver), "CVR0") + if l, _ := cl.expect("VER "); l != fmt.Sprintf("VER 1 MSNP%d", ver) { + t.Fatalf("version %q", l) + } + cl.cmd("INF") + cl.expect("INF 2 MD5") + cl.cmd("USR", "MD5", "I", handle) + l, _ := cl.expect("USR 3 MD5 S ") + salt := strings.Fields(l)[4] + cl.cmd("USR", "MD5", "S", digest(salt, pw)) + l, _, err := cl.line() + if err != nil { + t.Fatal(err) + } + return cl, l +} + +// online signs a client in at MSNP7, takes its lists and sets it online. +func online(t *testing.T, addr, name string) *client { + t.Helper() + cl, l := signIn(t, addr, name+"@bbs.test", "password1", 7) + if !strings.HasPrefix(l, "USR 4 OK ") { + t.Fatalf("%s: %q", name, l) + } + cl.expect("MSG Hotmail Hotmail ") + cl.cmd("SYN", "0") + cl.expect("LST 5 RL ") + cl.cmd("CHG", "NLN") + cl.expect("CHG 6 NLN") + return cl +} + +// switchboard has cl ask for a conversation and join it. +func (cl *client) switchboard(t *testing.T, handle string) *client { + t.Helper() + cl.cmd("XFR", "SB") + l, _ := cl.expect("XFR ") + f := strings.Fields(l) + if len(f) != 6 || f[2] != "SB" || f[4] != "CKI" { + t.Fatalf("xfr %q", l) + } + sc := dial(t, f[3]) + sc.cmd("USR", handle, f[5]) + sc.expect("USR 1 OK " + handle + " ") + return sc +} + +// answer has cl answer a ring (an RNG line) as handle; its switchboard +// connection, and the IRO lines it was told. +func answer(t *testing.T, rng, handle string) (*client, []string) { + t.Helper() + f := strings.Fields(rng) + if len(f) < 7 || f[0] != "RNG" || f[3] != "CKI" { + t.Fatalf("rng %q", rng) + } + sc := dial(t, f[2]) + sc.cmd("ANS", handle, f[4], f[1]) + var iro []string + for { + l, _ := sc.expect("") + if l == "ANS 1 OK" { + return sc, iro + } + if !strings.HasPrefix(l, "IRO 1 ") { + t.Fatalf("answering: %q", l) + } + iro = append(iro, l) + } +} + +type ircConn struct { + t *testing.T + c net.Conn + r *bufio.Reader +} + +func ircLogin(t *testing.T, addr, name string) *ircConn { + t.Helper() + c, err := net.Dial("tcp", addr) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { c.Close() }) + ic := &ircConn{t: t, c: c, r: bufio.NewReader(c)} + ic.send("PASS "+name+":password1", "NICK "+ircd.Nick(name), "USER u 0 * :"+name) + ic.expect(" 001 ") + return ic +} + +func (ic *ircConn) send(lines ...string) { + for _, l := range lines { + ic.c.Write([]byte(l + "\r\n")) + } +} + +func (ic *ircConn) expect(want string) string { + ic.t.Helper() + var seen []string + for { + ic.c.SetReadDeadline(time.Now().Add(3 * time.Second)) + l, err := ic.r.ReadString('\n') + if err != nil { + ic.t.Fatalf("waiting for %q: %v; saw %q", want, err, seen) + } + if strings.Contains(l, want) { + return l + } + seen = append(seen, strings.TrimSpace(l)) + } +} + +func (e *env) user(t *testing.T, name string) *store.User { + t.Helper() + u, err := e.b.Store.UserByName(name) + if err != nil { + t.Fatal(err) + } + return u +} + +// TestSignIn: an MD5 sign-in (the handle at any domain, the name with or +// without its spaces), its profile and lists; a wrong password, an +// unknown handle, a version not served; an account from before digests +// were kept, until its password is used in the clear; MSN 1.0's CTP. +func TestSignIn(t *testing.T) { + e := start(t) + cl, l := signIn(t, e.addr, "alice@hotmail.com", "password1", 7) + if l != "USR 4 OK alice@hotmail.com alice 1" { + t.Errorf("signed in: %q", l) + } + if _, p := cl.expect("MSG Hotmail Hotmail "); !strings.Contains(p, "text/x-msmsgsprofile") { + t.Errorf("profile %q", p) + } + cl.cmd("SYN", "41") + want := []string{"SYN 5 42", "GTC 5 42 A", "BLP 5 42 AL", "LSG 5 42 1 1 0 Other%20Contacts 0", + "LST 5 FL 42 0 0", "LST 5 AL 42 0 0", "LST 5 BL 42 0 0", "LST 5 RL 42 0 0"} + for _, w := range want { + if l, _ := cl.expect(""); l != w { + t.Errorf("got %q, want %q", l, w) + } + } + + _, l = signIn(t, e.addr, "CarolAnn@bbs.test", "password1", 6) + if l != "USR 4 OK CarolAnn@bbs.test Carol%20Ann 1" { + t.Errorf("carol: %q", l) + } + if _, l = signIn(t, e.addr, "bob@bbs.test", "wrong", 5); l != "911 4" { + t.Errorf("wrong password: %q", l) + } + if _, l = signIn(t, e.addr, "nobody@bbs.test", "password1", 5); l != "911 4" { + t.Errorf("unknown: %q", l) + } + nc := dial(t, e.addr) + nc.cmd("VER", "MSNP8", "CVR0") + if l, _ := nc.expect("VER "); l != "VER 1 0" { + t.Errorf("MSNP8: %q", l) + } + + if _, l = signIn(t, e.addr, "old@bbs.test", "password1", 7); l != "911 4" { + t.Errorf("old, no digest: %q", l) + } + if _, err := e.b.Store.CheckPassword("old", "password1"); err != nil { + t.Fatal(err) + } + if _, l = signIn(t, e.addr, "old@bbs.test", "password1", 7); !strings.HasPrefix(l, "USR 4 OK old@bbs.test old") { + t.Errorf("old, with its digest: %q", l) + } + + // MSN 1.0: the password in the clear (MSNP2 only) + cc := dial(t, e.addr) + cc.cmd("VER", "MSNP2") + cc.expect("VER 1 MSNP2") + cc.cmd("USR", "CTP", "I", "sysop@hotmail.com", "password1") + if l, _ := cc.expect("USR "); l != "USR 2 OK sysop@hotmail.com sysop" { + t.Errorf("CTP: %q", l) + } +} + +// TestContacts: adding a friend (the store's friends list, and online at +// once), who sees one on their reverse list; status changes; a block, by +// which one appears offline; removing. +func TestContacts(t *testing.T) { + e := start(t) + alice := online(t, e.addr, "alice") + bob := online(t, e.addr, "bob") + aliceU, bobU := e.user(t, "alice"), e.user(t, "bob") + + tr := alice.cmd("ADD", "FL", "bob@bbs.test", "bob", "0") + if l, _ := alice.expect("ADD " + tr + " "); !strings.HasPrefix(l, "ADD "+tr+" FL ") || !strings.HasSuffix(l, " bob@bbs.test bob 0") { + t.Errorf("add %q", l) + } + if l, _ := alice.expect("ILN " + tr); l != "ILN "+tr+" NLN bob@bbs.test bob" { + t.Errorf("bob on: %q", l) + } + if ok, _ := e.b.Store.IsFriend(aliceU.ID, bobU.ID); !ok { + t.Error("bob is not alice's friend in the store") + } + if l, _ := bob.expect("ADD 0 RL "); !strings.HasSuffix(l, " alice@bbs.test alice") { + t.Errorf("bob's reverse list: %q", l) + } + tr = alice.cmd("ADD", "FL", "bob@bbs.test", "bob", "0") + if l, _ := alice.expect(""); l != "215 "+tr { + t.Errorf("twice: %q", l) + } + tr = alice.cmd("ADD", "FL", "nobody@bbs.test", "nobody", "0") + if l, _ := alice.expect(""); l != "205 "+tr { + t.Errorf("nobody: %q", l) + } + + // statuses and names + bob.cmd("CHG", "BSY") + if l, _ := alice.expect("NLN "); l != "NLN BSY bob@bbs.test bob" { + t.Errorf("busy %q", l) + } + bob.cmd("REA", "bob@bbs.test", "Bobby%20B") + bob.expect("REA ") + if l, _ := alice.expect("NLN "); l != "NLN BSY bob@bbs.test Bobby%20B" { + t.Errorf("renamed %q", l) + } + bob.cmd("CHG", "HDN") + if l, _ := alice.expect("FLN "); l != "FLN bob@bbs.test" { + t.Errorf("hidden %q", l) + } + bob.cmd("CHG", "NLN") + alice.expect("NLN NLN bob@bbs.test") + + // bob blocks alice: offline to her, in the store, her messages refused + tr = bob.cmd("ADD", "BL", "alice@bbs.test", "alice") + bob.expect("ADD " + tr + " BL ") + if l, _ := alice.expect("FLN "); l != "FLN bob@bbs.test" { + t.Errorf("blocked %q", l) + } + if !e.b.Blocks(bobU, aliceU) { + t.Error("not blocked in the store") + } + tr = bob.cmd("REM", "BL", "alice@bbs.test") + bob.expect("REM " + tr + " BL ") + alice.expect("NLN NLN bob@bbs.test") + + // a friend added from elsewhere (IRC, the terminal) comes to the list + if _, err := e.b.AddFriend(aliceU, "Carol Ann"); err != nil { + t.Fatal(err) + } + if l, _ := alice.expect("ADD 0 FL "); !strings.Contains(l, " CarolAnn@bbs.test Carol%20Ann") { + t.Errorf("from elsewhere %q", l) + } + tr = alice.cmd("REM", "FL", "bob@bbs.test") + alice.expect("REM " + tr + " FL ") + if ok, _ := e.b.Store.IsFriend(aliceU.ID, bobU.ID); ok { + t.Error("bob is still alice's friend") + } + bob.expect("REM 0 RL ") +} + +// TestConversation: two MSN clients in a switchboard: a call rung and +// answered, a message both ways (acked, kept), one leaving. +func TestConversation(t *testing.T) { + e := start(t) + alice := online(t, e.addr, "alice") + bob := online(t, e.addr, "bob") + as := alice.switchboard(t, "alice@bbs.test") + tr := as.cmd("CAL", "bob@bbs.test") + if l, _ := as.expect("CAL "); !strings.HasPrefix(l, "CAL "+tr+" RINGING ") { + t.Fatalf("call %q", l) + } + rng, _ := bob.expect("RNG ") + if !strings.HasSuffix(rng, " alice@bbs.test alice") { + t.Errorf("rung %q", rng) + } + bs, iro := answer(t, rng, "bob@bbs.test") + if len(iro) != 1 || iro[0] != "IRO 1 1 1 alice@bbs.test alice" { + t.Errorf("iro %q", iro) + } + if l, _ := as.expect("JOI "); l != "JOI bob@bbs.test bob" { + t.Errorf("joi %q", l) + } + tr = as.msg("A", "hello bob") + if l, p := bs.expect("MSG "); !strings.HasPrefix(l, "MSG alice@bbs.test alice ") || !strings.HasSuffix(p, "\r\n\r\nhello bob") { + t.Errorf("bob got %q %q", l, p) + } + if l, _ := as.expect(""); l != "ACK "+tr { + t.Errorf("ack %q", l) + } + bs.msg("N", "hi alice") + if _, p := as.expect("MSG bob@bbs.test "); !strings.HasSuffix(p, "hi alice") { + t.Errorf("alice got %q", p) + } + cs, err := e.b.Store.ChatsBetween(e.user(t, "alice").ID, e.user(t, "bob").ID, 10) + if err != nil || len(cs) != 2 || cs[0].Text != "hello bob" || !cs[1].Delivered { + t.Errorf("kept %v %v", cs, err) + } + bs.cmd("OUT") + if l, _ := as.expect("BYE "); l != "BYE bob@bbs.test" { + t.Errorf("bye %q", l) + } + tr = as.cmd("CAL", "nobody@bbs.test") + if l, _ := as.expect(""); l != "208 "+tr { + t.Errorf("nobody %q", l) + } +} + +// TestIRC: an MSN client and an IRC user: she is in the conversation at +// once, has its lines as PRIVMSGs, and hers come back into it; once it is +// left, hers ring the client into a new one. One away has the client's +// lines kept, and the client told so. +func TestIRC(t *testing.T) { + e := start(t) + alice := online(t, e.addr, "alice") + carol := ircLogin(t, e.ircAddr, "Carol Ann") + as := alice.switchboard(t, "alice@bbs.test") + as.cmd("CAL", "CarolAnn@bbs.test") + as.expect("CAL ") + if l, _ := as.expect("JOI "); l != "JOI CarolAnn@bbs.test Carol%20Ann" { + t.Errorf("joi %q", l) + } + tr := as.msg("A", "hi carol") + if l := carol.expect(" PRIVMSG Carol_Ann "); !strings.Contains(l, ":alice!") || !strings.HasSuffix(strings.TrimSpace(l), ":hi carol") { + t.Errorf("carol got %q", l) + } + as.expect("ACK " + tr) + carol.send("PRIVMSG alice :hi from IRC") + if l, p := as.expect("MSG "); !strings.HasPrefix(l, "MSG CarolAnn@bbs.test Carol%20Ann ") || !strings.HasSuffix(p, "hi from IRC") { + t.Errorf("alice got %q %q", l, p) + } + + as.cmd("OUT") + carol.send("PRIVMSG alice :still there?") + rng, _ := alice.expect("RNG ") + if !strings.HasSuffix(rng, " CarolAnn@bbs.test Carol%20Ann") { + t.Errorf("rung %q", rng) + } + as2, iro := answer(t, rng, "alice@bbs.test") + if len(iro) != 1 || !strings.Contains(iro[0], " CarolAnn@bbs.test ") { + t.Errorf("iro %q", iro) + } + if _, p := as2.expect("MSG CarolAnn@bbs.test "); !strings.HasSuffix(p, "still there?") { + t.Errorf("queued %q", p) + } + + // carol goes: alice's lines are kept for her, and alice told once + carol.send("QUIT") + for i := 0; len(e.srv.nodesOf("Carol Ann")) > 0; i++ { + if i > 300 { + t.Fatal("carol never went") + } + time.Sleep(10 * time.Millisecond) + } + as2.msg("A", "bye then") + if _, p := as2.expect("MSG BBS@bbs.test BBS "); !strings.Contains(p, "Carol Ann is not on now") { + t.Errorf("told %q", p) + } + as2.expect("ACK ") + if cs, _ := e.b.Store.KeptChats(e.user(t, "Carol Ann").ID); len(cs) != 1 || cs[0].Text != "bye then" { + t.Errorf("kept %v", cs) + } +} + +// TestKept: lines kept while one was away come at their first status, +// rung into a conversation, with their time; a blocked user's do not. +func TestKept(t *testing.T) { + e := start(t) + carol := ircLogin(t, e.ircAddr, "Carol Ann") + carol.send("PRIVMSG bob :are you there?") + carol.expect(" 301 ") + bobU, carolU := e.user(t, "bob"), e.user(t, "Carol Ann") + + bob := online(t, e.addr, "bob") + rng, _ := bob.expect("RNG ") + bs, _ := answer(t, rng, "bob@bbs.test") + if _, p := bs.expect("MSG CarolAnn@bbs.test "); !strings.Contains(p, "while you were away) are you there?") { + t.Errorf("kept %q", p) + } + if cs, _ := e.b.Store.KeptChats(bobU.ID); len(cs) != 0 { + t.Errorf("still kept %v", cs) + } + + // bob blocks carol: her messages are refused, now and while he is away + tr := bob.cmd("ADD", "BL", "CarolAnn@bbs.test", "Carol%20Ann") + bob.expect("ADD " + tr + " BL ") + carol.send("PRIVMSG bob :hello?") + if l := carol.expect(" 404 "); !strings.Contains(l, "not taking your messages") { + t.Errorf("carol told %q", l) + } + bs.quiet("MSG CarolAnn") + bob.quiet("RNG ") + if !e.b.Blocks(bobU, carolU) { + t.Error("not blocked") + } +} diff --git a/internal/msn/ns.go b/internal/msn/ns.go new file mode 100644 index 0000000..f2e35bd --- /dev/null +++ b/internal/msn/ns.go @@ -0,0 +1,481 @@ +package msn + +import ( + "crypto/subtle" + "errors" + "fmt" + "io" + "net" + "strconv" + "strings" + "sync" + "time" + + "github.com/D-Modem/bbs/internal/bbs" + "github.com/D-Modem/bbs/internal/store" +) + +// statuses a client may set +var statuses = map[string]string{"NLN": "online", "BSY": "busy", "IDL": "idle", "BRB": "be right back", + "AWY": "away", "PHN": "on the phone", "LUN": "out to lunch", "HDN": "appearing offline"} + +// nsSession is a client signed in to the notification server, on a node +// of its own. +type nsSession struct { + s *Server + k *conn + host string + ver int + u *store.User + n *bbs.Node + handle string // as signed in + + loginTrid string // its USR S's + + todo chan func() + done chan struct{} + once sync.Once + + mu sync.Mutex + friendly string // its display name + status string // "" until its first CHG + blp string // AL: all may see it; BL: only its friends + gtc string + listVer int + synced bool // has had its lists (SYN) + fl map[int64]store.Friend // its friends, as last told + rl map[int64]bool // who has it as a friend, as last told + bl map[int64]bool // its blocked list, as last told + groups map[int]string // MSNP7 group ids: names ("" is 0, Other Contacts) + told map[int64]string // what it was last told of each friend's status ("": offline) + noted map[int64]bool // told that these are away (their messages kept) + keptSent bool +} + +// notification serves a notification session: the sign-in (begun with +// first, a VER), then its commands until it goes. +func (s *Server) notification(k *conn, host string, first *cmd) { + ns := &nsSession{s: s, k: k, host: host, todo: make(chan func(), queueLen), done: make(chan struct{}), + blp: "AL", gtc: "A", fl: map[int64]store.Friend{}, rl: map[int64]bool{}, bl: map[int64]bool{}, + groups: map[int]string{0: ""}, told: map[int64]string{}, noted: map[int64]bool{}} + if !ns.signIn(first) { + return + } + u := ns.u + n, err := s.B.Enter(&bbs.Caller{Via: "msn", Listener: "msn", Remote: host, Source: "ip:" + host, + Terminal: fmt.Sprintf("MSNP%d", ns.ver)}, ns.close) + if err != nil { + k.sendErr(errBusy, ns.loginTrid) + return + } + ns.n = n + n.SetUser(u) + n.Doing("MSN") + // one session an account (MSNP2-7 had no more): the older is told it + // signed in elsewhere + for _, o := range s.sessionsOf(u.ID) { + o.do(func() { + o.k.send("OUT", "OTH") + o.close() + }) + } + if err := ns.loadLists(); err != nil { + s.B.Log.Printf("node %d: msn: lists: %v", n.Num, err) + } + s.register(ns) + s.B.Log.Printf("node %d: %s on MSN (%s, MSNP%d)", n.Num, u.Name, host, ns.ver) + defer func() { + ns.close() + s.unregister(ns) + s.leaveSwitchboards(ns) + n.Leave() + s.B.Log.Printf("node %d: gone (msn)", n.Num) + s.changed(u) + }() + ok := []string{"USR", ns.loginTrid, "OK", ns.handle, encode(ns.friendly)} + if ns.ver >= 6 { + ok = append(ok, "1") // its e-mail address verified + } + ns.k.send(ok...) + ns.profile() + go ns.events() + ns.serve() +} + +// signIn is VER, INF, CVR and USR, up to a user checked (false: it failed; +// the connection is closed). +func (ns *nsSession) signIn(c *cmd) bool { + s := ns.s + var salt string + var target *store.User + for range 12 { + switch c.name { + case "VER": + ns.ver = 0 + for _, a := range c.args { + if v, ok := strings.CutPrefix(strings.ToUpper(a), "MSNP"); ok { + if n, err := strconv.Atoi(v); err == nil && n >= minVersion && n <= maxVersion && n > ns.ver { + ns.ver = n + } + } + } + if ns.ver == 0 { + ns.k.send("VER", c.trid, "0") + s.B.Log.Printf("msn: %s: a client for %s, which is not served (MSNP%d to %d are)", + ns.host, strings.Join(c.args, " "), minVersion, maxVersion) + return false + } + ns.k.send("VER", c.trid, fmt.Sprintf("MSNP%d", ns.ver)) + case "INF": + ns.k.send("INF", c.trid, "MD5") + case "CVR", "CVQ": + ns.cvr(c) + case "USR": + pkg, stage := strings.ToUpper(c.arg(0)), strings.ToUpper(c.arg(1)) + switch { + case pkg == "MD5" && stage == "I": + ns.handle = c.arg(2) + target = s.resolve(ns.handle) + if target != nil { + var err error + if salt, err = s.B.Store.MSNSalt(target.ID); err != nil { + s.B.Log.Printf("msn: the salt of %s: %v", target.Name, err) + } + } + if salt == "" { + salt = randomHex(10) // an unknown handle is challenged too; its sign-in fails + } + ns.k.send("USR", c.trid, "MD5", "S", salt) + case pkg == "MD5" && stage == "S" && salt != "": + ns.loginTrid = c.trid + u, err := ns.md5Login(target, salt, c.arg(2)) + return ns.signedIn(c.trid, u, err) + case pkg == "CTP" && stage == "I" && ns.ver == 2: + ns.handle = c.arg(2) + ns.loginTrid = c.trid + u, err := ns.passwordLogin(c.arg(2), decode(c.arg(3))) + return ns.signedIn(c.trid, u, err) + default: + ns.k.sendErr(errAuth, c.trid) + return false + } + case "OUT": + return false + default: + ns.k.sendErr(errNotLoggedIn, c.trid) + } + var err error + if c, err = ns.k.read(); err != nil { + return false + } + } + return false +} + +// signedIn finishes a sign-in: the user, or the error told (false). +func (ns *nsSession) signedIn(trid string, u *store.User, err error) bool { + if err == nil { + err = ns.s.may(u) + } + if err != nil { + code := errAuth + if errors.Is(err, bbs.ErrNotAllowed) { + code = errNotAllowed + } + ns.k.sendErr(code, trid) + return false + } + ns.u = u + ns.friendly = u.Name + if !strings.Contains(ns.handle, "@") { + ns.handle = ns.s.handleOf(u) + } + return true +} + +// md5Login checks an MD5 sign-in's digest against the account's. +func (ns *nsSession) md5Login(target *store.User, salt, digest string) (*store.User, error) { + s := ns.s + name := ns.handle + if target != nil { + name = target.Name + } + var stale bool + u, err := s.B.AuthenticateBy("msn", "ip:"+ns.host, name, func() (*store.User, error) { + if target == nil { + return nil, store.ErrNotFound + } + ksalt, d, ok, err := s.B.Store.MSNKey(target.ID) + if err != nil { + return nil, err + } + if !ok || ksalt != salt { + stale = true + return nil, store.ErrNotFound + } + if subtle.ConstantTimeCompare([]byte(d), []byte(strings.ToLower(digest))) != 1 { + return nil, store.ErrNotFound + } + return target, nil + }) + if stale && target != nil { + s.B.Log.Printf("msn: %s: %s has no MSN password digest yet: log in once by another way "+ + "(telnet, IRC, AIM, the web) or set the password again", ns.host, target.Name) + } + return u, err +} + +// passwordLogin checks a password sent in the clear (CTP, MSN 1.0). +func (ns *nsSession) passwordLogin(handle, pw string) (*store.User, error) { + name := handle + if u := ns.s.resolve(handle); u != nil { + name = u.Name + } + return ns.s.B.Authenticate("msn", "ip:"+ns.host, name, pw) +} + +// cvr answers a client's version: whatever it is, it is current. +func (ns *nsSession) cvr(c *cmd) { + v := c.arg(5) + if v == "" { + v = "1.0.0863" + } + site := ns.s.S.Site + if site == "" { + site = "http://" + ns.s.S.Domain + "/" + } + ns.k.send("CVR", c.trid, v, v, v, site, site) +} + +// profile is the initial profile message after sign-in. +func (ns *nsSession) profile() { + p := fmt.Sprintf("MIME-Version: 1.0\r\nContent-Type: text/x-msmsgsprofile; charset=UTF-8\r\n"+ + "LoginTime: %d\r\nEmailEnabled: 0\r\nMemberIdHigh: 0\r\nMemberIdLow: %d\r\n"+ + "lang_preference: 1033\r\npreferredEmail: \r\ncountry: \r\nPostalCode: \r\nGender: \r\n"+ + "Kid: 0\r\nAge: \r\nsid: 507\r\nkv: 2\r\nMSPAuth: %s\r\nClientIP: %s\r\nClientPort: 0\r\n\r\n", + time.Now().Unix(), ns.u.ID, randomHex(16), ns.host) + ns.k.sendPayload([]byte(p), "MSG", "Hotmail", "Hotmail") +} + +// closed reports that the session is over. +func (ns *nsSession) closed() bool { + select { + case <-ns.done: + return true + default: + return false + } +} + +// close ends the session. +func (ns *nsSession) close() { + ns.once.Do(func() { + close(ns.done) + ns.k.close() + }) +} + +// do has the session's goroutine do f (dropped if too much waits). +func (ns *nsSession) do(f func()) { + select { + case ns.todo <- f: + case <-ns.done: + default: + ns.s.B.Log.Printf("node %d: msn: too much waiting; dropped", ns.n.Num) + } +} + +// online: it has set a status (its first CHG). +func (ns *nsSession) online() bool { + ns.mu.Lock() + defer ns.mu.Unlock() + return ns.status != "" +} + +// statusNow is its status ("" before its first CHG). +func (ns *nsSession) statusNow() string { + ns.mu.Lock() + defer ns.mu.Unlock() + return ns.status +} + +// friendlyName is its display name. +func (ns *nsSession) friendlyName() string { + ns.mu.Lock() + defer ns.mu.Unlock() + return ns.friendly +} + +// events gives the client what its node is told, and does what the +// server asks of the session, until it goes. +func (ns *nsSession) events() { + for { + select { + case <-ns.done: + return + case f := <-ns.todo: + f() + case <-ns.n.Wake(): + if !ns.online() { + continue // held until it sets a status (its first CHG drains them) + } + ns.drain() + } + } +} + +// drain gives the client the node's events waiting. +func (ns *nsSession) drain() { + for _, e := range ns.n.Pending() { + ns.event(e) + } +} + +// serve reads the client's commands until it goes. +func (ns *nsSession) serve() { + for { + ns.k.c.SetDeadline(time.Now().Add(idleTimeout)) + c, err := ns.k.read() + if err != nil { + if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) && !ns.closed() { + ns.s.B.Log.Printf("node %d: msn: %v", ns.n.Num, err) + } + return + } + if c.name == "" { + continue + } + if c.name == "OUT" { + ns.k.send("OUT") + return + } + done := make(chan struct{}) + ns.do(func() { + defer close(done) + ns.command(c) + }) + select { + case <-done: + case <-ns.done: + return + } + } +} + +// command does a command (in the session's goroutine). +func (ns *nsSession) command(c *cmd) { + k := ns.k + switch c.name { + case "PNG": + k.send("QNG") + case "CVR", "CVQ": + ns.cvr(c) + case "INF": + k.send("INF", c.trid, "MD5") + case "SYN": + ns.syn(c) + case "LST": + ns.lst(c) + case "LSG": + ns.lsg(c) + case "CHG": + ns.chg(c) + case "ADD": + ns.add(c) + case "REM": + ns.rem(c) + case "REA": + ns.rea(c) + case "ADG", "RMG", "REG": + ns.group(c) + case "BLP": + if m := strings.ToUpper(c.arg(0)); m == "AL" || m == "BL" { + ns.mu.Lock() + ns.blp = m + ns.mu.Unlock() + k.send("BLP", c.trid, ns.bumpVer(), m) + ns.s.changed(ns.u) + } else { + k.sendErr(errBadParam, c.trid) + } + case "GTC": + if m := strings.ToUpper(c.arg(0)); m == "A" || m == "N" { + ns.mu.Lock() + ns.gtc = m + ns.mu.Unlock() + k.send("GTC", c.trid, ns.bumpVer(), m) + } else { + k.sendErr(errBadParam, c.trid) + } + case "XFR": + if strings.ToUpper(c.arg(0)) != "SB" { + k.sendErr(errBadParam, c.trid) + return + } + if st := ns.statusNow(); st == "" || st == "HDN" { + k.sendErr(errNoSB, c.trid) // offline or hidden: no conversations + return + } + sb := ns.s.newSwitchboard() + ck := ns.s.newCookie(sb, ns, "") + k.send("XFR", c.trid, "SB", ns.s.reachHost(k.c), "CKI", ck) + case "QRY": + k.send("QRY", c.trid) + case "URL": + if ns.s.S.Site == "" { + k.sendErr(errDisabled, c.trid) + return + } + k.send("URL", c.trid, ns.s.S.Site, ns.s.S.Site, "2") + case "SND", "SDC", "FND", "PAG", "IMS": + k.sendErr(errDisabled, c.trid) + case "USR", "VER": + k.sendErr(errSyntax, c.trid) + default: + k.sendErr(errSyntax, c.trid) + } +} + +// chg sets its status; the first also tells it who of its friends is on, +// and gives it what was kept for it. +func (ns *nsSession) chg(c *cmd) { + st := strings.ToUpper(c.arg(0)) + if st == "FLN" { + st = "HDN" + } + if _, ok := statuses[st]; !ok { + ns.k.sendErr(errBadParam, c.trid) + return + } + ns.mu.Lock() + first := ns.status == "" + ns.status = st + ns.mu.Unlock() + ns.k.send("CHG", c.trid, c.arg(0)) + doing := "MSN" + if st != "NLN" { + doing += " (" + statuses[st] + ")" + } + ns.n.Doing(doing) + if first { + ns.allContacts(c.trid) + ns.drain() + ns.deliverKept() + } + ns.s.changed(ns.u) +} + +// bumpVer is the list version after a change. +func (ns *nsSession) bumpVer() string { + ns.mu.Lock() + defer ns.mu.Unlock() + ns.listVer++ + return strconv.Itoa(ns.listVer) +} + +// ver is the list version now. +func (ns *nsSession) verNow() string { + ns.mu.Lock() + defer ns.mu.Unlock() + return strconv.Itoa(ns.listVer) +} diff --git a/internal/msn/presence.go b/internal/msn/presence.go new file mode 100644 index 0000000..76668ea --- /dev/null +++ b/internal/msn/presence.go @@ -0,0 +1,120 @@ +package msn + +import ( + "github.com/D-Modem/bbs/internal/store" +) + +// statusFor is the status viewer sees of u ("": offline). A user blocking +// the viewer, appearing offline, or (BLP BL) not having the viewer as a +// friend is offline to them; one on MSN has the status they set there; +// one on the BBS by any other route is online. +func (s *Server) statusFor(u, viewer *store.User) string { + if s.B.Blocks(u, viewer) { + return "" + } + best := "" + for _, ns := range s.sessionsOf(u.ID) { + ns.mu.Lock() + st, blp := ns.status, ns.blp + ns.mu.Unlock() + if st == "" { + continue + } + if st == "HDN" { + return "" + } + if blp == "BL" { + if ok, _ := s.B.Store.IsFriend(u.ID, viewer.ID); !ok { + return "" + } + } + if best == "" || st == "NLN" { + best = st + } + } + if best != "" { + return best + } + for _, n := range s.nodesOf(u.Name) { + if s.onNode(n.Num) == nil { + return "NLN" + } + } + return "" +} + +// friendlyFor is u's display name: as set on MSN, or their name. +func (s *Server) friendlyFor(u *store.User) string { + for _, ns := range s.sessionsOf(u.ID) { + if f := ns.friendlyName(); f != "" { + return f + } + } + return u.Name +} + +// renamed: a user's display name changed: those watching them are told. +func (s *Server) renamed(u *store.User) { + for _, x := range s.all() { + x.do(func() { + x.mu.Lock() + _, ok := x.fl[u.ID] + st := x.told[u.ID] + x.mu.Unlock() + if ok && st != "" && x.online() { + x.k.send("NLN", st, s.handleOf(u), encode(s.friendlyFor(u))) + } + }) + } +} + +// allContacts tells a client signing in which of its friends are on (ILN, +// on its first CHG's transaction). +func (ns *nsSession) allContacts(trid string) { + ns.mu.Lock() + fs := make([]store.Friend, 0, len(ns.fl)) + for _, f := range ns.fl { + fs = append(fs, f) + } + ns.mu.Unlock() + for _, f := range fs { + u, err := ns.s.B.Store.UserByID(f.ID) + if err != nil { + continue + } + st := ns.s.statusFor(u, ns.u) + ns.mu.Lock() + ns.told[f.ID] = st + ns.mu.Unlock() + if st != "" { + ns.k.send("ILN", trid, st, ns.s.handleOf(u), encode(ns.s.friendlyFor(u))) + } + } +} + +// contactChanged tells the client a friend's status, if it differs from +// what it was last told. +func (ns *nsSession) contactChanged(u *store.User) { + if u.ID == ns.u.ID || !ns.online() { + return + } + ns.mu.Lock() + _, ok := ns.fl[u.ID] + was := ns.told[u.ID] + ns.mu.Unlock() + if !ok { + return + } + st := ns.s.statusFor(u, ns.u) + if st == was { + return + } + ns.mu.Lock() + ns.told[u.ID] = st + ns.mu.Unlock() + if st == "" { + ns.k.send("FLN", ns.s.handleOf(u)) + return + } + ns.k.send("NLN", st, ns.s.handleOf(u), encode(ns.s.friendlyFor(u))) +} diff --git a/internal/msn/sb.go b/internal/msn/sb.go new file mode 100644 index 0000000..caad8bb --- /dev/null +++ b/internal/msn/sb.go @@ -0,0 +1,559 @@ +package msn + +import ( + "errors" + "fmt" + "io" + "net" + "strconv" + "strings" + "sync" + "time" + + "github.com/D-Modem/bbs/internal/bbs" + "github.com/D-Modem/bbs/internal/store" +) + +// A switchboard is a conversation: the MSN clients joined to it, each by +// a connection of its own, and the BBS users in it by other routes (IRC, +// AIM, a terminal), who are "virtual": what is said goes to them as +// private messages, and theirs comes back into it. + +// switchboard is one conversation. +type switchboard struct { + id string + s *Server + + mu sync.Mutex + joined []*sbConn + virtual []*virtual + invited map[int64]bool // users rung and not yet answered + queue map[int64][][]byte // MSG lines waiting for a user to answer + closed bool +} + +// virtual is one in a conversation by another route (u nil: the BBS's +// notices). +type virtual struct { + u *store.User + handle string + friendly string +} + +// sbConn is an MSN client's connection to a switchboard. +type sbConn struct { + k *conn + sb *switchboard + ns *nsSession + handle string + once sync.Once +} + +// sbCookie lets a client join a switchboard: by USR (the one that asked +// for it) or ANS (one rung). +type sbCookie struct { + sb *switchboard + ns *nsSession + answer bool + expires time.Time +} + +// newSwitchboard makes a conversation. +func (s *Server) newSwitchboard() *switchboard { + s.mu.Lock() + defer s.mu.Unlock() + sb := &switchboard{id: strconv.Itoa(s.nextSB), s: s, invited: map[int64]bool{}, queue: map[int64][][]byte{}} + s.nextSB++ + s.sbs[sb.id] = sb + return sb +} + +// newCookie is a cookie to join sb, for ns's client. +func (s *Server) newCookie(sb *switchboard, ns *nsSession, kind string) string { + ck := fmt.Sprintf("%d.%d", time.Now().UnixNano()%1000000000, randomNum()) + s.mu.Lock() + defer s.mu.Unlock() + for key, v := range s.cookies { + if time.Now().After(v.expires) { + delete(s.cookies, key) + } + } + s.cookies[ck] = &sbCookie{sb: sb, ns: ns, answer: kind == "ans", expires: time.Now().Add(cookieLife)} + return ck +} + +// randomNum is a random decimal number of 10 digits. +func randomNum() uint64 { + h := randomHex(8) + n, _ := strconv.ParseUint(h, 16, 64) + return n%9000000000 + 1000000000 +} + +// takeCookie spends a cookie (nil: none such, or expired). +func (s *Server) takeCookie(ck string) *sbCookie { + s.mu.Lock() + defer s.mu.Unlock() + k := s.cookies[ck] + delete(s.cookies, ck) + if k == nil || time.Now().After(k.expires) { + return nil + } + return k +} + +// switchboardConn serves a client's switchboard connection, begun with +// first (USR or ANS). +func (s *Server) switchboardConn(k *conn, host string, first *cmd) { + var ck *sbCookie + var handle string + switch first.name { + case "USR": + handle = first.arg(0) + ck = s.takeCookie(first.arg(1)) + if ck != nil && ck.answer { + ck = nil + } + case "ANS": + handle = first.arg(0) + ck = s.takeCookie(first.arg(1)) + if ck != nil && (!ck.answer || ck.sb.id != first.arg(2)) { + ck = nil + } + } + if ck == nil || ck.ns.closed() { + k.sendErr(errAuth, first.trid) + return + } + if u := s.resolve(handle); u == nil || u.ID != ck.ns.u.ID { + k.sendErr(errAuth, first.trid) + return + } + sc := &sbConn{k: k, sb: ck.sb, ns: ck.ns, handle: ck.ns.handle} + if !ck.sb.join(sc, first) { + k.sendErr(errNoSB, first.trid) + return + } + defer sc.leave(false) + for { + k.c.SetDeadline(time.Now().Add(sbIdle)) + c, err := k.read() + if err != nil { + var ne net.Error + if errors.As(err, &ne) && ne.Timeout() { + sc.leave(true) + } else if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) { + s.B.Log.Printf("node %d: msn switchboard: %v", sc.ns.n.Num, err) + } + return + } + switch c.name { + case "": + case "OUT": + return + case "CAL": + sc.call(c) + case "MSG": + sc.msg(c) + default: + k.sendErr(errSyntax, c.trid) + } + if sc.ns.closed() { + return + } + } +} + +// join puts a client in the conversation: USR, the one that asked for +// it; ANS, one rung, who is told who is there (IRO) and the others that +// it came (JOI). +func (sb *switchboard) join(sc *sbConn, first *cmd) bool { + sb.mu.Lock() + if sb.closed { + sb.mu.Unlock() + return false + } + friendly := encode(sc.ns.friendlyName()) + uid := sc.ns.u.ID + if first.name == "USR" { + sb.joined = append(sb.joined, sc) + sb.mu.Unlock() + sc.k.send("USR", first.trid, "OK", sc.handle, friendly) + return true + } + var others [][2]string + for _, o := range sb.joined { + others = append(others, [2]string{o.handle, encode(o.ns.friendlyName())}) + } + for _, v := range sb.virtual { + others = append(others, [2]string{v.handle, encode(v.friendly)}) + } + tell := append([]*sbConn(nil), sb.joined...) + sb.joined = append(sb.joined, sc) + delete(sb.invited, uid) + queued := sb.queue[uid] + delete(sb.queue, uid) + sb.mu.Unlock() + for i, o := range others { + sc.k.send("IRO", first.trid, strconv.Itoa(i+1), strconv.Itoa(len(others)), o[0], o[1]) + } + sc.k.send("ANS", first.trid, "OK") + for _, o := range tell { + o.k.send("JOI", sc.handle, friendly) + } + for _, m := range queued { + sc.k.write(m) + } + return true +} + +// leave takes a client out (timeout: for idling); the others are told, +// and a conversation with no client left ends. +func (sc *sbConn) leave(timeout bool) { + sc.once.Do(func() { + sb := sc.sb + sb.mu.Lock() + for i, o := range sb.joined { + if o == sc { + sb.joined = append(sb.joined[:i], sb.joined[i+1:]...) + break + } + } + rest := append([]*sbConn(nil), sb.joined...) + empty := len(sb.joined) == 0 && len(sb.invited) == 0 + if empty { + sb.closed = true + } + sb.mu.Unlock() + for _, o := range rest { + if timeout { + o.k.send("BYE", sc.handle, "1") + } else { + o.k.send("BYE", sc.handle) + } + } + if empty { + sb.s.dropSwitchboard(sb) + } + sc.k.close() + }) +} + +// dropSwitchboard forgets a conversation. +func (s *Server) dropSwitchboard(sb *switchboard) { + s.mu.Lock() + delete(s.sbs, sb.id) + for key, v := range s.cookies { + if v.sb == sb { + delete(s.cookies, key) + } + } + s.mu.Unlock() +} + +// leaveSwitchboards takes a client that signed out out of its +// conversations. +func (s *Server) leaveSwitchboards(ns *nsSession) { + s.mu.Lock() + sbs := make([]*switchboard, 0, len(s.sbs)) + for _, sb := range s.sbs { + sbs = append(sbs, sb) + } + s.mu.Unlock() + for _, sb := range sbs { + sb.mu.Lock() + var mine []*sbConn + for _, o := range sb.joined { + if o.ns == ns { + mine = append(mine, o) + } + } + delete(sb.invited, ns.u.ID) + delete(sb.queue, ns.u.ID) + sb.mu.Unlock() + for _, o := range mine { + o.leave(false) + } + } +} + +// has reports whether the user is in the conversation, joined, rung or +// by another route. +func (sb *switchboard) has(id int64) bool { + for _, o := range sb.joined { + if o.ns.u.ID == id { + return true + } + } + for _, v := range sb.virtual { + if v.u != nil && v.u.ID == id { + return true + } + } + return sb.invited[id] +} + +// call is CAL: a user asked into the conversation. One on MSN is rung +// (RNG) at each of their sessions; one on the BBS another way is in it at +// once, by that route. +func (sc *sbConn) call(c *cmd) { + s := sc.sb.s + t := s.resolve(c.arg(0)) + switch { + case t == nil: + sc.k.sendErr(errBadHandle, c.trid) + return + case t.ID == sc.ns.u.ID: + sc.k.sendErr(errBadParam, c.trid) + return + } + sb := sc.sb + sb.mu.Lock() + in := sb.has(t.ID) + sb.mu.Unlock() + if in { + sc.k.sendErr(errAlreadyThere, c.trid) + return + } + if s.statusFor(t, sc.ns.u) == "" { + sc.k.sendErr(errNotOnline, c.trid) + return + } + var ring []*nsSession + for _, o := range s.sessionsOf(t.ID) { + if st := o.statusNow(); st != "" && st != "HDN" { + ring = append(ring, o) + } + } + sc.k.send("CAL", c.trid, "RINGING", sb.id) + if len(ring) > 0 { + sb.mu.Lock() + sb.invited[t.ID] = true + sb.mu.Unlock() + for _, o := range ring { + sb.ring(o, sc.handle, sc.ns.friendlyName()) + } + return + } + v := &virtual{u: t, handle: s.handleOf(t), friendly: t.Name} + sb.mu.Lock() + sb.virtual = append(sb.virtual, v) + sb.mu.Unlock() + sc.k.send("JOI", v.handle, encode(v.friendly)) +} + +// ring has a client asked to answer the conversation (RNG), as from one +// in it. +func (sb *switchboard) ring(o *nsSession, fromHandle, fromFriendly string) { + sb.expireInvite(o.u.ID) + ck := sb.s.newCookie(sb, o, "ans") + host := sb.s.reachHost(o.k.c) + o.do(func() { o.k.send("RNG", sb.id, host, "CKI", ck, fromHandle, encode(fromFriendly)) }) +} + +// msg is MSG: a message to the others. Text goes to each client in the +// conversation and, as a private message, to those in it by other routes; +// anything else (typing, invitations) only to the clients. +func (sc *sbConn) msg(c *cmd) { + ack := strings.ToUpper(c.arg(0)) + m := parseMIME(c.payload) + text := "" + if strings.HasPrefix(m.contentType(), "text/plain") { + text = strings.Join(strings.Fields(strings.ReplaceAll(m.body, "\r\n", "\n")), " ") + } + sb := sc.sb + sb.mu.Lock() + var to []*sbConn + for _, o := range sb.joined { + if o != sc { + to = append(to, o) + } + } + vs := append([]*virtual(nil), sb.virtual...) + sb.mu.Unlock() + fail := func() { + if ack == "A" || ack == "N" || ack == "D" { + sc.k.send("NAK", c.trid) + } + } + if len(to) == 0 && (text == "" || len(vs) == 0) { + fail() + return + } + n := sc.ns.n + if text != "" { + if err := n.Throttle(); err != nil { + fail() + return + } + } + line := append([]byte(fmt.Sprintf("MSG %s %s %d\r\n", sc.handle, encode(sc.ns.friendlyName()), len(c.payload))), + c.payload...) + kept := map[int64]bool{} + for _, o := range to { + if text != "" && !kept[o.ns.u.ID] { + kept[o.ns.u.ID] = true + n.Keep(o.ns.u, text, true) // kept before it is seen + } + o.k.write(line) + } + ok := len(to) > 0 + for _, v := range vs { + if v.u == nil || text == "" { + continue + } + online, err := n.TellUser(v.u, text) + switch { + case errors.Is(err, bbs.ErrBlocked): + continue + case err != nil: + sc.ns.s.B.Log.Printf("node %d: msn: to %s: %v", n.Num, v.u.Name, err) + continue + } + ok = true + if !online { + sc.ns.noteAway(sc, v) + } + } + if !ok { + fail() + return + } + if ack == "A" || ack == "D" { + sc.k.send("ACK", c.trid) + } +} + +// noteAway tells a client (once) that one it talks with went, and will +// have its messages when they are next on. +func (ns *nsSession) noteAway(sc *sbConn, v *virtual) { + ns.mu.Lock() + noted := ns.noted[v.u.ID] + ns.noted[v.u.ID] = true + ns.mu.Unlock() + if noted { + return + } + text := v.u.Name + " is not on now; they will have your messages when they next sign on." + p := textPayload(text) + sc.k.write(append([]byte(fmt.Sprintf("MSG %s %s %d\r\n", ns.s.systemHandle(), encode(ns.s.S.System), len(p))), p...)) +} + +// fromOther gives a client a line from one in the conversation by another +// route (or the BBS's notices): now if it has joined, else when it +// answers. +func (sb *switchboard) fromOther(ns *nsSession, v *virtual, text string) bool { + p := textPayload(text) + line := append([]byte(fmt.Sprintf("MSG %s %s %d\r\n", v.handle, encode(v.friendly), len(p))), p...) + sb.mu.Lock() + if sb.closed { + sb.mu.Unlock() + return false + } + var to []*sbConn + for _, o := range sb.joined { + if o.ns == ns { + to = append(to, o) + } + } + if len(to) == 0 { + if !sb.invited[ns.u.ID] { + sb.mu.Unlock() + return false + } + sb.queue[ns.u.ID] = append(sb.queue[ns.u.ID], line) + sb.mu.Unlock() + return true + } + sb.mu.Unlock() + for _, o := range to { + o.k.write(line) + } + return true +} + +// virtualOf is the one by another route (handle) in the conversation +// (nil: none). +func (sb *switchboard) virtualOf(handle string) *virtual { + for _, v := range sb.virtual { + if strings.EqualFold(v.handle, handle) { + return v + } + } + return nil +} + +// deliverFrom gives a client a line from one not on MSN (u nil: the BBS's +// notices): into a conversation it has with them, or a new one it is rung +// to. +func (s *Server) deliverFrom(ns *nsSession, u *store.User, text string) { + v := &virtual{handle: s.systemHandle(), friendly: s.S.System} + if u != nil { + v = &virtual{u: u, handle: s.handleOf(u), friendly: u.Name} + } + s.mu.Lock() + var best *switchboard + for _, sb := range s.sbs { + sb.mu.Lock() + mine := sb.invited[ns.u.ID] + for _, o := range sb.joined { + if o.ns == ns { + mine = true + } + } + if mine && sb.virtualOf(v.handle) != nil && !sb.closed { + if best == nil || sbNewer(sb, best) { + best = sb + } + } + sb.mu.Unlock() + } + s.mu.Unlock() + if best != nil { + best.mu.Lock() + if x := best.virtualOf(v.handle); x != nil { + v = x + } + best.mu.Unlock() + if best.fromOther(ns, v, text) { + return + } + } + sb := s.newSwitchboard() + sb.mu.Lock() + sb.virtual = append(sb.virtual, v) + sb.invited[ns.u.ID] = true + sb.mu.Unlock() + sb.fromOther(ns, v, text) + sb.expireInvite(ns.u.ID) + ck := s.newCookie(sb, ns, "ans") + ns.k.send("RNG", sb.id, s.reachHost(ns.k.c), "CKI", ck, v.handle, encode(v.friendly)) +} + +// sbNewer: a was made after b. +func sbNewer(a, b *switchboard) bool { + x, _ := strconv.Atoi(a.id) + y, _ := strconv.Atoi(b.id) + return x > y +} + +// expireInvite forgets a user's invitation if they have not answered once +// their cookie is spent; a conversation left with no one in it ends. +func (sb *switchboard) expireInvite(id int64) { + time.AfterFunc(cookieLife+time.Second, func() { + sb.mu.Lock() + if !sb.invited[id] || sb.closed { + sb.mu.Unlock() + return + } + delete(sb.invited, id) + delete(sb.queue, id) + empty := len(sb.joined) == 0 && len(sb.invited) == 0 + if empty { + sb.closed = true + } + sb.mu.Unlock() + if empty { + sb.s.dropSwitchboard(sb) + } + }) +} diff --git a/internal/msn/server.go b/internal/msn/server.go new file mode 100644 index 0000000..b5b6c2f --- /dev/null +++ b/internal/msn/server.go @@ -0,0 +1,297 @@ +// Package msn is an MSN Messenger server (MSNP) for the BBS's chat, beside +// its IRC and AIM servers: MSN Messenger clients sign in with BBS names +// and passwords; their contact list is the user's friends list; an IM is +// a private message (a PRIVMSG to an IRC user, a line on a caller's +// terminal, an IM on AIM), kept for one away. +// +// It speaks MSNP2 to MSNP7: MSN Messenger 1.0 to 4.7 and Windows +// Messenger 4.x, which sign in by MD5 (or, MSN 1.0, by the password in +// the clear) over plain TCP. Later versions sign in by Passport over +// HTTPS, not served here yet. +// +// One port (1863) serves the whole of it: the dispatch and notification +// server (a client's first command is VER) and the switchboards, the +// conversations (a client's first command is USR with a cookie, or ANS). +package msn + +import ( + "bufio" + "context" + "crypto/rand" + "encoding/hex" + "errors" + "fmt" + "net" + "strings" + "sync" + "time" + + "github.com/D-Modem/bbs/internal/bbs" + "github.com/D-Modem/bbs/internal/sockets" + "github.com/D-Modem/bbs/internal/store" + "github.com/D-Modem/bbs/internal/tcpserv" +) + +// timeouts +const ( + loginTimeout = time.Minute // to sign in, or to join a switchboard + idleTimeout = 10 * time.Minute // without a command (clients PNG every 50 s or so) + sbIdle = 30 * time.Minute // a switchboard connection without a command + writeTimeout = 30 * time.Second + cookieLife = 2 * time.Minute // a switchboard cookie is used within this + queueLen = 512 // things waiting for a session's goroutine +) + +// the protocol versions served +const ( + minVersion = 2 + maxVersion = 7 +) + +// Settings are the [msn] section's. +type Settings struct { + Address string // where to listen + // Host is where clients are sent for switchboards, host:port; "": the + // address each one came to + Host string + // Domain makes users' handles: name@Domain. Clients may sign in with + // any domain (MSN 1.0 only takes @hotmail.com). + Domain string + MaxClients int + MaxPerIP int + // System is the name the BBS's notices come from + System string + // Site is a web address for the client's links (its inbox, its + // profile pages); "": none + Site string +} + +// Server serves MSNP. +type Server struct { + B *bbs.BBS + S Settings + + mu sync.Mutex + ns map[*nsSession]bool + byNode map[int]*nsSession + sbs map[string]*switchboard // by id + cookies map[string]*sbCookie + nextSB int +} + +// New checks the settings and makes the server. +func New(b *bbs.BBS, s Settings) (*Server, error) { + if s.Address == "" { + return nil, errors.New("msn: no address to listen on") + } + if s.Host != "" { + if _, _, err := net.SplitHostPort(s.Host); err != nil { + return nil, fmt.Errorf("msn: host: %w", err) + } + } + if s.Domain == "" { + s.Domain = "bbs.invalid" + } + if s.System == "" { + s.System = "BBS" + } + if s.MaxClients == 0 { + s.MaxClients = 256 + } + return &Server{B: b, S: s, ns: map[*nsSession]bool{}, byNode: map[int]*nsSession{}, + sbs: map[string]*switchboard{}, cookies: map[string]*sbCookie{}, nextSB: 1}, nil +} + +// Run listens until ctx is done. +func (s *Server) Run(ctx context.Context) error { + ln, err := sockets.Listen("tcp", s.S.Address) + if err != nil { + return fmt.Errorf("msn: %w", err) + } + return s.Serve(ctx, ln) +} + +// Serve answers on ln until ctx is done. +func (s *Server) Serve(ctx context.Context, ln net.Listener) error { + s.B.Store.SetKeepMSN(true) + stop := s.B.WatchPresence(s.presence) + defer stop() + stopFriends := s.B.WatchFriends(s.friendsChanged) + defer stopFriends() + ts := &tcpserv.Server{Name: "msn", MaxClients: s.S.MaxClients, MaxPerIP: s.S.MaxPerIP, Log: s.B.Log, + Handle: s.handle, + Refuse: func(c net.Conn) bool { return s.B.Refuse("msn", c.RemoteAddr()) }} + return ts.Serve(ctx, ln) +} + +// Clients is how many are signed in. +func (s *Server) Clients() int { + s.mu.Lock() + defer s.mu.Unlock() + return len(s.ns) +} + +// handle serves a connection: a notification session, or a switchboard's. +func (s *Server) handle(c net.Conn) { + host, _, _ := net.SplitHostPort(c.RemoteAddr().String()) + k := newConn(c, bufio.NewReaderSize(c, 8192)) + c.SetDeadline(time.Now().Add(loginTimeout)) + first, err := k.read() + if err != nil { + return + } + switch first.name { + case "VER": + s.notification(k, host, first) + case "USR", "ANS": + s.switchboardConn(k, host, first) + } +} + +// handleOf is a user's MSN handle: their name without its spaces, at the +// domain. +func (s *Server) handleOf(u *store.User) string { + return strings.ReplaceAll(u.Name, " ", "") + "@" + s.S.Domain +} + +// systemHandle is the handle the BBS's notices come from. +func (s *Server) systemHandle() string { + return strings.ReplaceAll(s.S.System, " ", "") + "@" + s.S.Domain +} + +// resolve is the account a handle names: its part before the @, as a +// name with or without its spaces, at any domain (nil: none). +func (s *Server) resolve(handle string) *store.User { + local, _, _ := strings.Cut(decode(handle), "@") + local = strings.TrimSpace(local) + if local == "" { + return nil + } + u, err := s.B.Store.UserByScreenName(local) + if err != nil { + return nil + } + return u +} + +// may: the user may use the chat. +func (s *Server) may(u *store.User) error { + if !s.B.LevelOf(u).Chat { + return bbs.ErrNotAllowed + } + return nil +} + +// register keeps a notification session on. +func (s *Server) register(ns *nsSession) { + s.mu.Lock() + s.ns[ns] = true + s.byNode[ns.n.Num] = ns + s.mu.Unlock() +} + +// unregister forgets it. +func (s *Server) unregister(ns *nsSession) { + s.mu.Lock() + delete(s.ns, ns) + if s.byNode[ns.n.Num] == ns { + delete(s.byNode, ns.n.Num) + } + s.mu.Unlock() +} + +// all are the notification sessions signed in. +func (s *Server) all() []*nsSession { + s.mu.Lock() + defer s.mu.Unlock() + out := make([]*nsSession, 0, len(s.ns)) + for ns := range s.ns { + out = append(out, ns) + } + return out +} + +// sessionsOf are a user's notification sessions. +func (s *Server) sessionsOf(id int64) []*nsSession { + var out []*nsSession + for _, ns := range s.all() { + if ns.u.ID == id { + out = append(out, ns) + } + } + return out +} + +// onNode is the session on a node (nil: the node is another kind). +func (s *Server) onNode(num int) *nsSession { + s.mu.Lock() + defer s.mu.Unlock() + return s.byNode[num] +} + +// nodesOf are the nodes a user is on. +func (s *Server) nodesOf(name string) []bbs.NodeInfo { + var out []bbs.NodeInfo + for _, n := range s.B.Nodes() { + if n.User != "" && strings.EqualFold(n.User, name) { + out = append(out, n) + } + } + return out +} + +// presence is told of a BBS user coming online or going. +func (s *Server) presence(name string, online bool) { + if len(s.all()) == 0 { + return + } + go func() { + u, err := s.B.Store.UserByName(name) + if err != nil { + return + } + s.changed(u) + }() +} + +// changed has every session told the user's state anew (where it +// differs from what it was told). +func (s *Server) changed(u *store.User) { + for _, x := range s.all() { + x.do(func() { x.contactChanged(u) }) + } +} + +// friendsChanged is told that a user's friends or blocked list changed: +// their own sessions sync their lists, the others their reverse lists and +// what they see of them. +func (s *Server) friendsChanged(user int64) { + go func() { + u, err := s.B.Store.UserByID(user) + if err != nil { + return + } + for _, x := range s.all() { + if x.u.ID == user { + x.do(x.syncLists) + } else { + x.do(func() { x.reverseChanged(u) }) + } + } + }() +} + +// randomHex is n random bytes, in hex. +func randomHex(n int) string { + b := make([]byte, n) + rand.Read(b) + return hex.EncodeToString(b) +} + +// reachHost is where a client on conn is sent for a switchboard. +func (s *Server) reachHost(c net.Conn) string { + if s.S.Host != "" { + return s.S.Host + } + return c.LocalAddr().String() +} diff --git a/internal/msn/wire.go b/internal/msn/wire.go new file mode 100644 index 0000000..e56fe7b --- /dev/null +++ b/internal/msn/wire.go @@ -0,0 +1,216 @@ +package msn + +import ( + "bufio" + "errors" + "fmt" + "net" + "strconv" + "strings" + "sync" + "time" +) + +// limits +const ( + maxLine = 2048 // a command line's bytes + maxPayload = 64 << 10 // a payload's (MSG, QRY) +) + +// cmd is a command a client sent: its name, transaction id and arguments, +// and its payload, for those with one. +type cmd struct { + name string + trid string + args []string + payload []byte +} + +// arg is the i'th argument ("": none). +func (c *cmd) arg(i int) string { + if i < len(c.args) { + return c.args[i] + } + return "" +} + +// payloadCmds are those a client sends with a payload, its length last. +var payloadCmds = map[string]bool{"MSG": true, "QRY": true, "UUX": true, "ADL": true, "RML": true, + "UUN": true, "UUM": true, "PAG": true, "SDC": true, "NOT": true, "FQY": true} + +var errLine = errors.New("msn: bad command line") + +// conn is a client's connection: commands in, lines out. +type conn struct { + c net.Conn + r *bufio.Reader + mu sync.Mutex // writes +} + +func newConn(c net.Conn, r *bufio.Reader) *conn { return &conn{c: c, r: r} } + +// read is the next command. +func (k *conn) read() (*cmd, error) { + line, err := k.r.ReadSlice('\n') + if errors.Is(err, bufio.ErrBufferFull) || len(line) > maxLine { + return nil, errLine + } + if err != nil { + return nil, err + } + f := strings.Fields(strings.TrimRight(string(line), "\r\n")) + if len(f) == 0 { + return &cmd{}, nil + } + c := &cmd{name: strings.ToUpper(f[0])} + if len(f) > 1 { + c.trid = f[1] + c.args = f[2:] + } + if payloadCmds[c.name] && len(f) >= 3 { + n, err := strconv.Atoi(f[len(f)-1]) + if err != nil || n < 0 || n > maxPayload { + return nil, errLine + } + c.payload = make([]byte, n) + if _, err := readFull(k.r, c.payload); err != nil { + return nil, err + } + } + return c, nil +} + +func readFull(r *bufio.Reader, b []byte) (int, error) { + n := 0 + for n < len(b) { + m, err := r.Read(b[n:]) + n += m + if err != nil { + return n, err + } + } + return n, nil +} + +// send writes a line (its words joined by spaces). +func (k *conn) send(words ...string) error { + return k.write([]byte(strings.Join(words, " ") + "\r\n")) +} + +// sendPayload writes a line ending in the payload's length, and the +// payload. +func (k *conn) sendPayload(payload []byte, words ...string) error { + line := strings.Join(append(words, strconv.Itoa(len(payload))), " ") + "\r\n" + return k.write(append([]byte(line), payload...)) +} + +// sendErr writes an error's number for a transaction. +func (k *conn) sendErr(code int, trid string) error { return k.send(strconv.Itoa(code), trid) } + +func (k *conn) write(b []byte) error { + k.mu.Lock() + defer k.mu.Unlock() + k.c.SetWriteDeadline(time.Now().Add(writeTimeout)) + _, err := k.c.Write(b) + return err +} + +func (k *conn) close() { k.c.Close() } + +// error numbers +const ( + errSyntax = 200 + errBadParam = 201 + errNoSuchUser = 205 + errNoDomain = 206 + errBadHandle = 208 + errBadFriendly = 209 + errListFull = 210 + errAlreadyThere = 215 + errNotOnList = 216 + errNotOnline = 217 + errInOpposite = 219 + errBadGroup = 224 + errNotInGroup = 225 + errGroupName = 228 + errNoSB = 280 + errNotLoggedIn = 302 + errInternal = 500 + errDisabled = 502 + errBusy = 600 + errRate = 800 + errAuth = 911 + errNotAllowed = 913 +) + +// encode is a name as MSNP carries it: URL encoded (a space %20, every +// byte that is not printable ASCII, and %). +func encode(s string) string { + var b strings.Builder + for i := 0; i < len(s); i++ { + c := s[i] + if c <= ' ' || c >= 0x7f || c == '%' { + fmt.Fprintf(&b, "%%%02X", c) + continue + } + b.WriteByte(c) + } + return b.String() +} + +// decode is a URL-encoded name in the clear (as it was, if it is not +// well encoded). +func decode(s string) string { + if !strings.Contains(s, "%") { + return s + } + var b []byte + for i := 0; i < len(s); i++ { + if s[i] == '%' && i+2 < len(s) { + if v, err := strconv.ParseUint(s[i+1:i+3], 16, 8); err == nil { + b = append(b, byte(v)) + i += 2 + continue + } + } + b = append(b, s[i]) + } + return string(b) +} + +// mime is a MSG payload: its headers, by lower-case name, and its body. +type mime struct { + headers map[string]string + body string +} + +// parseMIME reads a MSG payload. +func parseMIME(p []byte) mime { + m := mime{headers: map[string]string{}} + s := string(p) + head, body, ok := strings.Cut(s, "\r\n\r\n") + if !ok { + head, body, _ = strings.Cut(s, "\n\n") + } + m.body = body + for _, l := range strings.Split(head, "\n") { + k, v, ok := strings.Cut(strings.TrimRight(l, "\r"), ":") + if ok { + m.headers[strings.ToLower(strings.TrimSpace(k))] = strings.TrimSpace(v) + } + } + return m +} + +// contentType is the payload's media type, lower case, without its +// parameters. +func (m mime) contentType() string { + t, _, _ := strings.Cut(m.headers["content-type"], ";") + return strings.ToLower(strings.TrimSpace(t)) +} + +// textPayload is a plain text message's payload. +func textPayload(text string) []byte { + return []byte("MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n" + + "X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; CS=0; PF=0\r\n\r\n" + text) +} diff --git a/internal/oscar/events.go b/internal/oscar/events.go index 1f3c15c..048e056 100644 --- a/internal/oscar/events.go +++ b/internal/oscar/events.go @@ -12,7 +12,11 @@ import ( func (ss *session) event(e bbs.Event) { switch e.Kind { case bbs.Private: - ss.imFrom(e.From, e.Text) + text := e.Text + if e.Kept { + text = "(" + e.Time.Format("Jan 2 15:04") + ", while you were away) " + text + } + ss.imFrom(e.From, text) return case bbs.Said, bbs.Emoted, bbs.Joined, bbs.Left, bbs.Topic: if c := ss.chatOf(e.Room); c != nil { diff --git a/internal/oscar/feedbag.go b/internal/oscar/feedbag.go index a3b353b..5478154 100644 --- a/internal/oscar/feedbag.go +++ b/internal/oscar/feedbag.go @@ -1,6 +1,9 @@ package oscar import ( + "encoding/binary" + "sort" + "strings" "time" "github.com/D-Modem/bbs/internal/store" @@ -54,9 +57,11 @@ func itemBytes(b *buf, it store.FeedbagItem) { b.raw(it.Attrs) } -// feedbag is family 0x13: the buddy list kept on the server (SSI). +// feedbag is family 0x13: the buddy list kept on the server (SSI). Its +// buddies are the user's friends list, kept by the BBS: BBS users alone; +// its groups, permit and deny lists and preferences are kept as the +// client sent them. func (ss *session) feedbag(h snacHeader, r *rd) { - st := ss.s.B.Store switch h.sub { case 0x0002: // rights var t tlvs @@ -85,12 +90,15 @@ func (ss *session) feedbag(h snacHeader, r *rd) { t.addU16(0x000c, 200) ss.snac(0x0013, 0x0003, h.req, t.bytes()) case 0x0004, 0x0005: // the list (5: if changed since; it is sent anyway) - items, err := st.Feedbag(ss.u.ID) + items, err := ss.bag() if err != nil { ss.s.B.Log.Printf("node %d: the feedbag: %v", ss.n.Num, err) ss.fail(0x0013, h.req, 0x0005) return } + ss.mu.Lock() + ss.items, ss.bagSent = items, true + ss.mu.Unlock() ss.feedbagLoaded(items) // a long list goes in pieces, all but the last flagged as such const per = 150 @@ -145,39 +153,325 @@ func (ss *session) feedbag(h snacHeader, r *rd) { } } +// friendsGroup is the group friends go in when they have none of their +// own (added elsewhere: by IRC, the BBS), made if the list has none. +const friendsGroup = "Friends" + +// bag is the user's feedbag as the client is to have it: the items it +// keeps, and the friends list as its buddies. Friends not yet in the +// list (added elsewhere), or moved to another group elsewhere, are put +// in their group first, made if need be. +func (ss *session) bag() ([]store.FeedbagItem, error) { + ss.s.bagMu.Lock() + defer ss.s.bagMu.Unlock() + st := ss.s.B.Store + stored, err := st.Feedbag(ss.u.ID) + if err != nil { + return nil, err + } + var items, old []store.FeedbagItem // old: buddies kept as items before the friends list was + for _, it := range stored { + if it.ClassID == fbBuddy { + old = append(old, it) + } else { + items = append(items, it) + } + } + groups := map[uint16]int{} // group id → its item's index + for i, it := range items { + if it.ClassID == fbGroup { + groups[it.GroupID] = i + } + } + groupName := func(gid uint16) string { + if i, ok := groups[gid]; ok && gid != 0 { + return items[i].Name + } + return "" + } + if len(old) > 0 { + for _, it := range old { + u := ss.s.resolve(it.Name) + if u == nil || u.ID == ss.u.ID { + continue + } + if ok, err := st.IsFriend(ss.u.ID, u.ID); err != nil { + return nil, err + } else if !ok { + if err := st.PutFriend(ss.u.ID, store.Friend{ID: u.ID, Group: groupName(it.GroupID), Alias: alias(it.Attrs)}); err != nil { + return nil, err + } + if err := st.PutOSCARBuddy(ss.u.ID, store.OSCARBuddy{FriendID: u.ID, SN: it.Name, GroupID: it.GroupID, + ItemID: it.ItemID, Attrs: it.Attrs}); err != nil { + return nil, err + } + } + } + if err := st.DeleteFeedbag(ss.u.ID, old); err != nil { + return nil, err + } + } + fs, err := st.Friends(ss.u.ID) + if err != nil { + return nil, err + } + places, err := st.OSCARBuddies(ss.u.ID) + if err != nil { + return nil, err + } + used := map[[2]uint16]bool{} + for _, it := range items { + used[[2]uint16{it.GroupID, it.ItemID}] = true + } + // friends with a place in their group keep it + var unplaced []store.Friend + for _, f := range fs { + p, ok := places[f.ID] + k := [2]uint16{p.GroupID, p.ItemID} + _, group := groups[p.GroupID] + if ok && group && p.GroupID != 0 && p.ItemID != 0 && !used[k] && + (f.Group == "" || strings.EqualFold(groupName(p.GroupID), f.Group)) { + used[k] = true + } else { + unplaced = append(unplaced, f) + } + } + changed := map[uint16]bool{} // groups whose order changed + for _, f := range unplaced { + name := f.Group + if name == "" { + name = friendsGroup + } + gid := uint16(0) + for id := range groups { + if id != 0 && strings.EqualFold(groupName(id), name) { + gid = id + } + } + if gid == 0 { + gid = freeID(func(id uint16) bool { _, ok := groups[id]; return ok }) + items = append(items, store.FeedbagItem{Name: name, GroupID: gid, ClassID: fbGroup}) + groups[gid] = len(items) - 1 + if _, ok := groups[0]; !ok { // the root, which lists the groups + items = append(items, store.FeedbagItem{ClassID: fbGroup}) + groups[0] = len(items) - 1 + } + root := &items[groups[0]] + root.Attrs = withChild(root.Attrs, gid) + changed[0] = true + } + iid := freeID(func(id uint16) bool { return used[[2]uint16{gid, id}] }) + used[[2]uint16{gid, iid}] = true + g := &items[groups[gid]] + g.Attrs = withChild(g.Attrs, iid) + changed[gid] = true + p := places[f.ID] + p.FriendID, p.GroupID, p.ItemID = f.ID, gid, iid + if err := st.PutOSCARBuddy(ss.u.ID, p); err != nil { + return nil, err + } + places[f.ID] = p + } + if len(changed) > 0 { + var put []store.FeedbagItem + for gid := range changed { + put = append(put, items[groups[gid]]) + } + if err := st.PutFeedbag(ss.u.ID, put); err != nil { + return nil, err + } + } + for _, f := range fs { + p := places[f.ID] + items = append(items, store.FeedbagItem{Name: ss.friendName(f, p.SN), GroupID: p.GroupID, ItemID: p.ItemID, + ClassID: fbBuddy, Attrs: withAlias(p.Attrs, f.Alias)}) + } + sort.Slice(items, func(i, j int) bool { + if items[i].GroupID != items[j].GroupID { + return items[i].GroupID < items[j].GroupID + } + return items[i].ItemID < items[j].ItemID + }) + return items, nil +} + +// friendName is a friend as the client names them: as it wrote them (sn), +// or (added elsewhere, or renamed since) their ICQ number on ICQ, their +// name on AIM. +func (ss *session) friendName(f store.Friend, sn string) string { + if sn != "" && isUIN(sn) == ss.icq && (isUIN(sn) || ident(sn) == ident(f.Name)) { + return sn + } + if ss.icq { + return ss.s.uinOf(f.ID) + } + return f.Name +} + +// alias is a buddy's alias (TLV 0x131), "" if none. +func alias(attrs []byte) string { return parseTLVs(attrs).str(0x0131) } + +// withAlias is a buddy's TLVs with its alias as the friends list has it. +func withAlias(attrs []byte, a string) []byte { + if alias(attrs) == a { + return attrs + } + var out tlvs + for _, x := range parseTLVs(attrs) { + if x.t != 0x0131 { + out = append(out, x) + } + } + if a != "" { + out.addStr(0x0131, a) + } + return out.bytes() +} + +// freeID is the least id from 1 that taken says is not. +func freeID(taken func(uint16) bool) uint16 { + for id := uint16(1); id < 0x7fff; id++ { + if !taken(id) { + return id + } + } + return 0x7fff +} + +// withChild is a group's attributes with an item id added to its order +// (TLV 0xC8, the ids it holds). +func withChild(attrs []byte, id uint16) []byte { + var out tlvs + found := false + for _, x := range parseTLVs(attrs) { + if x.t == 0x00c8 && !found { + found = true + if !holds(x.v, id) { + x = tlv{0x00c8, binary.BigEndian.AppendUint16(append([]byte(nil), x.v...), id)} + } + } + out = append(out, x) + } + if !found { + out = append(out, tlv{0x00c8, binary.BigEndian.AppendUint16(nil, id)}) + } + return out.bytes() +} + +// holds reports whether a list of ids has id. +func holds(ids []byte, id uint16) bool { + for i := 0; i+1 < len(ids); i += 2 { + if binary.BigEndian.Uint16(ids[i:]) == id { + return true + } + } + return false +} + // changeItems adds, updates or deletes feedbag items: each one's status. +// A buddy is a friend: one not a BBS user is refused. func (ss *session) changeItems(sub uint16, items []store.FeedbagItem) []uint16 { st := ss.s.B.Store - have, err := st.Feedbag(ss.u.ID) - if err != nil { + codes := make([]uint16, len(items)) + fail := func(err error) []uint16 { ss.s.B.Log.Printf("node %d: the feedbag: %v", ss.n.Num, err) - codes := make([]uint16, len(items)) for i := range codes { codes[i] = fbInvalid } return codes } - exists := map[[2]uint16]bool{} + have, err := ss.bag() + if err != nil { + return fail(err) + } + places, err := st.OSCARBuddies(ss.u.ID) + if err != nil { + return fail(err) + } + exists := map[[2]uint16]store.FeedbagItem{} for _, it := range have { - exists[[2]uint16{it.GroupID, it.ItemID}] = true + exists[[2]uint16{it.GroupID, it.ItemID}] = it + } + friendAt := map[[2]uint16]int64{} + friend := map[int64][2]uint16{} + for id, p := range places { + friendAt[[2]uint16{p.GroupID, p.ItemID}] = id + friend[id] = [2]uint16{p.GroupID, p.ItemID} + } + groupName := func(gid uint16) string { + if g, ok := exists[[2]uint16{gid, 0}]; ok && g.ClassID == fbGroup && gid != 0 { + return g.Name + } + return "" } - codes := make([]uint16, len(items)) var put, del []store.FeedbagItem + friendsChanged := false for i, it := range items { k := [2]uint16{it.GroupID, it.ItemID} + was, ok := exists[k] + buddy := it.ClassID == fbBuddy || ok && was.ClassID == fbBuddy switch { - case sub == 0x0008 && exists[k]: + case sub == 0x0008 && ok: codes[i] = fbExists case sub == 0x0008 && len(have)+len(put) >= maxFeedbag: codes[i] = 0x000c // over the limit - case sub != 0x0008 && !exists[k]: + case sub != 0x0008 && !ok: codes[i] = fbNotFound + case buddy && sub == 0x000a: + if id, ok := friendAt[k]; ok { + if err := st.RemoveFriend(ss.u.ID, id); err != nil { + return fail(err) + } + delete(friend, id) + friendsChanged = true + } + delete(exists, k) + case buddy: + u := ss.s.resolve(it.Name) + if u == nil || u.ID == ss.u.ID || it.ClassID != fbBuddy { + codes[i] = fbInvalid // not a BBS user: no buddy + continue + } + if at, ok := friend[u.ID]; ok && at != k { + codes[i] = fbExists // on the list already, elsewhere + continue + } + if id, ok := friendAt[k]; ok && id != u.ID { + if err := st.RemoveFriend(ss.u.ID, id); err != nil { + return fail(err) + } + delete(friend, id) + } + if err := st.PutFriend(ss.u.ID, store.Friend{ID: u.ID, Group: groupName(it.GroupID), Alias: alias(it.Attrs)}); err != nil { + return fail(err) + } + if err := st.PutOSCARBuddy(ss.u.ID, store.OSCARBuddy{FriendID: u.ID, SN: it.Name, GroupID: it.GroupID, + ItemID: it.ItemID, Attrs: it.Attrs}); err != nil { + return fail(err) + } + friend[u.ID], friendAt[k] = k, u.ID + exists[k] = it + friendsChanged = true case sub == 0x000a: del = append(del, it) delete(exists, k) default: + if sub == 0x0009 && it.ClassID == fbGroup && it.GroupID != 0 && it.Name != was.Name { + // a group renamed: its friends' group is + for id, at := range friend { + if at[0] == it.GroupID { + if f, err := ss.friendOf(id); err == nil { + f.Group = it.Name + if err := st.PutFriend(ss.u.ID, f); err != nil { + return fail(err) + } + friendsChanged = true + } + } + } + } put = append(put, it) - exists[k] = true + exists[k] = it } } if len(put) > 0 { @@ -187,35 +481,102 @@ func (ss *session) changeItems(sub uint16, items []store.FeedbagItem) []uint16 { err = st.DeleteFeedbag(ss.u.ID, del) } if err != nil { - ss.s.B.Log.Printf("node %d: the feedbag: %v", ss.n.Num, err) - for i := range codes { - codes[i] = fbInvalid - } - return codes + return fail(err) } - if now, err := st.Feedbag(ss.u.ID); err == nil { + if now, err := ss.bag(); err == nil { + ss.mu.Lock() + ss.items = now + ss.mu.Unlock() ss.feedbagLoaded(now) } - // the user's other sessions are told of the change - for _, o := range ss.s.sessionsOf(ss.u.ID) { - if o == ss { - continue - } - var b buf - for _, it := range items { - itemBytes(&b, it) - } - o.do(func() { - o.snac(0x0013, sub, 0, b) - if now, err := st.Feedbag(o.u.ID); err == nil { - o.feedbagLoaded(now) - } - }) + if friendsChanged { + ss.s.B.FriendsChanged(ss.u.ID) // the user's other sessions, and the rest of the BBS + } else { + ss.s.friendsChanged(ss.u.ID) } ss.s.changed(ss.u) return codes } +// friendOf is the entry of one on the user's friends list. +func (ss *session) friendOf(id int64) (store.Friend, error) { + fs, err := ss.s.B.Store.Friends(ss.u.ID) + if err != nil { + return store.Friend{}, err + } + for _, f := range fs { + if f.ID == id { + return f, nil + } + } + return store.Friend{}, store.ErrNotFound +} + +// friendsChanged has each session of the user bring its client's buddy +// list up to date. +func (s *Server) friendsChanged(user int64) { + for _, o := range s.all() { + if o.u.ID == user { + o.do(o.syncBag) + } + } +} + +// syncBag sends the client what changed in its feedbag since it last had +// it (deleted, added, then updated items), and watches its buddies anew. +func (ss *session) syncBag() { + now, err := ss.bag() + if err != nil { + ss.s.B.Log.Printf("node %d: the feedbag: %v", ss.n.Num, err) + return + } + ss.mu.Lock() + old, sent := ss.items, ss.bagSent + if sent { + ss.items = now + } + ss.mu.Unlock() + if sent { + key := func(it store.FeedbagItem) [2]uint16 { return [2]uint16{it.GroupID, it.ItemID} } + was := map[[2]uint16]store.FeedbagItem{} + for _, it := range old { + was[key(it)] = it + } + is := map[[2]uint16]bool{} + var add, upd, del buf + for _, it := range now { + is[key(it)] = true + o, ok := was[key(it)] + switch { + case !ok: + itemBytes(&add, it) + case o.Name != it.Name || o.ClassID != it.ClassID || string(o.Attrs) != string(it.Attrs): + itemBytes(&upd, it) + } + } + for _, it := range old { + if !is[key(it)] { + itemBytes(&del, it) + } + } + if len(del)+len(add)+len(upd) > 0 { + ss.snac(0x0013, 0x0011, 0, nil) + for _, x := range []struct { + sub uint16 + b buf + }{{0x000a, del}, {0x0008, add}, {0x0009, upd}} { + if len(x.b) > 0 { + ss.snac(0x0013, x.sub, 0, x.b) + } + } + ss.snac(0x0013, 0x0012, 0, nil) + } + ss.feedbagLoaded(now) + return + } + ss.rewatch() // a client with its own list: the friends watched +} + // feedbagLoaded takes the buddies and privacy of the list, and watches // the buddies. func (ss *session) feedbagLoaded(items []store.FeedbagItem) { diff --git a/internal/oscar/icbm.go b/internal/oscar/icbm.go index 5d933e0..b6cbe18 100644 --- a/internal/oscar/icbm.go +++ b/internal/oscar/icbm.go @@ -37,7 +37,7 @@ func (ss *session) icbm(h snacHeader, r *rd) { ss.fail(0x0004, h.req, icbmRefused) case 0x000b: // the client's error or auto answer, for the sender ss.relayToSender(h, r, 0x000b) - case 0x0010: // offline messages: none kept + case 0x0010: // offline messages: given as IMs once the client is ready ss.snac(0x0004, 0x0017, h.req, nil) case 0x0014: // typing ss.relayToSender(h, r, 0x0014) @@ -176,18 +176,40 @@ func (ss *session) deliver(u *store.User, ck []byte, raw string, isHTML, auto bo if plain == "" { return nil } + if ss.s.B.Blocks(u, ss.u) { + return errOffline // on their blocked list (any front end's) + } for _, o := range ss.s.sessionsOf(u.ID) { if o.blocks(ss.u) { return errOffline } } - nodes := ss.s.nodesOf(u.Name) - if len(nodes) == 0 { - return errOffline - } if auto { plain = "(auto reply) " + plain } + nodes := ss.s.nodesOf(u.Name) + if len(nodes) == 0 { + if auto { + return nil // an auto reply is not kept + } + // kept for them, and the sender told so (once) + if err := ss.n.Throttle(); err != nil { + return err + } + ss.n.Keep(u, plain, false) + ss.mu.Lock() + noted := ss.noted[u.ID] + ss.noted[u.ID] = true + ss.mu.Unlock() + if !noted { + from := ss.systemName() + name := u.Name + ss.do(func() { + ss.imFrom(from, name+" is not on now; they will have your messages when they next sign on.") + }) + } + return nil + } native := false var lastErr error sent := false @@ -224,6 +246,12 @@ func (ss *session) deliver(u *store.User, ck []byte, raw string, isHTML, auto bo if native { ss.s.B.Log.Printf("node %d: %s sent an IM to %s", ss.n.Num, ss.u.Name, u.Name) } + if sent && !auto { + ss.n.Keep(u, plain, true) + ss.mu.Lock() + delete(ss.noted, u.ID) + ss.mu.Unlock() + } if !sent && lastErr != nil { return lastErr } diff --git a/internal/oscar/icq.go b/internal/oscar/icq.go index 3bd8ad6..24c007b 100644 --- a/internal/oscar/icq.go +++ b/internal/oscar/icq.go @@ -12,6 +12,7 @@ import ( // length, the client's UIN, a type, a sequence number, the request. const ( icqOfflineReq = 0x003c + icqOfflineMsg = 0x0041 icqOfflineDone = 0x0042 icqOfflineAck = 0x003e icqMetaReq = 0x07d0 @@ -48,7 +49,7 @@ func (r *lrd) str() string { return strings.TrimRight(decodeText(r.take(int(r.u16())), csASCII), "\x00") } -// icqMeta is family 0x15: offline messages (none are kept), and the +// icqMeta is family 0x15: offline messages (those kept), and the // directory: users' info and searches. func (ss *session) icqMeta(h snacHeader, r *rd) { if h.sub != 0x0002 { @@ -69,9 +70,7 @@ func (ss *session) icqMeta(h snacHeader, r *rd) { } switch kind { case icqOfflineReq: - var b le - b.u8(0) // none dropped - ss.icqReply(h.req, icqOfflineDone, seq, b, false) + ss.icqOffline(h.req, seq) case icqOfflineAck: case icqMetaReq: sub := q.u16() @@ -79,6 +78,41 @@ func (ss *session) icqMeta(h snacHeader, r *rd) { } } +// icqOffline sends the messages kept while the user was away, each with +// its sender and time (GMT), then that there are no more. +func (ss *session) icqOffline(req uint32, seq uint16) { + st := ss.s.B.Store + cs, err := st.KeptChats(ss.u.ID) + if err != nil { + ss.s.B.Log.Printf("node %d: kept messages: %v", ss.n.Num, err) + } + ids := make([]int64, 0, len(cs)) + for _, c := range cs { + if o, err := st.UserByID(c.FromID); err == nil && ss.blocks(o) { + continue // kept back: they are blocked + } + t := c.Sent.UTC() + var b le + b.u32(uint32(ss.s.S.UINBase) + uint32(c.FromID)) + b.u16(uint16(t.Year())) + b.u8(byte(t.Month())) + b.u8(byte(t.Day())) + b.u8(byte(t.Hour())) + b.u8(byte(t.Minute())) + b.u8(0x01) // a text message + b.u8(0) // flags + b.str(c.Text) + ss.icqReply(req, icqOfflineMsg, seq, b, true) + ids = append(ids, c.ID) + } + if err := st.ChatsDelivered(ids); err != nil { + ss.s.B.Log.Printf("node %d: kept messages: %v", ss.n.Num, err) + } + var b le + b.u8(0) // none dropped + ss.icqReply(req, icqOfflineDone, seq, b, false) +} + // icqReply sends a reply of kind (with its sequence number) to the // client; more: more replies follow. func (ss *session) icqReply(req uint32, kind, seq uint16, body []byte, more bool) { diff --git a/internal/oscar/oscar_test.go b/internal/oscar/oscar_test.go index b40c1b3..8974964 100644 --- a/internal/oscar/oscar_test.go +++ b/internal/oscar/oscar_test.go @@ -8,6 +8,7 @@ import ( "log" "net" "path/filepath" + "slices" "strings" "sync" "testing" @@ -401,7 +402,12 @@ func TestAIMToIRC(t *testing.T) { // Carol Ann, on IRC: she arrives, and IMs go both ways carol := ircLogin(t, e.ircAddr, "Carol Ann") - if sn, info := alice.arrival(); sn != "CarolAnn" && sn != "Carol Ann" { + // (bob's arrival can come again first, as his session settles) + sn, info := alice.arrival() + for i := 0; sn == "bob" && i < 3; i++ { + sn, info = alice.arrival() + } + if sn != "CarolAnn" && sn != "Carol Ann" { t.Errorf("carol arrival %q %v", sn, info) } alice.sendIM("Carol Ann", "hi & welcome", false) @@ -413,10 +419,14 @@ func TestAIMToIRC(t *testing.T) { t.Errorf("alice got %q %q", from, text) } - // offline, and unknown: not logged on + // one away: the IM is kept, and alice told so; one unknown: not logged on alice.sendIM("sysop", "anyone?", false) + if from, text := alice.recvIM(); from != "OnlineHost" || !strings.Contains(text, "sysop is not on now") { + t.Errorf("alice told %q %q", from, text) + } + alice.sendIM("nobody", "anyone?", false) if r := (&rd{p: alice.expect(0x04, 0x01)}); r.u16() != icbmNotLoggedOn { - t.Error("no error to an offline user") + t.Error("no error to an unknown user") } // bob goes: alice is told @@ -653,3 +663,145 @@ func TestP3(t *testing.T) { t.Fatal("not given to P3") } } + +// TestKeptIMs: IMs and PRIVMSGs to one away are kept, and given them when +// they come: on AIM as IMs after the client is ready, on ICQ as offline +// messages, on IRC as PRIVMSGs with their times; the conversation is +// there to read back by IRC. +func TestKeptIMs(t *testing.T) { + e := start(t) + host, ck, _ := login(t, e.addr, "alice", "password1", true) + alice := bos(t, host, ck) + alice.sendIM("bob", "are you there?", false) + alice.recvIM() // the note that bob is away + carol := ircLogin(t, e.ircAddr, "Carol Ann") + carol.send("PRIVMSG bob :hi from IRC") + if l := carol.expect(" 301 "); !strings.Contains(l, "next log in") { + t.Errorf("carol told %q", l) + } + + // bob comes by AIM: both, as IMs, after his client is ready + host, ck, _ = login(t, e.addr, "bob", "password1", true) + bob := bos(t, host, ck) + got := map[string]string{} + for range 2 { + from, text := bob.recvIM() + got[from] = text + } + if !strings.Contains(got["alice"], "while you were away) are you there?") { + t.Errorf("from alice %q", got["alice"]) + } + if !strings.Contains(got["CarolAnn"], "hi from IRC") && !strings.Contains(got["Carol Ann"], "hi from IRC") { + t.Errorf("from carol %v", got) + } + + // read back, by IRC + carol.send("PRIVMSG BBSServ :HISTORY bob") + if l := carol.expect(" hi from IRC"); !strings.Contains(l, "NOTICE") { + t.Errorf("history %q", l) + } + + // ICQ: an offline message, with its sender and time + bob.c.Close() + for i := 0; len(e.srv.nodesOf("bob")) > 0; i++ { + if i > 300 { + t.Fatal("bob never went") + } + time.Sleep(10 * time.Millisecond) + } + alice.sendIM("bob", "for ICQ", true) + alice.expect(0x04, 0x0c) // kept; alice was told once already + bobU, _ := e.b.Store.UserByName("bob") + aliceU, _ := e.b.Store.UserByName("alice") + uin := e.srv.uinOf(bobU.ID) + host, ck, _ = roastedLogin(t, e.addr, uin, "password1") + icq := bos(t, host, ck) + var q le + q.u16(0) + q.u32(e.srv.S.UINBase + uint32(bobU.ID)) + q.u16(icqOfflineReq) + q.u16(2) + binary.LittleEndian.PutUint16(q, uint16(len(q)-2)) + var t1 tlvs + t1.add(0x0001, q) + icq.send(0x15, 0x02, t1.bytes()) + v, _ := parseTLVs(icq.expect(0x15, 0x03)).get(0x0001) + r := &lrd{rd{p: v}} + r.u16() + r.u32() + if k := r.u16(); k != icqOfflineMsg { + t.Fatalf("kind %x", k) + } + r.u16() + if from := r.u32(); from != e.srv.S.UINBase+uint32(aliceU.ID) { + t.Errorf("from %d", from) + } + if y := r.u16(); y != uint16(time.Now().UTC().Year()) { + t.Errorf("year %d", y) + } + r.take(4) + r.take(2) + if text := r.str(); text != "for ICQ" { + t.Errorf("text %q", text) + } + v, _ = parseTLVs(icq.expect(0x15, 0x03)).get(0x0001) + r = &lrd{rd{p: v}} + r.u16() + r.u32() + if k := r.u16(); k != icqOfflineDone { + t.Errorf("then %x", k) + } + if cs, _ := e.b.Store.KeptChats(bobU.ID); len(cs) != 0 { + t.Errorf("still kept: %v", cs) + } +} + +// TestFriendsList: the server-stored buddy list is the friends list: a +// buddy not a BBS user is refused, one added from IRC comes to the AIM +// client in a Friends group, one deleted by AIM is off the list. +func TestFriendsList(t *testing.T) { + e := start(t) + host, ck, _ := login(t, e.addr, "alice", "password1", true) + alice := bos(t, host, ck) + alice.send(0x13, 0x04, nil) + alice.expect(0x13, 0x06) + var b buf + itemBytes(&b, store.FeedbagItem{Name: "nobody", GroupID: 1, ItemID: 9, ClassID: fbBuddy}) + alice.send(0x13, 0x08, b) + if c := alice.expect(0x13, 0x0e); !bytes.Equal(c, []byte{0, fbInvalid}) { + t.Errorf("a buddy not a user: %x", c) + } + + ic := ircLogin(t, e.ircAddr, "alice") + ic.send("PRIVMSG BBSServ :FRIENDS ADD Carol_Ann") + ic.expect("is on your friends list") + alice.expect(0x13, 0x11) + add := &rd{p: alice.expect(0x13, 0x08)} + var names []string + var carolItem store.FeedbagItem + for _, it := range readItems(add) { + names = append(names, it.Name) + if it.ClassID == fbBuddy { + carolItem = it + } + } + if carolItem.Name != "Carol Ann" || !slices.Contains(names, "Friends") { + t.Fatalf("added %q", names) + } + + aliceU, _ := e.b.Store.UserByName("alice") + if fs, _ := e.b.Store.Friends(aliceU.ID); len(fs) != 1 || fs[0].Name != "Carol Ann" { + t.Fatalf("friends %v", fs) + } + var d buf + itemBytes(&d, carolItem) + alice.send(0x13, 0x0a, d) + if c := alice.expect(0x13, 0x0e); !bytes.Equal(c, []byte{0, fbOK}) { + t.Errorf("delete: %x", c) + } + if fs, _ := e.b.Store.Friends(aliceU.ID); len(fs) != 0 { + t.Errorf("friends after: %v", fs) + } + ic.send("PRIVMSG BBSServ :FRIENDS") + ic.expect("Your friends list is empty") +} diff --git a/internal/oscar/presence.go b/internal/oscar/presence.go index d1b5d5a..cdc65e8 100644 --- a/internal/oscar/presence.go +++ b/internal/oscar/presence.go @@ -252,6 +252,14 @@ func (ss *session) rewatch() { watch[u.ID] = sn } } + // and the friends list, however the client keeps its list + if fs, err := ss.s.B.Store.Friends(ss.u.ID); err == nil { + for _, f := range fs { + if _, ok := watch[f.ID]; !ok { + watch[f.ID] = ss.friendName(f, "") + } + } + } ss.mu.Lock() var added []int64 for id := range watch { @@ -278,25 +286,65 @@ func (ss *session) buddy(h snacHeader, r *rd) { t.addU16(0x0004, 160) ss.snac(0x0003, 0x0003, h.req, t.bytes()) case 0x0004, 0x0005: + var sns []string ss.mu.Lock() for r.left() > 0 { sn := r.str8() if r.bad || sn == "" { break } + sns = append(sns, sn) if h.sub == 0x0004 { ss.listed[ident(sn)] = sn } else { delete(ss.listed, ident(sn)) } } + ssi := ss.bagSent ss.mu.Unlock() + if !ssi { + // a client that keeps its own list: that list is the friends list + ss.listFriends(sns, h.sub == 0x0004) + } ss.do(ss.rewatch) default: ss.fail(0x0003, h.req, 0x0008) } } +// listFriends puts the BBS users of a client's own buddy list on the +// friends list (add), or takes them off. +func (ss *session) listFriends(sns []string, add bool) { + st := ss.s.B.Store + changed := false + for _, sn := range sns { + u := ss.s.resolve(sn) + if u == nil || u.ID == ss.u.ID { + continue + } + ok, err := st.IsFriend(ss.u.ID, u.ID) + switch { + case err != nil: + ss.s.B.Log.Printf("node %d: the friends list: %v", ss.n.Num, err) + return + case add && !ok: + err = st.PutFriend(ss.u.ID, store.Friend{ID: u.ID}) + case !add && ok: + err = st.RemoveFriend(ss.u.ID, u.ID) + default: + continue + } + if err != nil { + ss.s.B.Log.Printf("node %d: the friends list: %v", ss.n.Num, err) + return + } + changed = true + } + if changed { + ss.s.B.FriendsChanged(ss.u.ID) + } +} + // permitDeny is family 9: the client-side permit and deny lists. func (ss *session) permitDeny(h snacHeader, r *rd) { switch h.sub { diff --git a/internal/oscar/server.go b/internal/oscar/server.go index 2b2b74a..c0d16b4 100644 --- a/internal/oscar/server.go +++ b/internal/oscar/server.go @@ -68,6 +68,7 @@ type Server struct { sessions map[*session]bool byNode map[int]*session cookies map[string]*cookie + bagMu sync.Mutex // placing friends in buddy lists } // New checks the settings and makes the server. @@ -107,6 +108,8 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error { s.B.Store.SetKeepOSCAR(true) stop := s.B.WatchPresence(s.presence) defer stop() + stopFriends := s.B.WatchFriends(s.friendsChanged) + defer stopFriends() ts := &tcpserv.Server{Name: "oscar", MaxClients: s.S.MaxClients, MaxPerIP: s.S.MaxPerIP, Log: s.B.Log, Handle: s.handle, Refuse: func(c net.Conn) bool { return s.B.Refuse("oscar", c.RemoteAddr()) }} diff --git a/internal/oscar/session.go b/internal/oscar/session.go index 1823817..278f421 100644 --- a/internal/oscar/session.go +++ b/internal/oscar/session.go @@ -52,7 +52,10 @@ type session struct { pdMode byte // permit/deny mode (1 all ... 5 buddies only) permit map[string]bool deny map[string]bool - bagOn bool // the feedbag is in use + bagOn bool // the feedbag is in use + items []store.FeedbagItem // the feedbag as the client last had it + bagSent bool // the client asked for the feedbag + noted map[int64]bool // told that these are away (their IMs kept) chats map[*chatConn]bool nav []*flapConn // service connections without rooms (chat nav) } @@ -91,7 +94,7 @@ func (s *Server) bos(fc *flapConn, host string, k *cookie) { signon: time.Now(), todo: make(chan func(), queueLen), done: make(chan struct{}), versions: map[uint16]uint16{}, listed: map[string]string{}, bagged: map[string]string{}, watch: map[int64]string{}, permit: map[string]bool{}, deny: map[string]bool{}, - pdMode: pdPermitAll, chats: map[*chatConn]bool{}} + pdMode: pdPermitAll, chats: map[*chatConn]bool{}, noted: map[int64]bool{}} n, err := s.B.Enter(&bbs.Caller{Via: via, Listener: "oscar", Remote: host, Source: "ip:" + host, Terminal: k.clientID}, ss.close) if err != nil { @@ -212,9 +215,10 @@ func (ss *session) events() { case f := <-ss.todo: f() case <-ss.n.Wake(): - for _, e := range ss.n.Pending() { - ss.event(e) + if !ss.ready() { + continue // held until the client is ready (online drains them) } + ss.drain() } } } @@ -364,9 +368,24 @@ func (ss *session) online() { ss.mu.Unlock() ss.n.Doing(ss.doing()) ss.do(ss.allArrived) + ss.do(ss.drain) + if !ss.icq { // ICQ asks for its offline messages itself + ss.do(func() { + for _, e := range ss.n.Kept() { + ss.event(e) + } + }) + } ss.s.changed(ss.u) } +// drain gives the client the node's events waiting. +func (ss *session) drain() { + for _, e := range ss.n.Pending() { + ss.event(e) + } +} + // doing is what who's online says of the session. func (ss *session) doing() string { ss.mu.Lock() diff --git a/internal/server/cis_test.go b/internal/server/cis_test.go index 9787a5a..f0e5f1f 100644 --- a/internal/server/cis_test.go +++ b/internal/server/cis_test.go @@ -2,6 +2,7 @@ package server import ( "bytes" + "fmt" "strconv" "strings" "testing" @@ -9,6 +10,8 @@ import ( "github.com/D-Modem/bbs/internal/bbs" "github.com/D-Modem/bbs/internal/cis" + "github.com/D-Modem/bbs/internal/store" + "github.com/D-Modem/bbs/internal/ui3270" "github.com/D-Modem/bbs/internal/xfer" ) @@ -120,7 +123,24 @@ func cimStart(t *testing.T, d *dialog) *xfer.BTransport { // Transport Layer, and HMI to the main menu, an article and the rest; // then a Secure Login. func TestCompuServeCIM(t *testing.T) { - e := start(t, func(s *bbs.Settings) { s.FailDelay = 0 }, cisListener()) + var post int64 + e := startFull(t, ui3270.Graphics{}, func(s *bbs.Settings) { s.FailDelay = 0 }, func(b *bbs.BBS, dir string) { + a, err := b.Store.CreateArea("Hardware", "", false) + if err != nil { + t.Fatal(err) + } + b.Store.SetAreaGroup(a.ID, "Amiga Tech") + sysop, _ := b.Store.UserByName("sysop") + alice, _ := b.Store.UserByName("alice") + if post, err = b.Store.Post(&store.Message{AreaID: a.ID, FromID: sysop.ID, From: "sysop", + To: "All", Subject: "Kickstart 1.3", Body: "Which ROM do you have?"}); err != nil { + t.Fatal(err) + } + if _, err := b.Store.SendMail(&store.Message{FromID: sysop.ID, From: "sysop", ToID: alice.ID, + To: "alice", Subject: "Hello", Body: "Welcome to CIM."}); err != nil { + t.Fatal(err) + } + }, cisListener()) d := e.dial("cis.sock") d.expect("Host Name: ") d.send("CPS\r") @@ -160,12 +180,55 @@ func TestCompuServeCIM(t *testing.T) { } ask(append([]byte{1, 0x34}, "CIS:TOP\x00\x00\x0D"...), 1, 0x35, 0) got = ask(append([]byte{1, 0x25}, "CIS:TOP\x00\x01"...), append([]byte{1, 0x27, 0}, "CIS:MEMBER\x00"...)...) - ask(append([]byte{1, 0x24}, "HOM:MAILHMI\x00"...), append([]byte{1, 0x28}, "CIS:MAIL\x00"...)...) - got = ask(append([]byte{1, 0x29}, "CIS:MAIL\x00\x00\x00\xDC\x05"...), 1, 0x04, 0x29, ' ') - if !bytes.Contains(got, []byte("CompuServe Mail")) { - t.Errorf("mail's text: %q", got) + // an article: its header, then its text in pieces + ask(append([]byte{1, 0x24}, "CIS:RATES\x00"...), append([]byte{1, 0x28}, "CIS:RATES\x00"...)...) + ask(append([]byte{1, 0x29}, "CIS:RATES\x00\x00\x00\xDC\x05"...), 1, 0x04, 0x29, ' ') + for { + got = ask([]byte{1, 0x2A, 0xDC, 0x05}, 1) + if got[1] == 0x2B { + break + } + if got[1] != 0x04 || got[2] != 0x2A { + t.Fatalf("a piece: % x", got[:3]) + } + } + + // the forums: the list, a forum, a section, a message + got = ask(append([]byte{1, 0x24}, "CIS:FORUMS\x00"...), append([]byte{1, 0x27, 0}, "CIS:FORUMS\x00"...)...) + if !bytes.Contains(got, []byte("\x02\x00Amiga Tech Forum\x00")) { + t.Fatalf("forums: %q", got) + } + got = ask(append([]byte{1, 0x25}, "CIS:FORUMS\x00\x02"...), append([]byte{1, 0x27, 0}, "CIS:AMIGATECH\x00"...)...) + if !bytes.Contains(got, []byte("Messages: Hardware (1)\x00")) { + t.Fatalf("forum: %q", got) + } + got = ask(append([]byte{1, 0x25}, "CIS:AMIGATECH\x00\x01"...), append([]byte{1, 0x27, 0}, "CIS:AMIGATECH/S0\x00"...)...) + if !bytes.Contains(got, []byte("Kickstart 1.3 (sysop)")) { + t.Fatalf("section: %q", got) + } + mname := fmt.Sprintf("CIS:AMIGATECH/M%d\x00", post) + ask(append([]byte{1, 0x25}, "CIS:AMIGATECH/S0\x00\x01"...), append([]byte{1, 0x28}, mname...)...) + got = ask(append(append([]byte{1, 0x29}, mname...), 0, 0, 0xDC, 5), 1, 0x04, 0x29) + if !bytes.Contains(got, []byte("Fm: sysop")) || !bytes.Contains(got, []byte("Which ROM do you have?")) { + t.Errorf("message: %q", got) } ask([]byte{1, 0x2A, 0xDC, 0x05}, 1, 0x2B, 0) + + // Mail: Get Mail asks for HOM:MAILHMI; a letter read is marked read + got = ask(append([]byte{1, 0x24}, "HOM:MAILHMI\x00"...), append([]byte{1, 0x27, 0}, "CIS:MAIL\x00"...)...) + if !bytes.Contains(got, []byte("\x01\x00* Hello (sysop [72000,2])\x00")) { + t.Fatalf("mailbox: %q", got) + } + got = ask(append([]byte{1, 0x25}, "CIS:MAIL\x00\x01"...), append([]byte{1, 0x28}, "CIS:MAIL/"...)...) + letter := got[2 : 2+bytes.IndexByte(got[2:], 0)+1] + got = ask(append(append([]byte{1, 0x29}, letter...), 0, 0, 0xDC, 5), 1, 0x04, 0x29) + if !bytes.Contains(got, []byte("Subj: Hello")) || !bytes.Contains(got, []byte("Welcome to CIM.")) { + t.Errorf("letter: %q", got) + } + ask([]byte{1, 0x2A, 0xDC, 0x05}, 1, 0x2B, 0) + if n, _ := e.b.Store.UnreadMail(1); n != 0 { + t.Errorf("%d unread after reading", n) + } ask(append([]byte{1, 0x24}, "CIS:NEWPAGE\x00"...), append([]byte{1, 0x28}, "CIS:NEW\x00"...)...) ask(append([]byte{1, 0x24}, "HOM:XYZZY\x00"...), append([]byte{1, 0x28}, "CIS:XYZZY\x00"...)...) got = ask(append([]byte{1, 0x22, 0x14}, "rates\x00"...), 1, 0x23) diff --git a/internal/server/config.go b/internal/server/config.go index 7ca4c27..27d6bd7 100644 --- a/internal/server/config.go +++ b/internal/server/config.go @@ -27,6 +27,7 @@ import ( "github.com/D-Modem/bbs/internal/ircd" "github.com/D-Modem/bbs/internal/logo" "github.com/D-Modem/bbs/internal/mrc" + "github.com/D-Modem/bbs/internal/msn" "github.com/D-Modem/bbs/internal/nntp" "github.com/D-Modem/bbs/internal/oscar" "github.com/D-Modem/bbs/internal/phone" @@ -61,6 +62,7 @@ type Config struct { Finger *finger.Settings // nil: no finger server IRC *ircd.Settings // nil: no IRC server OSCAR *oscar.Settings // nil: no AIM/ICQ server + MSN *msn.Settings // nil: no MSN Messenger server MRC *mrc.Settings // nil: not on Multi Relay Chat Screens *screens.Set // nil: no screens of the sysop's ScriptsDir string // "": no scripts @@ -140,6 +142,9 @@ func load(cf *config.File) (*Config, error) { if err := c.oscarSection(cf); err != nil { return nil, err } + if err := c.msnSection(cf); err != nil { + return nil, err + } if err := c.mrcSection(cf); err != nil { return nil, err } @@ -212,7 +217,7 @@ func load(cf *config.File) (*Config, error) { } for _, s := range cf.Sections { switch s.Kind { - case "general", "security", "backup", "modemmenu", "event", "listen", "ftp", "news", "nntp", "peer", "qwknet", "fido", "binkp", "link", "door", "finger", "gopher", "time", "ntp", "nts", "ptp", "irc", "oscar", "mrc", "menu", "strings", "http", "level", "chan": + case "general", "security", "backup", "modemmenu", "event", "listen", "ftp", "news", "nntp", "peer", "qwknet", "fido", "binkp", "link", "door", "finger", "gopher", "time", "ntp", "nts", "ptp", "irc", "oscar", "msn", "mrc", "menu", "strings", "http", "level", "chan": default: return nil, fmt.Errorf("line %d: unknown section [%s]", s.Line, s.Kind) } @@ -502,6 +507,12 @@ func listener(sec *config.Section) (*Listener, error) { if l.HeaderTimeout, err = sec.Seconds("header_timeout", 10, 1, 300); err != nil { return nil, err } + if l.Handoff, err = sec.Bool("handoff", false); err != nil { + return nil, err + } + if l.Handoff && (!l.Unix() || !l.Header || l.Kind != "raw") { + return nil, errors.New("handoff: needs type = raw on a unix socket, and header = yes") + } if l.TrustUser, err = sec.Bool("trust_user", false); err != nil { return nil, err } diff --git a/internal/server/handoff.go b/internal/server/handoff.go new file mode 100644 index 0000000..1fd7226 --- /dev/null +++ b/internal/server/handoff.go @@ -0,0 +1,200 @@ +package server + +import ( + "errors" + "fmt" + "io" + "net" + "os" + "strings" + "sync" + "syscall" + "time" + + "golang.org/x/sys/unix" + + "github.com/D-Modem/bbs/internal/bbs" +) + +// The handoff: a caller's line itself, a terminal, passed to the BBS over +// a unix socket (SCM_RIGHTS) with the session header, by modemmenu's item +// with handoff = yes (or app_dmodem's profile with handoff = yes, the +// modem's pty). The BBS reads and writes the terminal; nothing copies +// between. What the sender had read of the line and not used comes on +// the connection right after the header; then the connection carries +// nothing more and stays open while the BBS has the line. Closing it +// gives the line back; the sender closing it takes the line away. + +// ReadHeaderFD is ReadHeader on a unix socket, and the descriptor that +// came with it (nil: none came). +func ReadHeaderFD(c *net.UnixConn, timeout time.Duration) (map[string]string, *os.File, error) { + c.SetReadDeadline(time.Now().Add(timeout)) + defer c.SetReadDeadline(time.Time{}) + var got *os.File + fail := func(err error) (map[string]string, *os.File, error) { + if got != nil { + got.Close() + } + return nil, nil, err + } + h := map[string]string{} + var line []byte + b := make([]byte, 1) + oob := make([]byte, unix.CmsgSpace(4*4)) + for total := 0; ; total++ { + if total >= headerMaxBytes { + return fail(errors.New("header: too long")) + } + n, oobn, _, _, err := c.ReadMsgUnix(b, oob) + if oobn > 0 { + msgs, perr := unix.ParseSocketControlMessage(oob[:oobn]) + if perr != nil { + return fail(fmt.Errorf("header: %w", perr)) + } + for i := range msgs { + fds, _ := unix.ParseUnixRights(&msgs[i]) + for _, fd := range fds { + if got != nil { + unix.Close(fd) + return fail(errors.New("header: more than one descriptor")) + } + unix.CloseOnExec(fd) + got = os.NewFile(uintptr(fd), "handoff") + } + } + } + if err != nil { + return fail(fmt.Errorf("header: %w", err)) + } + if n == 0 { + return fail(errors.New("header: end of file")) + } + if b[0] != '\n' { + line = append(line, b[0]) + continue + } + s := strings.TrimSuffix(string(line), "\r") + line = line[:0] + if s == "" { + return h, got, nil + } + if len(h) >= headerMaxLines { + return fail(errors.New("header: too many lines")) + } + k, v, ok := strings.Cut(s, "=") + if !ok { + return fail(fmt.Errorf("header: no = in %q", bbs.Clean(s, 40))) + } + h[strings.ToUpper(strings.TrimSpace(k))] = v + } +} + +// lineConn is a handed-over line as a net.Conn: the terminal's bytes +// (after what came on the connection behind the header), the +// connection's addresses; the connection closing hangs it up, and Close +// gives the line back (the terminal's flags as they came) and closes +// the connection. +type lineConn struct { + tty *os.File + ctl net.Conn + first []byte + flags int + once sync.Once +} + +// newLineConn makes a lineConn of the terminal f, handed over on ctl. +func newLineConn(f *os.File, ctl net.Conn) (*lineConn, error) { + fd := int(f.Fd()) + if _, err := unix.IoctlGetTermios(fd, unix.TCGETS); err != nil { + f.Close() + return nil, errors.New("the line handed over is not a terminal") + } + flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFL, 0) + if err != nil { + f.Close() + return nil, err + } + // a copy of it non-blocking, so that deadlines work on it (the + // runtime polls it); f's own goes + nfd, err := unix.FcntlInt(uintptr(fd), unix.F_DUPFD_CLOEXEC, 0) + f.Close() + if err != nil { + return nil, err + } + if err := unix.SetNonblock(nfd, true); err != nil { + unix.Close(nfd) + return nil, err + } + tty := os.NewFile(uintptr(nfd), "handoff") + lc := &lineConn{tty: tty, ctl: ctl, flags: flags} + // what came after the header: there already, sent with it + ctl.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) + buf := make([]byte, 4096) + if n, _ := ctl.Read(buf); n > 0 { + lc.first = append([]byte(nil), buf[:n]...) + } + ctl.SetReadDeadline(time.Time{}) + go func() { + io.Copy(io.Discard, ctl) + lc.Close() + }() + return lc, nil +} + +// Read reads what came behind the header, then the terminal. +func (c *lineConn) Read(p []byte) (int, error) { + if len(c.first) > 0 { + n := copy(p, c.first) + c.first = c.first[n:] + return n, nil + } + n, err := c.tty.Read(p) + return n, closedErr(err) +} + +// Write writes to the terminal. +func (c *lineConn) Write(p []byte) (int, error) { + n, err := c.tty.Write(p) + return n, closedErr(err) +} + +// closedErr is err, as a connection's once the line is closed (hung up +// or given back): net.ErrClosed, which ends a call without a word in the +// log; a terminal hung up reads EIO, the end of the call too. +func closedErr(err error) error { + if errors.Is(err, os.ErrClosed) { + return net.ErrClosed + } + if errors.Is(err, syscall.EIO) { + return io.EOF + } + return err +} + +// Close gives the line back: the terminal's flags restored, our copy of +// it closed, and the connection closed. +func (c *lineConn) Close() error { + c.once.Do(func() { + if rc, err := c.tty.SyscallConn(); err == nil { + rc.Control(func(fd uintptr) { unix.FcntlInt(fd, unix.F_SETFL, c.flags) }) + } + c.tty.Close() + c.ctl.Close() + }) + return nil +} + +// LocalAddr is the connection's. +func (c *lineConn) LocalAddr() net.Addr { return c.ctl.LocalAddr() } + +// RemoteAddr is the connection's. +func (c *lineConn) RemoteAddr() net.Addr { return c.ctl.RemoteAddr() } + +// SetDeadline sets the terminal's. +func (c *lineConn) SetDeadline(t time.Time) error { return c.tty.SetDeadline(t) } + +// SetReadDeadline sets the terminal's. +func (c *lineConn) SetReadDeadline(t time.Time) error { return c.tty.SetReadDeadline(t) } + +// SetWriteDeadline sets the terminal's. +func (c *lineConn) SetWriteDeadline(t time.Time) error { return c.tty.SetWriteDeadline(t) } diff --git a/internal/server/handoff_test.go b/internal/server/handoff_test.go new file mode 100644 index 0000000..d1ec0f7 --- /dev/null +++ b/internal/server/handoff_test.go @@ -0,0 +1,133 @@ +package server + +import ( + "fmt" + "net" + "os" + "path/filepath" + "strconv" + "syscall" + "testing" + "time" + + "golang.org/x/sys/unix" +) + +// ptyConn is a pty's master as a net.Conn, for a dialog: the caller's +// end of a line whose terminal was handed over. +type ptyConn struct{ *os.File } + +// LocalAddr is none. +func (ptyConn) LocalAddr() net.Addr { return nil } + +// RemoteAddr is none. +func (ptyConn) RemoteAddr() net.Addr { return nil } + +// openPty is a new pty, raw: its master (non-blocking, for deadlines) and +// its terminal; the test is skipped where there is none. +func openPty(t *testing.T) (*os.File, *os.File) { + t.Helper() + fd, err := unix.Open("/dev/ptmx", unix.O_RDWR|unix.O_NOCTTY|unix.O_CLOEXEC|unix.O_NONBLOCK, 0) + if err != nil { + t.Skip("no pty:", err) + } + if err := unix.IoctlSetPointerInt(fd, unix.TIOCSPTLCK, 0); err != nil { + t.Skip("no pty:", err) + } + n, err := unix.IoctlGetInt(fd, unix.TIOCGPTN) + if err != nil { + t.Skip("no pty:", err) + } + s, err := os.OpenFile("/dev/pts/"+strconv.Itoa(n), os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + t.Skip("no pty:", err) + } + if tio, err := unix.IoctlGetTermios(int(s.Fd()), unix.TCGETS); err == nil { + tio.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON + tio.Oflag &^= unix.OPOST + tio.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN + unix.IoctlSetTermios(int(s.Fd()), unix.TCSETS, tio) + } + return os.NewFile(uintptr(fd), "ptmx"), s +} + +// handOver is a caller whose line (a pty's terminal) is handed to the +// listener at name with header, as modemmenu's handoff item does: the +// dialog on the line, and the connection +func (e *env) handOver(name, header, after string) (*dialog, *net.UnixConn) { + m, s := openPty(e.t) + c, err := net.Dial("unix", filepath.Join(e.dir, name)) + if err != nil { + e.t.Fatal(err) + } + uc := c.(*net.UnixConn) + if _, _, err := uc.WriteMsgUnix([]byte(header+"\n"+after), unix.UnixRights(int(s.Fd())), nil); err != nil { + e.t.Fatal(err) + } + s.Close() + e.t.Cleanup(func() { m.Close(); c.Close() }) + return &dialog{t: e.t, c: ptyConn{m}}, uc +} + +// TestHandoff: callers whose lines are handed over (SCM_RIGHTS) with the +// header, all on at once, each on its own terminal; logging off gives the +// line back (the connection closes), and the sender closing the +// connection takes it away (the BBS lets go of the terminal) +func TestHandoff(t *testing.T) { + const callers = 4 + e := start(t, nil, &Listener{Name: "menu", Kind: "raw", Address: "handoff.sock", ANSI: "no", + Header: true, Handoff: true, TrustUser: true, CreateUsers: true}) + var ds []*dialog + var cs []*net.UnixConn + for i := 0; i < callers; i++ { + d, c := e.handOver("handoff.sock", fmt.Sprintf("MODEM_USER=caller%d\nMODEM_RATE=26400/31200\n", i), "") + d.expect(fmt.Sprintf("Welcome, caller%d.", i)) + d.expect("Command: ") + ds, cs = append(ds, d), append(cs, c) + } + // who's on: every caller, each on a line of their own + ds[0].send("W") + for i := 0; i < callers; i++ { + ds[0].expect(fmt.Sprintf("caller%d", i)) + } + ds[0].expect("(its number, Enter for none): ") + ds[0].send("\r") + ds[0].expect("Command: ") + + // logging off: the line given back, the connection closed + for i := 0; i < callers-1; i++ { + ds[i].send("GY") + ds[i].expect("Thanks for calling.") + cs[i].SetReadDeadline(time.Now().Add(5 * time.Second)) + if _, err := cs[i].Read(make([]byte, 1)); err == nil || os.IsTimeout(err) { + t.Errorf("caller %d: the connection still open after logging off: %v", i, err) + } + } + // the sender takes the last line away: the BBS lets go of the + // terminal (its master reads the end once no one has the terminal) + last := ds[callers-1] + cs[callers-1].Close() + m := last.c.(ptyConn) + m.SetReadDeadline(time.Now().Add(5 * time.Second)) + buf := make([]byte, 256) + for { + _, err := m.Read(buf) + if err == nil { + continue + } + if os.IsTimeout(err) { + t.Error("the BBS still has the terminal after the connection closed") + } + break + } +} + +// TestHandoffWithoutLine: a handoff listener's header without a line is +// an ordinary call, its bytes on the connection +func TestHandoffWithoutLine(t *testing.T) { + e := start(t, nil, &Listener{Name: "menu", Kind: "raw", Address: "handoff.sock", ANSI: "no", + Header: true, Handoff: true, TrustUser: true, CreateUsers: true}) + d := e.dial("handoff.sock") + d.send("MODEM_USER=dave\n\n") + d.expect("Welcome, dave.") +} diff --git a/internal/server/msnconfig.go b/internal/server/msnconfig.go new file mode 100644 index 0000000..82305d0 --- /dev/null +++ b/internal/server/msnconfig.go @@ -0,0 +1,54 @@ +package server + +import ( + "fmt" + "net" + "strings" + + "github.com/D-Modem/bbs/internal/config" + "github.com/D-Modem/bbs/internal/msn" +) + +// msnSection reads [msn]: the MSN Messenger server for the chat. +func (c *Config) msnSection(cf *config.File) error { + s := cf.Get("msn", "") + if s == nil { + return nil + } + err := func() error { + m := &msn.Settings{Address: s.String("address", ":1863"), Host: s.String("host", ""), + Domain: strings.ToLower(s.String("domain", "")), System: s.String("system", "BBS"), + Site: s.String("site", "")} + if _, _, err := net.SplitHostPort(m.Address); err != nil { + return fmt.Errorf("address: %v", err) + } + if m.Host != "" { + if _, _, err := net.SplitHostPort(m.Host); err != nil { + return fmt.Errorf("host: %v (host:port, where clients are sent for conversations)", err) + } + } + if m.Domain != "" && (strings.ContainsAny(m.Domain, "@ /") || !strings.Contains(m.Domain, ".")) { + return fmt.Errorf("domain: a domain name, as msn.example.org (handles are name@domain)") + } + if m.System == "" || len(m.System) > 32 || strings.ContainsAny(m.System, "@ ") { + return fmt.Errorf("system: a name of 1 to 32 letters and digits") + } + if m.Site != "" && !strings.HasPrefix(m.Site, "http://") && !strings.HasPrefix(m.Site, "https://") { + return fmt.Errorf("site: a web address (http:// or https://)") + } + var err error + if m.MaxClients, err = s.Int("max_clients", 256, 1, 100000); err != nil { + return err + } + // each client opens a connection per conversation + if m.MaxPerIP, err = s.Int("max_per_ip", 16, 0, 1000); err != nil { + return err + } + c.MSN = m + return nil + }() + if err != nil { + return fmt.Errorf("[msn] %w", err) + } + return nil +} diff --git a/internal/server/server.go b/internal/server/server.go index 3571d39..d988ab6 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -62,6 +62,7 @@ type Listener struct { RIP string // auto (ask a BBS terminal program), yes, no VT string // auto: ask terminals what they are (DA1, DA2, ESC Z ...); no Header bool // read a session header first + Handoff bool // unix: the caller's line itself comes with the header (SCM_RIGHTS) HeaderTimeout time.Duration TrustUser bool // the header's MODEM_USER (rlogin's server user) is logged in CreateUsers bool // and gets an account if it has none @@ -375,7 +376,25 @@ func (s *Server) handle(nc net.Conn, l *Listener) { return } if l.Header { - h, err := ReadHeader(c, l.HeaderTimeout) + var h map[string]string + var err error + if uc, ok := nc.(*net.UnixConn); ok && l.Handoff { + var line *os.File + if h, line, err = ReadHeaderFD(uc, l.HeaderTimeout); err == nil && line != nil { + // the caller's line itself: the session on it, the + // connection only its life + lc, lerr := newLineConn(line, nc) + if lerr != nil { + s.B.Log.Printf("[listen %s] %s: %v", l.Name, remote, lerr) + return + } + defer lc.Close() + c = timedConn{lc} + s.B.Log.Printf("[listen %s] %s: the line handed over", l.Name, remote) + } + } else { + h, err = ReadHeader(c, l.HeaderTimeout) + } if err != nil { s.B.Log.Printf("[listen %s] %s: %v", l.Name, remote, err) return @@ -410,7 +429,7 @@ func (s *Server) handle(nc net.Conn, l *Listener) { default: err = s.text(c, c, l, node, "") } - if err != nil && !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) { + if err != nil && !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) && !errors.Is(err, os.ErrClosed) { s.B.Log.Printf("node %d: %v", node.Num, err) } s.B.Log.Printf("node %d: gone", node.Num) diff --git a/internal/store/blocks.go b/internal/store/blocks.go new file mode 100644 index 0000000..dd39052 --- /dev/null +++ b/internal/store/blocks.go @@ -0,0 +1,57 @@ +package store + +// A user's blocked list: BBS users who may not reach them nor see them +// online, the one list every front end that has one shares (MSN's Block +// List; AIM's deny list keeps its own, in the feedbag, for now). + +// Blocked are the users a user blocks, by name (Group and Alias unused). +func (s *Store) Blocked(user int64) ([]Friend, error) { + return s.friendRows(`SELECT b.blocked_id, u.name, '', '', b.added + FROM blocks b JOIN users u ON u.id = b.blocked_id WHERE b.user_id = ? ORDER BY u.name`, user) +} + +// IsBlocked reports whether user blocks other. +func (s *Store) IsBlocked(user, other int64) (bool, error) { + var n int + err := s.db.QueryRow(`SELECT COUNT(*) FROM blocks WHERE user_id = ? AND blocked_id = ?`, user, other).Scan(&n) + return n > 0, err +} + +// Block puts other on user's blocked list. +func (s *Store) Block(user, other int64) error { + _, err := s.db.Exec(`INSERT OR IGNORE INTO blocks (user_id, blocked_id, added) VALUES (?, ?, ?)`, user, other, now()) + return err +} + +// Unblock takes other off user's blocked list. +func (s *Store) Unblock(user, other int64) error { + _, err := s.db.Exec(`DELETE FROM blocks WHERE user_id = ? AND blocked_id = ?`, user, other) + return err +} + +// FriendOf are the users who have user on their friends list, by name +// (Group and Alias theirs). +func (s *Store) FriendOf(user int64) ([]Friend, error) { + return s.friendRows(`SELECT f.user_id, u.name, f.grp, f.alias, f.added + FROM friends f JOIN users u ON u.id = f.user_id WHERE f.friend_id = ? ORDER BY u.name`, user) +} + +// friendRows reads (id, name, group, alias, added) rows. +func (s *Store) friendRows(q string, args ...any) ([]Friend, error) { + rows, err := s.db.Query(q, args...) + if err != nil { + return nil, err + } + defer rows.Close() + var out []Friend + for rows.Next() { + var f Friend + var at int64 + if err := rows.Scan(&f.ID, &f.Name, &f.Group, &f.Alias, &at); err != nil { + return nil, err + } + f.Added = unix(at) + out = append(out, f) + } + return out, rows.Err() +} diff --git a/internal/store/chats.go b/internal/store/chats.go new file mode 100644 index 0000000..eeeab8b --- /dev/null +++ b/internal/store/chats.go @@ -0,0 +1,122 @@ +package store + +import ( + "strings" + "time" +) + +// Chat is a private line one user sent another, kept: by IRC, AIM, ICQ +// or the BBS's own chat. Delivered: the one it was to has had it. +type Chat struct { + ID int64 + FromID int64 + From string + ToID int64 + To string + Text string + Sent time.Time + Delivered bool +} + +const chatCols = `id, from_id, from_name, to_id, to_name, body, created, delivered` + +func scanChats(rows interface { + Next() bool + Scan(...any) error + Err() error +}) ([]Chat, error) { + var out []Chat + for rows.Next() { + var c Chat + var at int64 + if err := rows.Scan(&c.ID, &c.FromID, &c.From, &c.ToID, &c.To, &c.Text, &at, &c.Delivered); err != nil { + return nil, err + } + c.Sent = unix(at) + out = append(out, c) + } + return out, rows.Err() +} + +// AddChat keeps a line; its id. +func (s *Store) AddChat(c *Chat) (int64, error) { + at := c.Sent + if at.IsZero() { + at = time.Now() + } + return s.db.insertID(`INSERT INTO chats (from_id, from_name, to_id, to_name, body, created, delivered) + VALUES (?, ?, ?, ?, ?, ?, ?)`, c.FromID, c.From, c.ToID, c.To, c.Text, at.Unix(), c.Delivered) +} + +// KeptChats are the lines to a user they have not had yet, oldest first. +func (s *Store) KeptChats(to int64) ([]Chat, error) { + rows, err := s.db.Query(`SELECT `+chatCols+` FROM chats WHERE to_id = ? AND delivered = FALSE ORDER BY id`, to) + if err != nil { + return nil, err + } + defer rows.Close() + return scanChats(rows) +} + +// ChatsDelivered marks lines as had. +func (s *Store) ChatsDelivered(ids []int64) error { + if len(ids) == 0 { + return nil + } + args := make([]any, len(ids)) + for i, id := range ids { + args[i] = id + } + _, err := s.db.Exec(`UPDATE chats SET delivered = TRUE WHERE id IN (?`+strings.Repeat(", ?", len(ids)-1)+`)`, args...) + return err +} + +// ChatsBetween are the last lines (at most limit) between two users, either +// way, oldest first. +func (s *Store) ChatsBetween(a, b int64, limit int) ([]Chat, error) { + rows, err := s.db.Query(`SELECT `+chatCols+` FROM chats WHERE (from_id = ? AND to_id = ?) OR (from_id = ? AND to_id = ?) + ORDER BY id DESC LIMIT ?`, a, b, b, a, limit) + if err != nil { + return nil, err + } + defer rows.Close() + cs, err := scanChats(rows) + for i, j := 0, len(cs)-1; i < j; i, j = i+1, j-1 { + cs[i], cs[j] = cs[j], cs[i] + } + return cs, err +} + +// ChatPartner is one a user has talked with: their last line's time, and +// how many lines there are. +type ChatPartner struct { + ID int64 + Name string + Last time.Time + Lines int +} + +// ChatPartners are those a user has talked with, the latest first (at most +// limit). +func (s *Store) ChatPartners(user int64, limit int) ([]ChatPartner, error) { + rows, err := s.db.Query(`SELECT p.other, u.name, MAX(p.created), COUNT(*) FROM + (SELECT to_id AS other, created FROM chats WHERE from_id = ? + UNION ALL SELECT from_id AS other, created FROM chats WHERE to_id = ?) p + JOIN users u ON u.id = p.other + GROUP BY p.other, u.name ORDER BY MAX(p.created) DESC LIMIT ?`, user, user, limit) + if err != nil { + return nil, err + } + defer rows.Close() + var out []ChatPartner + for rows.Next() { + var p ChatPartner + var at int64 + if err := rows.Scan(&p.ID, &p.Name, &at, &p.Lines); err != nil { + return nil, err + } + p.Last = unix(at) + out = append(out, p) + } + return out, rows.Err() +} diff --git a/internal/store/copy.go b/internal/store/copy.go index 96e89f5..a045bff 100644 --- a/internal/store/copy.go +++ b/internal/store/copy.go @@ -13,7 +13,7 @@ import ( // copyOrder is the tables in an order their references allow. var copyOrder = []string{"users", "areas", "messages", "votes", "poll_answers", "poll_votes", "lastread", "scan_off", "mail", "file_areas", "files", "history", "peer_groups", "peer_push", "netmail_out", "api_tokens", "ssh_keys", "script_data", "calls", "qwk_seen", "qwk_msgs", "chat_rooms", "topic_read", "fido_subs", - "chan_boards", "chan_posts", "chan_bans", "chan_reports", "oscar_keys", "feedbag", "cis_keys"} + "chan_boards", "chan_posts", "chan_bans", "chan_reports", "oscar_keys", "feedbag", "cis_keys", "chats", "friends", "oscar_buddies", "msn_keys", "blocks"} var columnPat = regexp.MustCompile(`(?m)^\s*("?\w+"?)\s+(\{\w+\})`) diff --git a/internal/store/friends.go b/internal/store/friends.go new file mode 100644 index 0000000..155dcd6 --- /dev/null +++ b/internal/store/friends.go @@ -0,0 +1,137 @@ +package store + +import ( + "time" +) + +// Friend is one of the BBS users on a user's friends list: the one list +// every front end shows as its own (AIM and ICQ's buddy list, IRC's, +// the BBS's). Group and Alias are the user's own, for lists that have +// them ("": none). +type Friend struct { + ID int64 // the friend's user id + Name string // their name (read) + Group string + Alias string + Added time.Time +} + +// Friends is a user's friends list, by name. +func (s *Store) Friends(user int64) ([]Friend, error) { + rows, err := s.db.Query(`SELECT f.friend_id, u.name, f.grp, f.alias, f.added + FROM friends f JOIN users u ON u.id = f.friend_id WHERE f.user_id = ? ORDER BY u.name`, user) + if err != nil { + return nil, err + } + defer rows.Close() + var out []Friend + for rows.Next() { + var f Friend + var at int64 + if err := rows.Scan(&f.ID, &f.Name, &f.Group, &f.Alias, &at); err != nil { + return nil, err + } + f.Added = unix(at) + out = append(out, f) + } + return out, rows.Err() +} + +// IsFriend reports whether friend is on user's list. +func (s *Store) IsFriend(user, friend int64) (bool, error) { + var n int + err := s.db.QueryRow(`SELECT COUNT(*) FROM friends WHERE user_id = ? AND friend_id = ?`, user, friend).Scan(&n) + return n > 0, err +} + +// PutFriend adds a friend to a user's list, or sets their group and alias. +func (s *Store) PutFriend(user int64, f Friend) error { + t, err := s.db.Begin() + if err != nil { + return err + } + defer t.Rollback() + var n int + if err := t.QueryRow(`SELECT COUNT(*) FROM friends WHERE user_id = ? AND friend_id = ?`, user, f.ID).Scan(&n); err != nil { + return err + } + if n > 0 { + _, err = t.Exec(`UPDATE friends SET grp = ?, alias = ? WHERE user_id = ? AND friend_id = ?`, f.Group, f.Alias, user, f.ID) + } else { + _, err = t.Exec(`INSERT INTO friends (user_id, friend_id, grp, alias, added) VALUES (?, ?, ?, ?, ?)`, + user, f.ID, f.Group, f.Alias, now()) + } + if err != nil { + return err + } + return t.Commit() +} + +// RemoveFriend takes a friend off a user's list (and its place in any +// front end's list). +func (s *Store) RemoveFriend(user, friend int64) error { + t, err := s.db.Begin() + if err != nil { + return err + } + defer t.Rollback() + for _, q := range []string{`DELETE FROM friends WHERE user_id = ? AND friend_id = ?`, + `DELETE FROM oscar_buddies WHERE user_id = ? AND friend_id = ?`} { + if _, err := t.Exec(q, user, friend); err != nil { + return err + } + } + return t.Commit() +} + +// OSCARBuddy is a friend's place in a user's AIM/ICQ buddy list: the name +// as the client wrote it, its group and item ids, its TLVs. +type OSCARBuddy struct { + FriendID int64 + SN string + GroupID uint16 + ItemID uint16 + Attrs []byte +} + +// OSCARBuddies are the places of a user's friends in their buddy list, by +// friend. +func (s *Store) OSCARBuddies(user int64) (map[int64]OSCARBuddy, error) { + rows, err := s.db.Query(`SELECT friend_id, sn, group_id, item_id, attrs FROM oscar_buddies WHERE user_id = ?`, user) + if err != nil { + return nil, err + } + defer rows.Close() + out := map[int64]OSCARBuddy{} + for rows.Next() { + var b OSCARBuddy + var g, i int64 + if err := rows.Scan(&b.FriendID, &b.SN, &g, &i, &b.Attrs); err != nil { + return nil, err + } + b.GroupID, b.ItemID = uint16(g), uint16(i) + out[b.FriendID] = b + } + return out, rows.Err() +} + +// PutOSCARBuddy records a friend's place in a user's buddy list. +func (s *Store) PutOSCARBuddy(user int64, b OSCARBuddy) error { + t, err := s.db.Begin() + if err != nil { + return err + } + defer t.Rollback() + attrs := b.Attrs + if attrs == nil { + attrs = []byte{} + } + if _, err := t.Exec(`DELETE FROM oscar_buddies WHERE user_id = ? AND friend_id = ?`, user, b.FriendID); err != nil { + return err + } + if _, err := t.Exec(`INSERT INTO oscar_buddies (user_id, friend_id, sn, group_id, item_id, attrs) VALUES (?, ?, ?, ?, ?, ?)`, + user, b.FriendID, b.SN, int64(b.GroupID), int64(b.ItemID), attrs); err != nil { + return err + } + return t.Commit() +} diff --git a/internal/store/msn.go b/internal/store/msn.go new file mode 100644 index 0000000..a0798f6 --- /dev/null +++ b/internal/store/msn.go @@ -0,0 +1,91 @@ +package store + +import ( + "crypto/md5" + "crypto/rand" + "database/sql" + "encoding/hex" + "errors" +) + +// MSN Messenger's MD5 login (MSNP2 to MSNP7: MSN 1.0 to 4.7) proves the +// password by MD5(salt + password), the salt the server's, which a bcrypt +// hash cannot check. So each account gets a fixed salt and the digest of +// its password with it, kept whenever the password is known in the clear +// and bound to the password hash it was made with, as the AIM digests are +// (oscar.go). A fixed salt makes the digest replayable: anyone who sees +// a login can log in again. MSN 1.0 to 4.7 had no better way. + +// MSNDigest is an MD5 login's answer: MD5(salt + password), in lowercase +// hex. +func MSNDigest(salt, pw string) string { + h := md5.Sum([]byte(salt + pw)) + return hex.EncodeToString(h[:]) +} + +// SetKeepMSN says whether to keep the digests: only with an MSN server, +// as they would let anyone who read the database log in by MSN. +func (s *Store) SetKeepMSN(on bool) { s.keepMSN.Store(on) } + +// MSNKey is the account's MD5 login salt and digest; ok false: no current +// digest (none kept, or the password changed since). +func (s *Store) MSNKey(id int64) (salt, digest string, ok bool, err error) { + var bound, hash string + err = s.db.QueryRow(`SELECT m.salt, m.digest, m.bound, u.password FROM msn_keys m + JOIN users u ON u.id = m.user_id WHERE m.user_id = ?`, id).Scan(&salt, &digest, &bound, &hash) + if errors.Is(err, sql.ErrNoRows) { + return "", "", false, nil + } + if err != nil { + return "", "", false, err + } + return salt, digest, bound == hash && digest != "", nil +} + +// MSNSalt is the salt an MD5 login gives the account: its kept one, or a +// new one kept for it (with no digest yet). +func (s *Store) MSNSalt(id int64) (string, error) { + var salt string + err := s.db.QueryRow(`SELECT salt FROM msn_keys WHERE user_id = ?`, id).Scan(&salt) + if err == nil { + return salt, nil + } + if !errors.Is(err, sql.ErrNoRows) { + return "", err + } + b := make([]byte, 10) + rand.Read(b) + salt = hex.EncodeToString(b) + if _, err := s.db.Exec(`INSERT OR IGNORE INTO msn_keys (user_id, salt, digest, bound) VALUES (?, ?, '', '')`, id, salt); err != nil { + return "", err + } + // another login may have made one meanwhile + err = s.db.QueryRow(`SELECT salt FROM msn_keys WHERE user_id = ?`, id).Scan(&salt) + return salt, err +} + +// KeepMSNKey makes the account's MD5 login digest of pw (its password, +// just checked or set), bound to its password hash now, if the store keeps +// them (SetKeepMSN). Nothing is written if it is current already. +func (s *Store) KeepMSNKey(id int64, pw string) error { + if !s.keepMSN.Load() || pw == "" { + return nil + } + var hash string + if err := s.db.QueryRow(`SELECT password FROM users WHERE id = ?`, id).Scan(&hash); err != nil { + if errors.Is(err, sql.ErrNoRows) { + return ErrNotFound + } + return err + } + salt, err := s.MSNSalt(id) + if err != nil { + return err + } + d := MSNDigest(salt, pw) + if _, old, ok, err := s.MSNKey(id); err == nil && ok && old == d { + return nil + } + _, err = s.db.Exec(`UPDATE msn_keys SET digest = ?, bound = ? WHERE user_id = ?`, d, hash, id) + return err +} diff --git a/internal/store/msn_test.go b/internal/store/msn_test.go new file mode 100644 index 0000000..06bdfce --- /dev/null +++ b/internal/store/msn_test.go @@ -0,0 +1,82 @@ +package store + +import ( + "path/filepath" + "testing" +) + +// TestMSNKeys: digests kept only when asked, made at a password's check, +// stale once the password changes, made again (same salt) when it is set. +func TestMSNKeys(t *testing.T) { + BcryptCost = 4 + s, err := Open(filepath.Join(t.TempDir(), "bbs.db")) + if err != nil { + t.Fatal(err) + } + defer s.Close() + u, _ := s.CreateUser("alice", "password1", "", false) + if _, _, ok, _ := s.MSNKey(u.ID); ok { + t.Fatal("kept without SetKeepMSN") + } + s.SetKeepMSN(true) + if _, err := s.CheckPassword("alice", "password1"); err != nil { + t.Fatal(err) + } + salt, d, ok, err := s.MSNKey(u.ID) + if err != nil || !ok || salt == "" || d != MSNDigest(salt, "password1") { + t.Fatalf("key %q %q %v %v", salt, d, ok, err) + } + if again, _ := s.MSNSalt(u.ID); again != salt { + t.Errorf("salt changed: %q %q", salt, again) + } + s.db.Exec(`UPDATE users SET password = ? WHERE id = ?`, "x", u.ID) + if _, _, ok, _ := s.MSNKey(u.ID); ok { + t.Error("stale digest used") + } + s.SetPassword(u.ID, "password2") + if salt2, d2, ok, _ := s.MSNKey(u.ID); !ok || salt2 != salt || d2 != MSNDigest(salt, "password2") { + t.Errorf("after set: %q %q %v", salt2, d2, ok) + } + if MSNDigest("prefix", "password") != "61ed83ed9d177e0c99b83a2138623a4b" { + t.Error("digest form") + } +} + +// TestBlocks: blocking, unblocking, and who has a user as a friend. +func TestBlocks(t *testing.T) { + BcryptCost = 4 + s, err := Open(filepath.Join(t.TempDir(), "bbs.db")) + if err != nil { + t.Fatal(err) + } + defer s.Close() + a, _ := s.CreateUser("alice", "pw", "", false) + b, _ := s.CreateUser("bob", "pw", "", false) + c, _ := s.CreateUser("carol", "pw", "", false) + if err := s.Block(a.ID, b.ID); err != nil { + t.Fatal(err) + } + if err := s.Block(a.ID, b.ID); err != nil { + t.Fatal("twice:", err) + } + if ok, _ := s.IsBlocked(a.ID, b.ID); !ok { + t.Error("not blocked") + } + if ok, _ := s.IsBlocked(b.ID, a.ID); ok { + t.Error("blocked the other way") + } + bl, _ := s.Blocked(a.ID) + if len(bl) != 1 || bl[0].Name != "bob" { + t.Errorf("blocked %+v", bl) + } + s.Unblock(a.ID, b.ID) + if ok, _ := s.IsBlocked(a.ID, b.ID); ok { + t.Error("still blocked") + } + s.PutFriend(b.ID, Friend{ID: a.ID, Group: "Pals"}) + s.PutFriend(c.ID, Friend{ID: a.ID}) + of, _ := s.FriendOf(a.ID) + if len(of) != 2 || of[0].Name != "bob" || of[0].Group != "Pals" || of[1].Name != "carol" { + t.Errorf("friend of %+v", of) + } +} diff --git a/internal/store/schema.go b/internal/store/schema.go index 83c53be..2574082 100644 --- a/internal/store/schema.go +++ b/internal/store/schema.go @@ -248,6 +248,45 @@ CREATE TABLE IF NOT EXISTS feedbag ( attrs {blob}, PRIMARY KEY (user_id, group_id, item_id) )`, ` +CREATE TABLE IF NOT EXISTS chats ( + id {id}, + from_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + from_name {str} NOT NULL, + to_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + to_name {str} NOT NULL, + body {text} NOT NULL, + created {int} NOT NULL, + delivered {bool} NOT NULL DEFAULT FALSE +)`, ` +CREATE TABLE IF NOT EXISTS msn_keys ( + user_id {int} NOT NULL PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE, + salt {str} NOT NULL, + digest {str} NOT NULL, + bound {str} NOT NULL +)`, ` +CREATE TABLE IF NOT EXISTS blocks ( + user_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + blocked_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + added {int} NOT NULL, + PRIMARY KEY (user_id, blocked_id) +)`, ` +CREATE TABLE IF NOT EXISTS friends ( + user_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + friend_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + grp {str} NOT NULL DEFAULT '', + alias {str} NOT NULL DEFAULT '', + added {int} NOT NULL, + PRIMARY KEY (user_id, friend_id) +)`, ` +CREATE TABLE IF NOT EXISTS oscar_buddies ( + user_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + friend_id {int} NOT NULL REFERENCES users(id) ON DELETE CASCADE, + sn {str} NOT NULL, + group_id {int} NOT NULL, + item_id {int} NOT NULL, + attrs {blob}, + PRIMARY KEY (user_id, friend_id) +)`, ` CREATE TABLE IF NOT EXISTS chan_boards ( id {id}, dir {name} NOT NULL UNIQUE, @@ -365,6 +404,8 @@ var indexes = []struct { {"chan_posts_md5", "chan_posts", "board_id, md5", false}, {"chan_posts_ip", "chan_posts", "ip, created", false}, {"chan_reports_post", "chan_reports", "board_id, num", false}, + {"chats_to", "chats", "to_id, delivered", false}, + {"chats_pair", "chats", "from_id, to_id, id", false}, } // added are the columns added since the first schema: an older database diff --git a/internal/store/store.go b/internal/store/store.go index 88b022b..ad287c0 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -119,6 +119,8 @@ type Store struct { keepOSCAR atomic.Bool // keepCIS: and their CompuServe Secure Login keys (cis.go) keepCIS atomic.Bool + // keepMSN: and their MSN MD5 login digests (msn.go) + keepMSN atomic.Bool } // Open opens (and makes, if need be) the database at addr: a file's path @@ -256,6 +258,7 @@ func (s *Store) CreateUser(name, password, location string, sysop bool) (*User, if password != "" { s.KeepOSCARKeys(id, password) s.KeepCISKey(id, password) + s.KeepMSNKey(id, password) } return s.UserByID(id) } @@ -289,6 +292,7 @@ func (s *Store) CheckPassword(name, pw string) (*User, error) { } s.KeepOSCARKeys(u.ID, pw) // best effort: the login stands without them s.KeepCISKey(u.ID, pw) + s.KeepMSNKey(u.ID, pw) return u, nil } @@ -304,6 +308,9 @@ func (s *Store) SetPassword(id int64, pw string) error { if err := s.KeepCISKey(id, pw); err != nil { return err } + if err := s.KeepMSNKey(id, pw); err != nil { + return err + } return s.KeepOSCARKeys(id, pw) } diff --git a/mkdocs.yml b/mkdocs.yml index c13f208..4a3253f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -51,6 +51,7 @@ nav: - "Chat and paging": Chat-and-Paging.md - "IRC": IRC.md - "AIM and ICQ": AIM-and-ICQ.md + - "MSN Messenger": MSN-Messenger.md - "MRC": MRC.md - "Finger and gopher": Finger-and-Gopher.md - "Time: NTP, NTS and PTP": Time.md