Sujet : Re: Just got a Pi1B. What can you actually do with it these days?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.sys.raspberry-piDate : 08. Jun 2025, 05:13:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10232kp$3knls$4@dont-email.me>
References : 1 2
User-Agent : Pan/0.162 (Pokrosvk)
On Sat, 07 Jun 2025 00:20:28 GMT, Scott Alfter wrote:
... and run two instances of this to drive a laser printer and a
label printer:
>
https://gitlab.alfter.us/salfter/lp_server
Had a look at this source file
<
https://gitlab.alfter.us/salfter/lp_server/-/blob/master/src/lp_server.c?ref_type=heads>,
which I think is the guts of the thing.
Would be better to use poll(2) instead of select(2), to avoid the
limitations of the latter. I notice you only handle one connection at
a time.
Also, in the Check_restriction() function, you have
b = strdup( restrict );
but I never see anywhere that the string allocated in b is freed.
This is the kind of thing I would write in Python, rather than C. It
would be a lot less code, and a lot less trouble worrying about
memory.