Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Marriage is the sole cause of divorce.


devel / comp.lang.c / getOpsFromSelf() (Long Post)

SubjectAuthor
* getOpsFromSelf() (Long Post)Mike Sanders
+* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
|+* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
||`* Re: getOpsFromSelf() (Long Post)Mike Sanders
|| +* Re: getOpsFromSelf() (Long Post)Keith Thompson
|| |`* Re: getOpsFromSelf() (Long Post)Mike Sanders
|| | `* Re: getOpsFromSelf() (Long Post)Keith Thompson
|| |  +- Re: getOpsFromSelf() (Long Post)Lew Pitcher
|| |  `* Re: getOpsFromSelf() (Long Post)dave thompson 2
|| |   `* Re: getOpsFromSelf() (Long Post)Mike Sanders
|| |    `* Re: getOpsFromSelf() (Long Post)Lew Pitcher
|| |     `- Re: getOpsFromSelf() (Long Post)Mike Sanders
|| `* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
||  `- Re: getOpsFromSelf() (Long Post)Mike Sanders
|+* Re: getOpsFromSelf() (Long Post)Mike Sanders
||+* Re: getOpsFromSelf() (Long Post)Ben Bacarisse
|||`- Re: getOpsFromSelf() (Long Post)Mike Sanders
||`* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
|| +- Re: getOpsFromSelf() (Long Post)Mike Sanders
|| +* Re: getOpsFromSelf() (Long Post)Stefan Ram
|| |+- Re: getOpsFromSelf() (Long Post)Keith Thompson
|| |`* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
|| | `- Re: getOpsFromSelf() (Long Post)Stefan Ram
|| `* Re: getOpsFromSelf() (Long Post)Stefan Ram
||  +- Re: getOpsFromSelf() (Long Post)Scott Lurndal
||  +* Re: getOpsFromSelf() (Long Post)Spiros Bousbouras
||  |`- Re: getOpsFromSelf() (Long Post)Stefan Ram
||  `- Re: getOpsFromSelf() (Long Post)David Brown
|`* Re: getOpsFromSelf() (Long Post)Scott Lurndal
| `- Re: getOpsFromSelf() (Long Post)Mike Sanders
`* Re: getOpsFromSelf() (Long Post)immibis
 `- Re: getOpsFromSelf() (Long Post)Mike Sanders

Pages:12
getOpsFromSelf() (Long Post)

<ur1ie5$2cgfo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33563&group=comp.lang.c#33563

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: getOpsFromSelf() (Long Post)
Date: Tue, 20 Feb 2024 06:56:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 106
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <ur1ie5$2cgfo$1@dont-email.me>
Injection-Date: Tue, 20 Feb 2024 06:56:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fdd63b999f851d02af391c7f733829ce";
logging-data="2507256"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bsyml+lEJ4J0g1RzUz0g3"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:8gnzq9KPWIWs+ilEPh2dwslujvw=
 by: Mike Sanders - Tue, 20 Feb 2024 06:56 UTC

Just thinking aloud... Imagining here allowing more advanced users of
my app to modify a string of digits residing at the end of my project's
binary/exe. When the app loads, it reads in those digits. So far (knock
on wood), I've not run up against a single case where the code below has
failed to work under multiple OSs. A method mostly for power user's.

The user simply opens the compiled project in their favorite hex editor
& modifies the pre-existing string, a pseudo bitmask of sorts. Certainly
the user could unwittingly add/remove bytes rather than only modifying the
bytes, still its a nifty idea. But practical? I'm not so sure on that point.

Any other gotchas of note?

int main(int argc, char *argv[]) {

#ifdef WIN
getOpsFromSelf(NULL);
#else
getOpsFromSelf(argv[0]);
#endif

// work

return 0;

}

void getOpsFromSelf(char *fname) {

#ifdef WIN
char path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
#else
char path[PATH_MAX];
char *tmp = getpath(fname);
strncpy(path, tmp, sizeof(path));
path[sizeof(path) - 1] = '\0';
free(tmp);
#endif

FILE *bin = fopen(path, "rb");
if (bin == NULL) return; // return if file cant be opened

fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
unsigned char bytes[3];
fread(bytes, 1, 3, bin);
fclose(bin);

// ensure last 3 bytes are digits, else return
for (int i = 0; i < 2; i++) if (!isdigit(bytes[i])) return;

// assign values from bytes
ops.x = (bytes[0] == '1' || bytes[0] == '2') ? bytes[0] - '0' : 1; // 1-2
ops.y = (bytes[1] == '1') ? bytes[1] - '0' : 0; // 0-1
ops.z = (bytes[2] == '1') ? bytes[2] - '0' : 0; // 0-1

}

#ifdef NIX

char *getpath(char *fname) {

const char *PATH_SEPARATOR = ":"; // unix-like
const char *DIR_SEPARATOR = "/"; // unix-like
const int MAX_SIZE = 1024;

struct stat buffer;

if (stat(fname, &buffer) == 0) {
char *result = strdup(fname);
if (!result) return NULL; // memory allocation error <--
return result;
}

char *path_env = getenv("PATH");
if (!path_env) return NULL;

char path_env_copy[MAX_SIZE];
strncpy(path_env_copy, path_env, sizeof(path_env_copy));
path_env_copy[sizeof(path_env_copy) - 1] = '\0';

char full_path[MAX_SIZE];
char *dir = strtok(path_env_copy, PATH_SEPARATOR);

while (dir) {
snprintf(full_path, sizeof(full_path), "%s%s%s", dir,
(dir[strlen(dir) - 1] == DIR_SEPARATOR[0] ? "" :
DIR_SEPARATOR), fname);
if (stat(full_path, &buffer) == 0) {
char *result = strdup(full_path);
if (!result) return NULL; // memory allocation error <--
return result;
}
dir = strtok(NULL, PATH_SEPARATOR);
}

return NULL;
}

#endif

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<jh8EdBXIFQu4WLaKt@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33732&group=comp.lang.c#33732

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.chmurka.net!newsfeed.xs3.de!paganini.bofh.team!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sat, 24 Feb 2024 16:19:11 -0000 (UTC)
Organization: To protect and to server
Message-ID: <jh8EdBXIFQu4WLaKt@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 24 Feb 2024 16:19:11 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3213298"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:NOvXGoSV7aNx66ODYo63ll+3udp8IQ02IiXolsdvb7I=
X-Organisation: Weyland-Yutani
X-Notice: Filtered by postfilter v. 0.9.3
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Sat, 24 Feb 2024 16:19 UTC

On Tue, 20 Feb 2024 06:56:06 -0000 (UTC)
porkchop@invalid.foo (Mike Sanders) wrote:
>
> Just thinking aloud... Imagining here allowing more advanced users of
> my app to modify a string of digits residing at the end of my project's
> binary/exe. When the app loads, it reads in those digits. So far (knock
> on wood), I've not run up against a single case where the code below has
> failed to work under multiple OSs. A method mostly for power user's.
>
> The user simply opens the compiled project in their favorite hex editor
> & modifies the pre-existing string, a pseudo bitmask of sorts. Certainly
> the user could unwittingly add/remove bytes rather than only modifying the
> bytes, still its a nifty idea. But practical? I'm not so sure on that point.

Compared to other options like command line options or configuration files or
environmental variables or asking the user interactively to set the values ,
this approach seems very much worse. It is a lot less practical *and* fragile.
How can you know that this specific string will exist at a certain position
in the executable ?

> Any other gotchas of note?
>
> int main(int argc, char *argv[]) {
>
> #ifdef WIN
> getOpsFromSelf(NULL);
> #else
> getOpsFromSelf(argv[0]);

There are Unix conventions on what argv[0] will contain but no guarantees.
In particular , there is no guaranteed way to get the pathname of the
executable from argv[0] .This is another way your approach is fragile.

> #endif
>
> // work
>
> return 0;
>
> }
>
> void getOpsFromSelf(char *fname) {
>
> #ifdef WIN
> char path[MAX_PATH];
> GetModuleFileName(NULL, path, MAX_PATH);
> #else
> char path[PATH_MAX];
> char *tmp = getpath(fname);
> strncpy(path, tmp, sizeof(path));

What happens if getpath() returns NULL ?

> path[sizeof(path) - 1] = '\0';
> free(tmp);
> #endif
>
> FILE *bin = fopen(path, "rb");
> if (bin == NULL) return; // return if file cant be opened
>
> fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
> unsigned char bytes[3];
> fread(bytes, 1, 3, bin);
> fclose(bin);

You keep writing 3 .Best to use a symbolic constant.

>
> // ensure last 3 bytes are digits, else return
> for (int i = 0; i < 2; i++) if (!isdigit(bytes[i])) return;
>
> // assign values from bytes
> ops.x = (bytes[0] == '1' || bytes[0] == '2') ? bytes[0] - '0' : 1; // 1-2
> ops.y = (bytes[1] == '1') ? bytes[1] - '0' : 0; // 0-1
> ops.z = (bytes[2] == '1') ? bytes[2] - '0' : 0; // 0-1

I take it ops is a global variable ?

>
> }
>
> #ifdef NIX
>
> char *getpath(char *fname) {
>
> const char *PATH_SEPARATOR = ":"; // unix-like
> const char *DIR_SEPARATOR = "/"; // unix-like
> const int MAX_SIZE = 1024;
>
> struct stat buffer;
>
> if (stat(fname, &buffer) == 0) {
> char *result = strdup(fname);
> if (!result) return NULL; // memory allocation error <--
> return result;
> }

On Unix , if you just want to test for the existence of a file , access()
is a simpler way to do it.

> char *path_env = getenv("PATH");
> if (!path_env) return NULL;
>
> char path_env_copy[MAX_SIZE];
> strncpy(path_env_copy, path_env, sizeof(path_env_copy));
> path_env_copy[sizeof(path_env_copy) - 1] = '\0';
>
> char full_path[MAX_SIZE];
> char *dir = strtok(path_env_copy, PATH_SEPARATOR);
>
> while (dir) {
> snprintf(full_path, sizeof(full_path), "%s%s%s", dir,
> (dir[strlen(dir) - 1] == DIR_SEPARATOR[0] ? "" :
> DIR_SEPARATOR), fname);
> if (stat(full_path, &buffer) == 0) {
> char *result = strdup(full_path);
> if (!result) return NULL; // memory allocation error <--
This line is redundant.

> return result;
> }
> dir = strtok(NULL, PATH_SEPARATOR);
> }
>
> return NULL;
> }

I wouldn't use strtok() at all for this but rather strchr() and keep
track myself of the position in the string and not modify the string at
all. This way

- you can use the string returned by getenv() directly instead of having
to copy it.

- you don't have to call strlen() when you have already traversed the
string to find the separator. Traversing the string for a second time
probably won't have a noticeable effect for performance in this context
but this kind of thing where the code has done a certain somewhat costly
computation (traversing part of the string) and then immediately does
again almost the same computation instead of using the result found by
the first computation , grates me.

>
> #endif

--
- Yep 100x better then US prison, no pillows, no tv, no nothing except
a blanket and a small pad to sleep on.
- It is not a fair comparison. You have to look at it from a racist
perspective. Swedish prisons are meant for white folks. American
prisons are not.
http://suprbay.org/showthread.php?t=51513&page=2

Re: getOpsFromSelf() (Long Post)

<1HyZeCKHsTViXCSYj@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33733&group=comp.lang.c#33733

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sat, 24 Feb 2024 17:06:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <1HyZeCKHsTViXCSYj@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 24 Feb 2024 17:06:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e4b374d7bfe70b01256754dbc73748c";
logging-data="1375117"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jpB+goLZKjCQRqlxPTYdB"
Cancel-Lock: sha1:zZqSgcxLOEJ/zBW8p0Mldn75/Zo=
In-Reply-To: <jh8EdBXIFQu4WLaKt@bongo-ra.co>
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Sat, 24 Feb 2024 17:06 UTC

On Sat, 24 Feb 2024 16:19:11 -0000 (UTC)
Spiros Bousbouras <spibou@gmail.com> wrote:
> On Tue, 20 Feb 2024 06:56:06 -0000 (UTC)
> porkchop@invalid.foo (Mike Sanders) wrote:
> > char *path_env = getenv("PATH");
> > if (!path_env) return NULL;
> >
> > char path_env_copy[MAX_SIZE];
> > strncpy(path_env_copy, path_env, sizeof(path_env_copy));
> > path_env_copy[sizeof(path_env_copy) - 1] = '\0';
> >
> > char full_path[MAX_SIZE];
> > char *dir = strtok(path_env_copy, PATH_SEPARATOR);
> >
> > while (dir) {
> > snprintf(full_path, sizeof(full_path), "%s%s%s", dir,
> > (dir[strlen(dir) - 1] == DIR_SEPARATOR[0] ? "" :
> > DIR_SEPARATOR), fname);
> > if (stat(full_path, &buffer) == 0) {
> > char *result = strdup(full_path);
> > if (!result) return NULL; // memory allocation error <--
> This line is redundant.
>
> > return result;
> > }
> > dir = strtok(NULL, PATH_SEPARATOR);

If I remeber correctly , the convention is that if :: exists in PATH
then it's the same as :.: i.e. the current working directory. Your
code does not handle this case. Yet another reason to do the searching
in the string yourself instead of using strtok() .

> > }
> >
> > return NULL;
> > }
>
> I wouldn't use strtok() at all for this but rather strchr() and keep
> track myself of the position in the string and not modify the string at
> all. This way
>
> - you can use the string returned by getenv() directly instead of having
> to copy it.
>
> - you don't have to call strlen() when you have already traversed the
> string to find the separator. Traversing the string for a second time
> probably won't have a noticeable effect for performance in this context
> but this kind of thing where the code has done a certain somewhat costly
> computation (traversing part of the string) and then immediately does
> again almost the same computation instead of using the result found by
> the first computation , grates me.
>
> >
> > #endif

--
God grant me serenity to accept the code I cannot change, courage to
change the code I can, and wisdom to know the difference.
Erik Naggum

Re: getOpsFromSelf() (Long Post)

<urdmnf$1d3vr$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33737&group=comp.lang.c#33737

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sat, 24 Feb 2024 21:22:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 71
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <urdmnf$1d3vr$2@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
Injection-Date: Sat, 24 Feb 2024 21:22:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="db0fdc4e71042407c1143545d9a77daf";
logging-data="1478651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jmwGOYWoT+ktD+1OJxZYg"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:3vD3kbnElhu8hjoe9E9cADMhyUs=
 by: Mike Sanders - Sat, 24 Feb 2024 21:22 UTC

Spiros Bousbouras <spibou@gmail.com> wrote:

> Compared to other options like command line options or configuration files or
> environmental variables or asking the user interactively to set the values ,
> this approach seems very much worse. It is a lot less practical *and* fragile.
> How can you know that this specific string will exist at a certain position
> in the executable ?

Because it checks that does...

>> // ensure last 3 bytes are digits, else return
>> for (int i = 0; i < 2; i++) if (!isdigit(bytes[i])) return;
> What happens if getpath() returns NULL ?

Ouch busted...
> You keep writing 3 .Best to use a symbolic constant.

Why? 3 is always 3. Maybe I dont undestand what you mean...
> I take it ops is a global variable ?

In this example, yes.

> On Unix , if you just want to test for the existence of a file , access()
> is a simpler way to do it.
>
>> char *path_env = getenv("PATH");
>> if (!path_env) return NULL;
>>
>> char path_env_copy[MAX_SIZE];
>> strncpy(path_env_copy, path_env, sizeof(path_env_copy));
>> path_env_copy[sizeof(path_env_copy) - 1] = '\0';
>>
>> char full_path[MAX_SIZE];
>> char *dir = strtok(path_env_copy, PATH_SEPARATOR);
>>
>> while (dir) {
>> snprintf(full_path, sizeof(full_path), "%s%s%s", dir,
>> (dir[strlen(dir) - 1] == DIR_SEPARATOR[0] ? "" :
>> DIR_SEPARATOR), fname);
>> if (stat(full_path, &buffer) == 0) {
>> char *result = strdup(full_path);
>> if (!result) return NULL; // memory allocation error <--

> This line is redundant.

Please explain why you think so.

> I wouldn't use strtok() at all for this but rather strchr() and keep
> track myself of the position in the string and not modify the string at
> all. This way
>
> - you can use the string returned by getenv() directly instead of having
> to copy it.
>
> - you don't have to call strlen() when you have already traversed the
> string to find the separator. Traversing the string for a second time
> probably won't have a noticeable effect for performance in this context
> but this kind of thing where the code has done a certain somewhat costly
> computation (traversing part of the string) and then immediately does
> again almost the same computation instead of using the result found by
> the first computation , grates me.

I dunno, is it perfect? Nah. Is it a good start? Well, yeah =)

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<urdmt4$1d3vr$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33738&group=comp.lang.c#33738

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sat, 24 Feb 2024 21:25:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <urdmt4$1d3vr$3@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <1HyZeCKHsTViXCSYj@bongo-ra.co>
Injection-Date: Sat, 24 Feb 2024 21:25:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="db0fdc4e71042407c1143545d9a77daf";
logging-data="1478651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/31nWudAyYTIJfoVsDQeOt"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:TXCmBoYbMS+ND0EaZNhLRWZDooQ=
 by: Mike Sanders - Sat, 24 Feb 2024 21:25 UTC

Spiros Bousbouras <spibou@gmail.com> wrote:

> If I remeber correctly , the convention is that if :: exists in PATH
> then it's the same as :.: i.e. the current working directory. Your
> code does not handle this case. Yet another reason to do the searching
> in the string yourself instead of using strtok() .

It does handle the current directory... before it traverses the users path.

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<87le799xnr.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33748&group=comp.lang.c#33748

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sun, 25 Feb 2024 00:48:24 +0000
Organization: A noiseless patient Spider
Lines: 100
Message-ID: <87le799xnr.fsf@bsb.me.uk>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<urdmnf$1d3vr$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e770f46cfdd6e611e431e3de15c787fc";
logging-data="1562189"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WU4o/aSgwida6yVVwqq0QhxDoh25rwO0="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:0OxZiRZJLpHZZtgzNdGrHmg3Wyc=
sha1:75DtM2SIeVh8mNKWzJZ6oCWCc+E=
X-BSB-Auth: 1.9c5f60a47eb5c355b39d.20240225004824GMT.87le799xnr.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 25 Feb 2024 00:48 UTC

porkchop@invalid.foo (Mike Sanders) writes:

> Spiros Bousbouras <spibou@gmail.com> wrote:
>
>> Compared to other options like command line options or configuration files or
>> environmental variables or asking the user interactively to set the values ,
>> this approach seems very much worse. It is a lot less practical *and* fragile.
>> How can you know that this specific string will exist at a certain position
>> in the executable ?
>
> Because it checks that does...
>
>>> // ensure last 3 bytes are digits, else return
>>> for (int i = 0; i < 2; i++) if (!isdigit(bytes[i])) return;
>
>> What happens if getpath() returns NULL ?
>
> Ouch busted...
>
>> You keep writing 3 .Best to use a symbolic constant.
>
> Why? 3 is always 3. Maybe I dont undestand what you mean...

And 3 != 2. Maybe using "CODE_LENGTH" everywhere would have prevented
the (probable) bug above where the loop tests only two characters.
After

#define CODE_LENGTH 3

would you have written

for (int i = 0; i < CODE_LENGTH - 1; i++) ...

? I don't know, but I think you might have thought twice about that -1.

>> I take it ops is a global variable ?
>
> In this example, yes.
>
>> On Unix , if you just want to test for the existence of a file , access()
>> is a simpler way to do it.
>>
>>> char *path_env = getenv("PATH");
>>> if (!path_env) return NULL;
>>>
>>> char path_env_copy[MAX_SIZE];
>>> strncpy(path_env_copy, path_env, sizeof(path_env_copy));
>>> path_env_copy[sizeof(path_env_copy) - 1] = '\0';
>>>
>>> char full_path[MAX_SIZE];
>>> char *dir = strtok(path_env_copy, PATH_SEPARATOR);
>>>
>>> while (dir) {
>>> snprintf(full_path, sizeof(full_path), "%s%s%s", dir,
>>> (dir[strlen(dir) - 1] == DIR_SEPARATOR[0] ? "" :
>>> DIR_SEPARATOR), fname);
>>> if (stat(full_path, &buffer) == 0) {
>>> char *result = strdup(full_path);
>>> if (!result) return NULL; // memory allocation error <--
>
>> This line is redundant.
>
> Please explain why you think so.

Given the following line (return result;) there is no point in returning
NULL is the special case where result is NULL since NULL will be
returned when result is NULL. In fact, the whole three-line compound
statement is (semantically) equivalent to

return strdup(full_path);

>> I wouldn't use strtok() at all for this but rather strchr() and keep
>> track myself of the position in the string and not modify the string at
>> all. This way
>>
>> - you can use the string returned by getenv() directly instead of having
>> to copy it.
>>
>> - you don't have to call strlen() when you have already traversed the
>> string to find the separator. Traversing the string for a second time
>> probably won't have a noticeable effect for performance in this context
>> but this kind of thing where the code has done a certain somewhat costly
>> computation (traversing part of the string) and then immediately does
>> again almost the same computation instead of using the result found by
>> the first computation , grates me.
>
> I dunno, is it perfect? Nah. Is it a good start? Well, yeah =)

I could not tell what it was supposed to do so I didn't comment, but
there's definitely a "let's just try" sense to the code. For example,
you examine and use three characters, but you don't test if three
characters were actually read.

One specific C issue did jump out at me:

"A binary stream need not meaningfully support fseek calls with a
whence value of SEEK_END."

--
Ben.

Re: getOpsFromSelf() (Long Post)

<ure6fu$1gf1j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33752&group=comp.lang.c#33752

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sun, 25 Feb 2024 01:51:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <ure6fu$1gf1j$1@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <87le799xnr.fsf@bsb.me.uk>
Injection-Date: Sun, 25 Feb 2024 01:51:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a1613b5c599d9e1d52e8709e56c9ba25";
logging-data="1588275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+O4autRj2Bq+pQOD3YaMzt"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:FGaD4vnU7Guc5CPVE19XMBVB68g=
 by: Mike Sanders - Sun, 25 Feb 2024 01:51 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

> ? I don't know, but I think you might have thought twice about that -1.

Aye, good point.

> I could not tell what it was supposed to do so I didn't comment, but
> there's definitely a "let's just try" sense to the code. For example,
> you examine and use three characters, but you don't test if three
> characters were actually read.

Well, that's all that it is though Ben, the development of an idea.
(Thinking aloud was term I used), maybe I'll whittle on it more
sometime, maybe you can tweak it too ya'know, post some code,
live life, be happy Mr. Crabby =)

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<87y1b9wbfs.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33753&group=comp.lang.c#33753

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sat, 24 Feb 2024 17:59:51 -0800
Organization: None to speak of
Lines: 29
Message-ID: <87y1b9wbfs.fsf@nosuchdomain.example.com>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<1HyZeCKHsTViXCSYj@bongo-ra.co> <urdmt4$1d3vr$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="bb66de1b9b107dde749bb8d6bc16acf3";
logging-data="1586219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ReIV0ifExiicFI92x1ug0"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:DM8NPgMttpPdoJWEmsYEtyjliUE=
sha1:I7CF4cDdsr5G5gwazy+CjeAslEg=
 by: Keith Thompson - Sun, 25 Feb 2024 01:59 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Spiros Bousbouras <spibou@gmail.com> wrote:
>> If I remeber correctly , the convention is that if :: exists in PATH
>> then it's the same as :.: i.e. the current working directory. Your
>> code does not handle this case. Yet another reason to do the searching
>> in the string yourself instead of using strtok() .
>
> It does handle the current directory... before it traverses the users path.

I haven't read the code closely enough to know just what it does, but I
see it examines the $PATH environment variable.

(This is specific to Unix-like systems.)

If your code looks at the current directory regardless of what's in
$PATH, then it's probably misbehaving. If the current directory isn't
specified in $PATH, the current directory shouldn't be searched.

$PATH is a list of directory paths, separated by ':' characters. An
empty field refers to the current directory, which can also be specified
as '.'. This can appear at the beginning (if PATH starts with ":"), at
the end (if it ends with ":", or in the middle (if it contains ":").

It's recommended *not* to include the current directory in $PATH.

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

Re: getOpsFromSelf() (Long Post)

<urf9g5$1qtds$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33764&group=comp.lang.c#33764

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sun, 25 Feb 2024 11:49:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <urf9g5$1qtds$1@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <1HyZeCKHsTViXCSYj@bongo-ra.co> <urdmt4$1d3vr$3@dont-email.me> <87y1b9wbfs.fsf@nosuchdomain.example.com>
Injection-Date: Sun, 25 Feb 2024 11:49:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a1613b5c599d9e1d52e8709e56c9ba25";
logging-data="1930684"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wXkSlDl1A8pcA/8T6bs6e"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:W6pl3qrgEyay7arPVG1rgQ7Qbr8=
 by: Mike Sanders - Sun, 25 Feb 2024 11:49 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> It's recommended *not* to include the current directory in $PATH.

I've been thinking about that very thing in fact. It renders my
idea of a binary reading a few bytes from its-self all but dead.
I wont subvert a given security model for a configuration flag
or two...

But there you have it, a wonky idea, I've got plenty of them.

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<0SLCN.453028$Wp_8.87283@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33773&group=comp.lang.c#33773

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: getOpsFromSelf() (Long Post)
Newsgroups: comp.lang.c
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
Lines: 21
Message-ID: <0SLCN.453028$Wp_8.87283@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 25 Feb 2024 18:42:04 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 25 Feb 2024 18:42:04 GMT
X-Received-Bytes: 1582
 by: Scott Lurndal - Sun, 25 Feb 2024 18:42 UTC

Spiros Bousbouras <spibou@gmail.com> writes:
>On Tue, 20 Feb 2024 06:56:06 -0000 (UTC)
>porkchop@invalid.foo (Mike Sanders) wrote:
>>
>> Just thinking aloud... Imagining here allowing more advanced users of
>> my app to modify a string of digits residing at the end of my project's
>> binary/exe. When the app loads, it reads in those digits. So far (knock
>> on wood), I've not run up against a single case where the code below has
>> failed to work under multiple OSs. A method mostly for power user's.d

Talk about reinventing the wheel.

That was a feature in 1960's operating systems. Usually called
a switch register. Which was implemented first in hardware,
and later in the operating system. In several systems, the
OS (or binary loader) would load the value into some part
of the application's memory before it starts (in one case,
at address zero).

Using an environment variable is far preferable, at least on
unix-like or POSIX operating environments.

Re: getOpsFromSelf() (Long Post)

<87h6hww3x0.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33780&group=comp.lang.c#33780

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sun, 25 Feb 2024 14:54:35 -0800
Organization: None to speak of
Lines: 17
Message-ID: <87h6hww3x0.fsf@nosuchdomain.example.com>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<1HyZeCKHsTViXCSYj@bongo-ra.co> <urdmt4$1d3vr$3@dont-email.me>
<87y1b9wbfs.fsf@nosuchdomain.example.com>
<urf9g5$1qtds$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="bb66de1b9b107dde749bb8d6bc16acf3";
logging-data="2241799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EraX2Q/oFayDe0v2Vp/m8"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:whPqswzfPKdLvDrCzGlCajhs+to=
sha1:aFDsqEjzN93LxkPbiyezEF+8CRM=
 by: Keith Thompson - Sun, 25 Feb 2024 22:54 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> It's recommended *not* to include the current directory in $PATH.
>
> I've been thinking about that very thing in fact. It renders my
> idea of a binary reading a few bytes from its-self all but dead.
> I wont subvert a given security model for a configuration flag
> or two...
>
> But there you have it, a wonky idea, I've got plenty of them.

Under Linux, a program can find its executable via /proc/$$/exe .

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

Re: getOpsFromSelf() (Long Post)

<urggms$24htu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33781&group=comp.lang.c#33781

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Sun, 25 Feb 2024 22:58:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <urggms$24htu$1@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<1HyZeCKHsTViXCSYj@bongo-ra.co> <urdmt4$1d3vr$3@dont-email.me>
<87y1b9wbfs.fsf@nosuchdomain.example.com> <urf9g5$1qtds$1@dont-email.me>
<87h6hww3x0.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Feb 2024 22:58:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="524362c7ad23fbda53c1c3ebaf2b35a4";
logging-data="2246590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4QeGPJuwcdcF6PdKLZaHOHuCMbf8k+3A="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:oT2T/tPpqi+2yRgHfBrxE3npXgs=
 by: Lew Pitcher - Sun, 25 Feb 2024 22:58 UTC

On Sun, 25 Feb 2024 14:54:35 -0800, Keith Thompson wrote:

> porkchop@invalid.foo (Mike Sanders) writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> It's recommended *not* to include the current directory in $PATH.
>>
>> I've been thinking about that very thing in fact. It renders my
>> idea of a binary reading a few bytes from its-self all but dead.
>> I wont subvert a given security model for a configuration flag
>> or two...
>>
>> But there you have it, a wonky idea, I've got plenty of them.
>
> Under Linux, a program can find its executable via /proc/$$/exe .

With the caveat that /proc/$$/exe is a symlink.
As such, it may participate in a race condition where, if the
"real" executable (the target of the symlink) is deleted or
moved before the program references it's /proc/$$/exe, the
symlink may point to a non-existent, or /different/ executable.

--
Lew Pitcher
"In Skills We Trust"

Re: getOpsFromSelf() (Long Post)

<NMK4r+7PMexyUgngk@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33797&group=comp.lang.c#33797

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!news.nntp4.net!paganini.bofh.team!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 14:50:11 -0000 (UTC)
Organization: To protect and to server
Message-ID: <NMK4r+7PMexyUgngk@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Feb 2024 14:50:11 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3790039"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:bgM53L13JzdggOEg2e1ypjVlOSO2G7zlleQsrIlchAU=
X-Server-Commands: nowebcancel
X-Notice: Filtered by postfilter v. 0.9.3
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Mon, 26 Feb 2024 14:50 UTC

On Sat, 24 Feb 2024 21:22:55 -0000 (UTC)
porkchop@invalid.foo (Mike Sanders) wrote:
> Spiros Bousbouras <spibou@gmail.com> wrote:
>
> > Compared to other options like command line options or configuration files or
> > environmental variables or asking the user interactively to set the values ,
> > this approach seems very much worse. It is a lot less practical *and* fragile.
> > How can you know that this specific string will exist at a certain position
> > in the executable ?
>
> Because it checks that does...

Who checks it and using what algorithm ?

> >> // ensure last 3 bytes are digits, else return
> >> for (int i = 0; i < 2; i++) if (!isdigit(bytes[i])) return;
>
> > What happens if getpath() returns NULL ?
>
> Ouch busted...
>
> > You keep writing 3 .Best to use a symbolic constant.
>
> Why? 3 is always 3. Maybe I dont undestand what you mean...

For example , your code has

fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
unsigned char bytes[3];
fread(bytes, 1, 3, bin);

..Just reading this it is not immediate clear whether all appearances of 3
refer to the same conceptual entity or different ones which all happen to
have the value 3. Using a constant would have made it clear that it is the
former. Additionally , if you ever want to change the value , it is simpler
to only do it in one place.

Re: getOpsFromSelf() (Long Post)

<4ChoIpqkfcFQsXBXl@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33798&group=comp.lang.c#33798

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 15:07:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <4ChoIpqkfcFQsXBXl@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <1HyZeCKHsTViXCSYj@bongo-ra.co>
<urdmt4$1d3vr$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Feb 2024 15:07:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40172e3309d9e95926e610720165a9f3";
logging-data="2738232"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+wZZpHvG5BcD6MeljtxTG"
Cancel-Lock: sha1:ZzPHE4WJ6LhzLnyxhgRVUKIsdus=
In-Reply-To: <urdmt4$1d3vr$3@dont-email.me>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Mon, 26 Feb 2024 15:07 UTC

On Sat, 24 Feb 2024 21:25:56 -0000 (UTC)
porkchop@invalid.foo (Mike Sanders) wrote:
> Spiros Bousbouras <spibou@gmail.com> wrote:
>
> > If I remeber correctly , the convention is that if :: exists in PATH
> > then it's the same as :.: i.e. the current working directory. Your
> > code does not handle this case. Yet another reason to do the searching
> > in the string yourself instead of using strtok() .
>
> It does handle the current directory... before it traverses the users path.

Which may be the wrong order. Regardless of the overall merits of your idea ,
it should mimic as close as possible how the system finds executables. This
means not search in the current directory unless the appropriate constructs
exist in PATH and search the components in the same order as they appear in
PATH .This implies recognising :: in PATH and my point is that using
strtok() (apart from its other issues) makes it harder to do this.

Replying to <urf9g5$1qtds$1@dont-email.me> :

> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> > It's recommended *not* to include the current directory in $PATH.
>
> I've been thinking about that very thing in fact. It renders my
> idea of a binary reading a few bytes from its-self all but dead.
> I wont subvert a given security model for a configuration flag
> or two...

It is fine to include the current directory in PATH as long as you do it
right. Details are not on topic for this group.

--
vlaho.ninja/menu

Re: getOpsFromSelf() (Long Post)

<uri9tv$2jhph$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33800&group=comp.lang.c#33800

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 15:15:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uri9tv$2jhph$1@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co>
Injection-Date: Mon, 26 Feb 2024 15:15:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9fa50c57887cea1a70066dff5b6f6ab0";
logging-data="2737969"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L5krFYWlto64fSdQOYS1B"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:WnEhyijlRgCxIps6kB1X39GluNs=
 by: Mike Sanders - Mon, 26 Feb 2024 15:15 UTC

Spiros Bousbouras <spibou@gmail.com> wrote:

>
> For example , your code has
>
> fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
> unsigned char bytes[3];
> fread(bytes, 1, 3, bin);
>
> .Just reading this it is not immediate clear whether all appearances of 3
> refer to the same conceptual entity or different ones which all happen to
> have the value 3. Using a constant would have made it clear that it is the
> former. Additionally , if you ever want to change the value , it is simpler
> to only do it in one place.

I want to contest this point since its scope is always/only within that
function, but... yes you are correct in the final analysis.

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<uria8g$2jhph$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33802&group=comp.lang.c#33802

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkc...@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 15:20:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uria8g$2jhph$2@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <0SLCN.453028$Wp_8.87283@fx17.iad>
Injection-Date: Mon, 26 Feb 2024 15:20:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9fa50c57887cea1a70066dff5b6f6ab0";
logging-data="2737969"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6yNysbyupauolet0xJIxI"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:UGVZyNKkID/qtLmjFsW+zXLFRP8=
 by: Mike Sanders - Mon, 26 Feb 2024 15:20 UTC

Scott Lurndal <scott@slp53.sl.home> wrote:

> Talk about reinventing the wheel.

Could'nt afford the dealership's rates...
> That was a feature in 1960's operating systems. Usually called
> a switch register. Which was implemented first in hardware,
> and later in the operating system. In several systems, the
> OS (or binary loader) would load the value into some part
> of the application's memory before it starts (in one case,
> at address zero).
>
> Using an environment variable is far preferable, at least on
> unix-like or POSIX operating environments.

Interesting stuff.

Ya know, speaking only for myself, its a good idea in some
respects, I just havent found a real reason to use it. That
& where Keith is saying stay out the of the current directory
(& he's right about that at least in Unix-like OSs).

--
:wq
Mike Sanders

Re: getOpsFromSelf() (Long Post)

<fseek-20240226222154@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33823&group=comp.lang.c#33823

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: 26 Feb 2024 21:22:33 GMT
Organization: Stefan Ram
Lines: 5
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <fseek-20240226222154@ram.dialup.fu-berlin.de>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de sR+EzEpPqHLyTLYV3tQD1AKf0mw9lM56MMi7+AThjwaV+3
Cancel-Lock: sha1:o+zZIwGG0/HFujkRVW8zoiYTXY0= sha256:r5uUv5xMZU5EsXrzELonSKyVBrTsfd0HIC1IzVKCzbY=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Mon, 26 Feb 2024 21:22 UTC

Spiros Bousbouras <spibou@gmail.com> writes:
>fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file

A binary stream need not meaningfully support fseek calls
with a whence value of SEEK_END.

Re: getOpsFromSelf() (Long Post)

<878r36x5xd.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33827&group=comp.lang.c#33827

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 13:38:06 -0800
Organization: None to speak of
Lines: 23
Message-ID: <878r36x5xd.fsf@nosuchdomain.example.com>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co>
<fseek-20240226222154@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="9466d30cc4509f5291c1ad69a98237cd";
logging-data="2905086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ax1LueZV/yMQjsYFaDfXW"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:a/P6tr5ccFgtmnMhV26TQfwTOIg=
sha1:qlR1BV/i9Gtae/quQrBLuURpqNk=
 by: Keith Thompson - Mon, 26 Feb 2024 21:38 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Spiros Bousbouras <spibou@gmail.com> writes:
>>fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
>
> A binary stream need not meaningfully support fseek calls
> with a whence value of SEEK_END.

True, so the call is not completely portable -- but I doubt that there
are any hosted implementations that don't support such calls.

The reason for that line in the standard is to permit implementations
where, for example, binary files are represented as a sequence of
fixed-size blocks, with no information about how many bytes of the last
block are actually used. The last block might be padded with zero
bytes.

POSIX and Windows are not the whole world, but both support binary files
that are arbitrary byte streams.

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

Re: getOpsFromSelf() (Long Post)

<y3x3cHk9CnXWBo6yd@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33828&group=comp.lang.c#33828

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Mon, 26 Feb 2024 21:40:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <y3x3cHk9CnXWBo6yd@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me>
<NMK4r+7PMexyUgngk@bongo-ra.co> <fseek-20240226222154@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Feb 2024 21:40:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40172e3309d9e95926e610720165a9f3";
logging-data="2913022"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EEK6sX1f9MUbOcou4aZ7t"
Cancel-Lock: sha1:LOk/O/vNOay68oTftaeIQg50MOo=
In-Reply-To: <fseek-20240226222154@ram.dialup.fu-berlin.de>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Mon, 26 Feb 2024 21:40 UTC

On 26 Feb 2024 21:22:33 GMT
ram@zedat.fu-berlin.de (Stefan Ram) wrote:
> Spiros Bousbouras <spibou@gmail.com> writes:
> >fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
>
> A binary stream need not meaningfully support fseek calls
> with a whence value of SEEK_END.

The way your are quoting me gives the impression that I wrote the code.
I didn't , I was quoting Mike Sanders quote.

Second , Ben Bacarisse in <87le799xnr.fsf@bsb.me.uk> has already made
the same point.

Re: getOpsFromSelf() (Long Post)

<fseek-20240226225347@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33830&group=comp.lang.c#33830

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: 26 Feb 2024 21:54:20 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <fseek-20240226225347@ram.dialup.fu-berlin.de>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co> <fseek-20240226222154@ram.dialup.fu-berlin.de> <y3x3cHk9CnXWBo6yd@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de IjdJU69TfVlyrveaYueM4g3GsAw6kpOjHO6KsHoU6Dogy6
Cancel-Lock: sha1:Wjt57UbMKSfN3pc9z6Z0kwWjqKk= sha256:BlXpD30k2wvfhAZ05dgjAOSQ84YrhVIh1Te6AoVas68=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Mon, 26 Feb 2024 21:54 UTC

Spiros Bousbouras <spibou@gmail.com> writes:
>On 26 Feb 2024 21:22:33 GMT
>ram@zedat.fu-berlin.de (Stefan Ram) wrote:
>>Spiros Bousbouras <spibou@gmail.com> writes:
>>>fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file
>>A binary stream need not meaningfully support fseek calls
>>with a whence value of SEEK_END.
>The way your are quoting me gives the impression that I wrote the code.
>I didn't , I was quoting Mike Sanders quote.

Sorry! My newsreader has this standard attribution "writes".
It should be: "the post at the end of the References header
line contains:". Maybe I can change it. Your post contained
"fseek(bin, -3, SEEK_END);", but you have not written this.

Re: getOpsFromSelf() (Long Post)

<attribution-20240227165431@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33866&group=comp.lang.c#33866

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: 27 Feb 2024 15:55:58 GMT
Organization: Stefan Ram
Lines: 10
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <attribution-20240227165431@ram.dialup.fu-berlin.de>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 105IrWbn07HLtLTDZt+FuQuyqqPdzMO/RiNAI47P25cKK9
Cancel-Lock: sha1:SUHf+yxr/Y34n2ucDGPcg4CQ5z0= sha256:ASXY1x64cHE1Lnc4Tu1oU32YA5K/ISbhj2dyuMuqCCA=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Tue, 27 Feb 2024 15:55 UTC

Lines beginning with ">" are from the post at the end of the References:
>fseek(bin, -3, SEEK_END);

I am now testing a new attribution line added by my post script
(which I have written in Python). - If one still should read
"writes:", above something went wrong.

While I usually do post test posts to test newsgroups, in this case,
I post to "comp.lang.c", so that Spiros can see my new attribution
line and complain again should he still deem it to be misleading.

Re: getOpsFromSelf() (Long Post)

<gWnDN.101140$GX69.24796@fx46.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33867&group=comp.lang.c#33867

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx46.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: getOpsFromSelf() (Long Post)
Newsgroups: comp.lang.c
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co> <attribution-20240227165431@ram.dialup.fu-berlin.de>
Lines: 21
Message-ID: <gWnDN.101140$GX69.24796@fx46.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 27 Feb 2024 16:17:16 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 27 Feb 2024 16:17:16 GMT
X-Received-Bytes: 1634
 by: Scott Lurndal - Tue, 27 Feb 2024 16:17 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>Lines beginning with ">" are from the post at the end of the References:
>>fseek(bin, -3, SEEK_END);
>
> I am now testing a new attribution line added by my post script
> (which I have written in Python). - If one still should read
> "writes:", above something went wrong.
>
> While I usually do post test posts to test newsgroups, in this case,
> I post to "comp.lang.c", so that Spiros can see my new attribution
> line and complain again should he still deem it to be misleading.

If not misleading, it is still useless. The standard attribution
lines are far more readable and useful. Nobody wants to go searching
for a specific message id in order to determine who you are responding
to. And in replies, such as this one, the message-Id in question is
no longer at the end of the References: header, so your attribution line
becomes invalid.

Re: getOpsFromSelf() (Long Post)

<g96nl+vMavChDI2be@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33868&group=comp.lang.c#33868

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Tue, 27 Feb 2024 17:04:03 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <g96nl+vMavChDI2be@bongo-ra.co>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me>
<NMK4r+7PMexyUgngk@bongo-ra.co> <attribution-20240227165431@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 27 Feb 2024 17:04:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a3062f76191c000caa7f2e813ef9dcd1";
logging-data="3489213"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GNCSZoJoRwyDCn1ihRsHO"
Cancel-Lock: sha1:C4XHF5qbkMjeQlRrFly4gbck8rw=
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
In-Reply-To: <attribution-20240227165431@ram.dialup.fu-berlin.de>
 by: Spiros Bousbouras - Tue, 27 Feb 2024 17:04 UTC

On 27 Feb 2024 15:55:58 GMT
ram@zedat.fu-berlin.de (Stefan Ram) wrote:
> Lines beginning with ">" are from the post at the end of the References:
> >fseek(bin, -3, SEEK_END);
>
> I am now testing a new attribution line added by my post script
> (which I have written in Python). - If one still should read
> "writes:", above something went wrong.
>
> While I usually do post test posts to test newsgroups, in this case,
> I post to "comp.lang.c", so that Spiros can see my new attribution
> line and complain again should he still deem it to be misleading.

You're overcomplicating things. The misleading attribution arose because
you snipped too much context rather than because you used "writes". If you
had written and quoted from <NMK4r+7PMexyUgngk@bongo-ra.co> something
like

Spiros Bousbouras <spibou@gmail.com> writes:
> On Sat, 24 Feb 2024 21:22:55 -0000 (UTC)
> porkchop@invalid.foo (Mike Sanders) wrote:
> For example , your code has
>
> fseek(bin, -3, SEEK_END); // jump 3 bytes before end of file

then everything would have been clear and I wouldn't have complained. But
anyway , your new method is also unambiguous.

Re: getOpsFromSelf() (Long Post)

<url5k1$3aje2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33869&group=comp.lang.c#33869

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: Tue, 27 Feb 2024 18:20:01 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <url5k1$3aje2$1@dont-email.me>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co>
<urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co>
<attribution-20240227165431@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 27 Feb 2024 17:20:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5b013b32b0ae31855296b19afd591ff2";
logging-data="3493314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kQY3e5OIB3Kj6FX4Vn7D/xyEFWEQOqKo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:5VvDtQn8z1ZulKO2JYRWDubtufk=
In-Reply-To: <attribution-20240227165431@ram.dialup.fu-berlin.de>
Content-Language: en-GB
 by: David Brown - Tue, 27 Feb 2024 17:20 UTC

On 27/02/2024 16:55, Stefan Ram wrote:
> Lines beginning with ">" are from the post at the end of the References:
>> fseek(bin, -3, SEEK_END);
>
> I am now testing a new attribution line added by my post script
> (which I have written in Python). - If one still should read
> "writes:", above something went wrong.
>
> While I usually do post test posts to test newsgroups, in this case,
> I post to "comp.lang.c", so that Spiros can see my new attribution
> line and complain again should he still deem it to be misleading.

Your normal attribution was fine. Just don't snip so much context that
the post is meaningless. (It's not a big deal - sometimes people snip
inaccurately.)

But you /do/ have a problem with your indentation. It would be easier
to keep track of attributions and things in your posts if you indented
like everyone else, instead of doing it backwards.

Re: getOpsFromSelf() (Long Post)

<writes-20240227195359@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33872&group=comp.lang.c#33872

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: getOpsFromSelf() (Long Post)
Date: 27 Feb 2024 18:54:35 GMT
Organization: Stefan Ram
Lines: 7
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <writes-20240227195359@ram.dialup.fu-berlin.de>
References: <ur1ie5$2cgfo$1@dont-email.me> <jh8EdBXIFQu4WLaKt@bongo-ra.co> <urdmnf$1d3vr$2@dont-email.me> <NMK4r+7PMexyUgngk@bongo-ra.co> <attribution-20240227165431@ram.dialup.fu-berlin.de> <g96nl+vMavChDI2be@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de oHN57KA07omrZor7VuuYsg+RSHd1MkZamjhDAd0hzMAG/2
Cancel-Lock: sha1:CFcgXAzjkmnlD5hCYqhZpM6Ress= sha256:GxJfVrKfVit3cN7XdeNIE352mgDHSU/Q/NLOHtpVhW0=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Tue, 27 Feb 2024 18:54 UTC

Spiros Bousbouras <spibou@gmail.com> wrote or quoted:
>You're overcomplicating things.

My reference to the header "References" was too technical,
and it might not be good not to mention the author of the
referred post. So now I have instead changed the "writes:"
provided by my newsreader into: "wrote or quoted".

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor