diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/csv.m | 8 | ||||
| -rw-r--r-- | module/ida.m | 24 | ||||
| -rw-r--r-- | module/rfc822.m | 68 | ||||
| -rw-r--r-- | module/uris.m | 36 |
4 files changed, 136 insertions, 0 deletions
diff --git a/module/csv.m b/module/csv.m new file mode 100644 index 00000000..059d97ec --- /dev/null +++ b/module/csv.m @@ -0,0 +1,8 @@ +CSV: module +{ + PATH: con "/dis/lib/csv.dis"; + + init: fn(b: Bufio); + getline: fn(fd: ref Bufio->Iobuf): list of string; + quote: fn(s: string): string; +}; diff --git a/module/ida.m b/module/ida.m new file mode 100644 index 00000000..f2503dd7 --- /dev/null +++ b/module/ida.m @@ -0,0 +1,24 @@ +Ida: module +{ + PATH: con "/dis/lib/ida/ida.dis"; + + Frag: adt { + dlen: int; # length of original data + m: int; # minimum pieces for reconstruction + a: array of int; # encoding array row for this fragment + enc: array of int; # encoded data + + tag: array of byte; # user data, such as SHA1 hash + }; + + init: fn(); + fragment: fn(data: array of byte, m: int): ref Frag; + consistent: fn(frags: array of ref Frag): array of ref Frag; + reconstruct: fn(frags: array of ref Frag): (array of byte, string); +}; + +Idatab: module +{ + PATH: con "/dis/lib/ida/idatab.dis"; + init: fn(): array of int; +}; diff --git a/module/rfc822.m b/module/rfc822.m new file mode 100644 index 00000000..7e4c8897 --- /dev/null +++ b/module/rfc822.m @@ -0,0 +1,68 @@ +RFC822: module +{ + PATH: con "/dis/lib/rfc822.dis"; + + init: fn(b: Bufio); + + # TO DO: multipart ... + + # token values reserved to represent a word and a quoted string + Word, QString: con 1+iota; + + Maxrequest: con 16*1024; # more than enough for anything sensible + + Rfclex: adt { + fd: ref Bufio->Iobuf; # open on a single line + wordval: string; # text if Word or QString + tok: int; # last token seen + eof: int; # end of file (ignore subsequent ungetc) + + seen: list of (int, string); # pushback + + mk: fn(a: array of byte): ref Rfclex; + getc: fn(p: self ref Rfclex): int; + ungetc: fn(p: self ref Rfclex); + lex: fn(p: self ref Rfclex): int; + unlex: fn(p: self ref Rfclex); + skipws: fn(p: self ref Rfclex): int; + + line: fn(p: self ref Rfclex): string; + }; + + readheaders: fn(fd: ref Bufio->Iobuf, limit: int): array of (string, array of byte); + parseparams: fn(ps: ref Rfclex): list of (string, string); + parsecontent: fn(ps: ref Rfclex, multipart: int, head: list of ref Content): list of ref Content; + mimefields: fn(ps: ref Rfclex): list of (string, list of (string, string)); + # TO DO: parse addresses + + quotable: fn(s: string): int; + quote: fn(s: string): string; + + # convert an epoch time into http-formatted text + sec2date: fn(secs: int): string; + + # convert a date in http text format to seconds from epoch + date2sec: fn(s: string): int; + + # current time + now: fn(): int; + + # current time as a string + time: fn(): string; + + # + # mime-related things + # + Content: adt{ + generic: string; + specific: string; + params: list of (string, string); + + mk: fn(generic: string, specific: string, params: list of (string, string)): ref Content; + check: fn(c: self ref Content, oks: list of ref Content): int; + text: fn(c: self ref Content): string; + }; + + suffixclass: fn(name: string): (ref Content, ref Content); + dataclass: fn(a: array of byte): (ref Content, ref Content); +}; diff --git a/module/uris.m b/module/uris.m new file mode 100644 index 00000000..cc2226c6 --- /dev/null +++ b/module/uris.m @@ -0,0 +1,36 @@ +URIs: module +{ + PATH: con "/dis/lib/w3c/uris.dis"; + + # URI Generic Syntax (RFC 3986) + # + # scheme://authority/path?query#fragment + # + URI: adt + { + scheme: string; + userinfo: string; # authority, part I + host: string; # authority, part II + port: string; # authority, part III + path: string; # starts with / if path-abempty or path-absolute + query: string; # includes ? if not nil + fragment: string; # includes # if not nil + + parse: fn(s: string): ref URI; + text: fn(u: self ref URI): string; + authority: fn(u: self ref URI): string; + addbase: fn(u: self ref URI, base: ref URI): ref URI; + copy: fn(u: self ref URI): ref URI; + hasauthority: fn(u: self ref URI): int; + isabsolute: fn(u: self ref URI): int; + nodots: fn(u: self ref URI): ref URI; + pathonly: fn(u: self ref URI): ref URI; + userpw: fn(u: self ref URI): (string, string); # ``deprecated format'' + eq: fn(u: self ref URI, v: ref URI): int; + eqf: fn(u: self ref URI, v: ref URI): int; + }; + + init: fn(); + dec: fn(s: string): string; + enc: fn(s: string, safe: string): string; +}; |
