about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-04-30 17:27:13 -0400
committerJune McEnroe <june@causal.agency>2021-04-30 17:30:02 -0400
commit9b1be8c292cd26717330f77f34d0e285d4ae2d95 (patch)
tree7f2ffe4f208f71d18ef22d40bc2f2a1f9ffff32b
parentpalaver: Remove last vestiges of rc scripts (diff)
downloadpounce-9b1be8c292cd26717330f77f34d0e285d4ae2d95.tar.gz
pounce-9b1be8c292cd26717330f77f34d0e285d4ae2d95.zip
palaver: Add -s flag for case-sensitive matching
Diffstat (limited to '')
-rw-r--r--contrib/palaver/notify.c7
-rw-r--r--contrib/palaver/pounce-palaver.17
2 files changed, 10 insertions, 4 deletions
diff --git a/contrib/palaver/notify.c b/contrib/palaver/notify.c
index 7d3be5f..67d416c 100644
--- a/contrib/palaver/notify.c
+++ b/contrib/palaver/notify.c
@@ -283,6 +283,8 @@ static void handleReplyUserHost(struct Message *msg) {
 	}
 }
 
+static bool sensitive;
+
 static void keyword(sqlite3_context *ctx, int n, sqlite3_value *args[]) {
 	assert(n == 2);
 	const char *haystack = (const char *)sqlite3_value_text(args[0]);
@@ -311,7 +313,7 @@ static void keyword(sqlite3_context *ctx, int n, sqlite3_value *args[]) {
 	size_t len = strlen(needle);
 	const char *match = haystack;
 	sqlite3_result_int(ctx, false);
-	while (NULL != (match = strcasestr(match, needle))) {
+	while (NULL != (match = (sensitive ? strstr : strcasestr)(match, needle))) {
 		char a = (match > haystack ? match[-1] : ' ');
 		char b = (match[len] ? match[len] : ' ');
 		if (b == '\1') b = ' ';
@@ -693,7 +695,7 @@ int main(int argc, char *argv[]) {
 	const char *pass = NULL;
 	const char *user = "pounce-palaver";
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "!NPc:d:k:p:u:vw:"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "!NPc:d:k:p:su:vw:"));) {
 		switch (opt) {
 			break; case '!': insecure = true;
 			break; case 'N': noPreview = true;
@@ -702,6 +704,7 @@ int main(int argc, char *argv[]) {
 			break; case 'd': path = optarg;
 			break; case 'k': priv = optarg;
 			break; case 'p': port = optarg;
+			break; case 's': sensitive = true;
 			break; case 'u': user = optarg;
 			break; case 'v': verbose = true;
 			break; case 'w': pass = optarg;
diff --git a/contrib/palaver/pounce-palaver.1 b/contrib/palaver/pounce-palaver.1
index f88420e..37140c5 100644
--- a/contrib/palaver/pounce-palaver.1
+++ b/contrib/palaver/pounce-palaver.1
@@ -1,4 +1,4 @@
-.Dd August 27, 2020
+.Dd April 30, 2021
 .Dt POUNCE-PALAVER 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl PNv
+.Op Fl PNsv
 .Op Fl c Ar cert
 .Op Fl d Ar path
 .Op Fl k Ar priv
@@ -56,6 +56,9 @@ Load the TLS client private key from
 Connect to
 .Ar port .
 The default port is 6697.
+.It Fl s
+Match nick and keywords case-sensitively,
+despite the specification.
 .It Fl u Ar user
 Set the username to
 .Ar user .