Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Always look over your shoulder because everyone is watching and plotting against you.


devel / comp.lang.c / comms

SubjectAuthor
o commsmuta...@gmail.com

1
comms

<da5fd2d5-0bdb-4152-a3c9-89fcbd2736ban@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1269:: with SMTP id b9mr1869969qkl.273.1634167621245;
Wed, 13 Oct 2021 16:27:01 -0700 (PDT)
X-Received: by 2002:ac8:5689:: with SMTP id h9mr2663572qta.202.1634167621036;
Wed, 13 Oct 2021 16:27:01 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.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.lang.c
Date: Wed, 13 Oct 2021 16:27:00 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=202.169.113.201; posting-account=CeHKkQoAAAAowY1GfiJYG55VVc0s1zaG
NNTP-Posting-Host: 202.169.113.201
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <da5fd2d5-0bdb-4152-a3c9-89fcbd2736ban@googlegroups.com>
Subject: comms
From: mutazi...@gmail.com (muta...@gmail.com)
Injection-Date: Wed, 13 Oct 2021 23:27:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 136
 by: muta...@gmail.com - Wed, 13 Oct 2021 23:27 UTC

We had a discussion about a pure C90 system some
time ago. PDOS/386 (a mini Windows clone) is now
capable of compiling C programs, so all the components
are now in place. You can get it from:

http://pdos.org

We also had a discussion about the best way to do comms.
Now that I have control over both the C library and the OS,
I was able to do comms in a C90-compliant manner. You
can see the code below.

There is a philosophy question raised though. The C90
standard says that files are fully buffered only if the
device is non-interactive. That assumes that an OS and
hardware is capable of actually knowing that. I'm not
sure Windows, MVS and PDOS actually have appropriate
syscalls to make such a determination. I was thinking
maybe it would be better for stdin/stdout/stderr to be
line buffered by default, and everything else is fully
buffered unless the application does an explicit setvbuf.

My new code does an explicit setvbuf to switch off
buffering instead of relying on the C library to magically
know that the COM port needs to be character based.
I don't think accessing a news server is considered
interactive anyway.

The other thing my code does is do an fseek of 0 bytes
from CUR, as the C90 standard requires that when
switching to/from read/write.

Example code that works with the eternal-september
news server as proof of concept below.

Oh, also it is my intention to convert from ASCII to the
local character set, which may be EBCDIC, but z/PDOS
and Hercules/380 don't have the ability to connect to
eternal-september yet.

BFN. Paul.

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/pdpnntp.c

/*********************************************************************/
/* */
/* This Program Written by Paul Edwards */
/* Released to the Public Domain */
/* */
/*********************************************************************/
/*********************************************************************/
/* */
/* pdpnntp - a nntp newsgroup reader */
/* */
/*********************************************************************/

#include <stdio.h>
#include <stdlib.h>

static FILE *comm;
static char buf[1000];

static char *getline(FILE *comm, char *buf, size_t szbuf);
static char *putline(FILE *comm, char *buf);

int main(int argc, char **argv)
{ if (argc != 2)
{
printf("usage: pdpnntp <comm channel>\n");
return (EXIT_FAILURE);
}

comm = fopen(*(argv + 1), "r+b");
if (comm == NULL)
{
printf("can't open %s\n", *(argv + 1));
return (EXIT_FAILURE);
}

setvbuf(comm, NULL, _IONBF, 0);

getline(comm, buf, sizeof buf);
printf("%s\n", buf);

fseek(comm, 0, SEEK_CUR);

putline(comm, "LIST");

fseek(comm, 0, SEEK_CUR);

while (1)
{
getline(comm, buf, sizeof buf);
if (buf[0] == '.') break;
printf("%s\n", buf);
}

fclose(comm);
return (0);
}

static char *getline(FILE *comm, char *buf, size_t szbuf)
{ size_t x;
int c;

for (x = 0; x < szbuf - 2; x++)
{
c = getc(comm);
if (c == 0x0d)
{
getc(comm);
break;
}
buf[x] = c;
}
buf[x] = '\0';
return (buf);
}

static char *putline(FILE *comm, char *buf)
{ size_t x;

x = 0;
while (buf[x] != '\0')
{
putc(buf[x], comm);
x++;
}
putc(0x0d, comm);
putc(0x0a, comm);
return (buf);
}

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor