• Any rust programmers?

    From Apam@21:1/182.7 to All on Saturday, November 04, 2023 15:59:07
    I've been working on learning rust, and made a basic one liners door.

    I'm having trouble getting stdio redirection working properly, STDIN seems to be line buffered and blocking, I need to make it unbuffered and non-blocking.

    If you'd like to see the code it's here:

    https://gitlab.com/apamment/vine

    I have managed to get it working with socket passing using door32.sys and it's working on windows and netbsd (and i assume any other unix-like that has rust).

    Andrew


    --- WWIV 5.9.0.development
    * Origin: Cabinet of Curiosities - WWIV on NetBSD! (21:1/182.7)
  • From Avon@21:1/101 to Apam on Saturday, November 04, 2023 20:49:46
    On 04 Nov 2023 at 03:59p, Apam pondered and said...

    I've been working on learning rust, and made a basic one liners door.

    Just pipping in here... I did get your test netmail but not sure if you got my reply?

    10-4 big ben, rubber duck ...

    Kerr Avon [Blake's 7] 'I'm not expendable, I'm not stupid and I'm not going' avon[at]bbs.nz | bbs.nz | fsxnet.nz

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)
  • From Apam@21:1/182.7 to Avon on Saturday, November 04, 2023 18:10:07
    BY: Avon (21:1/101)

    |11A|09> |10Just pipping in here... I did get your test netmail but not sure if you|07
    |11A|09> |10got my reply? |07

    No I didn't might have something wrong with my netmail routing.

    Thanks :)

    Andrew


    --- WWIV 5.9.0.development
    * Origin: Cabinet of Curiosities - WWIV on NetBSD! (21:1/182.7)
  • From Avon@21:1/101 to Apam on Sunday, November 05, 2023 15:22:38
    On 04 Nov 2023 at 06:10p, Apam pondered and said...

    No I didn't might have something wrong with my netmail routing.
    Thanks :)

    all good, I'll have a look at my end to see what I can uncover.

    Kerr Avon [Blake's 7] 'I'm not expendable, I'm not stupid and I'm not going' avon[at]bbs.nz | bbs.nz | fsxnet.nz

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)
  • From Spectre@21:3/101 to Apam on Sunday, November 05, 2023 21:31:00
    Only seriously rusty programmers over here.... right out in FeO4 territory...

    Spec


    *** THE READER V4.50 [freeware]
    --- SuperBBS v1.17-3 (Eval)
    * Origin: Good Luck and drive offensively! (21:3/101)
  • From Nightfox@21:1/137 to Apam on Monday, November 06, 2023 08:49:34
    Re: Any rust programmers?
    By: Apam to All on Sat Nov 04 2023 03:59 pm

    I've been working on learning rust, and made a basic one liners door.

    I'm having trouble getting stdio redirection working properly, STDIN seems to be line buffered and blocking, I need to make it unbuffered and non-blocking.

    I haven't used Rust at all, but if you've made a BBS door, does that mean Rust can make use of a BBS door programming library (presumably written for C/C++)?

    Nightfox
    --- SBBSecho 3.20-Linux
    * Origin: Digital Distortion: digdist.synchro.net (21:1/137)
  • From Apam@21:1/182 to Nightfox on Tuesday, November 07, 2023 08:13:09
    BY: Nightfox (21:1/137)

    |11N|09> |10I haven't used Rust at all, but if you've made a BBS door, does that|07
    |11N|09> |10mean Rust can make use of a BBS door programming library (presumably|07
    |11N|09> |10written for C/C++)?|07

    I'm pretty sure it could, I didn't though. I would like to split up the door handling stuff into a seperate library or "crate", but thats a bit beyond me at present.

    Andrew


    --- WWIV 5.9.0.development[NetBSD]
    * Origin: Cabinet of Curiosities - WWIV on NetBSD! (21:1/182)
  • From tenser@21:1/101 to Apam on Friday, November 10, 2023 09:47:09
    On 04 Nov 2023 at 03:59p, Apam pondered and said...

    I've been working on learning rust, and made a basic one liners door.

    I'm having trouble getting stdio redirection working properly, STDIN
    seems to be line buffered and blocking, I need to make it unbuffered
    and non-blocking.

    If you'd like to see the code it's here:

    https://gitlab.com/apamment/vine

    I have managed to get it working with socket passing using door32.sys
    and it's working on windows and netbsd (and i assume any other
    unix-like that has rust).

    I'm not sure what you mean with respect to redirection and
    the blocking/buffering behavior of stdin. Can you explain
    what it is precisely that you're trying to do? Generally,
    at least on Unix-y systems, the buffering and/or blocking
    properties of standard input are handled below the stdio
    library. Indeed, if you need unbuffered/non-blocking
    semantics for a particular file-like object, stdio may not
    be the best abstraction.

    I'm looking at your code: I'd definitely recommend running
    `rustfmt` to start.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)
  • From Apam@21:1/182 to Tenser on Friday, November 10, 2023 08:30:25
    BY: tenser (21:1/101)

    |11t|09> |10I'm not sure what you mean with respect to redirection and|07 |11t|09> |10the blocking/buffering behavior of stdin. Can you explain|07 |11t|09> |10what it is precisely that you're trying to do? Generally,|07

    On linux, most bbs systems redirect stdin/stdout to the telnet socket. I'm trying to remove line buffering so i can read characters one at a time, and stop blocking so i can test for timeleft while waiting for input.


    |11t|09> |10library. Indeed, if you need unbuffered/non-blocking|07
    |11t|09> |10semantics for a particular file-like object, stdio may not|07 |11t|09> |10be the best abstraction.|07

    I did try from raw fd on fd 0 and 1, while it worked for stdout, it did not work for stdin.


    |11t|09> |10I'm looking at your code: I'd definitely recommend running|07 |11t|09> |10`rustfmt` to start.|07

    Cool! thanks for the tip! i imagine that's like clangformat?

    Andrew


    --- WWIV 5.9.0.development[NetBSD]
    * Origin: Cabinet of Curiosities - WWIV on NetBSD! (21:1/182)
  • From Digital Man@21:1/183 to Apam on Thursday, November 09, 2023 18:28:32
    Re: Re: Any rust programmers?
    By: Apam to Tenser on Fri Nov 10 2023 08:30 am

    BY: tenser (21:1/101)

    |11t|09> |10I'm not sure what you mean with respect to redirection and|07 |11t|09> |10the blocking/buffering behavior of stdin. Can you explain|07 |11t|09> |10what it is precisely that you're trying to do? Generally,|07

    On linux, most bbs systems redirect stdin/stdout to the telnet socket. I'm trying to remove line buffering so i can read characters one at a time, and stop blocking so i can test for timeleft while waiting for input.

    I'm don't know Rust, but this reference (https://doc.rust-lang.org/std/io/struct.BufReader.html) seems to imply you could instatiate BufReader::with_capacity(1, std::io::stdin);
    to create an unbuffered stdin reader. I have no idea if that'll work. <shrug> --
    digital man (rob)

    Synchronet "Real Fact" #35:
    The irc.synchro.net network has more servers than users
    Norco, CA WX: 67.7øF, 14.0% humidity, 0 mph ENE wind, 0.00 inches rain/24hrs --- SBBSecho 3.20-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (21:1/183)
  • From Apam@21:1/182 to Digital Man on Friday, November 10, 2023 14:52:32
    BY: Digital Man (21:1/183)

    |11DM|09> |10I'm don't know Rust, but this reference|07
    |11DM|09> |10(https://doc.rust-lang.org/std/io/struct.BufReader.html) seems to imply|07
    |11DM|09> |10you could instatiate BufReader::with_capacity(1, std::io::stdin);|07
    |11DM|09> |10to create an unbuffered stdin reader. I have no idea if that'll work.|07
    |11DM|09> |10<shrug>|07

    That does work, and so does the way I had it LOL, the problem was I wasn't setting termios to raw, so it was the terminal that was buffered not the door.

    I feel silly now... LOL

    Andrew


    --- WWIV 5.9.0.development[NetBSD]
    * Origin: Cabinet of Curiosities - WWIV on NetBSD! (21:1/182)
  • From tenser@21:1/101 to Apam on Saturday, November 11, 2023 11:08:31
    On 10 Nov 2023 at 08:30a, Apam pondered and said...

    BY: tenser (21:1/101)

    I'm not sure what you mean with respect to redirection and
    the blocking/buffering behavior of stdin. Can you explain
    what it is precisely that you're trying to do? Generally,

    On linux, most bbs systems redirect stdin/stdout to the telnet socket.
    I'm trying to remove line buffering so i can read characters one at a time, and stop blocking so i can test for timeleft while waiting for input.

    Gotcha. I think what this means at the system level is
    that IO to the standard in, out, and error streams is
    redirected to the network, which is independent of the
    "standard IO" library in a lot of ways.

    Given that you want to sample from both an input and test
    against a timeout, you may actually have a good candidate
    for using `async/await` and tokio; then you'd test between
    the timeout and input arriving on the socket.

    library. Indeed, if you need unbuffered/non-blocking
    semantics for a particular file-like object, stdio may not
    be the best abstraction.

    I did try from raw fd on fd 0 and 1, while it worked for stdout, it did not work for stdin.

    Looks like you found the issue by putting the tty into raw
    mode. Huzzah!

    I'm looking at your code: I'd definitely recommend running
    `rustfmt` to start.

    Cool! thanks for the tip! i imagine that's like clangformat?

    Yup. `cargo fmt` early and often.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)