Hello, I have looked at the code, and have a question about the redirectinit() function in /sys/src/cmd/ip/httpd/redirect.c: void redirectinit(void) { static Biobuf *b = nil; static Qid qid; char *file, *line, *s, *host, *field[3]; static char pfx[] = "http://"; file = "/sys/lib/httpd.rewrite"; if(b != nil){ if( (Bfildes(b), &qid) == 0) return; Bterm(b); } ... } In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for? Many thanks in advance and best regards, sahu
On 8/2/22 10:51, sahu@mailbox.org wrote:
> Hello,
>
> I have looked at the code, and have a question about the redirectinit() function in /sys/src/cmd/ip/httpd/redirect.c:
>
> void
> redirectinit(void)
> {
> static Biobuf *b = nil;
> static Qid qid;
> char *file, *line, *s, *host, *field[3];
> static char pfx[] = "http://";
>
> file = "/sys/lib/httpd.rewrite";
> if(b != nil){
> if( (Bfildes(b), &qid) == 0)
> return;
> Bterm(b);
> }
> ...
> }
>
> In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
>
> Many thanks in advance and best regards,
> sahu
Note that 'b' is declared as static, meaning it will retain it's values between calls.
So b will be nil on only the first call to this function, subsequent calls will have
a valid pointer.
---
Moody
Quoth sahu@mailbox.org:
> In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
The system ships with documentation.
% man Bfildes
<Bfildes manpage>
% lookman Biobuf
man 2 bio # bio(2)
man 2 object # object(2)
man 2 string # string(2)
% lookman Qid
(ok, this one gives a lot of output; you want man 5 intro)
And, nobody really said what Qid stands for, but it's just
a uniQue ID.
On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
>
> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
>
The B functions are buffered i/o; see the bio(2) manpage for more.
I have never heard a convincing theory explaining the selection of Q.
khm
On 8/2/22 11:13, Kurt H Maier wrote:
> On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
>>
>> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
>>
>
> The B functions are buffered i/o; see the bio(2) manpage for more.
>
> I have never heard a convincing theory explaining the selection of Q.
>
> khm
>
My thought has been the Q was for uniQue. But that doesn't
seem quite right.
Quoth Jacob Moody <moody@mail.posixcafe.org>:
> On 8/2/22 11:13, Kurt H Maier wrote:
> > On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
> >>
> >> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
> >>
> >
> > The B functions are buffered i/o; see the bio(2) manpage for more.
> >
> > I have never heard a convincing theory explaining the selection of Q.
> >
> > khm
> >
>
> My thought has been the Q was for uniQue. But that doesn't
> seem quite right.
Since many of the Unix room staff were either Canadian or
British, I think it stands for Queen's ID.
Maye you should ask the question about Q either the Q continuum, on the 9fans mailing list or the tuhs list and some of the old unix beards can answer? It would be really interesting to know or at least hear their thoughts. My theories: Q is a weird letter that's not often used in the alphabet, unlike a,b,c, and a big Q, so it's not a context specific prefix. Compare to, well, B for bio-stuff. Q as in, queue. Maybe at some point they had some kinda queue implementation for dynamic filesystems, and the Qid was some kinda identifier in that list? Q as in, star trek. I mean, who knows what they thought, maybe it was just some fun idea. sirjofri
On 8/2/22 13:34, sirjofri wrote: > Maye you should ask the question about Q either the Q continuum, on the > 9fans mailing list or the tuhs list and some of the old unix beards can > answer? It would be really interesting to know or at least hear their > thoughts. My theories: > > Q is a weird letter that's not often used in the alphabet, unlike a,b,c, > and a big Q, so it's not a context specific prefix. Compare to, well, B > for bio-stuff. > > Q as in, queue. Maybe at some point they had some kinda queue > implementation for dynamic filesystems, and the Qid was some kinda > identifier in that list? > > Q as in, star trek. I mean, who knows what they thought, maybe it was > just some fun idea. > > sirjofri I did some digging, according to Rob it's for unique. https://9fans.topicbox.com/groups/9fans/T2948a78ca9a0fb64-M4ef3befa1966557106cf1f93/9fans-why-u-h-why-qid
Thank you very much for all the good and helpful answers! :)