1*0e96539fSCharles.ForsythRFC822: module 2*0e96539fSCharles.Forsyth{ 3*0e96539fSCharles.Forsyth PATH: con "/dis/lib/rfc822.dis"; 4*0e96539fSCharles.Forsyth 5*0e96539fSCharles.Forsyth init: fn(b: Bufio); 6*0e96539fSCharles.Forsyth 7*0e96539fSCharles.Forsyth # TO DO: multipart ... 8*0e96539fSCharles.Forsyth 9*0e96539fSCharles.Forsyth # token values reserved to represent a word and a quoted string 10*0e96539fSCharles.Forsyth Word, QString: con 1+iota; 11*0e96539fSCharles.Forsyth 12*0e96539fSCharles.Forsyth Maxrequest: con 16*1024; # more than enough for anything sensible 13*0e96539fSCharles.Forsyth 14*0e96539fSCharles.Forsyth Rfclex: adt { 15*0e96539fSCharles.Forsyth fd: ref Bufio->Iobuf; # open on a single line 16*0e96539fSCharles.Forsyth wordval: string; # text if Word or QString 17*0e96539fSCharles.Forsyth tok: int; # last token seen 18*0e96539fSCharles.Forsyth eof: int; # end of file (ignore subsequent ungetc) 19*0e96539fSCharles.Forsyth 20*0e96539fSCharles.Forsyth seen: list of (int, string); # pushback 21*0e96539fSCharles.Forsyth 22*0e96539fSCharles.Forsyth mk: fn(a: array of byte): ref Rfclex; 23*0e96539fSCharles.Forsyth getc: fn(p: self ref Rfclex): int; 24*0e96539fSCharles.Forsyth ungetc: fn(p: self ref Rfclex); 25*0e96539fSCharles.Forsyth lex: fn(p: self ref Rfclex): int; 26*0e96539fSCharles.Forsyth unlex: fn(p: self ref Rfclex); 27*0e96539fSCharles.Forsyth skipws: fn(p: self ref Rfclex): int; 28*0e96539fSCharles.Forsyth 29*0e96539fSCharles.Forsyth line: fn(p: self ref Rfclex): string; 30*0e96539fSCharles.Forsyth }; 31*0e96539fSCharles.Forsyth 32*0e96539fSCharles.Forsyth readheaders: fn(fd: ref Bufio->Iobuf, limit: int): array of (string, array of byte); 33*0e96539fSCharles.Forsyth parseparams: fn(ps: ref Rfclex): list of (string, string); 34*0e96539fSCharles.Forsyth parsecontent: fn(ps: ref Rfclex, multipart: int, head: list of ref Content): list of ref Content; 35*0e96539fSCharles.Forsyth mimefields: fn(ps: ref Rfclex): list of (string, list of (string, string)); 36*0e96539fSCharles.Forsyth # TO DO: parse addresses 37*0e96539fSCharles.Forsyth 38*0e96539fSCharles.Forsyth quotable: fn(s: string): int; 39*0e96539fSCharles.Forsyth quote: fn(s: string): string; 40*0e96539fSCharles.Forsyth 41*0e96539fSCharles.Forsyth # convert an epoch time into http-formatted text 42*0e96539fSCharles.Forsyth sec2date: fn(secs: int): string; 43*0e96539fSCharles.Forsyth 44*0e96539fSCharles.Forsyth # convert a date in http text format to seconds from epoch 45*0e96539fSCharles.Forsyth date2sec: fn(s: string): int; 46*0e96539fSCharles.Forsyth 47*0e96539fSCharles.Forsyth # current time 48*0e96539fSCharles.Forsyth now: fn(): int; 49*0e96539fSCharles.Forsyth 50*0e96539fSCharles.Forsyth # current time as a string 51*0e96539fSCharles.Forsyth time: fn(): string; 52*0e96539fSCharles.Forsyth 53*0e96539fSCharles.Forsyth # 54*0e96539fSCharles.Forsyth # mime-related things 55*0e96539fSCharles.Forsyth # 56*0e96539fSCharles.Forsyth Content: adt{ 57*0e96539fSCharles.Forsyth generic: string; 58*0e96539fSCharles.Forsyth specific: string; 59*0e96539fSCharles.Forsyth params: list of (string, string); 60*0e96539fSCharles.Forsyth 61*0e96539fSCharles.Forsyth mk: fn(generic: string, specific: string, params: list of (string, string)): ref Content; 62*0e96539fSCharles.Forsyth check: fn(c: self ref Content, oks: list of ref Content): int; 63*0e96539fSCharles.Forsyth text: fn(c: self ref Content): string; 64*0e96539fSCharles.Forsyth }; 65*0e96539fSCharles.Forsyth 66*0e96539fSCharles.Forsyth suffixclass: fn(name: string): (ref Content, ref Content); 67*0e96539fSCharles.Forsyth dataclass: fn(a: array of byte): (ref Content, ref Content); 68*0e96539fSCharles.Forsyth}; 69