summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--unscoop.18
-rw-r--r--unscoop.c17
2 files changed, 16 insertions, 9 deletions
diff --git a/unscoop.1 b/unscoop.1
index 1954f97..6757304 100644
--- a/unscoop.1
+++ b/unscoop.1
@@ -1,4 +1,4 @@
-.Dd January 4, 2020
+.Dd April  5, 2020
 .Dt UNSCOOP 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl v
+.Op Fl nv
 .Op Fl N Ar network
 .Op Fl c Ar context
 .Op Fl d Ar path
@@ -87,6 +87,10 @@ The network and context must be set with
 and
 .Fl c .
 .
+.It Fl n
+Do not import any files.
+Compile regular expressions and exit.
+.
 .It Fl v
 Print SQL
 .Sy INSERT
diff --git a/unscoop.c b/unscoop.c
index 6e7b362..eabb594 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -299,24 +299,33 @@ static void dedupEvents(sqlite3 *db) {
 }
 
 int main(int argc, char *argv[]) {
+	bool test = false;
 	char *path = NULL;
 	bool dedup = false;
 	const char *network = NULL;
 	const char *context = NULL;
 	const struct Format *format = &Formats[0];
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "DN:c:d:f:v"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "DN:c:d:f:nv"));) {
 		switch (opt) {
 			break; case 'D': dedup = true;
 			break; case 'N': network = optarg;
 			break; case 'c': context = optarg;
 			break; case 'd': path = optarg;
 			break; case 'f': format = formatParse(optarg);
+			break; case 'n': test = true;
 			break; case 'v': verbose = true;
 			break; default:  return EX_USAGE;
 		}
 	}
 
+	regex_t pathRegex = compile(format->pattern);
+	regex_t regex[format->len];
+	for (size_t i = 0; i < format->len; ++i) {
+		regex[i] = compile(format->matchers[i].pattern);
+	}
+	if (test) return EX_OK;
+
 	dbFind(path, SQLITE_OPEN_READWRITE);
 	if (dbVersion() != DatabaseVersion) {
 		errx(EX_CONFIG, "database out of date; migrate with litterbox -m");
@@ -328,12 +337,6 @@ int main(int argc, char *argv[]) {
 		return EX_OK;
 	}
 
-	regex_t pathRegex = compile(format->pattern);
-	regex_t regex[format->len];
-	for (size_t i = 0; i < format->len; ++i) {
-		regex[i] = compile(format->matchers[i].pattern);
-	}
-
 	sqlite3_stmt *insertContext = NULL;
 	const char *InsertContext = SQL(
 		INSERT OR IGNORE INTO contexts (network, name, query)
2021-05-25import: Add missing scripts/wrap-compiler-for-flag-checkJune McEnroe 2021-05-08Import LibreSSL 3.3.3June McEnroe 2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe 2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe 2021-04-18Import LibreSSL 3.3.2June McEnroe 2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe 2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe Some compat sources (getentropy_linux.c for example) require OpenSSL. Reported by Robert Scheck. 2020-12-15Import LibreSSL 3.3.1June McEnroe 2020-11-24Import LibreSSL 3.3.0June McEnroe 2020-10-22Import LibreSSL 3.2.2June McEnroe 2020-09-29Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe