Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You can't cheat the phone company.


devel / comp.unix.shell / Query the data structure definition of c from the *nix man page.

SubjectAuthor
* Query the data structure definition of c from the *nix man page.hongy...@gmail.com
+- Re: Query the data structure definition of c from the *nix man page.Janis Papanagnou
+* Re: Query the data structure definition of c from the *nix man page.Kenny McCormack
|`- Re: Query the data structure definition of c from the *nix man page.Kaz Kylheku
`* Re: Query the data structure definition of c from the *nix man page.Josef Moellers
 `- Re: Query the data structure definition of c from the *nix man page.Keith Thompson

1
Query the data structure definition of c from the *nix man page.

<5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4291&group=comp.unix.shell#4291

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:525:: with SMTP id x5mr27006392qvw.8.1630406031148; Tue, 31 Aug 2021 03:33:51 -0700 (PDT)
X-Received: by 2002:a05:620a:15b9:: with SMTP id f25mr2220530qkk.400.1630406030987; Tue, 31 Aug 2021 03:33:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 31 Aug 2021 03:33:50 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=128.199.172.34; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 128.199.172.34
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
Subject: Query the data structure definition of c from the *nix man page.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 31 Aug 2021 10:33:51 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: hongy...@gmail.com - Tue, 31 Aug 2021 10:33 UTC

See the following c code snippet located at here [1]:

typedef struct protocol {
const int default_port;
int(*const parse_packet)(const char *, size_t, char **);
} protocol_t;

In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.

Any hints will be highly appreciated.

[1] https://github.com/hongyi-zhao/shadowsocksr-libev/blob/1be671bd5fe7cd55d3823d4669786c9ba7913b9e/src/protocol.h#L29

Regards,
HY

Re: Query the data structure definition of c from the *nix man page.

<sgl10a$31t$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4292&group=comp.unix.shell#4292

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Query the data structure definition of c from the *nix man page.
Date: Tue, 31 Aug 2021 12:41:14 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 26
Message-ID: <sgl10a$31t$1@news-1.m-online.net>
References: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
NNTP-Posting-Host: 2001:a61:2431:ec01:797a:1f8c:2ab8:9b04
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1630406474 3133 2001:a61:2431:ec01:797a:1f8c:2ab8:9b04 (31 Aug 2021 10:41:14 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Tue, 31 Aug 2021 10:41:14 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
 by: Janis Papanagnou - Tue, 31 Aug 2021 10:41 UTC

On 31.08.2021 12:33, hongy...@gmail.com wrote:
> See the following c code snippet located at here [1]:
>
> typedef struct protocol {
> const int default_port;
> int(*const parse_packet)(const char *, size_t, char **);
> } protocol_t;
>
> In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.
>
> Any hints will be highly appreciated.

Get a C language tutorial and look up "function pointer declarations".

Janis

PS: And keep your posting line lengths around 72..78 characters per
line. (Look up "Usenet" and "Netiquette" if it is unclear why.)

>
> [1] https://github.com/hongyi-zhao/shadowsocksr-libev/blob/1be671bd5fe7cd55d3823d4669786c9ba7913b9e/src/protocol.h#L29
>
> Regards,
> HY
>

Re: Query the data structure definition of c from the *nix man page.

<sgl10k$1g6qs$1@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4293&group=comp.unix.shell#4293

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Query the data structure definition of c from the *nix man page.
Date: Tue, 31 Aug 2021 10:41:24 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sgl10k$1g6qs$1@news.xmission.com>
References: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
Injection-Date: Tue, 31 Aug 2021 10:41:24 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1579868"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 31 Aug 2021 10:41 UTC

In article <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>,
hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>See the following c code snippet located at here [1]:
>
>typedef struct protocol {
> const int default_port;
> int(*const parse_packet)(const char *, size_t, char **);
>} protocol_t;
>
>In the above definition, it seems to me that the `int ...' line is difficult to
>understand. So I want to dig/find some clues from the extensive/exhaustive *nix
>man page. I'm not sure if there is a convenient way to do this.

Hi!

I don't understand brain surgery. I've made a few stabs at it, but all my
patients (so far) have died.

Can you help me?

--
To be evangelical is to spend every waking moment hovering around
two emotional states: fear and rage. Evangelicals are seriously the
angriest and most vicious bunch of self-pitying, constantly-moaning
whinybutts I've ever encountered.

Re: Query the data structure definition of c from the *nix man page.

<ip6qqtF2fugU1@mid.individual.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4294&group=comp.unix.shell#4294

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef.mo...@invalid.invalid (Josef Moellers)
Newsgroups: comp.unix.shell
Subject: Re: Query the data structure definition of c from the *nix man page.
Date: Tue, 31 Aug 2021 15:57:48 +0200
Lines: 36
Message-ID: <ip6qqtF2fugU1@mid.individual.net>
References: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 0gvTBm5K3kx1zW5vxWdE3g7tHwjmjIWDfcA4SLymZLKmCPuavj
Cancel-Lock: sha1:MtFuUFLM0ZUVZscLhJRry97OBLQ=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
Content-Language: en-US
 by: Josef Moellers - Tue, 31 Aug 2021 13:57 UTC

On 31.08.21 12:33, hongy...@gmail.com wrote:
> See the following c code snippet located at here [1]:
>
> typedef struct protocol {
> const int default_port;
> int(*const parse_packet)(const char *, size_t, char **);
> } protocol_t;
>
> In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.

I'm not sure if the manual pages will be of any help here, but analyzing
this is quite simple:

1) As there is a type designator ("int") at the beginning and a list of
(what looks like) parameters at the end, this looks like a function
declaration. So this is a function expecting three arguments of the
proper kind and returning an int.

2) Where there is usually a function *name*, there is a "*const
parse_packet" (put between parentheses to satisfy C's precendece rules),
so (leaving the "const" aside for a moment), "* parse_packet" is the
function "name", so "parse_packet" is the name of a pointer to the function.

3) The "const" in front of the pointer name means that this field is
"constant", so, once initialialized, cannot be changed any more.

Maybe check http://unixwiz.net/techtips/reading-cdecl.html

Josef

I can vaguely recall having seen a program which takes an arbitrarily
complex variable declaration and spits out a (human readable)
description of the declaration, eg
int *a; -> "a pointer to an int"
But I can't find it atm.

Re: Query the data structure definition of c from the *nix man page.

<871r69iqzy.fsf@nosuchdomain.example.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4295&group=comp.unix.shell#4295

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Query the data structure definition of c from the *nix man page.
Date: Tue, 31 Aug 2021 08:16:33 -0700
Organization: None to speak of
Lines: 50
Message-ID: <871r69iqzy.fsf@nosuchdomain.example.com>
References: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
<ip6qqtF2fugU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="92d4ef50dec0029532564256321dcd53";
logging-data="6103"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KpOG0SGZ0+kxi2BfWWHUg"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Lw0K+rWB65tDvKRUp7Nf7+9kgQg=
sha1:AR8TyI3KmI+Io6+jg1GbxKOuWeM=
 by: Keith Thompson - Tue, 31 Aug 2021 15:16 UTC

Josef Moellers <josef.moellers@invalid.invalid> writes:
> On 31.08.21 12:33, hongy...@gmail.com wrote:
>> See the following c code snippet located at here [1]:
>>
>> typedef struct protocol {
>> const int default_port;
>> int(*const parse_packet)(const char *, size_t, char **);
>> } protocol_t;
>>
>> In the above definition, it seems to me that the `int ...' line is difficult to understand. So I want to dig/find some clues from the extensive/exhaustive *nix man page. I'm not sure if there is a convenient way to do this.
>
> I'm not sure if the manual pages will be of any help here, but analyzing
> this is quite simple:
>
> 1) As there is a type designator ("int") at the beginning and a list of
> (what looks like) parameters at the end, this looks like a function
> declaration. So this is a function expecting three arguments of the
> proper kind and returning an int.
>
> 2) Where there is usually a function *name*, there is a "*const
> parse_packet" (put between parentheses to satisfy C's precendece rules),
> so (leaving the "const" aside for a moment), "* parse_packet" is the
> function "name", so "parse_packet" is the name of a pointer to the function.
>
> 3) The "const" in front of the pointer name means that this field is
> "constant", so, once initialialized, cannot be changed any more.
>
>
> Maybe check http://unixwiz.net/techtips/reading-cdecl.html
>
> Josef
>
> I can vaguely recall having seen a program which takes an arbitrarily
> complex variable declaration and spits out a (human readable)
> description of the declaration, eg
> int *a; -> "a pointer to an int"
> But I can't find it atm.

Yes, it's called "cdecl", also available online at https://cdecl.org/

$ cdecl
Type `help' or `?' for help
cdecl> explain int(*const parse_packet)(const char *, size_t, char **);
declare parse_packet as const pointer to function (pointer to const char, size_t, pointer to pointer to char) returning int
cdecl>

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Query the data structure definition of c from the *nix man page.

<20210831104448.989@kylheku.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4296&group=comp.unix.shell#4296

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Query the data structure definition of c from the *nix man page.
Date: Tue, 31 Aug 2021 17:48:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20210831104448.989@kylheku.com>
References: <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>
<sgl10k$1g6qs$1@news.xmission.com>
Injection-Date: Tue, 31 Aug 2021 17:48:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="60d8063099e771c4f4fe8ca40c9f50a8";
logging-data="11079"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UfaWitAqwVcNTm1OPqsDnkO1yKKV0kSI="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Q3wzhpWTxePoG55lLziWUf5fKRs=
 by: Kaz Kylheku - Tue, 31 Aug 2021 17:48 UTC

On 2021-08-31, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <5438567e-10f9-4a54-93e3-7b8699acdd00n@googlegroups.com>,
> hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>>See the following c code snippet located at here [1]:
>>
>>typedef struct protocol {
>> const int default_port;
>> int(*const parse_packet)(const char *, size_t, char **);
>>} protocol_t;
>>
>>In the above definition, it seems to me that the `int ...' line is difficult to
>>understand. So I want to dig/find some clues from the extensive/exhaustive *nix
>>man page. I'm not sure if there is a convenient way to do this.
>
> Hi!
>
> I don't understand brain surgery. I've made a few stabs at it, but all my
> patients (so far) have died.

Please post the smallest (or smallest-brained) patient before they died,
the dead version of the patient, and a description of their actual
expected behavior.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor