dot

packages and services management
Log | Files | Refs | README

commit be0c82fe77cf1c45213b2adb27a7cc508f6454e0
parent f53d8fdd971b30fcc2de526955b47858f95e1036
Author: Josuah Demangeon <mail@josuah.net>
Date:   Tue, 21 Nov 2017 18:00:23 +0100

updating ngircd.conf to new $HOME and add patch from Evil_Bob :)

Diffstat:
Mbin/mdoc | 2+-
Mngircd.conf | 6+++---
Apackage/sfeed/sfeed_twtxt.c | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/bin/mdoc b/bin/mdoc @@ -5,7 +5,7 @@ case $1 in date +'.Dd $Mdocdate: %B %d %Y$' ;; (bd) - printf '.Bd -literal\n' + printf '.Bd -literal -offset indent\n' sed -e 's/\\/\\\\/g' -e 's/^\./\\./' printf '.Ed' ;; diff --git a/ngircd.conf b/ngircd.conf @@ -11,11 +11,11 @@ ;Listen = 0.0.0.0 - # set to ~/etc/ngircd.d/motd + # set to ~/etc/ngircd.motd MotdFile = /home/etc/ngircd.motd ;MotdPhrase = "Welcome to cyberia.systems" - Network = cyberia.systems + Network = irc.cyberia.systems ;Password = none @@ -82,7 +82,7 @@ ;WebircPassword = xyz ;[SSL] - ;CertFile = /home/pi/programs/ngircd/etc/ssl/server-cert.pem + ;CertFile = /home/.local/tls/server-cert.pem ;CipherList = HIGH:!aNULL:@STRENGTH:!SSLv3 diff --git a/package/sfeed/sfeed_twtxt.c b/package/sfeed/sfeed_twtxt.c @@ -0,0 +1,84 @@ +#include <ctype.h> +#include <err.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "util.h" + +static char *line; +static size_t linesize; + +static void +printtext(FILE *fp, const char *s) +{ + for (; *s; s++) + if (!iscntrl(*s)) + fputc(*s, fp); +} + +static void +printfeed(FILE *fp, const char *feedname) +{ + char *fields[FieldLast]; + struct tm *tm; + time_t parsedtime; + ssize_t linelen; + + while ((linelen = getline(&line, &linesize, fp)) > 0) { + if (line[linelen - 1] == '\n') + line[--linelen] = '\0'; + if (!parseline(line, fields)) + break; + + parsedtime = 0; + strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (!(tm = gmtime(&parsedtime))) + err(1, "localtime"); + + fprintf(stdout, "%04d-%02d-%02dT%02d:%02d:%02dZ\t", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + if (feedname[0]) + printf("[%s] ", feedname); + printtext(stdout, fields[FieldTitle]); + if (fields[FieldLink][0]) { + fputs(" @<", stdout); + if (fields[FieldAuthor][0]) { + printtext(stdout, fields[FieldAuthor]); + fputs(" ", stdout); + } + printtext(stdout, fields[FieldLink]); + fputs(">", stdout); + } + putchar('\n'); + } +} + +int +main(int argc, char *argv[]) +{ + FILE *fp; + char *name; + int i; + + if (pledge(argc == 1 ? "stdio" : "stdio rpath", NULL) == -1) + err(1, "pledge"); + + if (argc == 1) { + printfeed(stdin, ""); + } else { + for (i = 1; i < argc; i++) { + if (!(fp = fopen(argv[i], "r"))) + err(1, "fopen: %s", argv[i]); + name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i]; + printfeed(fp, name); + if (ferror(fp)) + err(1, "ferror: %s", argv[i]); + fclose(fp); + } + } + return 0; +}