1: /* m_sync.c - synchronize message sequences */
   2: 
   3: #include "../h/mh.h"
   4: #include <stdio.h>
   5: #include <signal.h>
   6: 
   7: 
   8: /* decision logic
   9:     1.  public and folder readonly: make it private
  10:     2a. public: add it to the sequences file
  11:     2b. private: add it to the profile
  12:  */
  13: 
  14: 
  15: void m_sync (mp)
  16: register struct msgs *mp;
  17: {
  18:     int     bits;
  19:     register int    i;
  20:     register char  *cp;
  21:     char    flags,
  22:         attr[BUFSIZ],
  23:         seq[BUFSIZ];
  24:     register FILE  *fp;
  25: #ifdef BSD42
  26:     int     oldsig;
  27: #else not BSD42
  28:     int     (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
  29: #endif BSD42
  30: 
  31:     if (!(mp -> msgflags & SEQMOD))
  32:     return;
  33:     mp -> msgflags &= ~SEQMOD;
  34: 
  35:     m_getdefs ();
  36:     (void) sprintf (seq, "%s/%s", mp -> foldpath, mh_seq);
  37:     bits = FFATTRSLOT;
  38:     fp = NULL;
  39: 
  40:     flags = mp -> msgflags;
  41:     if (mh_seq == NULL || *mh_seq == NULL)
  42:     mp -> msgflags |= READONLY;
  43: 
  44:     for (i = 0; mp -> msgattrs[i]; i++) {
  45:     (void) sprintf (attr, "atr-%s-%s", mp -> msgattrs[i], mp -> foldpath);
  46:     if (mp -> msgflags & READONLY
  47:         || mp -> attrstats & (1 << (bits + i))) {
  48:     private: ;
  49:         if (cp = m_seq (mp, mp -> msgattrs[i]))
  50:         m_replace (attr, cp);
  51:         else
  52:         (void) m_delete (attr);
  53:     }
  54:     else {
  55:         (void) m_delete (attr);
  56:         if ((cp = m_seq (mp, mp -> msgattrs[i])) == NULL)
  57:         continue;
  58:         if (fp == NULL) {
  59:         if ((fp = fopen (seq, "w")) == NULL
  60:             && unlink (seq) != NOTOK
  61:             && (fp = fopen (seq, "w")) == NULL) {
  62:             admonish (attr, "unable to write");
  63:             goto private;
  64:         }
  65: #ifdef BSD42
  66:         oldsig = sigblock (sigmask(SIGHUP) | sigmask(SIGINT) |
  67:                    sigmask(SIGQUIT) | sigmask(SIGTERM));
  68: #else not BSD42
  69:         hstat = signal (SIGHUP, SIG_IGN);
  70:         istat = signal (SIGINT, SIG_IGN);
  71:         qstat = signal (SIGQUIT, SIG_IGN);
  72:         tstat = signal (SIGTERM, SIG_IGN);
  73: #endif BSD42
  74:         }
  75:         fprintf (fp, "%s: %s\n", mp -> msgattrs[i], cp);
  76:     }
  77:     }
  78: 
  79:     if (fp) {
  80:     (void) fclose (fp);
  81: #ifdef BSD42
  82:     (void) sigsetmask (oldsig);
  83: #else not BSD42
  84:     (void) signal (SIGHUP, hstat);
  85:     (void) signal (SIGINT, istat);
  86:     (void) signal (SIGQUIT, qstat);
  87:     (void) signal (SIGTERM, tstat);
  88: #endif BSD42
  89:     }
  90:     else
  91:     if (!(mp -> msgflags & READONLY))
  92:         (void) unlink (seq);
  93: 
  94:     mp -> msgflags = flags;
  95: }

Defined functions

m_sync defined in line 15; used 1 times
Last modified: 1986-05-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1044
Valid CSS Valid XHTML 1.0 Strict