Live data from Hacker News

Show HN: Gemini web client in 100 lines of C

github.com

41–47 of 47 posts

Re: Show HN: Gemini web client in 100 lines of C

#41
post #6
post #4

Earlier quoted context omitted.

Yea, you are right. Poor choose of words on my side. One can argue the definition of "web" but it would be much more precise to write "CLI client".

There’s nothing to argue. The "World Wide Web" or "Web" is defined as servers and clients communicating using the HTTP protocol. (Usually, it means that content is using HTML but this is not mandatory). "Gemini" is defined as servers and client communicating using the "Gemini" protocol (and content is usually in the gemtext format). Both are part of the Internet, which is defined as an INTERconnection of NETworks, th…

The word "web" is actually defined as "a complex system of interconnected elements." There is nothing to argue.

In spoken human language we have this concept called connotation, "web" being associated with http servers and clients is one example of this.

There is no rule that a word must only have one connotation, and Gemni is very much a "a complex system of interconnected elements".

So basically, this is just your opinion and you aren't the authority on what the word "web" means, and it's okay to tell people that the word is often used in a context they might not have known about, but claiming that "there is nothing to argue" is not correct.

Re: Show HN: Gemini web client in 100 lines of C

#42
post #39

Earlier quoted context omitted.

There's a page on the net somewhere, which was on HN front-page a while ago too, that listed all the useful warning flags for gcc, with an explanation. I'd look for it, as a C programmer. On phone now, so sadly don't have it handy.

If you or someone else finds the link to this, I would love this!

Not OP, but the one that sticks in my mind¹ with comments². Although, I also could've sworn I commented on it :/

¹ https://nullprogram.com/blog/2023/04/29/

² https://news.ycombinator.com/item?id=35758898

Re: Show HN: Gemini web client in 100 lines of C

#43

That program has made me realize there exists a single stylistic justification for 8 space tabs: you can fit up to six character goto labels into the indentation margins; you can put a label on any statement without adding a line. :)

Yes, that was my reasoning. Also there is non-written rule in this project that forbids me from going wider than 80 columns. With that I initially had indentation set to 2 spaces but later I realized that code is indented at most 2 times and it's better to make space for goto labels on the left.

Re: Show HN: Gemini web client in 100 lines of C

#44

This is cool. I asked ChatGPT4 to explain to me what it does, and it gives a useful overview: This is a minimal Gemini protocol client written in C. The Gemini protocol is an application-level internet protocol for serving hypertext documents over secure connections. The code includes various standard C libraries and the OpenSSL library for secure connections. The `WARN` macro definition is used to print warning mess…

Wow, this is actually very good description of program flow. There are only few small mistakes. For example:

> navigate through the history (when input starts with a digit)

Should be more like: navigate to link from currently displayed page (when input starts with a digit).

> It prints the response to `stdout` and also stores it in the temporary file.

Response is not printed to `stdout` at all. It is only stored in temporary file.

Also the possibility to use first program argument to overwrite the `less` command was ignored.

But overall very good job.

Re: Show HN: Gemini web client in 100 lines of C

#45
post #14

Earlier quoted context omitted.

Yes, wget and curl are web clients. This is not.

Right, but that has nothing to do with it being a command line app, which is what OP was objecting to.

I wasn't objecting to anything. I was just confused because I initially thought it was a Gemnini client web app.

Re: Show HN: Gemini web client in 100 lines of C

#46

Earlier quoted context omitted.

Right, but that has nothing to do with it being a command line app, which is what OP was objecting to.

I wasn't objecting to anything. I was just confused because I initially thought it was a Gemnini client web app.

Oh, that makes way more sense! I misunderstood you completely, my bad.

Re: Show HN: Gemini web client in 100 lines of C

#47
post #18

It's a nice project, but - I guess as is tradition with the majority of C projects - it has resource leaks and buffer overflows. There is at least one resource leak, namely, `sfd` is not closed when certain `WARN()` invocations jump back to the `start` label; for example, when `gethostbyname()` fails (i.e. try a non-existent domain and observe that the sockets remain open with `lsof`). (It also seems to be leaked in…

I looked into those points and:

1. `sfd` is now closed. This cost me an extra line of code tho so I had to improvise.

2. `j` was not initially -1 as even empty input contains one "\n" character. But it could go pass value of 0 underflowing the buffer when buffer contained only white space characters (like in case of single "\n"). This was corrected.

3. `h_addr_list[i]` about this one. I'm quite sure I took it from example in one of man pages. Anyway, I replaced it with `memcpy`.

I also tried to use valgrind. This is OFC my first step but I will continue my studies on detecting memory leaks in future projects.

Post reply on HN