bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] How to print an unsigned char?


From: Wolfgang Laun
Subject: Re: [bug-gawk] How to print an unsigned char?
Date: Mon, 25 Feb 2019 08:14:07 +0100

Having the system calls read and write as functions is only one part of the
cake. You'd need to have a data type that can play the role of the char[]
used as data buffer in these calls *with a well-defined, portable memory
representation. *As an example: how to compose something with the size of
10 memory units (bytes) consisting of the lowermost 1/2/3/4 bytes of
a/b/c/d, densely packed?

(I have browsed the gawk user manual's sections that sound relevant. Sorry
if I missed this being already available.)
Wolfgang


On Mon, 25 Feb 2019 at 00:07, Andrew J. Schorr <
address@hidden> wrote:

> On Sun, Feb 24, 2019 at 02:40:54PM -0600, Peng Yu wrote:
> > On 2/24/19, Eli Zaretskii <address@hidden> wrote:
> > > [Please use Reply All, please don't take this off-list.]
> > >
> > >> From: Peng Yu <address@hidden>
> > >> Date: Sun, 24 Feb 2019 12:11:45 -0600
> > >>
> > >> > Yes, don't use %c.
> > >> How?
> > >
> > > It depends on what you want to accomplish.  Can you describe your
> > > goal(s) in this matter?
> >
> > As the title says "How to print an unsigned char?"
>
> This can be done using the extension API. The get_file hook provides
> access to
> the file descriptor via the returned awk_input_buf_t or awk_output_buf_t.
> The
> select extension uses this in the "input_fd" and "output_fd" functions. So
> it
> should be fairly simple to create an extension that provides access to the
> read
> & write system calls for a gawk "file". We will eventually need this if
> anybody
> wants to implement a socket library.
>
> So it's simple: write a new gawk extension implementing read and write, and
> then you can use those functions to do binary I/O. Or just use Python
> where the
> file objects can be accessed through the high-level print function or the
> low-level read and write methods.
>
> Regards,
> Andy
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]