summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-05 15:51:18 -0500
committerJune McEnroe <june@causal.agency>2019-12-05 15:51:18 -0500
commita75db3e11323c528d8fabb1812fd97a305467d2b (patch)
treeb7a420240ce71f15d5bd4648599ac7a012d47761
parentDocument what the generic format matches (diff)
downloadlitterbox-a75db3e11323c528d8fabb1812fd97a305467d2b.tar.gz
litterbox-a75db3e11323c528d8fabb1812fd97a305467d2b.zip
Add textual format to unscoop
Diffstat (limited to '')
-rw-r--r--unscoop.13
-rw-r--r--unscoop.c66
2 files changed, 57 insertions, 12 deletions
diff --git a/unscoop.1 b/unscoop.1
index 0478481..0a9f0db 100644
--- a/unscoop.1
+++ b/unscoop.1
@@ -40,7 +40,8 @@ for the default database path.
 .It Fl f Ar format
 Set the input log format.
 The following formats are supported:
-.Sy generic .
+.Sy generic ,
+.Sy textual .
 .Pp
 The
 .Sy generic
diff --git a/unscoop.c b/unscoop.c
index d5494e0..2e62b57 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -31,9 +31,9 @@
 #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
 
 struct Matcher {
-	enum Type type;
 	const char *pattern;
 	regex_t regex;
+	enum Type type;
 	size_t time;
 	size_t nick;
 	size_t user;
@@ -42,25 +42,68 @@ struct Matcher {
 	size_t message;
 };
 
-#define WS "[[:blank:]]*"
+#define WS "[[:blank:]]"
 #define PAT_TIME "[[]([^]]+)[]]"
 #define PAT_MODE "[!~&@%+ ]?"
 
 static struct Matcher Generic[] = {
 	{
-		.type = Privmsg,
-		.pattern = "^" PAT_TIME WS "<" PAT_MODE "([^>]+)" ">" WS "(.+)",
-		.time = 1, .nick = 2, .message = 3,
+		"^" PAT_TIME WS "<" PAT_MODE "([^>]+)" ">" WS "(.+)",
+		.type = Privmsg, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" PAT_TIME WS "-" PAT_MODE "([^-]+)" "-" WS "(.+)",
+		.type = Notice, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" PAT_TIME WS "[*]" WS PAT_MODE "([^[:blank:]]+)" WS "(.+)",
+		.type = Action, .time = 1, .nick = 2, .message = 3,
+	},
+};
+
+#define PAT_USERHOST "[(]([^@]+)@([^)]+)[)]"
+#define PAT_MESSAGE "[(]([^)]+)[)]"
+
+static struct Matcher Textual[] = {
+	{
+		"^" PAT_TIME " <" PAT_MODE "([^>]+)> (.+)",
+		.type = Privmsg, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" PAT_TIME " -" PAT_MODE "([^-]+)- (.+)",
+		.type = Notice, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" PAT_TIME " • ([^:]+): (.+)",
+		.type = Action, .time = 1, .nick = 2, .message = 3,
+	},
+	{
+		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " joined the channel",
+		.type = Join, .time = 1, .nick = 2, .user = 3, .host = 4,
+	},
+	{
+		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " left the channel$",
+		.type = Part, .time = 1, .nick = 2, .user = 3, .host = 4,
+	},
+	{
+		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " left the channel " PAT_MESSAGE,
+		.type = Part, .time = 1, .nick = 2, .user = 3, .host = 4, .message = 5,
+	},
+	{
+		"^" PAT_TIME " ([^ ]+) kicked ([^ ]+) from the channel " PAT_MESSAGE,
+		.type = Kick, .time = 1, .nick = 2, .target = 3, .message = 4,
+	},
+	{
+		"^" PAT_TIME " ([^ ]+) " PAT_USERHOST " left IRC " PAT_MESSAGE,
+		.type = Quit, .time = 1, .nick = 2, .user = 3, .host = 4, .message = 5,
 	},
 	{
-		.type = Notice,
-		.pattern = "^" PAT_TIME WS "-" PAT_MODE "([^-]+)" "-" WS "(.+)",
-		.time = 1, .nick = 2, .message = 3,
+		"^" PAT_TIME " ([^ ]+) is now known as ([^ ]+)",
+		.type = Nick, .time = 1, .nick = 2, .target = 3,
 	},
 	{
-		.type = Action,
-		.pattern = "^" PAT_TIME WS "[*]" WS PAT_MODE "([^[:blank:]]+)" WS "(.+)",
-		.time = 1, .nick = 2, .message = 3,
+		"^" PAT_TIME " ([^ ]+) changed the topic to (.+)",
+		.type = Topic, .time = 1, .nick = 2, .message = 3,
 	},
 };
 
@@ -70,6 +113,7 @@ static const struct Format {
 	size_t len;
 } Formats[] = {
 	{ "generic", Generic, ARRAY_LEN(Generic) },
+	{ "textual", Textual, ARRAY_LEN(Textual) },
 };
 
 static const struct Format *formatParse(const char *name) {
ass='logsubject'>Convert pager navigation into a unordered listLukas Fleischer It is common practice and semantically appropriate to use unordered lists for long navigation lists. This also fixes the layout of very long pager navigations in Webkit-based browsers. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2013-03-20Makefile: remove CGIT-CFLAGS files in clean stageJason A. Donenfeld 2013-03-20ui-summary.c: Move urls variable into print_urls()Lukas Fleischer There's no need for this variable to be global. Printing the header in print_urls() instead of print_url() allows for moving this variable into print_urls() without having to pass any status to print_url(). Note that this only works as long as we don't call print_urls() more than once. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2013-03-20Fix colspan valuesLukas Fleischer This fixes a couple of minor oversights in previous commits and adjusts all cells using colspan to use the correct width. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2013-03-20html: check return value of writeJason A. Donenfeld This squelches a gcc warning. It's also correct that we check to see if there are any partial or failed writes. For now, we just print a warning to stderr. In the future, perhaps it will prove wise to exit(1) on partial writes. 2013-03-20ui-shared: squelch compiler warning.Jason A. Donenfeld Since tail is initialized to 0, we will never get a warning on the last if statement, but recent gcc complains anyway. So, we initialize len as well. Future gcc versions should be able to optimize this out anyway. 2013-03-20cgit.mk: Use SHELL_PATH_SQ to run gen-version.shJohn Keeping On some platforms (notably Solaris) /bin/sh doesn't support enough of POSIX for gen-version.sh to run. Git's Makefile provides SHELL_PATH_SQ to address this issue so we just have to use it. Signed-off-by: John Keeping <john@keeping.me.uk> 2013-03-20cgit.mk: don't rebuild everything if CGIT_VERSION changesJohn Keeping If CGIT_VERSION is in CGIT_CFLAGS then a change in version (for example because you have committed your changes) causes all of the CGit objects to be rebuilt. Avoid this by using EXTRA_CPPFLAGS to add the version for only those files that are affected and make them depend on VERSION. Signed-off-by: John Keeping <john@keeping.me.uk> 2013-03-20ui-patch: use cgit_version not CGIT_VERSIONJohn Keeping We already have a global cgit_version which is set from the #define'd CGIT_VERSION in cgit.c. Change ui-patch.c to use this so that we only need to rebuild cgit.o when the version changes. Signed-off-by: John Keeping <john@keeping.me.uk> 2013-03-20Makefile: re-use Git's Makefile where possibleJohn Keeping