This commit is contained in:
Your Name 2024-08-14 17:10:45 +03:00
parent f9cc013c8d
commit 8d63329fda
2 changed files with 16 additions and 25 deletions

4
README
View File

@ -4,6 +4,10 @@
md5 irc.c c43a8faf4ad199a30a1148b847867022
md5 irc.h bd6a06cb02d75da9896233db6ea20cd8
> сборка
git clone https://git.macaw.me/8nl/irclibs
cc -I irclibs/C irclibs/C/irc.c main.c -lssl -lcrypto
> gemini://any-key.press/tt/welcome.gmi
Сделано в соответствии с духом Тривиальных Технологий

33
main.c
View File

@ -116,37 +116,24 @@ void run_gemini(IRCC_client *client) {
if (SSL_connect(gem_cfg.ssl) < 1)
goto RG_CLOSE_TLS;
/* Send response */
/* Send request */
ssize_t size = snprintf(domain, sizeof(domain), "gemini://%s\r\n", uri);
if (SSL_write(gem_cfg.ssl, domain, size) < 1)
goto RG_CLOSE_TLS;
bool exit_flag = 0;
while (1) {
char buf[128];
/* Send response to the irc user */
char buf[256];
char *p = buf;
/* Read line */
while ((size = SSL_read(gem_cfg.ssl, p, 1)) > 0) {
if (*p == '\n' || p == buf + sizeof(buf)) {
*p = '\0';
break;
}
p++;
}
if (size <= 0) {
if (exit_flag)
break;
exit_flag = 1;
continue;
}
if (*p == '\n') {
*p = '\0';
p = buf;
IRCC_send(client, nick, buf);
exit_flag = 0;
}
else
p++;
}
ret = 0;
@ -217,7 +204,7 @@ int main(int argc, char **argv) {
break;
default:
printf("gem2irc - simple bridge between irc and gemini\ngem2irc -[n:p:h:tVD] [e.p CHANNEL1:PASSWORD CHANNEL2...]\n\t-n NICK\tdefault: %s\n\t-h HOST\tdefault: %s\n\t-p PORT\tdefault: %d\n\t-t Use ssl\tdefault: %s\n\t-D Print raw messages\n\t-V Version\n", cfg.nick, cfg.ip, cfg.port, (cfg.use_ssl) ? "true" : "false");
printf("gem2irc - simple bridge between irc and gemini\ngem2irc -[n:p:h:tVD] [e.p CHANNEL1:PASSWORD CHANNEL2...]\n\t-n NICK default: %s\n\t-h HOST default: %s\n\t-p PORT default: %d\n\t-t Use ssl default: %s\n\t-D Print raw messages\n\t-V Version\n", cfg.nick, cfg.ip, cfg.port, (cfg.use_ssl) ? "true" : "false");
return 0;
}
}