Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Less is more or less more -- Y_Plentyn on #LinuxGER


computers / comp.os.linux.misc / Re: POSIX and C

SubjectAuthor
* POSIX and CBill Cunningham
+- Re: POSIX and CBill Cunningham
`* Re: POSIX and CTauno Voipio
 `- Re: POSIX and CBill Cunningham

1
POSIX and C

<succf2$1jck$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/computers/article-flat.php?id=7028&group=comp.os.linux.misc#7028

 copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!aioe.org!rLmH1wui4PRxJNHaeZo9kA.user.46.165.242.75.POSTED!not-for-mail
From: nps...@nspam.net (Bill Cunningham)
Newsgroups: comp.os.linux.misc
Subject: POSIX and C
Date: Sun, 13 Feb 2022 20:49:22 -0500
Organization: Aioe.org NNTP Server
Message-ID: <succf2$1jck$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52628"; posting-host="rLmH1wui4PRxJNHaeZo9kA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Bill Cunningham - Mon, 14 Feb 2022 01:49 UTC

I am trying to deal with the struct stat type right now. There are about
12 members in this struct of sizes that I have no idea, all very unusual
types. The size of the struct stat is 144 bytes, but then there's the
offsets. Now I am going to try later in my linux box the offset macro.
This is not however available to everyone. Has anyone dealt with this
offset macro or looked at assembly where offset sizes cold be labeled to
manually see the offset sizes. I want to iterate through these members;
but there's no way to do it in C I am sure.That's of course C's beauty
as a system language. Where else could you alter values and address that
are in stack memory? :)

Re: POSIX and C

<succj0$1jck$2@gioia.aioe.org>

 copy mid

https://www.novabbs.com/computers/article-flat.php?id=7029&group=comp.os.linux.misc#7029

 copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!rLmH1wui4PRxJNHaeZo9kA.user.46.165.242.75.POSTED!not-for-mail
From: nps...@nspam.net (Bill Cunningham)
Newsgroups: comp.os.linux.misc
Subject: Re: POSIX and C
Date: Sun, 13 Feb 2022 20:51:28 -0500
Organization: Aioe.org NNTP Server
Message-ID: <succj0$1jck$2@gioia.aioe.org>
References: <succf2$1jck$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52628"; posting-host="rLmH1wui4PRxJNHaeZo9kA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Bill Cunningham - Mon, 14 Feb 2022 01:51 UTC

On 2/13/2022 8:49 PM, Bill Cunningham wrote:
> I am trying to deal with the struct stat type right now. There are about
> 12 members in this struct of sizes that I have no idea, all very unusual
> types. The size of the struct stat is 144 bytes, but then there's the
> offsets. Now I am going to try later in my linux box the offset macro.
> This is not however available to everyone. Has anyone dealt with this
> offset macro or looked at assembly where offset sizes cold be labeled to
> manually see the offset sizes. I want to iterate through these members;
> but there's no way to do it in C I am sure.That's of course C's beauty
> as a system language. Where else could you alter values and address that
> are in stack memory? :)
>

Opps sorry "could" not "cold".

Re: POSIX and C

<sud7dl$4jm$1@dont-email.me>

 copy mid

https://www.novabbs.com/computers/article-flat.php?id=7033&group=comp.os.linux.misc#7033

 copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tauno.vo...@notused.fi.invalid (Tauno Voipio)
Newsgroups: comp.os.linux.misc
Subject: Re: POSIX and C
Date: Mon, 14 Feb 2022 11:29:22 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <sud7dl$4jm$1@dont-email.me>
References: <succf2$1jck$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Feb 2022 09:29:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4199fb71f316223f9ebcfea5d00b4563";
logging-data="4726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WGSi2NqmLQQSN2RTQwCiU72+LNcEDH3o="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.6.0
Cancel-Lock: sha1:dHDVBOqEEhGdRfXtsY7zyNnrYKo=
In-Reply-To: <succf2$1jck$1@gioia.aioe.org>
 by: Tauno Voipio - Mon, 14 Feb 2022 09:29 UTC

On 14.2.22 3.49, Bill Cunningham wrote:
> I am trying to deal with the struct stat type right now. There are about
> 12 members in this struct of sizes that I have no idea, all very unusual
> types. The size of the struct stat is 144 bytes, but then there's the
> offsets. Now I am going to try later in my linux box the offset macro.
> This is not however available to everyone. Has anyone dealt with this
> offset macro or looked at assembly where offset sizes cold be labeled to
> manually see the offset sizes. I want to iterate through these members;
> but there's no way to do it in C I am sure.That's of course C's beauty
> as a system language. Where else could you alter values and address that
> are in stack memory? :)

You can get the size of an item with the sizeof operator.

There is the offsetof macro to get the byte offset of an item
in a structure:

/** Structure component offset macro
*
* @param stru A structure
* @param memb A member of @b stru
* @return Offset in bytes of @b memb in @b stru.
*/

#if !defined(offsetof)
#define offsetof(stru, memb) __builtin_offsetof(stru, memb)
#endif

If your compiler does not have the GCC built-in offsetof():

/* Structure component offset macro */

#ifndef offsetof
#define offsetof(stru, memb) (unsigned int)&(((stru *)0) -> memb)
#endif

A structure is not intended to be iterated, but to do so,
you may create a control table containing the offsets,
and sizes of the components, iterate it and use the data
in the control table to access the target fields. The field
sizes are not enough alone, as the structure may contain
alignment padding between elements.

The types in the system structures are defined in a mess of
nested definitions in the system headers.

--

-TV

Re: POSIX and C

<sueaqg$1hme$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/computers/article-flat.php?id=7038&group=comp.os.linux.misc#7038

 copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!aioe.org!rLmH1wui4PRxJNHaeZo9kA.user.46.165.242.75.POSTED!not-for-mail
From: nos...@nspam.net (Bill Cunningham)
Newsgroups: comp.os.linux.misc
Subject: Re: POSIX and C
Date: Mon, 14 Feb 2022 14:33:36 -0500
Organization: Aioe.org NNTP Server
Message-ID: <sueaqg$1hme$1@gioia.aioe.org>
References: <succf2$1jck$1@gioia.aioe.org> <sud7dl$4jm$1@dont-email.me>
<afb47028-a495-f78a-e9e6-97ee27e6df41@nspam.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="50894"; posting-host="rLmH1wui4PRxJNHaeZo9kA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bill Cunningham - Mon, 14 Feb 2022 19:33 UTC

On 2/14/2022 2:25 PM, Bill Cunningham wrote:
> On 2/14/2022 4:29 AM, Tauno Voipio wrote:
>> On 14.2.22 3.49, Bill Cunningham wrote:
>>> I am trying to deal with the struct stat type right now. There are
>>> about 12 members in this struct of sizes that I have no idea, all
>>> very unusual types. The size of the struct stat is 144 bytes, but
>>> then there's the offsets. Now I am going to try later in my linux
>>> box the offset macro. This is not however available to everyone. Has
>>> anyone dealt with this offset macro or looked at assembly where
>>> offset sizes cold be labeled to manually see the offset sizes. I
>>> want to iterate through these members; but there's no way to do it
>>> in C I am sure.That's of course C's beauty as a system language.
>>> Where else could you alter values and address that are in stack
>>> memory? :)
>>
>>
>> You can get the size of an item with the sizeof operator.
>>
>> There is the offsetof macro to get the byte offset of an item
>> in a structure:
>>
>> /**   Structure component offset macro
>>   *
>>   * @param stru A structure
>>   * @param memb A member of @b stru
>>   * @return Offset in bytes of @b memb in @b stru.
>>   */
>>
>> #if !defined(offsetof)
>> #define offsetof(stru, memb) __builtin_offsetof(stru, memb)
>> #endif
>>
>> If your compiler does not have the GCC built-in offsetof():
>>
>> /*   Structure component offset macro   */
>>
>> #ifndef offsetof
>> #define offsetof(stru, memb) (unsigned int)&(((stru *)0) -> memb)
>> #endif
>>
>> A structure is not intended to be iterated, but to do so,
>> you may create a control table containing the offsets,
>> and sizes of the components, iterate it and use the data
>> in the control table to access the target fields. The field
>> sizes are not enough alone, as the structure may contain
>> alignment padding between elements.
>>
>> The types in the system structures are defined in a mess of
>> nested definitions in the system headers.
>>
>
> I didn't believe it was, thanks for verifying that. There's only 12
> members or so in the struct stat, as defined in stat.h. So simply
> mentioning each one would not be too much effort. Using the stat
> command does list all information from metadata the struct holds.
> using the st_ino member is simple enough:
>
>     printf("%d\n",ss.st_ino);
>
> While there is a struct stat ss; declared.
> But, when there's a struct with thirty members, and you want to view
> all. That could be a bit gruesome. Sounds like offset is what I need.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor