+ flags = OP_NEW == op ? O_CREAT|O_TRUNC|O_RDWR : O_CREAT|O_RDWR;
+
+ if (OP_UPDATE == op || OP_DELETE == op) {
+ ibuf[0] = fbuf[0] = '\0';
+
+ strlcat(fbuf, dir, MAXPATHLEN);
+ strlcat(fbuf, "/", MAXPATHLEN);
+ sz1 = strlcat(fbuf, MANDOC_DB, MAXPATHLEN);
+
+ strlcat(ibuf, dir, MAXPATHLEN);
+ strlcat(ibuf, "/", MAXPATHLEN);
+ sz2 = strlcat(ibuf, MANDOC_IDX, MAXPATHLEN);
+
+ if (sz1 >= MAXPATHLEN || sz2 >= MAXPATHLEN) {
+ fprintf(stderr, "%s: Path too long\n", dir);
+ exit((int)MANDOCLEVEL_BADARG);
+ }
+
+ db = dbopen(fbuf, flags, 0644, DB_BTREE, &info);
+ idx = dbopen(ibuf, flags, 0644, DB_RECNO, NULL);
+
+ if (NULL == db) {
+ perror(fbuf);
+ exit((int)MANDOCLEVEL_SYSERR);
+ } else if (NULL == db) {
+ perror(ibuf);
+ exit((int)MANDOCLEVEL_SYSERR);
+ }
+
+ if (verb > 2) {
+ printf("%s: Opened\n", fbuf);
+ printf("%s: Opened\n", ibuf);
+ }
+
+ ofile_argbuild(argv, argc, verb, &of);
+ if (NULL == of)
+ goto out;
+
+ of = of->first;
+
+ index_prune(of, db, fbuf, idx, ibuf, verb,
+ &maxrec, &recs, &recsz);
+
+ if (OP_UPDATE == op)
+ index_merge(of, mp, &dbuf, &buf, hash,
+ db, fbuf, idx, ibuf, verb,
+ maxrec, recs, reccur);
+
+ goto out;
+ }
+