about summary refs log tree commit diff
path: root/contrib/palaver/notify.c
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 /contrib/palaver/notify.c
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 'contrib/palaver/notify.c')
-rw-r--r--contrib/palaver/notify.c7
1 files changed, 5 insertions, 2 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;