Annotation of 43BSDReno/contrib/mh/sbr/m_sync.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.