- /* get space separated list of sequence ranges */
- if (!(cp = seq_list(mp, mp->msgattrs[i]))) {
- context_del (attr); /* delete sequence from context */
- continue;
+ if (is_readonly(mp) || is_seq_private(mp, i)) {
+priv:
+ /* sequence is private */
+ context_replace(attr, cp); /* update seq in ctx */
+ } else {
+ /* sequence is public */
+ context_del(attr); /* delete sequence from context */
+
+ if (!fp) {
+ /*
+ ** Attempt to open file for public sequences.
+ ** If that fails (probably because folder is
+ ** readonly), then make sequence private.
+ */
+ if ((fp = lkfopen(seqfile, "w")) == NULL
+ && (unlink(seqfile) == -1 ||
+ (fp = lkfopen(seqfile, "w"))
+ == NULL)) {
+ admonish(attr, "unable to write");
+ goto priv;
+ }
+
+ /* block a few signals */
+ sigemptyset(&set);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+ sigprocmask(SIG_BLOCK, &set, &oset);
+ }
+ fprintf(fp, "%s: %s\n", mp->msgattrs[i], cp);
+ }